From 2d5cf627bc8fa9250b501290b336a5d4a6f1d06f Mon Sep 17 00:00:00 2001 From: clubapplets-server Date: Wed, 20 Sep 2023 17:48:24 +0000 Subject: [PATCH] [BOT] Applying format. --- lib/core/constants/faq.dart | 36 ++-- lib/core/models/faq_questions.dart | 2 +- lib/core/viewmodels/faq_viewmodel.dart | 8 +- lib/ui/router.dart | 3 +- lib/ui/views/faq_view.dart | 245 ++++++++++++------------ lib/ui/views/login_view.dart | 10 +- lib/ui/views/more_view.dart | 8 +- test/ui/views/faq_view_test.dart | 16 +- test/ui/views/login_view_test.dart | 6 +- test/ui/views/more_view_test.dart | 3 +- test/viewmodels/faq_viewmodel_test.dart | 4 +- 11 files changed, 176 insertions(+), 165 deletions(-) diff --git a/lib/core/constants/faq.dart b/lib/core/constants/faq.dart index f5c4612ba..05592e81a 100644 --- a/lib/core/constants/faq.dart +++ b/lib/core/constants/faq.dart @@ -16,8 +16,10 @@ class Faq { "en": "What password should I use to log in?" }, description: { - "fr": "Le mot de passe à utiliser correspond à celui utilisé pour la connexion à MonÉTS et les autres systèmes informatiques de l’ÉTS.", - "en": "The password is the one you use for logging into MonÉTS and other ÉTS computer systems." + "fr": + "Le mot de passe à utiliser correspond à celui utilisé pour la connexion à MonÉTS et les autres systèmes informatiques de l’ÉTS.", + "en": + "The password is the one you use for logging into MonÉTS and other ÉTS computer systems." }, ), QuestionItem( @@ -26,13 +28,16 @@ class Faq { "en": "I don't have access to the courses and program." }, description: { - "fr": "Les nouveaux étudiants pourraient ne pas voir l’horaire et les cours inscrits avant le début de la première session de cours. Cependant, ces informations apparaissent dès le début de la première session de cours.", - "en": "New students may not see the schedule and courses before the start of the first course session. However, this information becomes available at the beginning of the first course session." + "fr": + "Les nouveaux étudiants pourraient ne pas voir l’horaire et les cours inscrits avant le début de la première session de cours. Cependant, ces informations apparaissent dès le début de la première session de cours.", + "en": + "New students may not see the schedule and courses before the start of the first course session. However, this information becomes available at the beginning of the first course session." }, ), QuestionItem( title: { - "fr": "Je suis diplômé de l’ÉTS et je souhaite faire réactiver mon compte.", + "fr": + "Je suis diplômé de l’ÉTS et je souhaite faire réactiver mon compte.", "en": "I am an ÉTS graduate, and I want to reactivate my account." }, description: { @@ -46,8 +51,10 @@ class Faq { "en": "I can't see my grades anymore." }, description: { - "fr": "Il est possible qu’il s’agit de la période d'évaluation des cours. Vous devez compléter les évaluations sur SignETS. Les notes seront disponibles après avoir répondu aux évaluations.", - "en": "It is possible that this is the course evaluation period. You need to complete the evaluations on SignETS. Grades will be available after responding to the evaluations." + "fr": + "Il est possible qu’il s’agit de la période d'évaluation des cours. Vous devez compléter les évaluations sur SignETS. Les notes seront disponibles après avoir répondu aux évaluations.", + "en": + "It is possible that this is the course evaluation period. You need to complete the evaluations on SignETS. Grades will be available after responding to the evaluations." }, ), ]; @@ -59,8 +66,10 @@ class Faq { "en": "Where can I find my universal code?" }, description: { - "fr": "Le code universel se trouve dans la décision d’admission sur le portail de monÉTS.", - "en": "The universal code can be found in the admission decision on the MonÉTS portal." + "fr": + "Le code universel se trouve dans la décision d’admission sur le portail de monÉTS.", + "en": + "The universal code can be found in the admission decision on the MonÉTS portal." }, type: ActionType.webview, link: "https://portail.etsmtl.ca/home/Admission", @@ -70,7 +79,8 @@ class Faq { ), ActionItem( title: { - "fr": "Je suis diplômé de l’ÉTS et je souhaite faire réactiver mon compte.", + "fr": + "Je suis diplômé de l’ÉTS et je souhaite faire réactiver mon compte.", "en": "I am an ÉTS graduate, and I want to reactivate my account." }, description: { @@ -85,8 +95,10 @@ class Faq { ), ActionItem( title: { - "fr": "Questions concernant vos conditions d'admission, des inscriptions et des conditions relatives à la poursuite de vos études", - "en": "Questions about your admission conditions, registrations, and conditions for continuing your studies" + "fr": + "Questions concernant vos conditions d'admission, des inscriptions et des conditions relatives à la poursuite de vos études", + "en": + "Questions about your admission conditions, registrations, and conditions for continuing your studies" }, description: { "fr": "Veuillez contacter le Bureau de la registraire.", diff --git a/lib/core/models/faq_questions.dart b/lib/core/models/faq_questions.dart index ff1714fd6..a96bc41a3 100644 --- a/lib/core/models/faq_questions.dart +++ b/lib/core/models/faq_questions.dart @@ -9,4 +9,4 @@ class QuestionItem { @required this.title, @required this.description, }); -} \ No newline at end of file +} diff --git a/lib/core/viewmodels/faq_viewmodel.dart b/lib/core/viewmodels/faq_viewmodel.dart index 74da49568..2fba133d9 100644 --- a/lib/core/viewmodels/faq_viewmodel.dart +++ b/lib/core/viewmodels/faq_viewmodel.dart @@ -32,13 +32,11 @@ class FaqViewModel extends BaseViewModel { Future openMail(String addressEmail, BuildContext context) async { var email = ""; if (addressEmail == AppInfo.email) { - email = - mailtoStr(addressEmail, AppIntl.of(context).email_subject); + email = mailtoStr(addressEmail, AppIntl.of(context).email_subject); } else { - email = - mailtoStr(addressEmail, ""); + email = mailtoStr(addressEmail, ""); } - + final urlLaunchable = await _launchUrlService.canLaunch(email); if (urlLaunchable) { diff --git a/lib/ui/router.dart b/lib/ui/router.dart index 0d2b7c4ba..b7739e1c0 100644 --- a/lib/ui/router.dart +++ b/lib/ui/router.dart @@ -52,7 +52,8 @@ Route generateRoute(RouteSettings routeSettings) { case RouterPaths.faq: return MaterialPageRoute( settings: RouteSettings(name: routeSettings.name), - builder: (_) => FaqView(backgroundColor: routeSettings.arguments as Color)); + builder: (_) => + FaqView(backgroundColor: routeSettings.arguments as Color)); case RouterPaths.dashboard: final code = (routeSettings.arguments as UpdateCode) ?? UpdateCode.none; return PageRouteBuilder( diff --git a/lib/ui/views/faq_view.dart b/lib/ui/views/faq_view.dart index c725b27ca..911cd1793 100644 --- a/lib/ui/views/faq_view.dart +++ b/lib/ui/views/faq_view.dart @@ -24,126 +24,125 @@ class FaqView extends StatefulWidget { class _FaqViewState extends State { final Faq faq = Faq(); - + @override - Widget build(BuildContext context) => - ViewModelBuilder.reactive( - viewModelBuilder: () => FaqViewModel(), - builder: (context, model, child) { - return Scaffold( - backgroundColor: widget.backgroundColor, - body: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - getTitle(), - getSubtitle(AppIntl.of(context).questions_and_answers), - Padding( - padding: const EdgeInsets.only(left: 15.0, right: 15.0), - child: CarouselSlider( - options: CarouselOptions( - height: 250.0, - ), - items: faq.questions.asMap().entries.map((entry) { - final int index = entry.key; - final question = faq.questions[index]; + Widget build(BuildContext context) => ViewModelBuilder.reactive( + viewModelBuilder: () => FaqViewModel(), + builder: (context, model, child) { + return Scaffold( + backgroundColor: widget.backgroundColor, + body: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + getTitle(), + getSubtitle(AppIntl.of(context).questions_and_answers), + Padding( + padding: const EdgeInsets.only(left: 15.0, right: 15.0), + child: CarouselSlider( + options: CarouselOptions( + height: 250.0, + ), + items: faq.questions.asMap().entries.map((entry) { + final int index = entry.key; + final question = faq.questions[index]; - return Builder( - builder: (BuildContext context) { - return Container( - width: MediaQuery.of(context).size.width, - margin: const EdgeInsets.symmetric(horizontal: 5.0), - decoration: const BoxDecoration( - color: Color.fromARGB(255, 240, 238, 238), - borderRadius: BorderRadius.all(Radius.circular(8.0)), - ), - child: getQuestionCard( - question.title[model.locale.languageCode], - question.description[model.locale.languageCode], - ), - ); - }, - ); - }).toList(), + return Builder( + builder: (BuildContext context) { + return Container( + width: MediaQuery.of(context).size.width, + margin: const EdgeInsets.symmetric(horizontal: 5.0), + decoration: const BoxDecoration( + color: Color.fromARGB(255, 240, 238, 238), + borderRadius: + BorderRadius.all(Radius.circular(8.0)), + ), + child: getQuestionCard( + question.title[model.locale.languageCode], + question.description[model.locale.languageCode], + ), + ); + }, + ); + }).toList(), + ), ), - ), - getSubtitle(AppIntl.of(context).actions), - Expanded( - child: ListView.builder( - padding: const EdgeInsets.only(top: 1.0), - itemCount: faq.actions.length, - itemBuilder: (context, index) { - final action = faq.actions[index]; + getSubtitle(AppIntl.of(context).actions), + Expanded( + child: ListView.builder( + padding: const EdgeInsets.only(top: 1.0), + itemCount: faq.actions.length, + itemBuilder: (context, index) { + final action = faq.actions[index]; - return getActionCard( - action.title[model.locale.languageCode], - action.description[model.locale.languageCode], - action.type, - action.link, - action.iconName, - action.iconColor, - action.circleColor, - context, - model - ); - }, - ), - ) - ], - ), - ); - }, - ); + return getActionCard( + action.title[model.locale.languageCode], + action.description[model.locale.languageCode], + action.type, + action.link, + action.iconName, + action.iconColor, + action.circleColor, + context, + model); + }, + ), + ) + ], + ), + ); + }, + ); Padding getTitle() { return Padding( padding: const EdgeInsets.only(top: 60.0), - child: Row( - children: [ - Padding( - padding: const EdgeInsets.only(left: 5.0), - child: GestureDetector( - onTap: () { - Navigator.of(context).pop(); - }, - child: Padding( - padding: const EdgeInsets.only(left: 10.0), - child: Icon( - Icons.arrow_back, - color: widget.backgroundColor == Colors.white + child: Row( + children: [ + Padding( + padding: const EdgeInsets.only(left: 5.0), + child: GestureDetector( + onTap: () { + Navigator.of(context).pop(); + }, + child: Padding( + padding: const EdgeInsets.only(left: 10.0), + child: Icon( + Icons.arrow_back, + color: widget.backgroundColor == Colors.white ? Colors.black : Colors.white, - ), ), ), ), - const SizedBox(width: 8.0), - Expanded( - child: Text( - AppIntl.of(context).need_help, - textAlign: TextAlign.center, - style: Theme.of(context).textTheme.headline5.copyWith( - color: widget.backgroundColor == Colors.white - ? Colors.black - : Colors.white, - ), - ), + ), + const SizedBox(width: 8.0), + Expanded( + child: Text( + AppIntl.of(context).need_help, + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.headline5.copyWith( + color: widget.backgroundColor == Colors.white + ? Colors.black + : Colors.white, + ), ), - ], - ), - ); + ), + ], + ), + ); } Padding getSubtitle(String subtitle) { return Padding( padding: const EdgeInsets.only(left: 18.0, top: 18.0, bottom: 10.0), child: Text( - subtitle, - style: Theme.of(context).textTheme.headline5.copyWith( - color: widget.backgroundColor == Colors.white - ? Colors.black - : Colors.white, - ), - ), + subtitle, + style: Theme.of(context).textTheme.headline5.copyWith( + color: widget.backgroundColor == Colors.white + ? Colors.black + : Colors.white, + ), + ), ); } @@ -184,16 +183,15 @@ class _FaqViewState extends State { } Padding getActionCard( - String title, - String description, - ActionType type, + String title, + String description, + ActionType type, String link, IconData iconName, Color iconColor, Color circleColor, BuildContext context, - FaqViewModel model - ) { + FaqViewModel model) { return Padding( padding: const EdgeInsets.fromLTRB(15.0, 0.0, 15.0, 15.0), child: ElevatedButton( @@ -205,12 +203,12 @@ class _FaqViewState extends State { } }, style: ButtonStyle( - elevation: MaterialStateProperty.all(8.0), - shape: MaterialStateProperty.all( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8.0), - ), - )), + elevation: MaterialStateProperty.all(8.0), + shape: MaterialStateProperty.all( + RoundedRectangleBorder( + borderRadius: BorderRadius.circular(8.0), + ), + )), child: getActionCardInfo( context, title, @@ -246,22 +244,22 @@ class _FaqViewState extends State { Text( title, style: Theme.of(context).textTheme.bodyText2.copyWith( - fontSize: 18, - color: Theme.of(context).brightness == Brightness.light - ? Colors.black - : Colors.white, - ), + fontSize: 18, + color: Theme.of(context).brightness == Brightness.light + ? Colors.black + : Colors.white, + ), textAlign: TextAlign.left, ), const SizedBox(height: 10.0), Text( description, style: Theme.of(context).textTheme.bodyText2.copyWith( - fontSize: 16, - color: Theme.of(context).brightness == Brightness.light - ? Colors.black - : Colors.white, - ), + fontSize: 16, + color: Theme.of(context).brightness == Brightness.light + ? Colors.black + : Colors.white, + ), textAlign: TextAlign.justify, ) ], @@ -273,10 +271,11 @@ class _FaqViewState extends State { } Future openWebview(FaqViewModel model, String link) async { - model.launchWebsite(link, Theme.of(context).brightness); + model.launchWebsite(link, Theme.of(context).brightness); } - Future openMail(FaqViewModel model, BuildContext context, String addressEmail) async { + Future openMail( + FaqViewModel model, BuildContext context, String addressEmail) async { model.openMail(addressEmail, context); } } diff --git a/lib/ui/views/login_view.dart b/lib/ui/views/login_view.dart index be935529a..8135e44b6 100644 --- a/lib/ui/views/login_view.dart +++ b/lib/ui/views/login_view.dart @@ -216,10 +216,11 @@ class _LoginViewState extends State { ), onTap: () async { _navigationService.pushNamed( - RouterPaths.faq, - arguments: Utils.getColorByBrightness( - context, AppTheme.etsLightRed, AppTheme.primaryDark) - ); + RouterPaths.faq, + arguments: Utils.getColorByBrightness( + context, + AppTheme.etsLightRed, + AppTheme.primaryDark)); }, ), ), @@ -266,5 +267,4 @@ class _LoginViewState extends State { Color get submitTextColor => Utils.getColorByBrightness(context, AppTheme.etsLightRed, Colors.white); - } diff --git a/lib/ui/views/more_view.dart b/lib/ui/views/more_view.dart index 45dd42d22..8ed7f33d3 100644 --- a/lib/ui/views/more_view.dart +++ b/lib/ui/views/more_view.dart @@ -169,11 +169,9 @@ class _MoreViewState extends State { model), onTap: () { _analyticsService.logEvent(tag, "FAQ clicked"); - model.navigationService.pushNamed( - RouterPaths.faq, - arguments: Utils.getColorByBrightness( - context, Colors.white, AppTheme.primaryDark) - ); + model.navigationService.pushNamed(RouterPaths.faq, + arguments: Utils.getColorByBrightness( + context, Colors.white, AppTheme.primaryDark)); }), ListTile( title: Text(AppIntl.of(context).settings_title), diff --git a/test/ui/views/faq_view_test.dart b/test/ui/views/faq_view_test.dart index 55d241ce3..b7e33eef3 100644 --- a/test/ui/views/faq_view_test.dart +++ b/test/ui/views/faq_view_test.dart @@ -22,7 +22,7 @@ import 'package:notredame/core/constants/faq.dart'; void main() { group('FaqView - ', () { AppIntl appIntl; - + SettingsManager settingsManager; setUp(() async { @@ -47,21 +47,23 @@ void main() { expect(elevatedButton, findsNWidgets(numberOfButtons)); }); - testWidgets('has x IntrinsicHeight for the questions', (WidgetTester tester) async { + testWidgets('has x IntrinsicHeight for the questions', + (WidgetTester tester) async { SettingsManagerMock.stubLocale(settingsManager as SettingsManagerMock); - + await tester.pumpWidget(localizedWidget(child: const FaqView())); await tester.pumpAndSettle(); - final instrinsicHeight = find.byType(IntrinsicHeight, skipOffstage: false); + final instrinsicHeight = + find.byType(IntrinsicHeight, skipOffstage: false); - // Seulement 3 tuiles du carousel sont affichées à la fois + // Seulement 3 tuiles du carousel sont affichées à la fois expect(instrinsicHeight, findsNWidgets(3)); }); testWidgets('has 2 subtitles', (WidgetTester tester) async { SettingsManagerMock.stubLocale(settingsManager as SettingsManagerMock); - + await tester.pumpWidget(localizedWidget(child: const FaqView())); await tester.pumpAndSettle(); @@ -74,7 +76,7 @@ void main() { testWidgets('has 1 title', (WidgetTester tester) async { SettingsManagerMock.stubLocale(settingsManager as SettingsManagerMock); - + await tester.pumpWidget(localizedWidget(child: const FaqView())); await tester.pumpAndSettle(); diff --git a/test/ui/views/login_view_test.dart b/test/ui/views/login_view_test.dart index 9e99534ec..b8c474c25 100644 --- a/test/ui/views/login_view_test.dart +++ b/test/ui/views/login_view_test.dart @@ -79,8 +79,7 @@ void main() { await tester.pumpWidget(localizedWidget(child: LoginView())); await tester.pumpAndSettle(); - await tester - .tap(find.widgetWithText(InkWell, intl.need_help)); + await tester.tap(find.widgetWithText(InkWell, intl.need_help)); // Rebuild the widget after the state has changed. await tester.pump(); @@ -101,8 +100,7 @@ void main() { await tester.pumpWidget(localizedWidget(child: LoginView())); await tester.pumpAndSettle(); - await tester - .tap(find.widgetWithText(InkWell, intl.need_help)); + await tester.tap(find.widgetWithText(InkWell, intl.need_help)); // Rebuild the widget after the state has changed. await tester.pumpAndSettle(); diff --git a/test/ui/views/more_view_test.dart b/test/ui/views/more_view_test.dart index 396b9f227..d7cc7387f 100644 --- a/test/ui/views/more_view_test.dart +++ b/test/ui/views/more_view_test.dart @@ -158,7 +158,8 @@ void main() { // Rebuild the widget after the state has changed. await tester.pump(); - verify(navigation.pushNamed(RouterPaths.faq, arguments: Colors.white)).called(1); + verify(navigation.pushNamed(RouterPaths.faq, arguments: Colors.white)) + .called(1); }); testWidgets('settings', (WidgetTester tester) async { diff --git a/test/viewmodels/faq_viewmodel_test.dart b/test/viewmodels/faq_viewmodel_test.dart index aba4e57c4..b6fd76ea7 100644 --- a/test/viewmodels/faq_viewmodel_test.dart +++ b/test/viewmodels/faq_viewmodel_test.dart @@ -44,7 +44,9 @@ void main() { test('Calls launchInBrowser', () { viewModel.launchWebsite("https://clubapplets.ca/", Brightness.light); - verify(launchUrlService.launchInBrowser("https://clubapplets.ca/", Brightness.light)).called(1); + verify(launchUrlService.launchInBrowser( + "https://clubapplets.ca/", Brightness.light)) + .called(1); }); }); });