From f4aa5d7964244e7d6338732c911a1071c12d2cd5 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Fri, 14 Apr 2023 21:04:17 +0100 Subject: [PATCH 01/50] Initial commit --- uni/lib/generated/intl/messages_all.dart | 67 +++++++++ uni/lib/generated/intl/messages_en.dart | 33 +++++ uni/lib/generated/intl/messages_pt-PT.dart | 33 +++++ uni/lib/generated/intl/messages_pt_PT.dart | 28 ++++ uni/lib/generated/l10n.dart | 129 ++++++++++++++++++ uni/lib/l10n/intl_en.arb | 13 ++ uni/lib/l10n/intl_pt_PT.arb | 13 ++ uni/lib/main.dart | 9 ++ uni/lib/view/common_widgets/generic_card.dart | 4 +- .../widgets/course_unit_card.dart | 2 +- uni/lib/view/exams/exams.dart | 3 +- uni/lib/view/home/widgets/bus_stop_card.dart | 3 +- uni/lib/view/home/widgets/exam_card.dart | 3 +- .../view/home/widgets/main_cards_list.dart | 2 +- .../view/home/widgets/restaurant_card.dart | 3 +- uni/lib/view/home/widgets/schedule_card.dart | 3 +- .../widgets/library_occupation_card.dart | 2 +- .../profile/widgets/account_info_card.dart | 3 +- .../profile/widgets/course_info_card.dart | 2 +- .../view/profile/widgets/print_info_card.dart | 2 +- .../widgets/restaurant_page_card.dart | 2 +- uni/pubspec.yaml | 7 +- 22 files changed, 351 insertions(+), 15 deletions(-) create mode 100644 uni/lib/generated/intl/messages_all.dart create mode 100644 uni/lib/generated/intl/messages_en.dart create mode 100644 uni/lib/generated/intl/messages_pt-PT.dart create mode 100644 uni/lib/generated/intl/messages_pt_PT.dart create mode 100644 uni/lib/generated/l10n.dart create mode 100644 uni/lib/l10n/intl_en.arb create mode 100644 uni/lib/l10n/intl_pt_PT.arb diff --git a/uni/lib/generated/intl/messages_all.dart b/uni/lib/generated/intl/messages_all.dart new file mode 100644 index 000000000..171385879 --- /dev/null +++ b/uni/lib/generated/intl/messages_all.dart @@ -0,0 +1,67 @@ +// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart +// This is a library that looks up messages for specific locales by +// delegating to the appropriate library. + +// Ignore issues from commonly used lints in this file. +// ignore_for_file:implementation_imports, file_names, unnecessary_new +// ignore_for_file:unnecessary_brace_in_string_interps, directives_ordering +// ignore_for_file:argument_type_not_assignable, invalid_assignment +// ignore_for_file:prefer_single_quotes, prefer_generic_function_type_aliases +// ignore_for_file:comment_references + +import 'dart:async'; + +import 'package:flutter/foundation.dart'; +import 'package:intl/intl.dart'; +import 'package:intl/message_lookup_by_library.dart'; +import 'package:intl/src/intl_helpers.dart'; + +import 'messages_en.dart' as messages_en; +import 'messages_pt-PT.dart' as messages_pt_pt; + +typedef Future LibraryLoader(); +Map _deferredLibraries = { + 'en': () => new SynchronousFuture(null), + 'pt_PT': () => new SynchronousFuture(null), +}; + +MessageLookupByLibrary? _findExact(String localeName) { + switch (localeName) { + case 'en': + return messages_en.messages; + case 'pt_PT': + return messages_pt_pt.messages; + default: + return null; + } +} + +/// User programs should call this before using [localeName] for messages. +Future initializeMessages(String localeName) { + var availableLocale = Intl.verifiedLocale( + localeName, (locale) => _deferredLibraries[locale] != null, + onFailure: (_) => null); + if (availableLocale == null) { + return new SynchronousFuture(false); + } + var lib = _deferredLibraries[availableLocale]; + lib == null ? new SynchronousFuture(false) : lib(); + initializeInternalMessageLookup(() => new CompositeMessageLookup()); + messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); + return new SynchronousFuture(true); +} + +bool _messagesExistFor(String locale) { + try { + return _findExact(locale) != null; + } catch (e) { + return false; + } +} + +MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { + var actualLocale = + Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); + if (actualLocale == null) return null; + return _findExact(actualLocale); +} diff --git a/uni/lib/generated/intl/messages_en.dart b/uni/lib/generated/intl/messages_en.dart new file mode 100644 index 000000000..0b46069ec --- /dev/null +++ b/uni/lib/generated/intl/messages_en.dart @@ -0,0 +1,33 @@ +// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart +// This is a library that provides messages for a en locale. All the +// messages from the main program should be duplicated here with the same +// function name. + +// Ignore issues from commonly used lints in this file. +// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new +// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering +// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases +// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes +// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes + +import 'package:intl/intl.dart'; +import 'package:intl/message_lookup_by_library.dart'; + +final messages = new MessageLookup(); + +typedef String MessageIfAbsent(String messageStr, List args); + +class MessageLookup extends MessageLookupByLibrary { + String get localeName => 'en'; + + final messages = _notInlinedMessages(_notInlinedMessages); + static Map _notInlinedMessages(_) => { + "account_card_title": + MessageLookupByLibrary.simpleMessage("Checking account"), + "bus_card_title": MessageLookupByLibrary.simpleMessage("Buses"), + "exam_card_title": MessageLookupByLibrary.simpleMessage("Exams"), + "no_exams": MessageLookupByLibrary.simpleMessage( + "You do not have appointed exams\n"), + "schedule_card_title": MessageLookupByLibrary.simpleMessage("Schedule") + }; +} diff --git a/uni/lib/generated/intl/messages_pt-PT.dart b/uni/lib/generated/intl/messages_pt-PT.dart new file mode 100644 index 000000000..3f7941260 --- /dev/null +++ b/uni/lib/generated/intl/messages_pt-PT.dart @@ -0,0 +1,33 @@ +// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart +// This is a library that provides messages for a pt_PT locale. All the +// messages from the main program should be duplicated here with the same +// function name. + +// Ignore issues from commonly used lints in this file. +// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new +// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering +// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases +// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes +// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes + +import 'package:intl/intl.dart'; +import 'package:intl/message_lookup_by_library.dart'; + +final messages = new MessageLookup(); + +typedef String MessageIfAbsent(String messageStr, List args); + +class MessageLookup extends MessageLookupByLibrary { + String get localeName => 'pt_PT'; + + final messages = _notInlinedMessages(_notInlinedMessages); + static Map _notInlinedMessages(_) => { + "account_card_title": + MessageLookupByLibrary.simpleMessage("Conta Corrente"), + "bus_card_title": MessageLookupByLibrary.simpleMessage("Autocarros"), + "exam_card_title": MessageLookupByLibrary.simpleMessage("Exames"), + "no_exams": + MessageLookupByLibrary.simpleMessage("Não possui exames marcados"), + "schedule_card_title": MessageLookupByLibrary.simpleMessage("Horário") + }; +} diff --git a/uni/lib/generated/intl/messages_pt_PT.dart b/uni/lib/generated/intl/messages_pt_PT.dart new file mode 100644 index 000000000..2df3e416e --- /dev/null +++ b/uni/lib/generated/intl/messages_pt_PT.dart @@ -0,0 +1,28 @@ +// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart +// This is a library that provides messages for a pt_PT locale. All the +// messages from the main program should be duplicated here with the same +// function name. + +// Ignore issues from commonly used lints in this file. +// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new +// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering +// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases +// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes +// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes + +import 'package:intl/intl.dart'; +import 'package:intl/message_lookup_by_library.dart'; + +final messages = new MessageLookup(); + +typedef String MessageIfAbsent(String messageStr, List args); + +class MessageLookup extends MessageLookupByLibrary { + String get localeName => 'pt_PT'; + + final messages = _notInlinedMessages(_notInlinedMessages); + static Map _notInlinedMessages(_) => { + "no_exams": + MessageLookupByLibrary.simpleMessage("Não possui exames marcados") + }; +} diff --git a/uni/lib/generated/l10n.dart b/uni/lib/generated/l10n.dart new file mode 100644 index 000000000..34de502ef --- /dev/null +++ b/uni/lib/generated/l10n.dart @@ -0,0 +1,129 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +import 'package:flutter/material.dart'; +import 'package:intl/intl.dart'; +import 'intl/messages_all.dart'; + +// ************************************************************************** +// Generator: Flutter Intl IDE plugin +// Made by Localizely +// ************************************************************************** + +// ignore_for_file: non_constant_identifier_names, lines_longer_than_80_chars +// ignore_for_file: join_return_with_assignment, prefer_final_in_for_each +// ignore_for_file: avoid_redundant_argument_values, avoid_escaping_inner_quotes + +class S { + S(); + + static S? _current; + + static S get current { + assert(_current != null, + 'No instance of S was loaded. Try to initialize the S delegate before accessing S.current.'); + return _current!; + } + + static const AppLocalizationDelegate delegate = AppLocalizationDelegate(); + + static Future load(Locale locale) { + final name = (locale.countryCode?.isEmpty ?? false) + ? locale.languageCode + : locale.toString(); + final localeName = Intl.canonicalizedLocale(name); + return initializeMessages(localeName).then((_) { + Intl.defaultLocale = localeName; + final instance = S(); + S._current = instance; + + return instance; + }); + } + + static S of(BuildContext context) { + final instance = S.maybeOf(context); + assert(instance != null, + 'No instance of S present in the widget tree. Did you add S.delegate in localizationsDelegates?'); + return instance!; + } + + static S? maybeOf(BuildContext context) { + return Localizations.of(context, S); + } + + /// `Checking account` + String get account_card_title { + return Intl.message( + 'Checking account', + name: 'account_card_title', + desc: '', + args: [], + ); + } + + /// `Buses` + String get bus_card_title { + return Intl.message( + 'Buses', + name: 'bus_card_title', + desc: '', + args: [], + ); + } + + /// `Exams` + String get exam_card_title { + return Intl.message( + 'Exams', + name: 'exam_card_title', + desc: '', + args: [], + ); + } + + /// `You do not have appointed exams\n` + String get no_exams { + return Intl.message( + 'You do not have appointed exams\n', + name: 'no_exams', + desc: '', + args: [], + ); + } + + /// `Schedule` + String get schedule_card_title { + return Intl.message( + 'Schedule', + name: 'schedule_card_title', + desc: '', + args: [], + ); + } +} + +class AppLocalizationDelegate extends LocalizationsDelegate { + const AppLocalizationDelegate(); + + List get supportedLocales { + return const [ + Locale.fromSubtags(languageCode: 'en'), + Locale.fromSubtags(languageCode: 'pt', countryCode: 'PT'), + ]; + } + + @override + bool isSupported(Locale locale) => _isSupported(locale); + @override + Future load(Locale locale) => S.load(locale); + @override + bool shouldReload(AppLocalizationDelegate old) => false; + + bool _isSupported(Locale locale) { + for (var supportedLocale in supportedLocales) { + if (supportedLocale.languageCode == locale.languageCode) { + return true; + } + } + return false; + } +} diff --git a/uni/lib/l10n/intl_en.arb b/uni/lib/l10n/intl_en.arb new file mode 100644 index 000000000..eea78d8d4 --- /dev/null +++ b/uni/lib/l10n/intl_en.arb @@ -0,0 +1,13 @@ +{ + "@@locale": "en", + "account_card_title": "Checking account", + "@account_card_title": {}, + "bus_card_title": "Buses", + "@bus_card_title": {}, + "exam_card_title": "Exams", + "@exam_card_title": {}, + "no_exams": "You do not have appointed exams\n", + "@no_exams": {}, + "schedule_card_title": "Schedule", + "@schedule_card_title": {} +} \ No newline at end of file diff --git a/uni/lib/l10n/intl_pt_PT.arb b/uni/lib/l10n/intl_pt_PT.arb new file mode 100644 index 000000000..2744b3608 --- /dev/null +++ b/uni/lib/l10n/intl_pt_PT.arb @@ -0,0 +1,13 @@ +{ + "@@locale": "pt-PT", + "account_card_title": "Conta Corrente", + "@account_card_title": {}, + "bus_card_title": "Autocarros", + "@bus_card_title": {}, + "exam_card_title": "Exames", + "@exam_card_title": {}, + "no_exams": "Não possui exames marcados", + "@no_exams": {}, + "schedule_card_title": "Horário", + "@schedule_card_title": {} +} \ No newline at end of file diff --git a/uni/lib/main.dart b/uni/lib/main.dart index fa5edf566..c170a15aa 100644 --- a/uni/lib/main.dart +++ b/uni/lib/main.dart @@ -11,6 +11,8 @@ import 'package:uni/controller/on_start_up.dart'; import 'package:uni/model/providers/bus_stop_provider.dart'; import 'package:uni/model/providers/calendar_provider.dart'; import 'package:uni/model/providers/exam_provider.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'generated/l10n.dart'; import 'package:uni/model/providers/faculty_locations_provider.dart'; import 'package:uni/model/providers/favorite_cards_provider.dart'; import 'package:uni/model/providers/home_page_editing_mode_provider.dart'; @@ -142,6 +144,13 @@ class MyAppState extends State { darkTheme: applicationDarkTheme, themeMode: themeNotifier.getTheme(), home: const SplashScreen(), + localizationsDelegates: [ + S.delegate, + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], + supportedLocales: S.delegate.supportedLocales, navigatorKey: NavigationService.navigatorKey, onGenerateRoute: (RouteSettings settings) { final Map> transitions = { diff --git a/uni/lib/view/common_widgets/generic_card.dart b/uni/lib/view/common_widgets/generic_card.dart index be81dd354..76c97c888 100644 --- a/uni/lib/view/common_widgets/generic_card.dart +++ b/uni/lib/view/common_widgets/generic_card.dart @@ -30,7 +30,7 @@ abstract class GenericCard extends StatefulWidget { Widget buildCardContent(BuildContext context); - String getTitle(); + String getTitle(BuildContext context); dynamic onClick(BuildContext context); @@ -103,7 +103,7 @@ class GenericCardState extends State { alignment: Alignment.centerLeft, padding: const EdgeInsets.symmetric(horizontal: 15), margin: const EdgeInsets.only(top: 15, bottom: 10), - child: Text(widget.getTitle(), + child: Text(widget.getTitle(context), style: (widget.smallTitle ? Theme.of(context).textTheme.headline6! : Theme.of(context) diff --git a/uni/lib/view/course_units/widgets/course_unit_card.dart b/uni/lib/view/course_units/widgets/course_unit_card.dart index a3df1298d..7a9da2e69 100644 --- a/uni/lib/view/course_units/widgets/course_unit_card.dart +++ b/uni/lib/view/course_units/widgets/course_unit_card.dart @@ -29,7 +29,7 @@ class CourseUnitCard extends GenericCard { } @override - String getTitle() { + String getTitle(context) { return courseUnit.name.length > maxTitleLength ? '${courseUnit.name.split(' ').sublist(0, 5).join(' ')}...' : courseUnit.name; diff --git a/uni/lib/view/exams/exams.dart b/uni/lib/view/exams/exams.dart index 0d43565fb..390a09d97 100644 --- a/uni/lib/view/exams/exams.dart +++ b/uni/lib/view/exams/exams.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:uni/model/providers/exam_provider.dart'; import 'package:uni/model/entities/exam.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/view/common_widgets/pages_layouts/general/general.dart'; import 'package:uni/view/exams/widgets/exam_page_title.dart'; import 'package:uni/view/common_widgets/row_container.dart'; @@ -42,7 +43,7 @@ class ExamsPageViewState extends GeneralPageViewState { if (exams.isEmpty) { columns.add(Center( heightFactor: 2, - child: Text('Não possui exames marcados.', + child: Text(S.of(context).no_exams, style: Theme.of(context).textTheme.headline6), )); return columns; diff --git a/uni/lib/view/home/widgets/bus_stop_card.dart b/uni/lib/view/home/widgets/bus_stop_card.dart index 685d31101..ecb83d22e 100644 --- a/uni/lib/view/home/widgets/bus_stop_card.dart +++ b/uni/lib/view/home/widgets/bus_stop_card.dart @@ -4,6 +4,7 @@ import 'package:uni/model/request_status.dart'; import 'package:uni/model/entities/bus_stop.dart'; import 'package:uni/model/providers/bus_stop_provider.dart'; import 'package:uni/utils/drawer_items.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/view/bus_stop_next_arrivals/widgets/bus_stop_row.dart'; import 'package:uni/view/bus_stop_selection/bus_stop_selection.dart'; import 'package:uni/view/common_widgets/generic_card.dart'; @@ -16,7 +17,7 @@ class BusStopCard extends GenericCard { : super.fromEditingInformation(key, editingMode, onDelete); @override - String getTitle() => 'Autocarros'; + String getTitle(BuildContext context) => S.of(context).bus_card_title; @override onClick(BuildContext context) => diff --git a/uni/lib/view/home/widgets/exam_card.dart b/uni/lib/view/home/widgets/exam_card.dart index aa7d4f268..068f9e806 100644 --- a/uni/lib/view/home/widgets/exam_card.dart +++ b/uni/lib/view/home/widgets/exam_card.dart @@ -7,6 +7,7 @@ import 'package:uni/view/common_widgets/request_dependent_widget_builder.dart'; import 'package:uni/view/common_widgets/row_container.dart'; import 'package:uni/view/common_widgets/generic_card.dart'; import 'package:uni/utils/drawer_items.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/view/home/widgets/exam_card_shimmer.dart'; import 'package:uni/view/exams/widgets/exam_row.dart'; import 'package:uni/view/exams/widgets/exam_title.dart'; @@ -20,7 +21,7 @@ class ExamCard extends GenericCard { : super.fromEditingInformation(key, editingMode, onDelete); @override - String getTitle() => 'Exames'; + String getTitle(BuildContext context) => S.of(context).exam_card_title; @override onClick(BuildContext context) => diff --git a/uni/lib/view/home/widgets/main_cards_list.dart b/uni/lib/view/home/widgets/main_cards_list.dart index ee2fa9c63..401f5cde4 100644 --- a/uni/lib/view/home/widgets/main_cards_list.dart +++ b/uni/lib/view/home/widgets/main_cards_list.dart @@ -116,7 +116,7 @@ class MainCardsList extends StatelessWidget { decoration: const BoxDecoration(), child: ListTile( title: Text( - e.value(Key(e.key.index.toString()), false, null).getTitle(), + e.value(Key(e.key.index.toString()), false, null).getTitle(context), textAlign: TextAlign.center, ), onTap: () { diff --git a/uni/lib/view/home/widgets/restaurant_card.dart b/uni/lib/view/home/widgets/restaurant_card.dart index 69255adfa..cddd6cc14 100644 --- a/uni/lib/view/home/widgets/restaurant_card.dart +++ b/uni/lib/view/home/widgets/restaurant_card.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:uni/model/providers/restaurant_provider.dart'; import 'package:uni/view/common_widgets/date_rectangle.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/view/common_widgets/generic_card.dart'; import 'package:uni/view/common_widgets/request_dependent_widget_builder.dart'; import 'package:uni/view/common_widgets/row_container.dart'; @@ -15,7 +16,7 @@ class RestaurantCard extends GenericCard { : super.fromEditingInformation(key, editingMode, onDelete); @override - String getTitle() => 'Cantinas'; + String getTitle(context) => 'Cantinas'; @override onClick(BuildContext context) => null; diff --git a/uni/lib/view/home/widgets/schedule_card.dart b/uni/lib/view/home/widgets/schedule_card.dart index 2ba31b108..d8c9511c7 100644 --- a/uni/lib/view/home/widgets/schedule_card.dart +++ b/uni/lib/view/home/widgets/schedule_card.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:uni/model/entities/lecture.dart'; import 'package:uni/model/entities/time_utilities.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/model/providers/lecture_provider.dart'; import 'package:uni/view/common_widgets/date_rectangle.dart'; import 'package:uni/view/common_widgets/request_dependent_widget_builder.dart'; @@ -105,7 +106,7 @@ class ScheduleCard extends GenericCard { } @override - String getTitle() => 'Horário'; + String getTitle(context) => S.of(context).schedule_card_title; @override onClick(BuildContext context) => diff --git a/uni/lib/view/library/widgets/library_occupation_card.dart b/uni/lib/view/library/widgets/library_occupation_card.dart index 966d9c71d..f4745f800 100644 --- a/uni/lib/view/library/widgets/library_occupation_card.dart +++ b/uni/lib/view/library/widgets/library_occupation_card.dart @@ -16,7 +16,7 @@ class LibraryOccupationCard extends GenericCard { : super.fromEditingInformation(key, editingMode, onDelete); @override - String getTitle() => 'Ocupação da Biblioteca'; + String getTitle(context) => 'Ocupação da Biblioteca'; @override onClick(BuildContext context) => diff --git a/uni/lib/view/profile/widgets/account_info_card.dart b/uni/lib/view/profile/widgets/account_info_card.dart index e690f0baf..4b952c676 100644 --- a/uni/lib/view/profile/widgets/account_info_card.dart +++ b/uni/lib/view/profile/widgets/account_info_card.dart @@ -3,6 +3,7 @@ import 'package:provider/provider.dart'; import 'package:uni/model/providers/profile_state_provider.dart'; import 'package:uni/view/common_widgets/generic_card.dart'; import 'package:uni/view/profile/widgets/tuition_notification_switch.dart'; +import 'package:uni/generated/l10n.dart'; /// Manages the 'Current account' section inside the user's page (accessible /// through the top-right widget with the user picture) @@ -69,7 +70,7 @@ class AccountInfoCard extends GenericCard { } @override - String getTitle() => 'Conta Corrente'; + String getTitle(context) => S.of(context).account_card_title; @override onClick(BuildContext context) {} diff --git a/uni/lib/view/profile/widgets/course_info_card.dart b/uni/lib/view/profile/widgets/course_info_card.dart index 4c2b14476..68dcbcdc6 100644 --- a/uni/lib/view/profile/widgets/course_info_card.dart +++ b/uni/lib/view/profile/widgets/course_info_card.dart @@ -97,7 +97,7 @@ class CourseInfoCard extends GenericCard { } @override - String getTitle() { + String getTitle(context) { return course.name ?? 'Curso sem nome'; } diff --git a/uni/lib/view/profile/widgets/print_info_card.dart b/uni/lib/view/profile/widgets/print_info_card.dart index c30e87e37..f97ebeca2 100644 --- a/uni/lib/view/profile/widgets/print_info_card.dart +++ b/uni/lib/view/profile/widgets/print_info_card.dart @@ -60,7 +60,7 @@ class PrintInfoCard extends GenericCard { } @override - String getTitle() => 'Impressões'; + String getTitle(context) => 'Impressões'; @override onClick(BuildContext context) {} diff --git a/uni/lib/view/restaurant/widgets/restaurant_page_card.dart b/uni/lib/view/restaurant/widgets/restaurant_page_card.dart index 9dbfd2773..2c86aee67 100644 --- a/uni/lib/view/restaurant/widgets/restaurant_page_card.dart +++ b/uni/lib/view/restaurant/widgets/restaurant_page_card.dart @@ -13,7 +13,7 @@ class RestaurantPageCard extends GenericCard { } @override - String getTitle() { + String getTitle(context) { return restaurantName; } diff --git a/uni/pubspec.yaml b/uni/pubspec.yaml index d0b897829..ca53121bc 100644 --- a/uni/pubspec.yaml +++ b/uni/pubspec.yaml @@ -35,6 +35,8 @@ environment: dependencies: flutter: sdk: flutter + flutter_localizations: + sdk: flutter html: ^0.15.0 http: ^0.13.0 tuple: ^2.0.0 @@ -165,5 +167,8 @@ flutter_icons: image_path: "assets/icon/icon.png" adaptive_icon_background: "#75171E" adaptive_icon_foreground: "assets/icon/android_icon_foreground.png" - +flutter_intl: + enabled: true + localizely: + project_id: 788a209d-5f55-4f7d-ad09-6033b2b65fc1 From e7aa34f6dbc04e4179628ab4fea18fdeefbe5a2e Mon Sep 17 00:00:00 2001 From: DGoiana Date: Wed, 19 Apr 2023 23:33:34 +0100 Subject: [PATCH 02/50] Main page and navigation drawer translation --- uni/lib/generated/intl/messages_all.dart | 6 +- uni/lib/generated/intl/messages_en.dart | 54 ++++- uni/lib/generated/intl/messages_pt-PT.dart | 52 ++++- uni/lib/generated/intl/messages_pt_PT.dart | 28 --- uni/lib/generated/l10n.dart | 211 +++++++++++++++++- uni/lib/l10n/intl_en.arb | 50 ++++- uni/lib/l10n/intl_pt_PT.arb | 48 +++- uni/lib/main.dart | 4 +- uni/lib/model/entities/exam.dart | 64 +++--- uni/lib/model/entities/time_utilities.dart | 28 ++- uni/lib/utils/drawer_items.dart | 24 +- uni/lib/view/common_widgets/generic_card.dart | 3 +- .../common_widgets/last_update_timestamp.dart | 3 +- .../general/widgets/navigation_drawer.dart | 7 +- uni/lib/view/home/widgets/bus_stop_card.dart | 10 +- uni/lib/view/home/widgets/exam_card.dart | 12 +- .../view/home/widgets/main_cards_list.dart | 15 +- .../view/home/widgets/restaurant_card.dart | 1 - .../profile/widgets/account_info_card.dart | 6 +- 19 files changed, 517 insertions(+), 109 deletions(-) delete mode 100644 uni/lib/generated/intl/messages_pt_PT.dart diff --git a/uni/lib/generated/intl/messages_all.dart b/uni/lib/generated/intl/messages_all.dart index 171385879..d06573802 100644 --- a/uni/lib/generated/intl/messages_all.dart +++ b/uni/lib/generated/intl/messages_all.dart @@ -38,13 +38,13 @@ MessageLookupByLibrary? _findExact(String localeName) { /// User programs should call this before using [localeName] for messages. Future initializeMessages(String localeName) { - var availableLocale = Intl.verifiedLocale( + final availableLocale = Intl.verifiedLocale( localeName, (locale) => _deferredLibraries[locale] != null, onFailure: (_) => null); if (availableLocale == null) { return new SynchronousFuture(false); } - var lib = _deferredLibraries[availableLocale]; + final lib = _deferredLibraries[availableLocale]; lib == null ? new SynchronousFuture(false) : lib(); initializeInternalMessageLookup(() => new CompositeMessageLookup()); messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); @@ -60,7 +60,7 @@ bool _messagesExistFor(String locale) { } MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { - var actualLocale = + final actualLocale = Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); if (actualLocale == null) return null; return _findExact(actualLocale); diff --git a/uni/lib/generated/intl/messages_en.dart b/uni/lib/generated/intl/messages_en.dart index 0b46069ec..b3f9e5563 100644 --- a/uni/lib/generated/intl/messages_en.dart +++ b/uni/lib/generated/intl/messages_en.dart @@ -20,14 +20,64 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'en'; + static String m0(time) => "last refresh at ${time}"; + + static String m1(time) => + "${Intl.plural(time, one: 'Refreshed ${time} minute ago', other: 'Refreshed ${time} minutes ago')}"; + + static String m2(title) => "${Intl.select(title, { + 'horario': 'Schedule', + 'exames': 'Exams', + 'area': 'Personal Area', + 'cadeiras': 'Course Units', + 'autocarros': 'Buses', + 'locais': 'Places', + 'restaurantes': 'Restaurants', + 'calendario': 'Calendar', + 'biblioteca': 'Library', + 'uteis': 'Utils', + 'sobre': 'About', + 'bugs': 'Bugs and Suggestions', + 'other': 'Other', + })}"; + final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { "account_card_title": MessageLookupByLibrary.simpleMessage("Checking account"), + "add_widget": MessageLookupByLibrary.simpleMessage("Add widget"), + "all_widgets_added": MessageLookupByLibrary.simpleMessage( + "All available widgets have already been added to your personal area!"), + "balance": MessageLookupByLibrary.simpleMessage("Balance:"), "bus_card_title": MessageLookupByLibrary.simpleMessage("Buses"), + "bus_error": + MessageLookupByLibrary.simpleMessage("Unable to get information"), + "buses_personalize": + MessageLookupByLibrary.simpleMessage("Personalize your buses here"), + "cancel": MessageLookupByLibrary.simpleMessage("Cancel"), + "edit_off": MessageLookupByLibrary.simpleMessage("Edit"), + "edit_on": MessageLookupByLibrary.simpleMessage("Finish editing"), "exam_card_title": MessageLookupByLibrary.simpleMessage("Exams"), + "fee_date": + MessageLookupByLibrary.simpleMessage("Deadline for next fee:"), + "fee_notification": + MessageLookupByLibrary.simpleMessage("Notify next deadline:"), + "last_refresh_time": m0, + "last_timestamp": m1, + "logout": MessageLookupByLibrary.simpleMessage("Log out"), + "nav_title": m2, + "no_data": MessageLookupByLibrary.simpleMessage( + "There is no data to show at this time"), "no_exams": MessageLookupByLibrary.simpleMessage( - "You do not have appointed exams\n"), - "schedule_card_title": MessageLookupByLibrary.simpleMessage("Schedule") + "You have no exams scheduled\n"), + "no_selected_exams": MessageLookupByLibrary.simpleMessage( + "There are no exams to present"), + "restaurant_card_title": + MessageLookupByLibrary.simpleMessage("Restaurants"), + "schedule_card_title": MessageLookupByLibrary.simpleMessage("Schedule"), + "stcp_stops": + MessageLookupByLibrary.simpleMessage("STCP - Upcoming Trips"), + "widget_prompt": MessageLookupByLibrary.simpleMessage( + "Choose a widget to add to your personal area:") }; } diff --git a/uni/lib/generated/intl/messages_pt-PT.dart b/uni/lib/generated/intl/messages_pt-PT.dart index 3f7941260..3c93a7011 100644 --- a/uni/lib/generated/intl/messages_pt-PT.dart +++ b/uni/lib/generated/intl/messages_pt-PT.dart @@ -20,14 +20,64 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'pt_PT'; + static String m0(time) => "última atualização às ${time}"; + + static String m1(time) => + "${Intl.plural(time, one: '${time} minuto', other: '${time} minutos')}"; + + static String m2(title) => "${Intl.select(title, { + 'horario': 'Horário', + 'exames': 'Exames', + 'area': 'Área Pessoal', + 'cadeiras': 'Cadeiras', + 'autocarros': 'Autocarros', + 'locais': 'Locais', + 'restaurantes': 'Restaurantes', + 'calendario': 'Calendário', + 'biblioteca': 'Biblioteca', + 'uteis': 'Úteis', + 'sobre': 'Sobre', + 'bugs': 'Bugs e Sugestões', + 'other': 'Outros', + })}"; + final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { "account_card_title": MessageLookupByLibrary.simpleMessage("Conta Corrente"), + "add_widget": MessageLookupByLibrary.simpleMessage("Adicionar widget"), + "all_widgets_added": MessageLookupByLibrary.simpleMessage( + "Todos os widgets disponíveis já foram adicionados à tua área pessoal!"), + "balance": MessageLookupByLibrary.simpleMessage("Saldo:"), "bus_card_title": MessageLookupByLibrary.simpleMessage("Autocarros"), + "bus_error": MessageLookupByLibrary.simpleMessage( + "Não foi possível obter informação"), + "buses_personalize": MessageLookupByLibrary.simpleMessage( + "Configura aqui os teus autocarros"), + "cancel": MessageLookupByLibrary.simpleMessage("Cancelar\n"), + "edit_off": MessageLookupByLibrary.simpleMessage("Editar\n"), + "edit_on": MessageLookupByLibrary.simpleMessage("Concluir edição"), "exam_card_title": MessageLookupByLibrary.simpleMessage("Exames"), + "fee_date": MessageLookupByLibrary.simpleMessage( + "Data limite próxima prestação:"), + "fee_notification": MessageLookupByLibrary.simpleMessage( + "Notificar próxima data limite:"), + "last_refresh_time": m0, + "last_timestamp": m1, + "logout": MessageLookupByLibrary.simpleMessage("Terminar sessão"), + "nav_title": m2, + "no_data": MessageLookupByLibrary.simpleMessage( + "Não há dados a mostrar neste momento"), "no_exams": MessageLookupByLibrary.simpleMessage("Não possui exames marcados"), - "schedule_card_title": MessageLookupByLibrary.simpleMessage("Horário") + "no_selected_exams": MessageLookupByLibrary.simpleMessage( + "Não existem exames para apresentar"), + "restaurant_card_title": + MessageLookupByLibrary.simpleMessage("Restaurantes"), + "schedule_card_title": MessageLookupByLibrary.simpleMessage("Horário"), + "stcp_stops": + MessageLookupByLibrary.simpleMessage("STCP - Próximas Viagens"), + "widget_prompt": MessageLookupByLibrary.simpleMessage( + "Escolhe um widget para adicionares à tua área pessoal:") }; } diff --git a/uni/lib/generated/intl/messages_pt_PT.dart b/uni/lib/generated/intl/messages_pt_PT.dart deleted file mode 100644 index 2df3e416e..000000000 --- a/uni/lib/generated/intl/messages_pt_PT.dart +++ /dev/null @@ -1,28 +0,0 @@ -// DO NOT EDIT. This is code generated via package:intl/generate_localized.dart -// This is a library that provides messages for a pt_PT locale. All the -// messages from the main program should be duplicated here with the same -// function name. - -// Ignore issues from commonly used lints in this file. -// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new -// ignore_for_file:prefer_single_quotes,comment_references, directives_ordering -// ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases -// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes -// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes - -import 'package:intl/intl.dart'; -import 'package:intl/message_lookup_by_library.dart'; - -final messages = new MessageLookup(); - -typedef String MessageIfAbsent(String messageStr, List args); - -class MessageLookup extends MessageLookupByLibrary { - String get localeName => 'pt_PT'; - - final messages = _notInlinedMessages(_notInlinedMessages); - static Map _notInlinedMessages(_) => { - "no_exams": - MessageLookupByLibrary.simpleMessage("Não possui exames marcados") - }; -} diff --git a/uni/lib/generated/l10n.dart b/uni/lib/generated/l10n.dart index 34de502ef..cd42ec413 100644 --- a/uni/lib/generated/l10n.dart +++ b/uni/lib/generated/l10n.dart @@ -60,6 +60,36 @@ class S { ); } + /// `Add widget` + String get add_widget { + return Intl.message( + 'Add widget', + name: 'add_widget', + desc: '', + args: [], + ); + } + + /// `All available widgets have already been added to your personal area!` + String get all_widgets_added { + return Intl.message( + 'All available widgets have already been added to your personal area!', + name: 'all_widgets_added', + desc: '', + args: [], + ); + } + + /// `Balance:` + String get balance { + return Intl.message( + 'Balance:', + name: 'balance', + desc: '', + args: [], + ); + } + /// `Buses` String get bus_card_title { return Intl.message( @@ -70,6 +100,56 @@ class S { ); } + /// `Unable to get information` + String get bus_error { + return Intl.message( + 'Unable to get information', + name: 'bus_error', + desc: '', + args: [], + ); + } + + /// `Personalize your buses here` + String get buses_personalize { + return Intl.message( + 'Personalize your buses here', + name: 'buses_personalize', + desc: '', + args: [], + ); + } + + /// `Cancel` + String get cancel { + return Intl.message( + 'Cancel', + name: 'cancel', + desc: '', + args: [], + ); + } + + /// `Edit` + String get edit_off { + return Intl.message( + 'Edit', + name: 'edit_off', + desc: '', + args: [], + ); + } + + /// `Finish editing` + String get edit_on { + return Intl.message( + 'Finish editing', + name: 'edit_on', + desc: '', + args: [], + ); + } + /// `Exams` String get exam_card_title { return Intl.message( @@ -80,16 +160,123 @@ class S { ); } - /// `You do not have appointed exams\n` + /// `Deadline for next fee:` + String get fee_date { + return Intl.message( + 'Deadline for next fee:', + name: 'fee_date', + desc: '', + args: [], + ); + } + + /// `Notify next deadline:` + String get fee_notification { + return Intl.message( + 'Notify next deadline:', + name: 'fee_notification', + desc: '', + args: [], + ); + } + + /// `last refresh at {time}` + String last_refresh_time(Object time) { + return Intl.message( + 'last refresh at $time', + name: 'last_refresh_time', + desc: '', + args: [time], + ); + } + + /// `{time, plural, one{Refreshed {time} minute ago} other{Refreshed {time} minutes ago}}` + String last_timestamp(num time) { + return Intl.plural( + time, + one: 'Refreshed $time minute ago', + other: 'Refreshed $time minutes ago', + name: 'last_timestamp', + desc: '', + args: [time], + ); + } + + /// `Log out` + String get logout { + return Intl.message( + 'Log out', + name: 'logout', + desc: '', + args: [], + ); + } + + /// `{title, select, horario{Schedule} exames{Exams} area{Personal Area} cadeiras{Course Units} autocarros{Buses} locais{Places} restaurantes{Restaurants} calendario{Calendar} biblioteca{Library} uteis{Utils} sobre{About} bugs{Bugs and Suggestions} other{Other}}` + String nav_title(Object title) { + return Intl.select( + title, + { + 'horario': 'Schedule', + 'exames': 'Exams', + 'area': 'Personal Area', + 'cadeiras': 'Course Units', + 'autocarros': 'Buses', + 'locais': 'Places', + 'restaurantes': 'Restaurants', + 'calendario': 'Calendar', + 'biblioteca': 'Library', + 'uteis': 'Utils', + 'sobre': 'About', + 'bugs': 'Bugs and Suggestions', + 'other': 'Other', + }, + name: 'nav_title', + desc: '', + args: [title], + ); + } + + /// `There is no data to show at this time` + String get no_data { + return Intl.message( + 'There is no data to show at this time', + name: 'no_data', + desc: '', + args: [], + ); + } + + /// `You have no exams scheduled\n` String get no_exams { return Intl.message( - 'You do not have appointed exams\n', + 'You have no exams scheduled\n', name: 'no_exams', desc: '', args: [], ); } + /// `There are no exams to present` + String get no_selected_exams { + return Intl.message( + 'There are no exams to present', + name: 'no_selected_exams', + desc: '', + args: [], + ); + } + + /// `Restaurants` + String get restaurant_card_title { + return Intl.message( + 'Restaurants', + name: 'restaurant_card_title', + desc: '', + args: [], + ); + } + /// `Schedule` String get schedule_card_title { return Intl.message( @@ -99,6 +286,26 @@ class S { args: [], ); } + + /// `STCP - Upcoming Trips` + String get stcp_stops { + return Intl.message( + 'STCP - Upcoming Trips', + name: 'stcp_stops', + desc: '', + args: [], + ); + } + + /// `Choose a widget to add to your personal area:` + String get widget_prompt { + return Intl.message( + 'Choose a widget to add to your personal area:', + name: 'widget_prompt', + desc: '', + args: [], + ); + } } class AppLocalizationDelegate extends LocalizationsDelegate { diff --git a/uni/lib/l10n/intl_en.arb b/uni/lib/l10n/intl_en.arb index eea78d8d4..8f48675c6 100644 --- a/uni/lib/l10n/intl_en.arb +++ b/uni/lib/l10n/intl_en.arb @@ -2,12 +2,58 @@ "@@locale": "en", "account_card_title": "Checking account", "@account_card_title": {}, + "add_widget": "Add widget", + "@add_widget": {}, + "all_widgets_added": "All available widgets have already been added to your personal area!", + "@all_widgets_added": {}, + "balance": "Balance:", + "@balance": {}, "bus_card_title": "Buses", "@bus_card_title": {}, + "bus_error": "Unable to get information", + "@bus_error": {}, + "buses_personalize": "Personalize your buses here", + "@buses_personalize": {}, + "cancel": "Cancel", + "@cancel": {}, + "edit_off": "Edit", + "@edit_off": {}, + "edit_on": "Finish editing", + "@edit_on": {}, "exam_card_title": "Exams", "@exam_card_title": {}, - "no_exams": "You do not have appointed exams\n", + "fee_date": "Deadline for next fee:", + "@fee_date": {}, + "fee_notification": "Notify next deadline:", + "@fee_notification": {}, + "last_refresh_time": "last refresh at {time}", + "@last_refresh_time": { + "placeholders": { + "time": {} + } + }, + "last_timestamp": "{time, plural, one{Refreshed {time} minute ago} other{Refreshed {time} minutes ago}}", + "@last_timestamp": { + "placeholders": { + "time": {} + } + }, + "logout": "Log out", + "@logout": {}, + "nav_title": "{title, select, horario{Schedule} exames{Exams} area{Personal Area} cadeiras{Course Units} autocarros{Buses} locais{Places} restaurantes{Restaurants} calendario{Calendar} biblioteca{Library} uteis{Utils} sobre{About} bugs{Bugs and Suggestions} other{Other}}", + "@nav_title": {}, + "no_data": "There is no data to show at this time", + "@no_data": {}, + "no_exams": "You have no exams scheduled\n", "@no_exams": {}, + "no_selected_exams": "There are no exams to present", + "@no_selected_exams": {}, + "restaurant_card_title": "Restaurants", + "@restaurant_card_title": {}, "schedule_card_title": "Schedule", - "@schedule_card_title": {} + "@schedule_card_title": {}, + "stcp_stops": "STCP - Upcoming Trips", + "@stcp_stops": {}, + "widget_prompt": "Choose a widget to add to your personal area:", + "@widget_prompt": {} } \ No newline at end of file diff --git a/uni/lib/l10n/intl_pt_PT.arb b/uni/lib/l10n/intl_pt_PT.arb index 2744b3608..f698d58f2 100644 --- a/uni/lib/l10n/intl_pt_PT.arb +++ b/uni/lib/l10n/intl_pt_PT.arb @@ -2,12 +2,58 @@ "@@locale": "pt-PT", "account_card_title": "Conta Corrente", "@account_card_title": {}, + "add_widget": "Adicionar widget", + "@add_widget": {}, + "all_widgets_added": "Todos os widgets disponíveis já foram adicionados à tua área pessoal!", + "@all_widgets_added": {}, + "balance": "Saldo:", + "@balance": {}, "bus_card_title": "Autocarros", "@bus_card_title": {}, + "bus_error": "Não foi possível obter informação", + "@bus_error": {}, + "buses_personalize": "Configura aqui os teus autocarros", + "@buses_personalize": {}, + "cancel": "Cancelar\n", + "@cancel": {}, + "edit_off": "Editar\n", + "@edit_off": {}, + "edit_on": "Concluir edição", + "@edit_on": {}, "exam_card_title": "Exames", "@exam_card_title": {}, + "fee_date": "Data limite próxima prestação:", + "@fee_date": {}, + "fee_notification": "Notificar próxima data limite:", + "@fee_notification": {}, + "last_refresh_time": "última atualização às {time}", + "@last_refresh_time": { + "placeholders": { + "time": {} + } + }, + "last_timestamp": "{time, plural, one{{time} minuto} other{{time} minutos}}", + "@last_timestamp": { + "placeholders": { + "time": {} + } + }, + "logout": "Terminar sessão", + "@logout": {}, + "nav_title": "{title, select, horario{Horário} exames{Exames} area{Área Pessoal} cadeiras{Cadeiras} autocarros{Autocarros} locais{Locais} restaurantes{Restaurantes} calendario{Calendário} biblioteca{Biblioteca} uteis{Úteis} sobre{Sobre} bugs{Bugs e Sugestões} other{Outros}}", + "@nav_title": {}, + "no_data": "Não há dados a mostrar neste momento", + "@no_data": {}, "no_exams": "Não possui exames marcados", "@no_exams": {}, + "no_selected_exams": "Não existem exames para apresentar", + "@no_selected_exams": {}, + "restaurant_card_title": "Restaurantes", + "@restaurant_card_title": {}, "schedule_card_title": "Horário", - "@schedule_card_title": {} + "@schedule_card_title": {}, + "stcp_stops": "STCP - Próximas Viagens", + "@stcp_stops": {}, + "widget_prompt": "Escolhe um widget para adicionares à tua área pessoal:", + "@widget_prompt": {} } \ No newline at end of file diff --git a/uni/lib/main.dart b/uni/lib/main.dart index c170a15aa..353ac3a0c 100644 --- a/uni/lib/main.dart +++ b/uni/lib/main.dart @@ -12,7 +12,7 @@ import 'package:uni/model/providers/bus_stop_provider.dart'; import 'package:uni/model/providers/calendar_provider.dart'; import 'package:uni/model/providers/exam_provider.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; -import 'generated/l10n.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/model/providers/faculty_locations_provider.dart'; import 'package:uni/model/providers/favorite_cards_provider.dart'; import 'package:uni/model/providers/home_page_editing_mode_provider.dart'; @@ -144,7 +144,7 @@ class MyAppState extends State { darkTheme: applicationDarkTheme, themeMode: themeNotifier.getTheme(), home: const SplashScreen(), - localizationsDelegates: [ + localizationsDelegates: const [ S.delegate, GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, diff --git a/uni/lib/model/entities/exam.dart b/uni/lib/model/entities/exam.dart index 9dce8c199..bf696bfb6 100644 --- a/uni/lib/model/entities/exam.dart +++ b/uni/lib/model/entities/exam.dart @@ -1,35 +1,39 @@ +import 'dart:io'; + import 'package:intl/intl.dart'; import 'package:logger/logger.dart'; enum WeekDays { - monday("Segunda"), - tuesday("Terça"), - wednesday("Quarta"), - thursday("Quinta"), - friday("Sexta"), - saturday("Sábado"), - sunday("Domingo"); - - final String day; - const WeekDays(this.day); + monday("Segunda", "Monday"), + tuesday("Terça", "Tuesday"), + wednesday("Quarta", "Wednesday"), + thursday("Quinta", "Thursday"), + friday("Sexta", "Friday"), + saturday("Sábado", "Saturday"), + sunday("Domingo", "Sunday"); + + final String dayPT; + final String dayEN; + const WeekDays(this.dayPT, this.dayEN); } enum Months { - january("janeiro"), - february("fevereiro"), - march("março"), - april("abril"), - may("maio"), - june("junho"), - july("julho"), - august("agosto"), - september("setembro"), - october("outubro"), - november("novembro"), - december("dezembro"); - - final String month; - const Months(this.month); + january("janeiro", "January"), + february("fevereiro", "February"), + march("março", "March"), + april("abril", "April"), + may("maio", "May"), + june("junho", "June"), + july("julho", "July"), + august("agosto", "August"), + september("setembro", "September"), + october("outubro", "October"), + november("novembro", "November"), + december("dezembro", "December"); + + final String monthPT; + final String monthEN; + const Months(this.monthPT, this.monthEN); } /// Manages a generic Exam. @@ -83,9 +87,15 @@ class Exam { /// Returns whether or not this exam has already ended. bool hasEnded() => DateTime.now().compareTo(end) >= 0; - String get weekDay => WeekDays.values[begin.weekday - 1].day; + String get weekDay{ + if(Platform.localeName == 'pt_PT') return WeekDays.values[begin.weekday - 1].dayPT; + return WeekDays.values[begin.weekday - 1].dayEN; + } - String get month => Months.values[begin.month - 1].month; + String get month{ + if(Platform.localeName == 'pt_PT') return Months.values[begin.month - 1].monthPT; + return Months.values[begin.weekday - 1].monthEN; + } String get beginTime => formatTime(begin); diff --git a/uni/lib/model/entities/time_utilities.dart b/uni/lib/model/entities/time_utilities.dart index 9180392b8..6a9d2727d 100644 --- a/uni/lib/model/entities/time_utilities.dart +++ b/uni/lib/model/entities/time_utilities.dart @@ -1,10 +1,13 @@ +import 'dart:io'; + extension TimeString on DateTime { String toTimeHourMinString() { return '${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}'; } static List getWeekdaysStrings({bool startMonday = true, bool includeWeekend = true}) { - final List weekdays = [ + + final List weekdaysPT = [ 'Segunda-Feira', 'Terça-Feira', 'Quarta-Feira', @@ -14,11 +17,28 @@ extension TimeString on DateTime { 'Domingo' ]; + final List weekdaysEN = [ + 'Monday', + 'Tuesday', + 'Wednesday', + 'Thursday', + 'Friday', + 'Saturday', + 'Sunday' + ]; + + final String locale = Platform.localeName; + if (!startMonday) { - weekdays.removeAt(6); - weekdays.insert(0, 'Domingo'); + weekdaysPT.removeAt(6); + weekdaysEN.removeAt(6); + weekdaysPT.insert(0, 'Domingo'); + weekdaysEN.insert(0, 'Sunday'); } - return includeWeekend ? weekdays : weekdays.sublist(0, 5); + if(locale == 'pt_PT') return includeWeekend ? weekdaysPT : weekdaysPT.sublist(0, 5); + return includeWeekend ? weekdaysEN : weekdaysEN.sublist(0, 5); + + } } diff --git a/uni/lib/utils/drawer_items.dart b/uni/lib/utils/drawer_items.dart index a9580353c..e9bfce583 100644 --- a/uni/lib/utils/drawer_items.dart +++ b/uni/lib/utils/drawer_items.dart @@ -1,16 +1,16 @@ enum DrawerItem { - navPersonalArea('Área Pessoal'), - navSchedule('Horário'), - navExams('Exames'), - navCourseUnits('Cadeiras'), - navStops('Autocarros'), - navLocations('Locais', faculties: {'feup'}), - navRestaurants('Restaurantes'), - navCalendar('Calendário'), - navLibrary('Biblioteca', faculties: {'feup'}), - navUsefulInfo('Úteis', faculties: {'feup'}), - navAbout('Sobre'), - navBugReport('Bugs e Sugestões'), + navPersonalArea('area'), + navSchedule('horario'), + navExams('exames'), + navCourseUnits('cadeiras'), + navStops('autocarros'), + navLocations('locais', faculties: {'feup'}), + navRestaurants('restaurantes'), + navCalendar('calendario'), + navLibrary('biblioteca', faculties: {'feup'}), + navUsefulInfo('uteis', faculties: {'feup'}), + navAbout('sobre'), + navBugReport('bugs'), navLogOut('Terminar sessão'); final String title; diff --git a/uni/lib/view/common_widgets/generic_card.dart b/uni/lib/view/common_widgets/generic_card.dart index 76c97c888..4c6ae0344 100644 --- a/uni/lib/view/common_widgets/generic_card.dart +++ b/uni/lib/view/common_widgets/generic_card.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:uni/model/entities/time_utilities.dart'; +import 'package:uni/generated/l10n.dart'; /// App default card abstract class GenericCard extends StatefulWidget { @@ -52,7 +53,7 @@ abstract class GenericCard extends StatefulWidget { return Container( alignment: Alignment.center, - child: Text('última atualização às ${parsedTime.toTimeHourMinString()}', + child: Text(S.of(context).last_refresh_time(parsedTime.toTimeHourMinString()), style: Theme.of(context).textTheme.caption)); } } diff --git a/uni/lib/view/common_widgets/last_update_timestamp.dart b/uni/lib/view/common_widgets/last_update_timestamp.dart index 23617e16e..2935a261e 100644 --- a/uni/lib/view/common_widgets/last_update_timestamp.dart +++ b/uni/lib/view/common_widgets/last_update_timestamp.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:uni/generated/l10n.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:uni/model/providers/last_user_info_provider.dart'; @@ -52,7 +53,7 @@ class _LastUpdateTimeStampState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( - 'Atualizado há $elapsedTimeMinutes minuto${elapsedTimeMinutes != 1 ? 's' : ''}', + S.of(context).last_timestamp(elapsedTimeMinutes), style: Theme.of(context).textTheme.subtitle2) ]); } diff --git a/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart b/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart index ac5e65da2..15be8ee7c 100644 --- a/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart +++ b/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart @@ -3,6 +3,7 @@ import 'package:provider/provider.dart'; import 'package:uni/model/providers/session_provider.dart'; import 'package:uni/utils/drawer_items.dart'; import 'package:uni/view/theme_notifier.dart'; +import 'package:uni/generated/l10n.dart'; class AppNavigationDrawer extends StatefulWidget { final BuildContext parentContext; @@ -65,7 +66,7 @@ class AppNavigationDrawerState extends State { } Widget createLogoutBtn() { - final String logOutText = DrawerItem.navLogOut.title; + final String logOutText = S.of(context).logout; return TextButton( onPressed: () => _onLogOut(logOutText), style: TextButton.styleFrom( @@ -110,8 +111,8 @@ class AppNavigationDrawerState extends State { child: ListTile( title: Container( padding: const EdgeInsets.only(bottom: 3.0, left: 20.0), - child: Text(d.title, - style: TextStyle( + child: Text(S.of(context).nav_title(d.title), + style: TextStyle( fontSize: 18.0, color: Theme.of(context).primaryColor, fontWeight: FontWeight.normal)), diff --git a/uni/lib/view/home/widgets/bus_stop_card.dart b/uni/lib/view/home/widgets/bus_stop_card.dart index ecb83d22e..f4160c078 100644 --- a/uni/lib/view/home/widgets/bus_stop_card.dart +++ b/uni/lib/view/home/widgets/bus_stop_card.dart @@ -48,7 +48,7 @@ Widget getCardContent(BuildContext context, Map stopData, b child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text('Configura os teus autocarros', + Text(S.of(context).buses_personalize, maxLines: 1, overflow: TextOverflow.ellipsis, style: Theme.of(context).textTheme.subtitle2!.apply()), @@ -77,7 +77,7 @@ Widget getCardContent(BuildContext context, Map stopData, b getCardTitle(context), Container( padding: const EdgeInsets.all(8.0), - child: Text('Não foi possível obter informação', + child: Text(S.of(context).bus_error, style: Theme.of(context).textTheme.subtitle1)) ]); } @@ -88,7 +88,7 @@ Widget getCardTitle(context) { return Row( children: [ const Icon(Icons.directions_bus), // color lightgrey - Text('STCP - Próximas Viagens', + Text(S.of(context).stcp_stops, style: Theme.of(context).textTheme.subtitle1), ], ); @@ -103,8 +103,8 @@ Widget getBusStopsInfo(context, Map stopData) { children: getEachBusStopInfo(context, stopData), )); } else { - return const Center( - child: Text('Não há dados a mostrar neste momento', + return Center( + child: Text(S.of(context).no_data, maxLines: 2, overflow: TextOverflow.fade), ); } diff --git a/uni/lib/view/home/widgets/exam_card.dart b/uni/lib/view/home/widgets/exam_card.dart index 068f9e806..91919c228 100644 --- a/uni/lib/view/home/widgets/exam_card.dart +++ b/uni/lib/view/home/widgets/exam_card.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:uni/model/entities/exam.dart'; @@ -46,7 +48,7 @@ class ExamCard extends GenericCard { content: exams, contentChecker: exams.isNotEmpty, onNullContent: Center( - child: Text('Não existem exames para apresentar', + child: Text(S.of(context).no_selected_exams, style: Theme.of(context).textTheme.headline6), ), contentLoadingWidget: const ExamCardShimmer().build(context), @@ -89,8 +91,12 @@ class ExamCard extends GenericCard { /// others in the card). Widget createRowFromExam(BuildContext context, Exam exam) { return Column(children: [ - DateRectangle( - date: '${exam.weekDay}, ${exam.begin.day} de ${exam.month}'), + if (Platform.localeName == 'pt_PT') ...[ + DateRectangle( + date: '${exam.weekDay}, ${exam.begin.day} de ${exam.month}')] + else ...[ + DateRectangle( + date: '${exam.weekDay}, ${exam.begin.day} ${exam.month}')], RowContainer( child: ExamRow( exam: exam, diff --git a/uni/lib/view/home/widgets/main_cards_list.dart b/uni/lib/view/home/widgets/main_cards_list.dart index 401f5cde4..f3b373c60 100644 --- a/uni/lib/view/home/widgets/main_cards_list.dart +++ b/uni/lib/view/home/widgets/main_cards_list.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/controller/local_storage/app_shared_preferences.dart'; import 'package:uni/model/providers/favorite_cards_provider.dart'; import 'package:uni/model/providers/home_page_editing_mode_provider.dart'; @@ -13,7 +14,6 @@ import 'package:uni/view/home/widgets/bus_stop_card.dart'; import 'package:uni/view/home/widgets/exam_card.dart'; import 'package:uni/view/common_widgets/page_title.dart'; import 'package:uni/view/home/widgets/schedule_card.dart'; -import 'package:uni/utils/drawer_items.dart'; typedef CardCreator = GenericCard Function( Key key, bool isEditingMode, dynamic Function()? onDelete); @@ -84,7 +84,7 @@ class MainCardsList extends StatelessWidget { builder: (BuildContext context) { return AlertDialog( title: Text( - 'Escolhe um widget para adicionares à tua área pessoal:', + S.of(context).widget_prompt, style: Theme.of(context).textTheme.headline5), content: SizedBox( height: 200.0, @@ -93,12 +93,12 @@ class MainCardsList extends StatelessWidget { ), actions: [ TextButton( - child: Text('Cancelar', + child: Text(S.of(context).cancel, style: Theme.of(context).textTheme.bodyText2), onPressed: () => Navigator.pop(context)) ]); }), //Add FAB functionality here - tooltip: 'Adicionar widget', + tooltip: S.of(context).add_widget, child: Icon(Icons.add, color: Theme.of(context).colorScheme.onPrimary), ); } @@ -129,8 +129,7 @@ class MainCardsList extends StatelessWidget { return possibleCardAdditions.isEmpty ? [ - const Text( - '''Todos os widgets disponíveis já foram adicionados à tua área pessoal!''') + Text(S.of(context).all_widgets_added) ] : possibleCardAdditions; } @@ -141,13 +140,13 @@ class MainCardsList extends StatelessWidget { padding: const EdgeInsets.fromLTRB(20, 20, 20, 5), child: Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ PageTitle( - name: DrawerItem.navPersonalArea.title, center: false, pad: false), + name: S.of(context).nav_title('area'), center: false, pad: false), GestureDetector( onTap: () => Provider.of(context, listen: false) .setHomePageEditingMode(!editingModeProvider.isEditing), child: Text( - editingModeProvider.isEditing ? 'Concluir Edição' : 'Editar', + editingModeProvider.isEditing ? S.of(context).edit_on : S.of(context).edit_off, style: Theme.of(context).textTheme.caption)) ]), ); diff --git a/uni/lib/view/home/widgets/restaurant_card.dart b/uni/lib/view/home/widgets/restaurant_card.dart index cddd6cc14..eaca0ed75 100644 --- a/uni/lib/view/home/widgets/restaurant_card.dart +++ b/uni/lib/view/home/widgets/restaurant_card.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:uni/model/providers/restaurant_provider.dart'; import 'package:uni/view/common_widgets/date_rectangle.dart'; -import 'package:uni/generated/l10n.dart'; import 'package:uni/view/common_widgets/generic_card.dart'; import 'package:uni/view/common_widgets/request_dependent_widget_builder.dart'; import 'package:uni/view/common_widgets/row_container.dart'; diff --git a/uni/lib/view/profile/widgets/account_info_card.dart b/uni/lib/view/profile/widgets/account_info_card.dart index 4b952c676..2ea8ae081 100644 --- a/uni/lib/view/profile/widgets/account_info_card.dart +++ b/uni/lib/view/profile/widgets/account_info_card.dart @@ -28,7 +28,7 @@ class AccountInfoCard extends GenericCard { Container( margin: const EdgeInsets.only( top: 20.0, bottom: 8.0, left: 20.0), - child: Text('Saldo: ', + child: Text(S.of(context).balance, style: Theme.of(context).textTheme.subtitle2), ), Container( @@ -40,7 +40,7 @@ class AccountInfoCard extends GenericCard { Container( margin: const EdgeInsets.only( top: 8.0, bottom: 20.0, left: 20.0), - child: Text('Data limite próxima prestação: ', + child: Text(S.of(context).fee_date, style: Theme.of(context).textTheme.subtitle2), ), Container( @@ -52,7 +52,7 @@ class AccountInfoCard extends GenericCard { Container( margin: const EdgeInsets.only(top: 8.0, bottom: 20.0, left: 20.0), - child: Text("Notificar próxima data limite: ", + child: Text(S.of(context).fee_notification, style: Theme.of(context).textTheme.subtitle2) ), Container( From 503fdbda417bc6b00c10005aa2f3ba1594bb9feb Mon Sep 17 00:00:00 2001 From: DGoiana Date: Wed, 19 Apr 2023 23:40:47 +0100 Subject: [PATCH 03/50] Error and lint fixing --- uni/lib/generated/intl/messages_all.dart | 6 +++--- uni/lib/generated/intl/messages_pt-PT.dart | 2 +- uni/lib/l10n/intl_pt_PT.arb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/uni/lib/generated/intl/messages_all.dart b/uni/lib/generated/intl/messages_all.dart index d06573802..171385879 100644 --- a/uni/lib/generated/intl/messages_all.dart +++ b/uni/lib/generated/intl/messages_all.dart @@ -38,13 +38,13 @@ MessageLookupByLibrary? _findExact(String localeName) { /// User programs should call this before using [localeName] for messages. Future initializeMessages(String localeName) { - final availableLocale = Intl.verifiedLocale( + var availableLocale = Intl.verifiedLocale( localeName, (locale) => _deferredLibraries[locale] != null, onFailure: (_) => null); if (availableLocale == null) { return new SynchronousFuture(false); } - final lib = _deferredLibraries[availableLocale]; + var lib = _deferredLibraries[availableLocale]; lib == null ? new SynchronousFuture(false) : lib(); initializeInternalMessageLookup(() => new CompositeMessageLookup()); messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); @@ -60,7 +60,7 @@ bool _messagesExistFor(String locale) { } MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { - final actualLocale = + var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); if (actualLocale == null) return null; return _findExact(actualLocale); diff --git a/uni/lib/generated/intl/messages_pt-PT.dart b/uni/lib/generated/intl/messages_pt-PT.dart index 3c93a7011..ba426a450 100644 --- a/uni/lib/generated/intl/messages_pt-PT.dart +++ b/uni/lib/generated/intl/messages_pt-PT.dart @@ -23,7 +23,7 @@ class MessageLookup extends MessageLookupByLibrary { static String m0(time) => "última atualização às ${time}"; static String m1(time) => - "${Intl.plural(time, one: '${time} minuto', other: '${time} minutos')}"; + "${Intl.plural(time, one: 'Atualizado há ${time} minuto', other: 'Atualizado há ${time} minutos')}"; static String m2(title) => "${Intl.select(title, { 'horario': 'Horário', diff --git a/uni/lib/l10n/intl_pt_PT.arb b/uni/lib/l10n/intl_pt_PT.arb index f698d58f2..4ec03fc74 100644 --- a/uni/lib/l10n/intl_pt_PT.arb +++ b/uni/lib/l10n/intl_pt_PT.arb @@ -32,7 +32,7 @@ "time": {} } }, - "last_timestamp": "{time, plural, one{{time} minuto} other{{time} minutos}}", + "last_timestamp": "{time, plural, one{Atualizado há {time} minuto} other{Atualizado há {time} minutos}}", "@last_timestamp": { "placeholders": { "time": {} From 6ae272146680e22a42055e97253a206a246a3d1b Mon Sep 17 00:00:00 2001 From: Diogo Martins <81827192+DGoiana@users.noreply.github.com> Date: Wed, 19 Apr 2023 23:42:03 +0100 Subject: [PATCH 04/50] Update messages_all.dart --- uni/lib/generated/intl/messages_all.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uni/lib/generated/intl/messages_all.dart b/uni/lib/generated/intl/messages_all.dart index 171385879..97b06cb2c 100644 --- a/uni/lib/generated/intl/messages_all.dart +++ b/uni/lib/generated/intl/messages_all.dart @@ -16,8 +16,8 @@ import 'package:intl/intl.dart'; import 'package:intl/message_lookup_by_library.dart'; import 'package:intl/src/intl_helpers.dart'; -import 'messages_en.dart' as messages_en; -import 'messages_pt-PT.dart' as messages_pt_pt; +import 'package:uni/generated/intl/messages_en.dart' as messages_en; +import 'package:uni/generated/intl/messages_pt-PT.dart' as messages_pt_pt; typedef Future LibraryLoader(); Map _deferredLibraries = { From fd3a3d148ac0ae6f4b49ab11f07d5583d7808dfd Mon Sep 17 00:00:00 2001 From: DGoiana Date: Thu, 20 Apr 2023 12:08:29 +0100 Subject: [PATCH 05/50] Buses page translation --- uni/lib/generated/intl/messages_all.dart | 6 +- uni/lib/generated/intl/messages_en.dart | 27 +++- uni/lib/generated/intl/messages_pt-PT.dart | 27 +++- uni/lib/generated/l10n.dart | 137 ++++++++++++++---- uni/lib/l10n/intl_en.arb | 36 +++-- uni/lib/l10n/intl_pt_PT.arb | 36 +++-- .../bus_stop_next_arrivals.dart | 4 +- .../bus_stop_selection.dart | 11 +- .../widgets/bus_stop_search.dart | 11 +- uni/lib/view/course_units/course_units.dart | 11 +- .../view/exams/widgets/exam_page_title.dart | 8 +- uni/lib/view/home/widgets/bus_stop_card.dart | 2 +- uni/lib/view/home/widgets/exam_card.dart | 2 +- uni/lib/view/home/widgets/schedule_card.dart | 2 +- uni/lib/view/schedule/schedule.dart | 3 +- 15 files changed, 234 insertions(+), 89 deletions(-) diff --git a/uni/lib/generated/intl/messages_all.dart b/uni/lib/generated/intl/messages_all.dart index 97b06cb2c..525f677ec 100644 --- a/uni/lib/generated/intl/messages_all.dart +++ b/uni/lib/generated/intl/messages_all.dart @@ -38,13 +38,13 @@ MessageLookupByLibrary? _findExact(String localeName) { /// User programs should call this before using [localeName] for messages. Future initializeMessages(String localeName) { - var availableLocale = Intl.verifiedLocale( + final availableLocale = Intl.verifiedLocale( localeName, (locale) => _deferredLibraries[locale] != null, onFailure: (_) => null); if (availableLocale == null) { return new SynchronousFuture(false); } - var lib = _deferredLibraries[availableLocale]; + final lib = _deferredLibraries[availableLocale]; lib == null ? new SynchronousFuture(false) : lib(); initializeInternalMessageLookup(() => new CompositeMessageLookup()); messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); @@ -60,7 +60,7 @@ bool _messagesExistFor(String locale) { } MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { - var actualLocale = + final actualLocale = Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); if (actualLocale == null) return null; return _findExact(actualLocale); diff --git a/uni/lib/generated/intl/messages_en.dart b/uni/lib/generated/intl/messages_en.dart index b3f9e5563..4ad58118e 100644 --- a/uni/lib/generated/intl/messages_en.dart +++ b/uni/lib/generated/intl/messages_en.dart @@ -23,7 +23,7 @@ class MessageLookup extends MessageLookupByLibrary { static String m0(time) => "last refresh at ${time}"; static String m1(time) => - "${Intl.plural(time, one: 'Refreshed ${time} minute ago', other: 'Refreshed ${time} minutes ago')}"; + "${Intl.plural(time, zero: 'Refreshed ${time} minutes ago', one: 'Refreshed ${time} minute ago', other: 'Refreshed ${time} minutes ago')}"; static String m2(title) => "${Intl.select(title, { 'horario': 'Schedule', @@ -45,19 +45,28 @@ class MessageLookup extends MessageLookupByLibrary { static Map _notInlinedMessages(_) => { "account_card_title": MessageLookupByLibrary.simpleMessage("Checking account"), + "add": MessageLookupByLibrary.simpleMessage("Add"), "add_widget": MessageLookupByLibrary.simpleMessage("Add widget"), "all_widgets_added": MessageLookupByLibrary.simpleMessage( "All available widgets have already been added to your personal area!"), "balance": MessageLookupByLibrary.simpleMessage("Balance:"), - "bus_card_title": MessageLookupByLibrary.simpleMessage("Buses"), "bus_error": MessageLookupByLibrary.simpleMessage("Unable to get information"), + "bus_information": MessageLookupByLibrary.simpleMessage( + "Select the buses you want information about:"), "buses_personalize": MessageLookupByLibrary.simpleMessage("Personalize your buses here"), + "buses_text": MessageLookupByLibrary.simpleMessage( + "Favorite buses will be displayed in the favorites \'Bus\' widget. The remaining ones will only be displayed on the page."), "cancel": MessageLookupByLibrary.simpleMessage("Cancel"), + "conclude": MessageLookupByLibrary.simpleMessage("Done"), + "configured_buses": + MessageLookupByLibrary.simpleMessage("Configured Buses"), + "confirm": MessageLookupByLibrary.simpleMessage("Confirm"), "edit_off": MessageLookupByLibrary.simpleMessage("Edit"), "edit_on": MessageLookupByLibrary.simpleMessage("Finish editing"), - "exam_card_title": MessageLookupByLibrary.simpleMessage("Exams"), + "exams_filter": + MessageLookupByLibrary.simpleMessage("Exam Filter Settings"), "fee_date": MessageLookupByLibrary.simpleMessage("Deadline for next fee:"), "fee_notification": @@ -66,18 +75,22 @@ class MessageLookup extends MessageLookupByLibrary { "last_timestamp": m1, "logout": MessageLookupByLibrary.simpleMessage("Log out"), "nav_title": m2, + "no_course_units": MessageLookupByLibrary.simpleMessage( + "No course units in the selected period"), "no_data": MessageLookupByLibrary.simpleMessage( "There is no data to show at this time"), "no_exams": MessageLookupByLibrary.simpleMessage( "You have no exams scheduled\n"), + "no_results": MessageLookupByLibrary.simpleMessage("No match"), + "no_selected_courses": MessageLookupByLibrary.simpleMessage( + "There are no course units to display"), "no_selected_exams": MessageLookupByLibrary.simpleMessage( "There are no exams to present"), - "restaurant_card_title": - MessageLookupByLibrary.simpleMessage("Restaurants"), - "schedule_card_title": MessageLookupByLibrary.simpleMessage("Schedule"), + "semester": MessageLookupByLibrary.simpleMessage("Semester"), "stcp_stops": MessageLookupByLibrary.simpleMessage("STCP - Upcoming Trips"), "widget_prompt": MessageLookupByLibrary.simpleMessage( - "Choose a widget to add to your personal area:") + "Choose a widget to add to your personal area:"), + "year": MessageLookupByLibrary.simpleMessage("Year") }; } diff --git a/uni/lib/generated/intl/messages_pt-PT.dart b/uni/lib/generated/intl/messages_pt-PT.dart index ba426a450..864d0c121 100644 --- a/uni/lib/generated/intl/messages_pt-PT.dart +++ b/uni/lib/generated/intl/messages_pt-PT.dart @@ -23,7 +23,7 @@ class MessageLookup extends MessageLookupByLibrary { static String m0(time) => "última atualização às ${time}"; static String m1(time) => - "${Intl.plural(time, one: 'Atualizado há ${time} minuto', other: 'Atualizado há ${time} minutos')}"; + "${Intl.plural(time, zero: 'Atualizado há ${time} minutos', one: 'Atualizado há ${time} minuto', other: 'Atualizado há ${time} minutos')}"; static String m2(title) => "${Intl.select(title, { 'horario': 'Horário', @@ -45,19 +45,28 @@ class MessageLookup extends MessageLookupByLibrary { static Map _notInlinedMessages(_) => { "account_card_title": MessageLookupByLibrary.simpleMessage("Conta Corrente"), + "add": MessageLookupByLibrary.simpleMessage("Adicionar"), "add_widget": MessageLookupByLibrary.simpleMessage("Adicionar widget"), "all_widgets_added": MessageLookupByLibrary.simpleMessage( "Todos os widgets disponíveis já foram adicionados à tua área pessoal!"), "balance": MessageLookupByLibrary.simpleMessage("Saldo:"), - "bus_card_title": MessageLookupByLibrary.simpleMessage("Autocarros"), "bus_error": MessageLookupByLibrary.simpleMessage( "Não foi possível obter informação"), + "bus_information": MessageLookupByLibrary.simpleMessage( + "Seleciona os autocarros dos quais queres informação:"), "buses_personalize": MessageLookupByLibrary.simpleMessage( "Configura aqui os teus autocarros"), + "buses_text": MessageLookupByLibrary.simpleMessage( + "Os autocarros favoritos serão apresentados no widget \'Autocarros\' dos favoritos. Os restantes serão apresentados apenas na página."), "cancel": MessageLookupByLibrary.simpleMessage("Cancelar\n"), + "conclude": MessageLookupByLibrary.simpleMessage("Concluído"), + "configured_buses": + MessageLookupByLibrary.simpleMessage("Autocarros Configurados"), + "confirm": MessageLookupByLibrary.simpleMessage("Confirmar"), "edit_off": MessageLookupByLibrary.simpleMessage("Editar\n"), "edit_on": MessageLookupByLibrary.simpleMessage("Concluir edição"), - "exam_card_title": MessageLookupByLibrary.simpleMessage("Exames"), + "exams_filter": + MessageLookupByLibrary.simpleMessage("Definições Filtro de Exames"), "fee_date": MessageLookupByLibrary.simpleMessage( "Data limite próxima prestação:"), "fee_notification": MessageLookupByLibrary.simpleMessage( @@ -66,18 +75,22 @@ class MessageLookup extends MessageLookupByLibrary { "last_timestamp": m1, "logout": MessageLookupByLibrary.simpleMessage("Terminar sessão"), "nav_title": m2, + "no_course_units": MessageLookupByLibrary.simpleMessage( + "Sem cadeiras no período selecionado"), "no_data": MessageLookupByLibrary.simpleMessage( "Não há dados a mostrar neste momento"), "no_exams": MessageLookupByLibrary.simpleMessage("Não possui exames marcados"), + "no_results": MessageLookupByLibrary.simpleMessage("Sem resultados"), + "no_selected_courses": MessageLookupByLibrary.simpleMessage( + "Não existem cadeiras para apresentar"), "no_selected_exams": MessageLookupByLibrary.simpleMessage( "Não existem exames para apresentar"), - "restaurant_card_title": - MessageLookupByLibrary.simpleMessage("Restaurantes"), - "schedule_card_title": MessageLookupByLibrary.simpleMessage("Horário"), + "semester": MessageLookupByLibrary.simpleMessage("Semestre"), "stcp_stops": MessageLookupByLibrary.simpleMessage("STCP - Próximas Viagens"), "widget_prompt": MessageLookupByLibrary.simpleMessage( - "Escolhe um widget para adicionares à tua área pessoal:") + "Escolhe um widget para adicionares à tua área pessoal:"), + "year": MessageLookupByLibrary.simpleMessage("Ano") }; } diff --git a/uni/lib/generated/l10n.dart b/uni/lib/generated/l10n.dart index cd42ec413..129b6e382 100644 --- a/uni/lib/generated/l10n.dart +++ b/uni/lib/generated/l10n.dart @@ -1,7 +1,7 @@ // GENERATED CODE - DO NOT MODIFY BY HAND import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; -import 'intl/messages_all.dart'; +import 'package:uni/generated/intl/messages_all.dart'; // ************************************************************************** // Generator: Flutter Intl IDE plugin @@ -60,6 +60,16 @@ class S { ); } + /// `Add` + String get add { + return Intl.message( + 'Add', + name: 'add', + desc: '', + args: [], + ); + } + /// `Add widget` String get add_widget { return Intl.message( @@ -90,16 +100,6 @@ class S { ); } - /// `Buses` - String get bus_card_title { - return Intl.message( - 'Buses', - name: 'bus_card_title', - desc: '', - args: [], - ); - } - /// `Unable to get information` String get bus_error { return Intl.message( @@ -120,6 +120,26 @@ class S { ); } + /// `Favorite buses will be displayed in the favorites 'Bus' widget. The remaining ones will only be displayed on the page.` + String get buses_text { + return Intl.message( + 'Favorite buses will be displayed in the favorites \'Bus\' widget. The remaining ones will only be displayed on the page.', + name: 'buses_text', + desc: '', + args: [], + ); + } + + /// `Select the buses you want information about:` + String get bus_information { + return Intl.message( + 'Select the buses you want information about:', + name: 'bus_information', + desc: '', + args: [], + ); + } + /// `Cancel` String get cancel { return Intl.message( @@ -130,6 +150,36 @@ class S { ); } + /// `Done` + String get conclude { + return Intl.message( + 'Done', + name: 'conclude', + desc: '', + args: [], + ); + } + + /// `Configured Buses` + String get configured_buses { + return Intl.message( + 'Configured Buses', + name: 'configured_buses', + desc: '', + args: [], + ); + } + + /// `Confirm` + String get confirm { + return Intl.message( + 'Confirm', + name: 'confirm', + desc: '', + args: [], + ); + } + /// `Edit` String get edit_off { return Intl.message( @@ -150,11 +200,11 @@ class S { ); } - /// `Exams` - String get exam_card_title { + /// `Exam Filter Settings` + String get exams_filter { return Intl.message( - 'Exams', - name: 'exam_card_title', + 'Exam Filter Settings', + name: 'exams_filter', desc: '', args: [], ); @@ -190,10 +240,11 @@ class S { ); } - /// `{time, plural, one{Refreshed {time} minute ago} other{Refreshed {time} minutes ago}}` + /// `{time, plural, zero{Refreshed {time} minutes ago} one{Refreshed {time} minute ago} other{Refreshed {time} minutes ago}}` String last_timestamp(num time) { return Intl.plural( time, + zero: 'Refreshed $time minutes ago', one: 'Refreshed $time minute ago', other: 'Refreshed $time minutes ago', name: 'last_timestamp', @@ -237,6 +288,16 @@ class S { ); } + /// `No course units in the selected period` + String get no_course_units { + return Intl.message( + 'No course units in the selected period', + name: 'no_course_units', + desc: '', + args: [], + ); + } + /// `There is no data to show at this time` String get no_data { return Intl.message( @@ -257,31 +318,41 @@ class S { ); } - /// `There are no exams to present` - String get no_selected_exams { + /// `No match` + String get no_results { return Intl.message( - 'There are no exams to present', - name: 'no_selected_exams', + 'No match', + name: 'no_results', desc: '', args: [], ); } - /// `Restaurants` - String get restaurant_card_title { + /// `There are no course units to display` + String get no_selected_courses { return Intl.message( - 'Restaurants', - name: 'restaurant_card_title', + 'There are no course units to display', + name: 'no_selected_courses', desc: '', args: [], ); } - /// `Schedule` - String get schedule_card_title { + /// `There are no exams to present` + String get no_selected_exams { return Intl.message( - 'Schedule', - name: 'schedule_card_title', + 'There are no exams to present', + name: 'no_selected_exams', + desc: '', + args: [], + ); + } + + /// `Semester` + String get semester { + return Intl.message( + 'Semester', + name: 'semester', desc: '', args: [], ); @@ -306,6 +377,16 @@ class S { args: [], ); } + + /// `Year` + String get year { + return Intl.message( + 'Year', + name: 'year', + desc: '', + args: [], + ); + } } class AppLocalizationDelegate extends LocalizationsDelegate { diff --git a/uni/lib/l10n/intl_en.arb b/uni/lib/l10n/intl_en.arb index 8f48675c6..2984a64ff 100644 --- a/uni/lib/l10n/intl_en.arb +++ b/uni/lib/l10n/intl_en.arb @@ -2,26 +2,36 @@ "@@locale": "en", "account_card_title": "Checking account", "@account_card_title": {}, + "add": "Add", + "@add": {}, "add_widget": "Add widget", "@add_widget": {}, "all_widgets_added": "All available widgets have already been added to your personal area!", "@all_widgets_added": {}, "balance": "Balance:", "@balance": {}, - "bus_card_title": "Buses", - "@bus_card_title": {}, "bus_error": "Unable to get information", "@bus_error": {}, "buses_personalize": "Personalize your buses here", "@buses_personalize": {}, + "buses_text": "Favorite buses will be displayed in the favorites 'Bus' widget. The remaining ones will only be displayed on the page.", + "@buses_text": {}, + "bus_information": "Select the buses you want information about:", + "@bus_information": {}, "cancel": "Cancel", "@cancel": {}, + "conclude": "Done", + "@conclude": {}, + "configured_buses": "Configured Buses", + "@configured_buses": {}, + "confirm": "Confirm", + "@confirm": {}, "edit_off": "Edit", "@edit_off": {}, "edit_on": "Finish editing", "@edit_on": {}, - "exam_card_title": "Exams", - "@exam_card_title": {}, + "exams_filter": "Exam Filter Settings", + "@exams_filter": {}, "fee_date": "Deadline for next fee:", "@fee_date": {}, "fee_notification": "Notify next deadline:", @@ -32,7 +42,7 @@ "time": {} } }, - "last_timestamp": "{time, plural, one{Refreshed {time} minute ago} other{Refreshed {time} minutes ago}}", + "last_timestamp": "{time, plural, zero{Refreshed {time} minutes ago} one{Refreshed {time} minute ago} other{Refreshed {time} minutes ago}}", "@last_timestamp": { "placeholders": { "time": {} @@ -42,18 +52,24 @@ "@logout": {}, "nav_title": "{title, select, horario{Schedule} exames{Exams} area{Personal Area} cadeiras{Course Units} autocarros{Buses} locais{Places} restaurantes{Restaurants} calendario{Calendar} biblioteca{Library} uteis{Utils} sobre{About} bugs{Bugs and Suggestions} other{Other}}", "@nav_title": {}, + "no_course_units": "No course units in the selected period", + "@no_course_units": {}, "no_data": "There is no data to show at this time", "@no_data": {}, "no_exams": "You have no exams scheduled\n", "@no_exams": {}, + "no_results": "No match", + "@no_results": {}, + "no_selected_courses": "There are no course units to display", + "@no_selected_courses": {}, "no_selected_exams": "There are no exams to present", "@no_selected_exams": {}, - "restaurant_card_title": "Restaurants", - "@restaurant_card_title": {}, - "schedule_card_title": "Schedule", - "@schedule_card_title": {}, + "semester": "Semester", + "@semester": {}, "stcp_stops": "STCP - Upcoming Trips", "@stcp_stops": {}, "widget_prompt": "Choose a widget to add to your personal area:", - "@widget_prompt": {} + "@widget_prompt": {}, + "year": "Year", + "@year": {} } \ No newline at end of file diff --git a/uni/lib/l10n/intl_pt_PT.arb b/uni/lib/l10n/intl_pt_PT.arb index 4ec03fc74..962d9e75b 100644 --- a/uni/lib/l10n/intl_pt_PT.arb +++ b/uni/lib/l10n/intl_pt_PT.arb @@ -2,26 +2,36 @@ "@@locale": "pt-PT", "account_card_title": "Conta Corrente", "@account_card_title": {}, + "add": "Adicionar", + "@add": {}, "add_widget": "Adicionar widget", "@add_widget": {}, "all_widgets_added": "Todos os widgets disponíveis já foram adicionados à tua área pessoal!", "@all_widgets_added": {}, "balance": "Saldo:", "@balance": {}, - "bus_card_title": "Autocarros", - "@bus_card_title": {}, "bus_error": "Não foi possível obter informação", "@bus_error": {}, "buses_personalize": "Configura aqui os teus autocarros", "@buses_personalize": {}, + "buses_text": "Os autocarros favoritos serão apresentados no widget 'Autocarros' dos favoritos. Os restantes serão apresentados apenas na página.", + "@buses_text": {}, + "bus_information": "Seleciona os autocarros dos quais queres informação:", + "@bus_information": {}, "cancel": "Cancelar\n", "@cancel": {}, + "conclude": "Concluído", + "@conclude": {}, + "configured_buses": "Autocarros Configurados", + "@configured_buses": {}, + "confirm": "Confirmar", + "@confirm": {}, "edit_off": "Editar\n", "@edit_off": {}, "edit_on": "Concluir edição", "@edit_on": {}, - "exam_card_title": "Exames", - "@exam_card_title": {}, + "exams_filter": "Definições Filtro de Exames", + "@exams_filter": {}, "fee_date": "Data limite próxima prestação:", "@fee_date": {}, "fee_notification": "Notificar próxima data limite:", @@ -32,7 +42,7 @@ "time": {} } }, - "last_timestamp": "{time, plural, one{Atualizado há {time} minuto} other{Atualizado há {time} minutos}}", + "last_timestamp": "{time, plural, zero{Atualizado há {time} minutos} one{Atualizado há {time} minuto} other{Atualizado há {time} minutos}}", "@last_timestamp": { "placeholders": { "time": {} @@ -42,18 +52,24 @@ "@logout": {}, "nav_title": "{title, select, horario{Horário} exames{Exames} area{Área Pessoal} cadeiras{Cadeiras} autocarros{Autocarros} locais{Locais} restaurantes{Restaurantes} calendario{Calendário} biblioteca{Biblioteca} uteis{Úteis} sobre{Sobre} bugs{Bugs e Sugestões} other{Outros}}", "@nav_title": {}, + "no_course_units": "Sem cadeiras no período selecionado", + "@no_course_units": {}, "no_data": "Não há dados a mostrar neste momento", "@no_data": {}, "no_exams": "Não possui exames marcados", "@no_exams": {}, + "no_results": "Sem resultados", + "@no_results": {}, + "no_selected_courses": "Não existem cadeiras para apresentar", + "@no_selected_courses": {}, "no_selected_exams": "Não existem exames para apresentar", "@no_selected_exams": {}, - "restaurant_card_title": "Restaurantes", - "@restaurant_card_title": {}, - "schedule_card_title": "Horário", - "@schedule_card_title": {}, + "semester": "Semestre", + "@semester": {}, "stcp_stops": "STCP - Próximas Viagens", "@stcp_stops": {}, "widget_prompt": "Escolhe um widget para adicionares à tua área pessoal:", - "@widget_prompt": {} + "@widget_prompt": {}, + "year": "Ano", + "@year": {} } \ No newline at end of file diff --git a/uni/lib/view/bus_stop_next_arrivals/bus_stop_next_arrivals.dart b/uni/lib/view/bus_stop_next_arrivals/bus_stop_next_arrivals.dart index 5d9b5142f..2f666a051 100644 --- a/uni/lib/view/bus_stop_next_arrivals/bus_stop_next_arrivals.dart +++ b/uni/lib/view/bus_stop_next_arrivals/bus_stop_next_arrivals.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:uni/model/request_status.dart'; import 'package:uni/model/entities/bus_stop.dart'; +import 'package:uni/utils/drawer_items.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/model/providers/bus_stop_provider.dart'; import 'package:uni/view/bus_stop_next_arrivals/widgets/bus_stop_row.dart'; import 'package:uni/view/bus_stop_selection/bus_stop_selection.dart'; @@ -107,7 +109,7 @@ class NextArrivalsState extends State { Container getPageTitle() { return Container( padding: const EdgeInsets.only(bottom: 12.0), - child: const PageTitle(name: 'Autocarros')); + child: PageTitle(name: S.of(context).nav_title(DrawerItem.navStops.title))); } /// Returns a list of widgets for a failed request diff --git a/uni/lib/view/bus_stop_selection/bus_stop_selection.dart b/uni/lib/view/bus_stop_selection/bus_stop_selection.dart index 545fb6e2c..b100b346c 100644 --- a/uni/lib/view/bus_stop_selection/bus_stop_selection.dart +++ b/uni/lib/view/bus_stop_selection/bus_stop_selection.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:uni/controller/local_storage/app_bus_stop_database.dart'; import 'package:uni/model/entities/bus_stop.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/model/providers/bus_stop_provider.dart'; import 'package:uni/view/bus_stop_selection/widgets/bus_stop_search.dart'; import 'package:uni/view/bus_stop_selection/widgets/bus_stop_selection_row.dart'; @@ -45,12 +46,10 @@ class BusStopSelectionPageState bottom: 20, ), children: [ - const PageTitle(name: 'Autocarros Configurados'), + PageTitle(name: S.of(context).configured_buses), Container( padding: const EdgeInsets.all(20.0), - child: const Text( - '''Os autocarros favoritos serão apresentados no widget 'Autocarros' dos favoritos.''' - '''Os restantes serão apresentados apenas na página.''', + child: Text( S.of(context).buses_text, textAlign: TextAlign.center)), Column(children: rows), Container( @@ -62,11 +61,11 @@ class BusStopSelectionPageState ElevatedButton( onPressed: () => showSearch( context: context, delegate: BusStopSearch()), - child: const Text('Adicionar'), + child: Text(S.of(context).add), ), ElevatedButton( onPressed: () => Navigator.pop(context), - child: const Text('Concluído'), + child: Text(S.of(context).conclude), ), ])) ]); diff --git a/uni/lib/view/bus_stop_selection/widgets/bus_stop_search.dart b/uni/lib/view/bus_stop_selection/widgets/bus_stop_search.dart index 88b58ae68..3ffc07a6e 100644 --- a/uni/lib/view/bus_stop_selection/widgets/bus_stop_search.dart +++ b/uni/lib/view/bus_stop_selection/widgets/bus_stop_search.dart @@ -6,6 +6,7 @@ import 'package:provider/provider.dart'; import 'package:uni/controller/fetchers/departures_fetcher.dart'; import 'package:uni/controller/local_storage/app_bus_stop_database.dart'; import 'package:uni/model/entities/bus_stop.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/model/providers/bus_stop_provider.dart'; import 'package:uni/view/bus_stop_selection/widgets/form.dart'; @@ -83,7 +84,7 @@ class BusStopSearch extends SearchDelegate { onNonMatch: (m) => ''), updateStopCallback); return AlertDialog( - title: Text('Seleciona os autocarros dos quais queres informação:', + title: Text(S.of(context).bus_information, style: Theme.of(context).textTheme.headline5), content: SizedBox( height: 200.0, @@ -92,11 +93,11 @@ class BusStopSearch extends SearchDelegate { ), actions: [ TextButton( - child: Text('Cancelar', + child: Text(S.of(context).cancel, style: Theme.of(context).textTheme.bodyText2), onPressed: () => Navigator.pop(context)), ElevatedButton( - child: const Text('Confirmar'), + child: Text(S.of(context).confirm), onPressed: () async { if (stopData!.configuredBuses.isNotEmpty) { Provider.of(context, listen: false) @@ -125,8 +126,8 @@ class BusStopSearch extends SearchDelegate { return Container( margin: const EdgeInsets.all(8.0), height: 24.0, - child: const Center( - child: Text('Sem resultados.'), + child: Center( + child: Text(S.of(context).no_results), )); } else { suggestionsList = snapshot.data!; diff --git a/uni/lib/view/course_units/course_units.dart b/uni/lib/view/course_units/course_units.dart index d45b605ce..16320b4d5 100644 --- a/uni/lib/view/course_units/course_units.dart +++ b/uni/lib/view/course_units/course_units.dart @@ -1,6 +1,7 @@ import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/model/request_status.dart'; import 'package:uni/model/entities/course_unit.dart'; import 'package:uni/model/providers/profile_state_provider.dart'; @@ -86,7 +87,7 @@ class CourseUnitsPageViewState contentChecker: courseUnits?.isNotEmpty ?? false, onNullContent: Center( heightFactor: 10, - child: Text('Não existem cadeiras para apresentar', + child: Text(S.of(context).no_selected_courses, style: Theme.of(context).textTheme.headline6), )) ]); @@ -97,12 +98,12 @@ class CourseUnitsPageViewState return Row( crossAxisAlignment: CrossAxisAlignment.end, children: [ - PageTitle(name: DrawerItem.navCourseUnits.title), + PageTitle(name: S.of(context).nav_title(DrawerItem.navCourseUnits.title)), const Spacer(), DropdownButtonHideUnderline( child: DropdownButton( alignment: AlignmentDirectional.centerEnd, - disabledHint: const Text('Semestre'), + disabledHint: Text(S.of(context).semester), value: selectedSemester, icon: const Icon(Icons.arrow_drop_down), onChanged: (String? newValue) { @@ -119,7 +120,7 @@ class CourseUnitsPageViewState const SizedBox(width: 10), DropdownButtonHideUnderline( child: DropdownButton( - disabledHint: const Text('Ano'), + disabledHint: Text(S.of(context).year), value: selectedSchoolYear, icon: const Icon(Icons.arrow_drop_down), onChanged: (String? newValue) { @@ -141,7 +142,7 @@ class CourseUnitsPageViewState if ((courseUnits as List).isEmpty) { return Center( heightFactor: 10, - child: Text('Sem cadeiras no período selecionado', + child: Text(S.of(context).no_course_units, style: Theme.of(context).textTheme.headline6)); } return Expanded( diff --git a/uni/lib/view/exams/widgets/exam_page_title.dart b/uni/lib/view/exams/widgets/exam_page_title.dart index 32769c369..148494973 100644 --- a/uni/lib/view/exams/widgets/exam_page_title.dart +++ b/uni/lib/view/exams/widgets/exam_page_title.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; +import 'package:uni/utils/drawer_items.dart'; import 'package:uni/view/exams/widgets/exam_filter_menu.dart'; import 'package:uni/view/common_widgets/page_title.dart'; +import 'package:uni/generated/l10n.dart'; class ExamPageTitle extends StatelessWidget { const ExamPageTitle({Key? key}) : super(key: key); @@ -12,9 +14,9 @@ class ExamPageTitle extends StatelessWidget { alignment: Alignment.center, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: const [ - PageTitle(name: 'Exames', center: false, pad: false), - Material(child: ExamFilterMenu()), + children: [ + PageTitle(name: S.of(context).nav_title(DrawerItem.navExams.title), center: false, pad: false), + const Material(child: ExamFilterMenu()), ], ), ); diff --git a/uni/lib/view/home/widgets/bus_stop_card.dart b/uni/lib/view/home/widgets/bus_stop_card.dart index f4160c078..ffcb7609a 100644 --- a/uni/lib/view/home/widgets/bus_stop_card.dart +++ b/uni/lib/view/home/widgets/bus_stop_card.dart @@ -17,7 +17,7 @@ class BusStopCard extends GenericCard { : super.fromEditingInformation(key, editingMode, onDelete); @override - String getTitle(BuildContext context) => S.of(context).bus_card_title; + String getTitle(BuildContext context) => S.of(context).nav_title(DrawerItem.navStops.title); @override onClick(BuildContext context) => diff --git a/uni/lib/view/home/widgets/exam_card.dart b/uni/lib/view/home/widgets/exam_card.dart index 91919c228..4fab0dfa0 100644 --- a/uni/lib/view/home/widgets/exam_card.dart +++ b/uni/lib/view/home/widgets/exam_card.dart @@ -23,7 +23,7 @@ class ExamCard extends GenericCard { : super.fromEditingInformation(key, editingMode, onDelete); @override - String getTitle(BuildContext context) => S.of(context).exam_card_title; + String getTitle(BuildContext context) => S.of(context).nav_title(DrawerItem.navExams.title); @override onClick(BuildContext context) => diff --git a/uni/lib/view/home/widgets/schedule_card.dart b/uni/lib/view/home/widgets/schedule_card.dart index d8c9511c7..c165aab06 100644 --- a/uni/lib/view/home/widgets/schedule_card.dart +++ b/uni/lib/view/home/widgets/schedule_card.dart @@ -106,7 +106,7 @@ class ScheduleCard extends GenericCard { } @override - String getTitle(context) => S.of(context).schedule_card_title; + String getTitle(context) => S.of(context).nav_title(DrawerItem.navSchedule.title); @override onClick(BuildContext context) => diff --git a/uni/lib/view/schedule/schedule.dart b/uni/lib/view/schedule/schedule.dart index 954e6c9c6..81d77c0e1 100644 --- a/uni/lib/view/schedule/schedule.dart +++ b/uni/lib/view/schedule/schedule.dart @@ -4,6 +4,7 @@ import 'package:uni/model/request_status.dart'; import 'package:uni/model/entities/lecture.dart'; import 'package:uni/model/entities/time_utilities.dart'; import 'package:uni/model/providers/lecture_provider.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/utils/drawer_items.dart'; import 'package:uni/view/common_widgets/page_title.dart'; import 'package:uni/view/common_widgets/pages_layouts/general/general.dart'; @@ -92,7 +93,7 @@ class SchedulePageViewState extends GeneralPageViewState scrollDirection: Axis.vertical, shrinkWrap: true, children: [ - PageTitle(name: DrawerItem.navSchedule.title), + PageTitle(name: S.of(context).nav_title(DrawerItem.navSchedule.title)), TabBar( controller: tabController, isScrollable: true, From 1140560d199b7c1e6558b5a5f0adbb474cec6759 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Wed, 26 Apr 2023 14:53:42 +0100 Subject: [PATCH 06/50] Library and restaurants pages translated --- uni/lib/generated/intl/messages_en.dart | 10 +++ uni/lib/generated/intl/messages_pt-PT.dart | 10 +++ uni/lib/generated/l10n.dart | 70 +++++++++++++++++++ uni/lib/l10n/intl_en.arb | 14 ++++ uni/lib/l10n/intl_pt_PT.arb | 14 ++++ uni/lib/view/library/library.dart | 8 ++- .../widgets/library_occupation_card.dart | 3 +- .../view/restaurant/restaurant_page_view.dart | 13 ++-- 8 files changed, 133 insertions(+), 9 deletions(-) diff --git a/uni/lib/generated/intl/messages_en.dart b/uni/lib/generated/intl/messages_en.dart index 4ad58118e..272a24d0c 100644 --- a/uni/lib/generated/intl/messages_en.dart +++ b/uni/lib/generated/intl/messages_en.dart @@ -71,9 +71,15 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Deadline for next fee:"), "fee_notification": MessageLookupByLibrary.simpleMessage("Notify next deadline:"), + "floor": MessageLookupByLibrary.simpleMessage("Floor"), + "floors": MessageLookupByLibrary.simpleMessage("Floors"), "last_refresh_time": m0, "last_timestamp": m1, + "library": MessageLookupByLibrary.simpleMessage("Library"), + "library_occupation": + MessageLookupByLibrary.simpleMessage("Library Occupation"), "logout": MessageLookupByLibrary.simpleMessage("Log out"), + "menus": MessageLookupByLibrary.simpleMessage("Menus"), "nav_title": m2, "no_course_units": MessageLookupByLibrary.simpleMessage( "No course units in the selected period"), @@ -81,6 +87,10 @@ class MessageLookup extends MessageLookupByLibrary { "There is no data to show at this time"), "no_exams": MessageLookupByLibrary.simpleMessage( "You have no exams scheduled\n"), + "no_menu_info": MessageLookupByLibrary.simpleMessage( + "There is no information available about meals"), + "no_menus": MessageLookupByLibrary.simpleMessage( + "There are no meals available"), "no_results": MessageLookupByLibrary.simpleMessage("No match"), "no_selected_courses": MessageLookupByLibrary.simpleMessage( "There are no course units to display"), diff --git a/uni/lib/generated/intl/messages_pt-PT.dart b/uni/lib/generated/intl/messages_pt-PT.dart index 864d0c121..70ba3a2a7 100644 --- a/uni/lib/generated/intl/messages_pt-PT.dart +++ b/uni/lib/generated/intl/messages_pt-PT.dart @@ -71,9 +71,15 @@ class MessageLookup extends MessageLookupByLibrary { "Data limite próxima prestação:"), "fee_notification": MessageLookupByLibrary.simpleMessage( "Notificar próxima data limite:"), + "floor": MessageLookupByLibrary.simpleMessage("Piso"), + "floors": MessageLookupByLibrary.simpleMessage("Pisos"), "last_refresh_time": m0, "last_timestamp": m1, + "library": MessageLookupByLibrary.simpleMessage("Biblioteca"), + "library_occupation": + MessageLookupByLibrary.simpleMessage("Ocupação da Biblioteca"), "logout": MessageLookupByLibrary.simpleMessage("Terminar sessão"), + "menus": MessageLookupByLibrary.simpleMessage("Ementas"), "nav_title": m2, "no_course_units": MessageLookupByLibrary.simpleMessage( "Sem cadeiras no período selecionado"), @@ -81,6 +87,10 @@ class MessageLookup extends MessageLookupByLibrary { "Não há dados a mostrar neste momento"), "no_exams": MessageLookupByLibrary.simpleMessage("Não possui exames marcados"), + "no_menu_info": MessageLookupByLibrary.simpleMessage( + "Não há informação disponível sobre refeições"), + "no_menus": MessageLookupByLibrary.simpleMessage( + "Não há refeições disponíveis"), "no_results": MessageLookupByLibrary.simpleMessage("Sem resultados"), "no_selected_courses": MessageLookupByLibrary.simpleMessage( "Não existem cadeiras para apresentar"), diff --git a/uni/lib/generated/l10n.dart b/uni/lib/generated/l10n.dart index 129b6e382..6767d7e46 100644 --- a/uni/lib/generated/l10n.dart +++ b/uni/lib/generated/l10n.dart @@ -230,6 +230,26 @@ class S { ); } + /// `Floor` + String get floor { + return Intl.message( + 'Floor', + name: 'floor', + desc: '', + args: [], + ); + } + + /// `Floors` + String get floors { + return Intl.message( + 'Floors', + name: 'floors', + desc: '', + args: [], + ); + } + /// `last refresh at {time}` String last_refresh_time(Object time) { return Intl.message( @@ -253,6 +273,26 @@ class S { ); } + /// `Library` + String get library { + return Intl.message( + 'Library', + name: 'library', + desc: '', + args: [], + ); + } + + /// `Library Occupation` + String get library_occupation { + return Intl.message( + 'Library Occupation', + name: 'library_occupation', + desc: '', + args: [], + ); + } + /// `Log out` String get logout { return Intl.message( @@ -263,6 +303,16 @@ class S { ); } + /// `Menus` + String get menus { + return Intl.message( + 'Menus', + name: 'menus', + desc: '', + args: [], + ); + } + /// `{title, select, horario{Schedule} exames{Exams} area{Personal Area} cadeiras{Course Units} autocarros{Buses} locais{Places} restaurantes{Restaurants} calendario{Calendar} biblioteca{Library} uteis{Utils} sobre{About} bugs{Bugs and Suggestions} other{Other}}` String nav_title(Object title) { return Intl.select( @@ -318,6 +368,26 @@ class S { ); } + /// `There is no information available about meals` + String get no_menu_info { + return Intl.message( + 'There is no information available about meals', + name: 'no_menu_info', + desc: '', + args: [], + ); + } + + /// `There are no meals available` + String get no_menus { + return Intl.message( + 'There are no meals available', + name: 'no_menus', + desc: '', + args: [], + ); + } + /// `No match` String get no_results { return Intl.message( diff --git a/uni/lib/l10n/intl_en.arb b/uni/lib/l10n/intl_en.arb index 2984a64ff..d2488eeec 100644 --- a/uni/lib/l10n/intl_en.arb +++ b/uni/lib/l10n/intl_en.arb @@ -36,6 +36,10 @@ "@fee_date": {}, "fee_notification": "Notify next deadline:", "@fee_notification": {}, + "floor": "Floor", + "@floor": {}, + "floors": "Floors", + "@floors": {}, "last_refresh_time": "last refresh at {time}", "@last_refresh_time": { "placeholders": { @@ -48,8 +52,14 @@ "time": {} } }, + "library": "Library", + "@library": {}, + "library_occupation": "Library Occupation", + "@library_occupation": {}, "logout": "Log out", "@logout": {}, + "menus": "Menus", + "@menus": {}, "nav_title": "{title, select, horario{Schedule} exames{Exams} area{Personal Area} cadeiras{Course Units} autocarros{Buses} locais{Places} restaurantes{Restaurants} calendario{Calendar} biblioteca{Library} uteis{Utils} sobre{About} bugs{Bugs and Suggestions} other{Other}}", "@nav_title": {}, "no_course_units": "No course units in the selected period", @@ -58,6 +68,10 @@ "@no_data": {}, "no_exams": "You have no exams scheduled\n", "@no_exams": {}, + "no_menu_info": "There is no information available about meals", + "@no_menu_info": {}, + "no_menus": "There are no meals available", + "@no_menus": {}, "no_results": "No match", "@no_results": {}, "no_selected_courses": "There are no course units to display", diff --git a/uni/lib/l10n/intl_pt_PT.arb b/uni/lib/l10n/intl_pt_PT.arb index 962d9e75b..60fb93236 100644 --- a/uni/lib/l10n/intl_pt_PT.arb +++ b/uni/lib/l10n/intl_pt_PT.arb @@ -36,6 +36,10 @@ "@fee_date": {}, "fee_notification": "Notificar próxima data limite:", "@fee_notification": {}, + "floor": "Piso", + "@floor": {}, + "floors": "Pisos", + "@floors": {}, "last_refresh_time": "última atualização às {time}", "@last_refresh_time": { "placeholders": { @@ -48,8 +52,14 @@ "time": {} } }, + "library": "Biblioteca", + "@library": {}, + "library_occupation": "Ocupação da Biblioteca", + "@library_occupation": {}, "logout": "Terminar sessão", "@logout": {}, + "menus": "Ementas", + "@menus": {}, "nav_title": "{title, select, horario{Horário} exames{Exames} area{Área Pessoal} cadeiras{Cadeiras} autocarros{Autocarros} locais{Locais} restaurantes{Restaurantes} calendario{Calendário} biblioteca{Biblioteca} uteis{Úteis} sobre{Sobre} bugs{Bugs e Sugestões} other{Outros}}", "@nav_title": {}, "no_course_units": "Sem cadeiras no período selecionado", @@ -58,6 +68,10 @@ "@no_data": {}, "no_exams": "Não possui exames marcados", "@no_exams": {}, + "no_menu_info": "Não há informação disponível sobre refeições", + "@no_menu_info": {}, + "no_menus": "Não há refeições disponíveis", + "@no_menus": {}, "no_results": "Sem resultados", "@no_results": {}, "no_selected_courses": "Não existem cadeiras para apresentar", diff --git a/uni/lib/view/library/library.dart b/uni/lib/view/library/library.dart index 228110583..16632292c 100644 --- a/uni/lib/view/library/library.dart +++ b/uni/lib/view/library/library.dart @@ -5,6 +5,8 @@ import 'package:uni/model/entities/library_occupation.dart'; import 'package:uni/model/providers/library_occupation_provider.dart'; import 'package:uni/view/common_widgets/page_title.dart'; import 'package:uni/view/common_widgets/pages_layouts/general/general.dart'; +import 'package:uni/generated/l10n.dart'; +import 'package:uni/utils/drawer_items.dart'; import 'package:uni/view/library/widgets/library_occupation_card.dart'; class LibraryPageView extends StatefulWidget { @@ -49,9 +51,9 @@ class LibraryPage extends StatelessWidget { scrollDirection: Axis.vertical, shrinkWrap: true, children: [ - const PageTitle(name: 'Biblioteca'), + PageTitle(name: S.of(context).nav_title(DrawerItem.navLibrary.title)), LibraryOccupationCard(), - if (occupation != null) const PageTitle(name: 'Pisos'), + if (occupation != null) PageTitle(name: S.of(context).floors), if (occupation != null) getFloorRows(context, occupation!), ]); } @@ -93,7 +95,7 @@ class LibraryPage extends StatelessWidget { ]), child: Column(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - Text('Piso ${floor.number}', + Text('${S.of(context).floor} ${floor.number}', style: Theme.of(context).textTheme.headline5), Text('${floor.percentage}%', style: Theme.of(context).textTheme.headline6), diff --git a/uni/lib/view/library/widgets/library_occupation_card.dart b/uni/lib/view/library/widgets/library_occupation_card.dart index f4745f800..f730e445f 100644 --- a/uni/lib/view/library/widgets/library_occupation_card.dart +++ b/uni/lib/view/library/widgets/library_occupation_card.dart @@ -6,6 +6,7 @@ import 'package:uni/model/request_status.dart'; import 'package:uni/utils/drawer_items.dart'; import 'package:uni/view/common_widgets/generic_card.dart'; import 'package:uni/view/common_widgets/request_dependent_widget_builder.dart'; +import 'package:uni/generated/l10n.dart'; /// Manages the library card section inside the personal area. class LibraryOccupationCard extends GenericCard { @@ -16,7 +17,7 @@ class LibraryOccupationCard extends GenericCard { : super.fromEditingInformation(key, editingMode, onDelete); @override - String getTitle(context) => 'Ocupação da Biblioteca'; + String getTitle(context) => S.of(context).library_occupation; @override onClick(BuildContext context) => diff --git a/uni/lib/view/restaurant/restaurant_page_view.dart b/uni/lib/view/restaurant/restaurant_page_view.dart index aeafcf5fd..fd6bc6a30 100644 --- a/uni/lib/view/restaurant/restaurant_page_view.dart +++ b/uni/lib/view/restaurant/restaurant_page_view.dart @@ -1,11 +1,13 @@ import 'package:provider/provider.dart'; import 'package:uni/model/entities/meal.dart'; import 'package:flutter/material.dart'; +import 'package:uni/model/entities/time_utilities.dart'; import 'package:uni/model/providers/restaurant_provider.dart'; import 'package:uni/model/request_status.dart'; import 'package:uni/view/common_widgets/page_title.dart'; import 'package:uni/view/common_widgets/pages_layouts/general/general.dart'; import 'package:uni/model/utils/day_of_week.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/model/entities/restaurant.dart'; import 'package:uni/view/common_widgets/request_dependent_widget_builder.dart'; @@ -49,7 +51,7 @@ class _CanteenPageState extends GeneralPageViewState Container( padding: const EdgeInsets.fromLTRB(20, 20, 20, 10), alignment: Alignment.center, - child: const PageTitle(name: 'Ementas', center: false, pad: false), + child: PageTitle(name: S.of(context).menus , center: false, pad: false), ), TabBar( controller: tabController, @@ -64,7 +66,7 @@ class _CanteenPageState extends GeneralPageViewState contentGenerator: createTabViewBuilder, content: restaurants, contentChecker: restaurants.isNotEmpty, - onNullContent: const Center(child: Text('Não há refeições disponíveis.'))) + onNullContent: Center(child: Text(S.of(context).no_menus))) ]); } @@ -87,12 +89,14 @@ class _CanteenPageState extends GeneralPageViewState } List createTabs(BuildContext context) { + final List daysOfTheWeek = + TimeString.getWeekdaysStrings(includeWeekend: true); final List tabs = []; for (var i = 0; i < DayOfWeek.values.length; i++) { tabs.add(Container( color: Theme.of(context).backgroundColor, - child: Tab(key: Key('cantine-page-tab-$i'), text: toString(DayOfWeek.values[i])), + child: Tab(key: Key('cantine-page-tab-$i'), text: daysOfTheWeek[i]), )); } @@ -119,8 +123,7 @@ class _CanteenPageState extends GeneralPageViewState key: Key('cantine-page-day-column-$day'), child: Column( mainAxisSize: MainAxisSize.min, - children: - const [Center (child: Text("Não há informação disponível sobre refeições")),], + children: [Center (child: Text(S.of(context).no_menu_info)),], ) ); } else { From 449d780a48acd0a829c1152c6baf7e1caaf67e78 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Sat, 17 Jun 2023 16:29:12 +0100 Subject: [PATCH 07/50] Utils page translation --- uni/lib/generated/intl/messages_en.dart | 33 ++- uni/lib/generated/intl/messages_pt-PT.dart | 31 ++- uni/lib/generated/l10n.dart | 194 ++++++++++++++++-- uni/lib/l10n/intl_en.arb | 40 +++- uni/lib/l10n/intl_pt_PT.arb | 38 +++- uni/lib/utils/duration_string_formatter.dart | 46 +++++ .../generic_expansion_card.dart | 4 +- uni/lib/view/useful_info/useful_info.dart | 4 +- .../widgets/academic_services_card.dart | 12 +- .../useful_info/widgets/copy_center_card.dart | 10 +- .../useful_info/widgets/dona_bia_card.dart | 10 +- .../useful_info/widgets/infodesk_card.dart | 10 +- .../widgets/multimedia_center_card.dart | 10 +- .../useful_info/widgets/other_links_card.dart | 7 +- .../widgets/sigarra_links_card.dart | 17 +- 15 files changed, 411 insertions(+), 55 deletions(-) create mode 100644 uni/lib/utils/duration_string_formatter.dart diff --git a/uni/lib/generated/intl/messages_en.dart b/uni/lib/generated/intl/messages_en.dart index 272a24d0c..af42487cb 100644 --- a/uni/lib/generated/intl/messages_en.dart +++ b/uni/lib/generated/intl/messages_en.dart @@ -37,12 +37,14 @@ class MessageLookup extends MessageLookupByLibrary { 'biblioteca': 'Library', 'uteis': 'Utils', 'sobre': 'About', - 'bugs': 'Bugs and Suggestions', + 'bugs': 'Bugs/ Suggestions', 'other': 'Other', })}"; final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { + "academic_services": + MessageLookupByLibrary.simpleMessage("Academic services"), "account_card_title": MessageLookupByLibrary.simpleMessage("Checking account"), "add": MessageLookupByLibrary.simpleMessage("Add"), @@ -59,10 +61,19 @@ class MessageLookup extends MessageLookupByLibrary { "buses_text": MessageLookupByLibrary.simpleMessage( "Favorite buses will be displayed in the favorites \'Bus\' widget. The remaining ones will only be displayed on the page."), "cancel": MessageLookupByLibrary.simpleMessage("Cancel"), + "class_registration": + MessageLookupByLibrary.simpleMessage("Class Registration"), "conclude": MessageLookupByLibrary.simpleMessage("Done"), "configured_buses": MessageLookupByLibrary.simpleMessage("Configured Buses"), "confirm": MessageLookupByLibrary.simpleMessage("Confirm"), + "copy_center": MessageLookupByLibrary.simpleMessage("Copy center"), + "copy_center_building": MessageLookupByLibrary.simpleMessage( + "Floor -1 of building B | AEFEUP building"), + "dona_bia": MessageLookupByLibrary.simpleMessage( + "D. Beatriz\'s stationery store"), + "dona_bia_building": MessageLookupByLibrary.simpleMessage( + "Floor -1 of building B (B-142)"), "edit_off": MessageLookupByLibrary.simpleMessage("Edit"), "edit_on": MessageLookupByLibrary.simpleMessage("Finish editing"), "exams_filter": @@ -73,14 +84,20 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Notify next deadline:"), "floor": MessageLookupByLibrary.simpleMessage("Floor"), "floors": MessageLookupByLibrary.simpleMessage("Floors"), + "geral_registration": + MessageLookupByLibrary.simpleMessage("General Registration"), + "improvement_registration": + MessageLookupByLibrary.simpleMessage("Enrollment for Improvement"), "last_refresh_time": m0, "last_timestamp": m1, - "library": MessageLookupByLibrary.simpleMessage("Library"), "library_occupation": MessageLookupByLibrary.simpleMessage("Library Occupation"), "logout": MessageLookupByLibrary.simpleMessage("Log out"), "menus": MessageLookupByLibrary.simpleMessage("Menus"), + "multimedia_center": + MessageLookupByLibrary.simpleMessage("Multimedia center"), "nav_title": m2, + "news": MessageLookupByLibrary.simpleMessage("News"), "no_course_units": MessageLookupByLibrary.simpleMessage( "No course units in the selected period"), "no_data": MessageLookupByLibrary.simpleMessage( @@ -96,9 +113,21 @@ class MessageLookup extends MessageLookupByLibrary { "There are no course units to display"), "no_selected_exams": MessageLookupByLibrary.simpleMessage( "There are no exams to present"), + "other_links": MessageLookupByLibrary.simpleMessage("Other links"), + "personal_assistance": + MessageLookupByLibrary.simpleMessage("Face-to-face assistance"), + "print": MessageLookupByLibrary.simpleMessage("Print"), + "room": MessageLookupByLibrary.simpleMessage("Room"), + "school_calendar": + MessageLookupByLibrary.simpleMessage("School Calendar"), "semester": MessageLookupByLibrary.simpleMessage("Semester"), "stcp_stops": MessageLookupByLibrary.simpleMessage("STCP - Upcoming Trips"), + "tele_assistance": + MessageLookupByLibrary.simpleMessage("Telephone assistance"), + "tele_personal_assistance": MessageLookupByLibrary.simpleMessage( + "Face-to-face and telephone assistance"), + "telephone": MessageLookupByLibrary.simpleMessage("Telephone"), "widget_prompt": MessageLookupByLibrary.simpleMessage( "Choose a widget to add to your personal area:"), "year": MessageLookupByLibrary.simpleMessage("Year") diff --git a/uni/lib/generated/intl/messages_pt-PT.dart b/uni/lib/generated/intl/messages_pt-PT.dart index 70ba3a2a7..8b5b6c33a 100644 --- a/uni/lib/generated/intl/messages_pt-PT.dart +++ b/uni/lib/generated/intl/messages_pt-PT.dart @@ -43,6 +43,8 @@ class MessageLookup extends MessageLookupByLibrary { final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { + "academic_services": + MessageLookupByLibrary.simpleMessage("Serviços académicos"), "account_card_title": MessageLookupByLibrary.simpleMessage("Conta Corrente"), "add": MessageLookupByLibrary.simpleMessage("Adicionar"), @@ -59,10 +61,19 @@ class MessageLookup extends MessageLookupByLibrary { "buses_text": MessageLookupByLibrary.simpleMessage( "Os autocarros favoritos serão apresentados no widget \'Autocarros\' dos favoritos. Os restantes serão apresentados apenas na página."), "cancel": MessageLookupByLibrary.simpleMessage("Cancelar\n"), + "class_registration": + MessageLookupByLibrary.simpleMessage("Inscrição de Turmas"), "conclude": MessageLookupByLibrary.simpleMessage("Concluído"), "configured_buses": MessageLookupByLibrary.simpleMessage("Autocarros Configurados"), "confirm": MessageLookupByLibrary.simpleMessage("Confirmar"), + "copy_center": MessageLookupByLibrary.simpleMessage("Centro de cópias"), + "copy_center_building": MessageLookupByLibrary.simpleMessage( + "Piso -1 do edifício B | Edifício da AEFEUP"), + "dona_bia": + MessageLookupByLibrary.simpleMessage("Papelaria D. Beatriz"), + "dona_bia_building": MessageLookupByLibrary.simpleMessage( + "Piso -1 do edifício B (B-142)"), "edit_off": MessageLookupByLibrary.simpleMessage("Editar\n"), "edit_on": MessageLookupByLibrary.simpleMessage("Concluir edição"), "exams_filter": @@ -73,14 +84,20 @@ class MessageLookup extends MessageLookupByLibrary { "Notificar próxima data limite:"), "floor": MessageLookupByLibrary.simpleMessage("Piso"), "floors": MessageLookupByLibrary.simpleMessage("Pisos"), + "geral_registration": + MessageLookupByLibrary.simpleMessage("Inscrição Geral"), + "improvement_registration": + MessageLookupByLibrary.simpleMessage("Inscrição para Melhoria"), "last_refresh_time": m0, "last_timestamp": m1, - "library": MessageLookupByLibrary.simpleMessage("Biblioteca"), "library_occupation": MessageLookupByLibrary.simpleMessage("Ocupação da Biblioteca"), "logout": MessageLookupByLibrary.simpleMessage("Terminar sessão"), "menus": MessageLookupByLibrary.simpleMessage("Ementas"), + "multimedia_center": + MessageLookupByLibrary.simpleMessage("Centro de multimédia"), "nav_title": m2, + "news": MessageLookupByLibrary.simpleMessage("Notícias"), "no_course_units": MessageLookupByLibrary.simpleMessage( "Sem cadeiras no período selecionado"), "no_data": MessageLookupByLibrary.simpleMessage( @@ -96,9 +113,21 @@ class MessageLookup extends MessageLookupByLibrary { "Não existem cadeiras para apresentar"), "no_selected_exams": MessageLookupByLibrary.simpleMessage( "Não existem exames para apresentar"), + "other_links": MessageLookupByLibrary.simpleMessage("Outros links"), + "personal_assistance": + MessageLookupByLibrary.simpleMessage("Atendimento presencial"), + "print": MessageLookupByLibrary.simpleMessage("Impressão"), + "room": MessageLookupByLibrary.simpleMessage("Sala"), + "school_calendar": + MessageLookupByLibrary.simpleMessage("Calendário Escolar"), "semester": MessageLookupByLibrary.simpleMessage("Semestre"), "stcp_stops": MessageLookupByLibrary.simpleMessage("STCP - Próximas Viagens"), + "tele_assistance": + MessageLookupByLibrary.simpleMessage("Atendimento telefónico"), + "tele_personal_assistance": MessageLookupByLibrary.simpleMessage( + "Atendimento presencial e telefónico"), + "telephone": MessageLookupByLibrary.simpleMessage("Telefone"), "widget_prompt": MessageLookupByLibrary.simpleMessage( "Escolhe um widget para adicionares à tua área pessoal:"), "year": MessageLookupByLibrary.simpleMessage("Ano") diff --git a/uni/lib/generated/l10n.dart b/uni/lib/generated/l10n.dart index 6767d7e46..3ec3d979b 100644 --- a/uni/lib/generated/l10n.dart +++ b/uni/lib/generated/l10n.dart @@ -50,6 +50,16 @@ class S { return Localizations.of(context, S); } + /// `Academic services` + String get academic_services { + return Intl.message( + 'Academic services', + name: 'academic_services', + desc: '', + args: [], + ); + } + /// `Checking account` String get account_card_title { return Intl.message( @@ -150,6 +160,16 @@ class S { ); } + /// `Class Registration` + String get class_registration { + return Intl.message( + 'Class Registration', + name: 'class_registration', + desc: '', + args: [], + ); + } + /// `Done` String get conclude { return Intl.message( @@ -180,6 +200,46 @@ class S { ); } + /// `Copy center` + String get copy_center { + return Intl.message( + 'Copy center', + name: 'copy_center', + desc: '', + args: [], + ); + } + + /// `Floor -1 of building B | AEFEUP building` + String get copy_center_building { + return Intl.message( + 'Floor -1 of building B | AEFEUP building', + name: 'copy_center_building', + desc: '', + args: [], + ); + } + + /// `D. Beatriz's stationery store` + String get dona_bia { + return Intl.message( + 'D. Beatriz\'s stationery store', + name: 'dona_bia', + desc: '', + args: [], + ); + } + + /// `Floor -1 of building B (B-142)` + String get dona_bia_building { + return Intl.message( + 'Floor -1 of building B (B-142)', + name: 'dona_bia_building', + desc: '', + args: [], + ); + } + /// `Edit` String get edit_off { return Intl.message( @@ -250,6 +310,26 @@ class S { ); } + /// `General Registration` + String get geral_registration { + return Intl.message( + 'General Registration', + name: 'geral_registration', + desc: '', + args: [], + ); + } + + /// `Enrollment for Improvement` + String get improvement_registration { + return Intl.message( + 'Enrollment for Improvement', + name: 'improvement_registration', + desc: '', + args: [], + ); + } + /// `last refresh at {time}` String last_refresh_time(Object time) { return Intl.message( @@ -273,16 +353,6 @@ class S { ); } - /// `Library` - String get library { - return Intl.message( - 'Library', - name: 'library', - desc: '', - args: [], - ); - } - /// `Library Occupation` String get library_occupation { return Intl.message( @@ -313,7 +383,17 @@ class S { ); } - /// `{title, select, horario{Schedule} exames{Exams} area{Personal Area} cadeiras{Course Units} autocarros{Buses} locais{Places} restaurantes{Restaurants} calendario{Calendar} biblioteca{Library} uteis{Utils} sobre{About} bugs{Bugs and Suggestions} other{Other}}` + /// `Multimedia center` + String get multimedia_center { + return Intl.message( + 'Multimedia center', + name: 'multimedia_center', + desc: '', + args: [], + ); + } + + /// `{title, select, horario{Schedule} exames{Exams} area{Personal Area} cadeiras{Course Units} autocarros{Buses} locais{Places} restaurantes{Restaurants} calendario{Calendar} biblioteca{Library} uteis{Utils} sobre{About} bugs{Bugs/ Suggestions} other{Other}}` String nav_title(Object title) { return Intl.select( title, @@ -329,7 +409,7 @@ class S { 'biblioteca': 'Library', 'uteis': 'Utils', 'sobre': 'About', - 'bugs': 'Bugs and Suggestions', + 'bugs': 'Bugs/ Suggestions', 'other': 'Other', }, name: 'nav_title', @@ -338,6 +418,16 @@ class S { ); } + /// `News` + String get news { + return Intl.message( + 'News', + name: 'news', + desc: '', + args: [], + ); + } + /// `No course units in the selected period` String get no_course_units { return Intl.message( @@ -418,6 +508,56 @@ class S { ); } + /// `Other links` + String get other_links { + return Intl.message( + 'Other links', + name: 'other_links', + desc: '', + args: [], + ); + } + + /// `Face-to-face assistance` + String get personal_assistance { + return Intl.message( + 'Face-to-face assistance', + name: 'personal_assistance', + desc: '', + args: [], + ); + } + + /// `Print` + String get print { + return Intl.message( + 'Print', + name: 'print', + desc: '', + args: [], + ); + } + + /// `Room` + String get room { + return Intl.message( + 'Room', + name: 'room', + desc: '', + args: [], + ); + } + + /// `School Calendar` + String get school_calendar { + return Intl.message( + 'School Calendar', + name: 'school_calendar', + desc: '', + args: [], + ); + } + /// `Semester` String get semester { return Intl.message( @@ -438,6 +578,36 @@ class S { ); } + /// `Telephone assistance` + String get tele_assistance { + return Intl.message( + 'Telephone assistance', + name: 'tele_assistance', + desc: '', + args: [], + ); + } + + /// `Face-to-face and telephone assistance` + String get tele_personal_assistance { + return Intl.message( + 'Face-to-face and telephone assistance', + name: 'tele_personal_assistance', + desc: '', + args: [], + ); + } + + /// `Telephone` + String get telephone { + return Intl.message( + 'Telephone', + name: 'telephone', + desc: '', + args: [], + ); + } + /// `Choose a widget to add to your personal area:` String get widget_prompt { return Intl.message( diff --git a/uni/lib/l10n/intl_en.arb b/uni/lib/l10n/intl_en.arb index d2488eeec..d728c29f3 100644 --- a/uni/lib/l10n/intl_en.arb +++ b/uni/lib/l10n/intl_en.arb @@ -1,5 +1,7 @@ { "@@locale": "en", + "academic_services": "Academic services", + "@academic_services": {}, "account_card_title": "Checking account", "@account_card_title": {}, "add": "Add", @@ -20,12 +22,22 @@ "@bus_information": {}, "cancel": "Cancel", "@cancel": {}, + "class_registration": "Class Registration", + "@class_registration": {}, "conclude": "Done", "@conclude": {}, "configured_buses": "Configured Buses", "@configured_buses": {}, "confirm": "Confirm", "@confirm": {}, + "copy_center": "Copy center", + "@copy_center": {}, + "copy_center_building": "Floor -1 of building B | AEFEUP building", + "@copy_center_building": {}, + "dona_bia": "D. Beatriz's stationery store", + "@dona_bia": {}, + "dona_bia_building": "Floor -1 of building B (B-142)", + "@dona_bia_building": {}, "edit_off": "Edit", "@edit_off": {}, "edit_on": "Finish editing", @@ -40,6 +52,10 @@ "@floor": {}, "floors": "Floors", "@floors": {}, + "geral_registration": "General Registration", + "@geral_registration": {}, + "improvement_registration": "Enrollment for Improvement", + "@improvement_registration": {}, "last_refresh_time": "last refresh at {time}", "@last_refresh_time": { "placeholders": { @@ -52,16 +68,18 @@ "time": {} } }, - "library": "Library", - "@library": {}, "library_occupation": "Library Occupation", "@library_occupation": {}, "logout": "Log out", "@logout": {}, "menus": "Menus", "@menus": {}, - "nav_title": "{title, select, horario{Schedule} exames{Exams} area{Personal Area} cadeiras{Course Units} autocarros{Buses} locais{Places} restaurantes{Restaurants} calendario{Calendar} biblioteca{Library} uteis{Utils} sobre{About} bugs{Bugs and Suggestions} other{Other}}", + "multimedia_center": "Multimedia center", + "@multimedia_center": {}, + "nav_title": "{title, select, horario{Schedule} exames{Exams} area{Personal Area} cadeiras{Course Units} autocarros{Buses} locais{Places} restaurantes{Restaurants} calendario{Calendar} biblioteca{Library} uteis{Utils} sobre{About} bugs{Bugs/ Suggestions} other{Other}}", "@nav_title": {}, + "news": "News", + "@news": {}, "no_course_units": "No course units in the selected period", "@no_course_units": {}, "no_data": "There is no data to show at this time", @@ -78,10 +96,26 @@ "@no_selected_courses": {}, "no_selected_exams": "There are no exams to present", "@no_selected_exams": {}, + "other_links": "Other links", + "@other_links": {}, + "personal_assistance": "Face-to-face assistance", + "@personal_assistance": {}, + "print": "Print", + "@print": {}, + "room": "Room", + "@room": {}, + "school_calendar": "School Calendar", + "@school_calendar": {}, "semester": "Semester", "@semester": {}, "stcp_stops": "STCP - Upcoming Trips", "@stcp_stops": {}, + "tele_assistance": "Telephone assistance", + "@tele_assistance": {}, + "tele_personal_assistance": "Face-to-face and telephone assistance", + "@tele_personal_assistance": {}, + "telephone": "Telephone", + "@telephone": {}, "widget_prompt": "Choose a widget to add to your personal area:", "@widget_prompt": {}, "year": "Year", diff --git a/uni/lib/l10n/intl_pt_PT.arb b/uni/lib/l10n/intl_pt_PT.arb index 60fb93236..c9a2cc393 100644 --- a/uni/lib/l10n/intl_pt_PT.arb +++ b/uni/lib/l10n/intl_pt_PT.arb @@ -1,5 +1,7 @@ { "@@locale": "pt-PT", + "academic_services": "Serviços académicos", + "@academic_services": {}, "account_card_title": "Conta Corrente", "@account_card_title": {}, "add": "Adicionar", @@ -20,12 +22,22 @@ "@bus_information": {}, "cancel": "Cancelar\n", "@cancel": {}, + "class_registration": "Inscrição de Turmas", + "@class_registration": {}, "conclude": "Concluído", "@conclude": {}, "configured_buses": "Autocarros Configurados", "@configured_buses": {}, "confirm": "Confirmar", "@confirm": {}, + "copy_center": "Centro de cópias", + "@copy_center": {}, + "copy_center_building": "Piso -1 do edifício B | Edifício da AEFEUP", + "@copy_center_building": {}, + "dona_bia": "Papelaria D. Beatriz", + "@dona_bia": {}, + "dona_bia_building": "Piso -1 do edifício B (B-142)", + "@dona_bia_building": {}, "edit_off": "Editar\n", "@edit_off": {}, "edit_on": "Concluir edição", @@ -40,6 +52,10 @@ "@floor": {}, "floors": "Pisos", "@floors": {}, + "geral_registration": "Inscrição Geral", + "@geral_registration": {}, + "improvement_registration": "Inscrição para Melhoria", + "@improvement_registration": {}, "last_refresh_time": "última atualização às {time}", "@last_refresh_time": { "placeholders": { @@ -52,16 +68,18 @@ "time": {} } }, - "library": "Biblioteca", - "@library": {}, "library_occupation": "Ocupação da Biblioteca", "@library_occupation": {}, "logout": "Terminar sessão", "@logout": {}, "menus": "Ementas", "@menus": {}, + "multimedia_center": "Centro de multimédia", + "@multimedia_center": {}, "nav_title": "{title, select, horario{Horário} exames{Exames} area{Área Pessoal} cadeiras{Cadeiras} autocarros{Autocarros} locais{Locais} restaurantes{Restaurantes} calendario{Calendário} biblioteca{Biblioteca} uteis{Úteis} sobre{Sobre} bugs{Bugs e Sugestões} other{Outros}}", "@nav_title": {}, + "news": "Notícias", + "@news": {}, "no_course_units": "Sem cadeiras no período selecionado", "@no_course_units": {}, "no_data": "Não há dados a mostrar neste momento", @@ -78,10 +96,26 @@ "@no_selected_courses": {}, "no_selected_exams": "Não existem exames para apresentar", "@no_selected_exams": {}, + "other_links": "Outros links", + "@other_links": {}, + "personal_assistance": "Atendimento presencial", + "@personal_assistance": {}, + "print": "Impressão", + "@print": {}, + "room": "Sala", + "@room": {}, + "school_calendar": "Calendário Escolar", + "@school_calendar": {}, "semester": "Semestre", "@semester": {}, "stcp_stops": "STCP - Próximas Viagens", "@stcp_stops": {}, + "tele_assistance": "Atendimento telefónico", + "@tele_assistance": {}, + "tele_personal_assistance": "Atendimento presencial e telefónico", + "@tele_personal_assistance": {}, + "telephone": "Telefone", + "@telephone": {}, "widget_prompt": "Escolhe um widget para adicionares à tua área pessoal:", "@widget_prompt": {}, "year": "Ano", diff --git a/uni/lib/utils/duration_string_formatter.dart b/uni/lib/utils/duration_string_formatter.dart new file mode 100644 index 000000000..6d92006f1 --- /dev/null +++ b/uni/lib/utils/duration_string_formatter.dart @@ -0,0 +1,46 @@ +extension DurationStringFormatter on Duration{ + + static final formattingRegExp = RegExp('{}'); + + String toFormattedString(String singularPhrase, String pluralPhrase, {String term = "{}"}){ + if (!singularPhrase.contains(term) || !pluralPhrase.contains(term)) { + throw ArgumentError("singularPhrase or plurarPhrase don't have a string that can be formatted..."); + } + if(inSeconds == 1){ + return singularPhrase.replaceAll(formattingRegExp, "$inSeconds segundo"); + } + if(inSeconds < 60){ + return pluralPhrase.replaceAll(formattingRegExp, "$inSeconds segundos"); + } + if(inMinutes == 1){ + return singularPhrase.replaceAll(formattingRegExp, "$inMinutes minuto"); + } + if(inMinutes < 60){ + return pluralPhrase.replaceAll(formattingRegExp, "$inMinutes minutos"); + } + if(inHours == 1){ + return singularPhrase.replaceAll(formattingRegExp, "$inHours hora"); + } + if(inHours < 24){ + return pluralPhrase.replaceAll(formattingRegExp, "$inHours horas"); + } + if(inDays == 1){ + return singularPhrase.replaceAll(formattingRegExp, "$inDays dia"); + } + if(inDays <= 7){ + return pluralPhrase.replaceAll(formattingRegExp, "$inDays dias"); + + } + if((inDays / 7).floor() == 1){ + return singularPhrase.replaceAll(formattingRegExp, "${(inDays / 7).floor()} semana"); + } + if((inDays / 7).floor() > 1){ + return pluralPhrase.replaceAll(formattingRegExp, "${(inDays / 7).floor()} semanas"); + } + if((inDays / 30).floor() == 1){ + return singularPhrase.replaceAll(formattingRegExp, "${(inDays / 30).floor()} mês"); + } + return pluralPhrase.replaceAll(formattingRegExp, "${(inDays / 30).floor()} meses"); + + } +} \ No newline at end of file diff --git a/uni/lib/view/common_widgets/generic_expansion_card.dart b/uni/lib/view/common_widgets/generic_expansion_card.dart index 9d88e714c..3189ccd62 100644 --- a/uni/lib/view/common_widgets/generic_expansion_card.dart +++ b/uni/lib/view/common_widgets/generic_expansion_card.dart @@ -10,7 +10,7 @@ abstract class GenericExpansionCard extends StatefulWidget { return GenericExpansionCardState(); } - String getTitle(); + String getTitle(context); Widget buildCardContent(BuildContext context); } @@ -26,7 +26,7 @@ class GenericExpansionCardState extends State { expandedColor: (Theme.of(context).brightness == Brightness.light) ? const Color.fromARGB(0xf, 0, 0, 0) : const Color.fromARGB(255, 43, 43, 43), - title: Text(widget.getTitle(), + title: Text(widget.getTitle(context), style: Theme.of(context) .textTheme .headline5 diff --git a/uni/lib/view/useful_info/useful_info.dart b/uni/lib/view/useful_info/useful_info.dart index cb6b83dc7..cae99fb98 100644 --- a/uni/lib/view/useful_info/useful_info.dart +++ b/uni/lib/view/useful_info/useful_info.dart @@ -8,6 +8,8 @@ import 'package:uni/view/useful_info/widgets/multimedia_center_card.dart'; import 'package:uni/view/useful_info/widgets/other_links_card.dart'; import 'package:uni/view/useful_info/widgets/sigarra_links_card.dart'; import 'package:uni/view/common_widgets/page_title.dart'; +import 'package:uni/generated/l10n.dart'; +import 'package:uni/utils/drawer_items.dart'; class UsefulInfoPageView extends StatefulWidget { const UsefulInfoPageView({super.key}); @@ -35,6 +37,6 @@ class UsefulInfoPageViewState extends GeneralPageViewState { Container _getPageTitle() { return Container( padding: const EdgeInsets.only(bottom: 6.0), - child: const PageTitle(name: 'Úteis')); + child: PageTitle(name: S.of(context).nav_title(DrawerItem.navUsefulInfo.title))); } } diff --git a/uni/lib/view/useful_info/widgets/academic_services_card.dart b/uni/lib/view/useful_info/widgets/academic_services_card.dart index 2b7ffc0be..f6e4c4313 100644 --- a/uni/lib/view/useful_info/widgets/academic_services_card.dart +++ b/uni/lib/view/useful_info/widgets/academic_services_card.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:uni/view/common_widgets/generic_expansion_card.dart'; import 'package:uni/view/useful_info/widgets/text_components.dart'; +import 'package:uni/generated/l10n.dart'; +import 'package:uni/utils/drawer_items.dart'; class AcademicServicesCard extends GenericExpansionCard { const AcademicServicesCard({Key? key}) : super(key: key); @@ -9,12 +11,12 @@ class AcademicServicesCard extends GenericExpansionCard { Widget buildCardContent(BuildContext context) { return Column( children: [ - h1('Horário', context, initial: true), - h2('Atendimento presencial', context), + h1(S.of(context).nav_title(DrawerItem.navSchedule.title), context, initial: true), + h2(S.of(context).personal_assistance, context), infoText('11:00h - 16:00h', context), - h2('Atendimento telefónico', context), + h2(S.of(context).tele_assistance, context), infoText('9:30h - 12:00h | 14:00h - 16:00h', context), - h1('Telefone', context), + h1(S.of(context).telephone, context), infoText('+351 225 081 977', context, link: 'tel:225 081 977', last: true), ], @@ -22,5 +24,5 @@ class AcademicServicesCard extends GenericExpansionCard { } @override - String getTitle() => 'Serviços Académicos'; + String getTitle(context) => S.of(context).academic_services; } diff --git a/uni/lib/view/useful_info/widgets/copy_center_card.dart b/uni/lib/view/useful_info/widgets/copy_center_card.dart index 62124f7d3..251b8b22c 100644 --- a/uni/lib/view/useful_info/widgets/copy_center_card.dart +++ b/uni/lib/view/useful_info/widgets/copy_center_card.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:uni/view/common_widgets/generic_expansion_card.dart'; import 'package:uni/view/useful_info/widgets/text_components.dart'; +import 'package:uni/generated/l10n.dart'; +import 'package:uni/utils/drawer_items.dart'; class CopyCenterCard extends GenericExpansionCard { const CopyCenterCard({Key? key}) : super(key: key); @@ -9,10 +11,10 @@ class CopyCenterCard extends GenericExpansionCard { Widget buildCardContent(BuildContext context) { return Column( children: [ - h1('Horário', context, initial: true), - h2('Piso -1 do edifício B | Edifício da AEFEUP', context), + h1(S.of(context).nav_title(DrawerItem.navSchedule.title), context, initial: true), + h2(S.of(context).copy_center_building, context), infoText('9:00h - 11:30h | 12:30h - 18:00h', context), - h1('Telefone', context), + h1(S.of(context).telephone, context), h2('FEUP ', context), infoText('+351 220 994 122', context, link: 'tel:220 994 122'), h2('AEFEUP ', context), @@ -25,5 +27,5 @@ class CopyCenterCard extends GenericExpansionCard { } @override - String getTitle() => 'Centro de Cópias'; + String getTitle(context) => S.of(context).copy_center; } diff --git a/uni/lib/view/useful_info/widgets/dona_bia_card.dart b/uni/lib/view/useful_info/widgets/dona_bia_card.dart index fc1abd773..7554e8617 100644 --- a/uni/lib/view/useful_info/widgets/dona_bia_card.dart +++ b/uni/lib/view/useful_info/widgets/dona_bia_card.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:uni/view/common_widgets/generic_expansion_card.dart'; import 'package:uni/view/useful_info/widgets/text_components.dart'; +import 'package:uni/generated/l10n.dart'; +import 'package:uni/utils/drawer_items.dart'; class DonaBiaCard extends GenericExpansionCard { const DonaBiaCard({Key? key}) : super(key: key); @@ -9,10 +11,10 @@ class DonaBiaCard extends GenericExpansionCard { Widget buildCardContent(BuildContext context) { return Column( children: [ - h1('Horário', context, initial: true), - h2('Piso -1 do edifício B (B -142)', context), + h1(S.of(context).nav_title(DrawerItem.navSchedule.title), context, initial: true), + h2(S.of(context).dona_bia_building, context), infoText('8:30h - 12:00h | 13:30h - 19:00h', context), - h1('Telefone', context), + h1(S.of(context).telephone, context), infoText('+351 225 081 416', context, link: 'tel:225 081 416'), h1('Email', context), infoText('papelaria.fe.up@gmail.com', context, @@ -22,5 +24,5 @@ class DonaBiaCard extends GenericExpansionCard { } @override - String getTitle() => 'Papelaria D. Beatriz'; + String getTitle(context) => S.of(context).dona_bia; } diff --git a/uni/lib/view/useful_info/widgets/infodesk_card.dart b/uni/lib/view/useful_info/widgets/infodesk_card.dart index 66cf8dac6..f99dfcaec 100644 --- a/uni/lib/view/useful_info/widgets/infodesk_card.dart +++ b/uni/lib/view/useful_info/widgets/infodesk_card.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:uni/view/common_widgets/generic_expansion_card.dart'; import 'package:uni/view/useful_info/widgets/text_components.dart'; +import 'package:uni/generated/l10n.dart'; +import 'package:uni/utils/drawer_items.dart'; class InfoDeskCard extends GenericExpansionCard { const InfoDeskCard({Key? key}) : super(key: key); @@ -9,10 +11,10 @@ class InfoDeskCard extends GenericExpansionCard { Widget buildCardContent(BuildContext context) { return Column( children: [ - h1('Horário', context, initial: true), - h2('Atendimento presencial e telefónico', context), + h1(S.of(context).nav_title(DrawerItem.navSchedule.title), context, initial: true), + h2(S.of(context).tele_personal_assistance, context), infoText('9:30h - 13:00h | 14:00h - 17:30h', context), - h1('Telefone', context), + h1(S.of(context).telephone, context), infoText('+351 225 081 400', context, link: 'tel:225 081 400'), h1('Email', context), infoText('infodesk@fe.up.pt', context, @@ -22,5 +24,5 @@ class InfoDeskCard extends GenericExpansionCard { } @override - String getTitle() => 'Infodesk'; + String getTitle(context) => 'Infodesk'; } diff --git a/uni/lib/view/useful_info/widgets/multimedia_center_card.dart b/uni/lib/view/useful_info/widgets/multimedia_center_card.dart index ce667f641..832dc84a7 100644 --- a/uni/lib/view/useful_info/widgets/multimedia_center_card.dart +++ b/uni/lib/view/useful_info/widgets/multimedia_center_card.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; import 'package:uni/view/common_widgets/generic_expansion_card.dart'; import 'package:uni/view/useful_info/widgets/text_components.dart'; +import 'package:uni/generated/l10n.dart'; +import 'package:uni/utils/drawer_items.dart'; class MultimediaCenterCard extends GenericExpansionCard { const MultimediaCenterCard({Key? key}) : super(key: key); @@ -9,10 +11,10 @@ class MultimediaCenterCard extends GenericExpansionCard { Widget buildCardContent(BuildContext context) { return Column( children: [ - h1('Horário', context, initial: true), - h2('Sala B123', context), + h1(S.of(context).nav_title(DrawerItem.navSchedule.title), context, initial: true), + h2('${S.of(context).room} B123', context), infoText('9:00h - 12:30h | 14:30h - 17:00h', context), - h1('Telefone', context), + h1(S.of(context).telephone, context), infoText('+351 225 081 466', context, link: 'tel:225 081 466'), h1('Email', context), infoText('imprimir@fe.up.pt', context, @@ -22,5 +24,5 @@ class MultimediaCenterCard extends GenericExpansionCard { } @override - String getTitle() => 'Centro de Multimédia'; + String getTitle(context) => S.of(context).multimedia_center; } diff --git a/uni/lib/view/useful_info/widgets/other_links_card.dart b/uni/lib/view/useful_info/widgets/other_links_card.dart index 92561b92d..59acfd6e0 100644 --- a/uni/lib/view/useful_info/widgets/other_links_card.dart +++ b/uni/lib/view/useful_info/widgets/other_links_card.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:uni/view/common_widgets/generic_expansion_card.dart'; import 'package:uni/view/useful_info/widgets/link_button.dart'; +import 'package:uni/generated/l10n.dart'; /// Manages the 'Current account' section inside the user's page (accessible /// through the top-right widget with the user picture) @@ -9,11 +10,11 @@ class OtherLinksCard extends GenericExpansionCard { @override Widget buildCardContent(BuildContext context) { - return Column(children: const [ - LinkButton(title: 'Impressão', link: 'https://print.up.pt') + return Column(children: [ + LinkButton(title: S.of(context).print, link: 'https://print.up.pt') ]); } @override - String getTitle() => 'Outros Links'; + String getTitle(context) => S.of(context).other_links; } diff --git a/uni/lib/view/useful_info/widgets/sigarra_links_card.dart b/uni/lib/view/useful_info/widgets/sigarra_links_card.dart index 90fcbe3d0..cd675ad1f 100644 --- a/uni/lib/view/useful_info/widgets/sigarra_links_card.dart +++ b/uni/lib/view/useful_info/widgets/sigarra_links_card.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:uni/view/common_widgets/generic_expansion_card.dart'; import 'package:uni/view/useful_info/widgets/link_button.dart'; +import 'package:uni/generated/l10n.dart'; /// Manages the 'Current account' section inside the user's page (accessible /// through the top-right widget with the user picture) @@ -9,31 +10,31 @@ class SigarraLinksCard extends GenericExpansionCard { @override Widget buildCardContent(BuildContext context) { - return Column(children: const [ + return Column(children: [ LinkButton( - title: 'Notícias', + title: S.of(context).news, link: 'https://sigarra.up.pt/feup/pt/noticias_geral.lista_noticias'), - LinkButton( + const LinkButton( title: 'Erasmus', link: 'https://sigarra.up.pt/feup/pt/web_base.gera_pagina?P_pagina=257769'), LinkButton( - title: 'Inscrição Geral', + title: S.of(context).geral_registration, link: 'https://sigarra.up.pt/feup/pt/ins_geral.inscricao'), LinkButton( - title: 'Inscrição de Turmas', + title: S.of(context).class_registration, link: 'https://sigarra.up.pt/feup/pt/it_geral.ver_insc'), LinkButton( - title: 'Inscrição para Melhoria', + title: S.of(context).improvement_registration, link: 'https://sigarra.up.pt/feup/pt/inqueritos_geral.inqueritos_list'), LinkButton( - title: 'Calendário Escolar', + title: S.of(context).school_calendar, link: 'https://sigarra.up.pt/feup/pt/web_base.gera_pagina?p_pagina=p%c3%a1gina%20est%c3%a1tica%20gen%c3%a9rica%20106') ]); } @override - String getTitle() => 'Links Sigarra'; + String getTitle(context) => 'Links Sigarra'; } From 00831a79ae52dc152e7c726082fa5ad36ccf885d Mon Sep 17 00:00:00 2001 From: DGoiana Date: Mon, 19 Jun 2023 22:58:17 +0100 Subject: [PATCH 08/50] Error fixing --- uni/lib/model/entities/time_utilities.dart | 2 +- uni/lib/view/restaurant/restaurant_page_view.dart | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/uni/lib/model/entities/time_utilities.dart b/uni/lib/model/entities/time_utilities.dart index a253239f8..45072ba4e 100644 --- a/uni/lib/model/entities/time_utilities.dart +++ b/uni/lib/model/entities/time_utilities.dart @@ -1,5 +1,5 @@ import 'dart:io'; -import 'package:flutter/material.dart +import 'package:flutter/material.dart'; extension TimeString on DateTime { String toTimeHourMinString() { diff --git a/uni/lib/view/restaurant/restaurant_page_view.dart b/uni/lib/view/restaurant/restaurant_page_view.dart index ed0816644..5cdd61b5b 100644 --- a/uni/lib/view/restaurant/restaurant_page_view.dart +++ b/uni/lib/view/restaurant/restaurant_page_view.dart @@ -1,9 +1,9 @@ import 'package:provider/provider.dart'; import 'package:uni/model/entities/meal.dart'; import 'package:flutter/material.dart'; -import 'package:uni/model/entities/time_utilities.dart'; import 'package:uni/model/providers/restaurant_provider.dart'; import 'package:uni/model/request_status.dart'; +import 'package:uni/model/entities/time_utilities.dart'; import 'package:uni/view/common_widgets/page_title.dart'; import 'package:uni/view/common_widgets/pages_layouts/general/general.dart'; import 'package:uni/model/utils/day_of_week.dart'; @@ -89,14 +89,13 @@ class _CanteenPageState extends GeneralPageViewState } List createTabs(BuildContext context) { - final List daysOfTheWeek = - TimeString.getWeekdaysStrings(includeWeekend: true); + final List daysOfTheWeek = TimeString.getWeekdaysStrings(includeWeekend: true); final List tabs = []; for (var i = 0; i < DayOfWeek.values.length; i++) { tabs.add(Container( color: Theme.of(context).backgroundColor, - child: Tab(key: Key('cantine-page-tab-$i'), text: toString(DayOfWeek.values[i])), + child: Tab(key: Key('cantine-page-tab-$i'), text: daysOfTheWeek[i]), )); } From d018f768c8d9835f626e08a6c4b7ad0f4c19742c Mon Sep 17 00:00:00 2001 From: DGoiana Date: Tue, 20 Jun 2023 01:58:13 +0100 Subject: [PATCH 09/50] Bugs and suggestions page translation --- uni/lib/generated/intl/messages_en.dart | 27 +++ uni/lib/generated/intl/messages_pt-PT.dart | 27 +++ uni/lib/generated/l10n.dart | 160 ++++++++++++++++++ uni/lib/l10n/intl_en.arb | 32 ++++ uni/lib/l10n/intl_pt_PT.arb | 32 ++++ .../about/widgets/terms_and_conditions.dart | 4 +- uni/lib/view/bug_report/widgets/form.dart | 53 +++--- .../view/bug_report/widgets/text_field.dart | 5 +- .../bus_stop_next_arrivals.dart | 2 +- .../view/restaurant/restaurant_page_view.dart | 2 +- 10 files changed, 316 insertions(+), 28 deletions(-) diff --git a/uni/lib/generated/intl/messages_en.dart b/uni/lib/generated/intl/messages_en.dart index af42487cb..961f762bb 100644 --- a/uni/lib/generated/intl/messages_en.dart +++ b/uni/lib/generated/intl/messages_en.dart @@ -52,6 +52,10 @@ class MessageLookup extends MessageLookupByLibrary { "all_widgets_added": MessageLookupByLibrary.simpleMessage( "All available widgets have already been added to your personal area!"), "balance": MessageLookupByLibrary.simpleMessage("Balance:"), + "bs_description": MessageLookupByLibrary.simpleMessage( + "Did you find any bugs in the application?\\nDo you have any suggestions for the app?\\nTell us so we can improve!"), + "bug_description": MessageLookupByLibrary.simpleMessage( + "Bug found, how to reproduce it, etc."), "bus_error": MessageLookupByLibrary.simpleMessage("Unable to get information"), "bus_information": MessageLookupByLibrary.simpleMessage( @@ -67,15 +71,23 @@ class MessageLookup extends MessageLookupByLibrary { "configured_buses": MessageLookupByLibrary.simpleMessage("Configured Buses"), "confirm": MessageLookupByLibrary.simpleMessage("Confirm"), + "consent": MessageLookupByLibrary.simpleMessage( + "I consent to this information being reviewed by NIAEFEUP and may be deleted at my request."), + "contact": MessageLookupByLibrary.simpleMessage("Contact (optional)"), "copy_center": MessageLookupByLibrary.simpleMessage("Copy center"), "copy_center_building": MessageLookupByLibrary.simpleMessage( "Floor -1 of building B | AEFEUP building"), + "description": MessageLookupByLibrary.simpleMessage("Description"), + "desired_email": MessageLookupByLibrary.simpleMessage( + "Email where you want to be contacted"), "dona_bia": MessageLookupByLibrary.simpleMessage( "D. Beatriz\'s stationery store"), "dona_bia_building": MessageLookupByLibrary.simpleMessage( "Floor -1 of building B (B-142)"), "edit_off": MessageLookupByLibrary.simpleMessage("Edit"), "edit_on": MessageLookupByLibrary.simpleMessage("Finish editing"), + "empty_text": + MessageLookupByLibrary.simpleMessage("Please fill in this field"), "exams_filter": MessageLookupByLibrary.simpleMessage("Exam Filter Settings"), "fee_date": @@ -92,12 +104,16 @@ class MessageLookup extends MessageLookupByLibrary { "last_timestamp": m1, "library_occupation": MessageLookupByLibrary.simpleMessage("Library Occupation"), + "loading_terms": MessageLookupByLibrary.simpleMessage( + "Loading Terms and Conditions..."), "logout": MessageLookupByLibrary.simpleMessage("Log out"), "menus": MessageLookupByLibrary.simpleMessage("Menus"), "multimedia_center": MessageLookupByLibrary.simpleMessage("Multimedia center"), "nav_title": m2, "news": MessageLookupByLibrary.simpleMessage("News"), + "no_bus_stops": + MessageLookupByLibrary.simpleMessage("No configured stops"), "no_course_units": MessageLookupByLibrary.simpleMessage( "No course units in the selected period"), "no_data": MessageLookupByLibrary.simpleMessage( @@ -113,21 +129,32 @@ class MessageLookup extends MessageLookupByLibrary { "There are no course units to display"), "no_selected_exams": MessageLookupByLibrary.simpleMessage( "There are no exams to present"), + "occurrence_type": + MessageLookupByLibrary.simpleMessage("Type of occurrence"), "other_links": MessageLookupByLibrary.simpleMessage("Other links"), "personal_assistance": MessageLookupByLibrary.simpleMessage("Face-to-face assistance"), "print": MessageLookupByLibrary.simpleMessage("Print"), + "problem_id": MessageLookupByLibrary.simpleMessage( + "Brief identification of the problem"), "room": MessageLookupByLibrary.simpleMessage("Room"), "school_calendar": MessageLookupByLibrary.simpleMessage("School Calendar"), "semester": MessageLookupByLibrary.simpleMessage("Semester"), + "send": MessageLookupByLibrary.simpleMessage("Send"), + "sent_error": MessageLookupByLibrary.simpleMessage( + "An error occurred in sending"), "stcp_stops": MessageLookupByLibrary.simpleMessage("STCP - Upcoming Trips"), + "success": MessageLookupByLibrary.simpleMessage("Sent with success"), "tele_assistance": MessageLookupByLibrary.simpleMessage("Telephone assistance"), "tele_personal_assistance": MessageLookupByLibrary.simpleMessage( "Face-to-face and telephone assistance"), "telephone": MessageLookupByLibrary.simpleMessage("Telephone"), + "title": MessageLookupByLibrary.simpleMessage("Title"), + "valid_email": + MessageLookupByLibrary.simpleMessage("Please enter a valid email"), "widget_prompt": MessageLookupByLibrary.simpleMessage( "Choose a widget to add to your personal area:"), "year": MessageLookupByLibrary.simpleMessage("Year") diff --git a/uni/lib/generated/intl/messages_pt-PT.dart b/uni/lib/generated/intl/messages_pt-PT.dart index 8b5b6c33a..c119ccd93 100644 --- a/uni/lib/generated/intl/messages_pt-PT.dart +++ b/uni/lib/generated/intl/messages_pt-PT.dart @@ -52,6 +52,10 @@ class MessageLookup extends MessageLookupByLibrary { "all_widgets_added": MessageLookupByLibrary.simpleMessage( "Todos os widgets disponíveis já foram adicionados à tua área pessoal!"), "balance": MessageLookupByLibrary.simpleMessage("Saldo:"), + "bs_description": MessageLookupByLibrary.simpleMessage( + "Encontraste algum bug na aplicação?\\nTens alguma sugestão para a app?\\nConta-nos para que possamos melhorar!"), + "bug_description": MessageLookupByLibrary.simpleMessage( + "Bug encontrado, como o reproduzir, etc"), "bus_error": MessageLookupByLibrary.simpleMessage( "Não foi possível obter informação"), "bus_information": MessageLookupByLibrary.simpleMessage( @@ -67,15 +71,23 @@ class MessageLookup extends MessageLookupByLibrary { "configured_buses": MessageLookupByLibrary.simpleMessage("Autocarros Configurados"), "confirm": MessageLookupByLibrary.simpleMessage("Confirmar"), + "consent": MessageLookupByLibrary.simpleMessage( + "Consinto que esta informação seja revista pelo NIAEFEUP, podendo ser eliminada a meu pedido."), + "contact": MessageLookupByLibrary.simpleMessage("Contacto (opcional)"), "copy_center": MessageLookupByLibrary.simpleMessage("Centro de cópias"), "copy_center_building": MessageLookupByLibrary.simpleMessage( "Piso -1 do edifício B | Edifício da AEFEUP"), + "description": MessageLookupByLibrary.simpleMessage("Descrição"), + "desired_email": MessageLookupByLibrary.simpleMessage( + "Email em que desejas ser contactado"), "dona_bia": MessageLookupByLibrary.simpleMessage("Papelaria D. Beatriz"), "dona_bia_building": MessageLookupByLibrary.simpleMessage( "Piso -1 do edifício B (B-142)"), "edit_off": MessageLookupByLibrary.simpleMessage("Editar\n"), "edit_on": MessageLookupByLibrary.simpleMessage("Concluir edição"), + "empty_text": MessageLookupByLibrary.simpleMessage( + "Por favor preenche este campo"), "exams_filter": MessageLookupByLibrary.simpleMessage("Definições Filtro de Exames"), "fee_date": MessageLookupByLibrary.simpleMessage( @@ -92,12 +104,16 @@ class MessageLookup extends MessageLookupByLibrary { "last_timestamp": m1, "library_occupation": MessageLookupByLibrary.simpleMessage("Ocupação da Biblioteca"), + "loading_terms": MessageLookupByLibrary.simpleMessage( + "Carregando os Termos e Condições..."), "logout": MessageLookupByLibrary.simpleMessage("Terminar sessão"), "menus": MessageLookupByLibrary.simpleMessage("Ementas"), "multimedia_center": MessageLookupByLibrary.simpleMessage("Centro de multimédia"), "nav_title": m2, "news": MessageLookupByLibrary.simpleMessage("Notícias"), + "no_bus_stops": MessageLookupByLibrary.simpleMessage( + "Não existe nenhuma paragem configurada"), "no_course_units": MessageLookupByLibrary.simpleMessage( "Sem cadeiras no período selecionado"), "no_data": MessageLookupByLibrary.simpleMessage( @@ -113,21 +129,32 @@ class MessageLookup extends MessageLookupByLibrary { "Não existem cadeiras para apresentar"), "no_selected_exams": MessageLookupByLibrary.simpleMessage( "Não existem exames para apresentar"), + "occurrence_type": + MessageLookupByLibrary.simpleMessage("Tipo de ocorrência"), "other_links": MessageLookupByLibrary.simpleMessage("Outros links"), "personal_assistance": MessageLookupByLibrary.simpleMessage("Atendimento presencial"), "print": MessageLookupByLibrary.simpleMessage("Impressão"), + "problem_id": MessageLookupByLibrary.simpleMessage( + "Breve identificação do problema"), "room": MessageLookupByLibrary.simpleMessage("Sala"), "school_calendar": MessageLookupByLibrary.simpleMessage("Calendário Escolar"), "semester": MessageLookupByLibrary.simpleMessage("Semestre"), + "send": MessageLookupByLibrary.simpleMessage("Enviar"), + "sent_error": + MessageLookupByLibrary.simpleMessage("Ocorreu um erro no envio"), "stcp_stops": MessageLookupByLibrary.simpleMessage("STCP - Próximas Viagens"), + "success": MessageLookupByLibrary.simpleMessage("Enviado com sucesso"), "tele_assistance": MessageLookupByLibrary.simpleMessage("Atendimento telefónico"), "tele_personal_assistance": MessageLookupByLibrary.simpleMessage( "Atendimento presencial e telefónico"), "telephone": MessageLookupByLibrary.simpleMessage("Telefone"), + "title": MessageLookupByLibrary.simpleMessage("Título"), + "valid_email": MessageLookupByLibrary.simpleMessage( + "Por favor insere um email válido"), "widget_prompt": MessageLookupByLibrary.simpleMessage( "Escolhe um widget para adicionares à tua área pessoal:"), "year": MessageLookupByLibrary.simpleMessage("Ano") diff --git a/uni/lib/generated/l10n.dart b/uni/lib/generated/l10n.dart index 3ec3d979b..0181657c7 100644 --- a/uni/lib/generated/l10n.dart +++ b/uni/lib/generated/l10n.dart @@ -110,6 +110,26 @@ class S { ); } + /// `Did you find any bugs in the application?\nDo you have any suggestions for the app?\nTell us so we can improve!` + String get bs_description { + return Intl.message( + 'Did you find any bugs in the application?\\nDo you have any suggestions for the app?\\nTell us so we can improve!', + name: 'bs_description', + desc: '', + args: [], + ); + } + + /// `Bug found, how to reproduce it, etc.` + String get bug_description { + return Intl.message( + 'Bug found, how to reproduce it, etc.', + name: 'bug_description', + desc: '', + args: [], + ); + } + /// `Unable to get information` String get bus_error { return Intl.message( @@ -200,6 +220,26 @@ class S { ); } + /// `I consent to this information being reviewed by NIAEFEUP and may be deleted at my request.` + String get consent { + return Intl.message( + 'I consent to this information being reviewed by NIAEFEUP and may be deleted at my request.', + name: 'consent', + desc: '', + args: [], + ); + } + + /// `Contact (optional)` + String get contact { + return Intl.message( + 'Contact (optional)', + name: 'contact', + desc: '', + args: [], + ); + } + /// `Copy center` String get copy_center { return Intl.message( @@ -220,6 +260,26 @@ class S { ); } + /// `Description` + String get description { + return Intl.message( + 'Description', + name: 'description', + desc: '', + args: [], + ); + } + + /// `Email where you want to be contacted` + String get desired_email { + return Intl.message( + 'Email where you want to be contacted', + name: 'desired_email', + desc: '', + args: [], + ); + } + /// `D. Beatriz's stationery store` String get dona_bia { return Intl.message( @@ -260,6 +320,16 @@ class S { ); } + /// `Please fill in this field` + String get empty_text { + return Intl.message( + 'Please fill in this field', + name: 'empty_text', + desc: '', + args: [], + ); + } + /// `Exam Filter Settings` String get exams_filter { return Intl.message( @@ -363,6 +433,16 @@ class S { ); } + /// `Loading Terms and Conditions...` + String get loading_terms { + return Intl.message( + 'Loading Terms and Conditions...', + name: 'loading_terms', + desc: '', + args: [], + ); + } + /// `Log out` String get logout { return Intl.message( @@ -428,6 +508,16 @@ class S { ); } + /// `No configured stops` + String get no_bus_stops { + return Intl.message( + 'No configured stops', + name: 'no_bus_stops', + desc: '', + args: [], + ); + } + /// `No course units in the selected period` String get no_course_units { return Intl.message( @@ -508,6 +598,16 @@ class S { ); } + /// `Type of occurrence` + String get occurrence_type { + return Intl.message( + 'Type of occurrence', + name: 'occurrence_type', + desc: '', + args: [], + ); + } + /// `Other links` String get other_links { return Intl.message( @@ -538,6 +638,16 @@ class S { ); } + /// `Brief identification of the problem` + String get problem_id { + return Intl.message( + 'Brief identification of the problem', + name: 'problem_id', + desc: '', + args: [], + ); + } + /// `Room` String get room { return Intl.message( @@ -568,6 +678,26 @@ class S { ); } + /// `Send` + String get send { + return Intl.message( + 'Send', + name: 'send', + desc: '', + args: [], + ); + } + + /// `An error occurred in sending` + String get sent_error { + return Intl.message( + 'An error occurred in sending', + name: 'sent_error', + desc: '', + args: [], + ); + } + /// `STCP - Upcoming Trips` String get stcp_stops { return Intl.message( @@ -578,6 +708,16 @@ class S { ); } + /// `Sent with success` + String get success { + return Intl.message( + 'Sent with success', + name: 'success', + desc: '', + args: [], + ); + } + /// `Telephone assistance` String get tele_assistance { return Intl.message( @@ -608,6 +748,26 @@ class S { ); } + /// `Title` + String get title { + return Intl.message( + 'Title', + name: 'title', + desc: '', + args: [], + ); + } + + /// `Please enter a valid email` + String get valid_email { + return Intl.message( + 'Please enter a valid email', + name: 'valid_email', + desc: '', + args: [], + ); + } + /// `Choose a widget to add to your personal area:` String get widget_prompt { return Intl.message( diff --git a/uni/lib/l10n/intl_en.arb b/uni/lib/l10n/intl_en.arb index d728c29f3..5778da1f5 100644 --- a/uni/lib/l10n/intl_en.arb +++ b/uni/lib/l10n/intl_en.arb @@ -12,6 +12,10 @@ "@all_widgets_added": {}, "balance": "Balance:", "@balance": {}, + "bs_description": "Did you find any bugs in the application?\\nDo you have any suggestions for the app?\\nTell us so we can improve!", + "@bs_description": {}, + "bug_description": "Bug found, how to reproduce it, etc.", + "@bug_description": {}, "bus_error": "Unable to get information", "@bus_error": {}, "buses_personalize": "Personalize your buses here", @@ -30,10 +34,18 @@ "@configured_buses": {}, "confirm": "Confirm", "@confirm": {}, + "consent": "I consent to this information being reviewed by NIAEFEUP and may be deleted at my request.", + "@consent": {}, + "contact": "Contact (optional)", + "@contact": {}, "copy_center": "Copy center", "@copy_center": {}, "copy_center_building": "Floor -1 of building B | AEFEUP building", "@copy_center_building": {}, + "description": "Description", + "@description": {}, + "desired_email": "Email where you want to be contacted", + "@desired_email": {}, "dona_bia": "D. Beatriz's stationery store", "@dona_bia": {}, "dona_bia_building": "Floor -1 of building B (B-142)", @@ -42,6 +54,8 @@ "@edit_off": {}, "edit_on": "Finish editing", "@edit_on": {}, + "empty_text": "Please fill in this field", + "@empty_text": {}, "exams_filter": "Exam Filter Settings", "@exams_filter": {}, "fee_date": "Deadline for next fee:", @@ -70,6 +84,8 @@ }, "library_occupation": "Library Occupation", "@library_occupation": {}, + "loading_terms": "Loading Terms and Conditions...", + "@loading_terms": {}, "logout": "Log out", "@logout": {}, "menus": "Menus", @@ -80,6 +96,8 @@ "@nav_title": {}, "news": "News", "@news": {}, + "no_bus_stops": "No configured stops", + "@no_bus_stops": {}, "no_course_units": "No course units in the selected period", "@no_course_units": {}, "no_data": "There is no data to show at this time", @@ -96,26 +114,40 @@ "@no_selected_courses": {}, "no_selected_exams": "There are no exams to present", "@no_selected_exams": {}, + "occurrence_type": "Type of occurrence", + "@occurrence_type": {}, "other_links": "Other links", "@other_links": {}, "personal_assistance": "Face-to-face assistance", "@personal_assistance": {}, "print": "Print", "@print": {}, + "problem_id": "Brief identification of the problem", + "@problem_id": {}, "room": "Room", "@room": {}, "school_calendar": "School Calendar", "@school_calendar": {}, "semester": "Semester", "@semester": {}, + "send": "Send", + "@send": {}, + "sent_error": "An error occurred in sending", + "@sent_error": {}, "stcp_stops": "STCP - Upcoming Trips", "@stcp_stops": {}, + "success": "Sent with success", + "@success": {}, "tele_assistance": "Telephone assistance", "@tele_assistance": {}, "tele_personal_assistance": "Face-to-face and telephone assistance", "@tele_personal_assistance": {}, "telephone": "Telephone", "@telephone": {}, + "title": "Title", + "@title": {}, + "valid_email": "Please enter a valid email", + "@valid_email": {}, "widget_prompt": "Choose a widget to add to your personal area:", "@widget_prompt": {}, "year": "Year", diff --git a/uni/lib/l10n/intl_pt_PT.arb b/uni/lib/l10n/intl_pt_PT.arb index c9a2cc393..4a6c48c60 100644 --- a/uni/lib/l10n/intl_pt_PT.arb +++ b/uni/lib/l10n/intl_pt_PT.arb @@ -12,6 +12,10 @@ "@all_widgets_added": {}, "balance": "Saldo:", "@balance": {}, + "bs_description": "Encontraste algum bug na aplicação?\\nTens alguma sugestão para a app?\\nConta-nos para que possamos melhorar!", + "@bs_description": {}, + "bug_description": "Bug encontrado, como o reproduzir, etc", + "@bug_description": {}, "bus_error": "Não foi possível obter informação", "@bus_error": {}, "buses_personalize": "Configura aqui os teus autocarros", @@ -30,10 +34,18 @@ "@configured_buses": {}, "confirm": "Confirmar", "@confirm": {}, + "consent": "Consinto que esta informação seja revista pelo NIAEFEUP, podendo ser eliminada a meu pedido.", + "@consent": {}, + "contact": "Contacto (opcional)", + "@contact": {}, "copy_center": "Centro de cópias", "@copy_center": {}, "copy_center_building": "Piso -1 do edifício B | Edifício da AEFEUP", "@copy_center_building": {}, + "description": "Descrição", + "@description": {}, + "desired_email": "Email em que desejas ser contactado", + "@desired_email": {}, "dona_bia": "Papelaria D. Beatriz", "@dona_bia": {}, "dona_bia_building": "Piso -1 do edifício B (B-142)", @@ -42,6 +54,8 @@ "@edit_off": {}, "edit_on": "Concluir edição", "@edit_on": {}, + "empty_text": "Por favor preenche este campo", + "@empty_text": {}, "exams_filter": "Definições Filtro de Exames", "@exams_filter": {}, "fee_date": "Data limite próxima prestação:", @@ -70,6 +84,8 @@ }, "library_occupation": "Ocupação da Biblioteca", "@library_occupation": {}, + "loading_terms": "Carregando os Termos e Condições...", + "@loading_terms": {}, "logout": "Terminar sessão", "@logout": {}, "menus": "Ementas", @@ -80,6 +96,8 @@ "@nav_title": {}, "news": "Notícias", "@news": {}, + "no_bus_stops": "Não existe nenhuma paragem configurada", + "@no_bus_stops": {}, "no_course_units": "Sem cadeiras no período selecionado", "@no_course_units": {}, "no_data": "Não há dados a mostrar neste momento", @@ -96,26 +114,40 @@ "@no_selected_courses": {}, "no_selected_exams": "Não existem exames para apresentar", "@no_selected_exams": {}, + "occurrence_type": "Tipo de ocorrência", + "@occurrence_type": {}, "other_links": "Outros links", "@other_links": {}, "personal_assistance": "Atendimento presencial", "@personal_assistance": {}, "print": "Impressão", "@print": {}, + "problem_id": "Breve identificação do problema", + "@problem_id": {}, "room": "Sala", "@room": {}, "school_calendar": "Calendário Escolar", "@school_calendar": {}, "semester": "Semestre", "@semester": {}, + "send": "Enviar", + "@send": {}, + "sent_error": "Ocorreu um erro no envio", + "@sent_error": {}, "stcp_stops": "STCP - Próximas Viagens", "@stcp_stops": {}, + "success": "Enviado com sucesso", + "@success": {}, "tele_assistance": "Atendimento telefónico", "@tele_assistance": {}, "tele_personal_assistance": "Atendimento presencial e telefónico", "@tele_personal_assistance": {}, "telephone": "Telefone", "@telephone": {}, + "title": "Título", + "@title": {}, + "valid_email": "Por favor insere um email válido", + "@valid_email": {}, "widget_prompt": "Escolhe um widget para adicionares à tua área pessoal:", "@widget_prompt": {}, "year": "Ano", diff --git a/uni/lib/view/about/widgets/terms_and_conditions.dart b/uni/lib/view/about/widgets/terms_and_conditions.dart index 6f1407a36..e5ae8fb91 100644 --- a/uni/lib/view/about/widgets/terms_and_conditions.dart +++ b/uni/lib/view/about/widgets/terms_and_conditions.dart @@ -3,14 +3,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_markdown/flutter_markdown.dart'; import 'package:uni/controller/load_static/terms_and_conditions.dart'; import 'package:url_launcher/url_launcher.dart'; +import 'package:uni/generated/l10n.dart'; + class TermsAndConditions extends StatelessWidget { - static String termsAndConditionsSaved = 'Carregando os Termos e Condições...'; const TermsAndConditions({Key? key}) : super(key: key); @override Widget build(BuildContext context) { + String termsAndConditionsSaved = S.of(context).loading_terms; final Future termsAndConditionsFuture = readTermsAndConditions(); return FutureBuilder( future: termsAndConditionsFuture, diff --git a/uni/lib/view/bug_report/widgets/form.dart b/uni/lib/view/bug_report/widgets/form.dart index f63d5b9fb..89086a02d 100644 --- a/uni/lib/view/bug_report/widgets/form.dart +++ b/uni/lib/view/bug_report/widgets/form.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:io'; import 'package:email_validator/email_validator.dart'; import 'package:flutter/material.dart'; @@ -7,6 +8,8 @@ import 'package:http/http.dart' as http; import 'package:logger/logger.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:tuple/tuple.dart'; +import 'package:uni/utils/drawer_items.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/model/entities/bug_report.dart'; import 'package:uni/view/bug_report/widgets/text_field.dart'; import 'package:uni/view/common_widgets/page_title.dart'; @@ -58,8 +61,11 @@ class BugReportFormState extends State { void loadBugClassList() { bugList = []; - bugDescriptions.forEach((int key, Tuple2 tup) => - {bugList.add(DropdownMenuItem(value: key, child: Text(tup.item1)))}); + + bugDescriptions.forEach((int key, Tuple2 tup){ + if(Platform.localeName == 'pt_PT') {bugList.add(DropdownMenuItem(value: key, child: Text(tup.item1)));} + else {bugList.add(DropdownMenuItem(value: key, child: Text(tup.item2)));} + }); } @override @@ -79,8 +85,8 @@ class BugReportFormState extends State { Icons.title, minLines: 1, maxLines: 2, - description: 'Título', - labelText: 'Breve identificação do problema', + description: S.of(context).title, + labelText: S.of(context).problem_id, bottomMargin: 30.0, )); @@ -89,8 +95,8 @@ class BugReportFormState extends State { Icons.description, minLines: 1, maxLines: 30, - description: 'Descrição', - labelText: 'Bug encontrado, como o reproduzir, etc', + description: S.of(context).description, + labelText: S.of(context).bug_description, bottomMargin: 30.0, )); @@ -99,14 +105,14 @@ class BugReportFormState extends State { Icons.mail, minLines: 1, maxLines: 2, - description: 'Contacto (opcional)', - labelText: 'Email em que desejas ser contactado', + description: S.of(context).contact, + labelText: S.of(context).desired_email, bottomMargin: 30.0, isOptional: true, formatValidator: (value) { return EmailValidator.validate(value) ? null - : 'Por favor insere um email válido'; + : S.of(context).valid_email; }, )); @@ -123,10 +129,10 @@ class BugReportFormState extends State { margin: const EdgeInsets.symmetric(vertical: 10.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: const [ - Icon(Icons.bug_report, size: 40.0), - PageTitle(name: 'Bugs e Sugestões', center: false), - Icon(Icons.bug_report, size: 40.0), + children: [ + const Icon(Icons.bug_report, size: 40.0), + PageTitle(name: S.of(context).nav_title(DrawerItem.navBugReport.title), center: false), + const Icon(Icons.bug_report, size: 40.0), ], )); } @@ -138,8 +144,7 @@ class BugReportFormState extends State { padding: const EdgeInsets.only(bottom: 20), child: Center( child: Text( - '''Encontraste algum bug na aplicação?\nTens alguma ''' - '''sugestão para a app?\nConta-nos para que possamos melhorar!''', + S.of(context).bs_description, style: Theme.of(context).textTheme.bodyMedium, textAlign: TextAlign.center), ), @@ -155,7 +160,7 @@ class BugReportFormState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - 'Tipo de ocorrência', + S.of(context).occurrence_type, style: Theme.of(context).textTheme.bodyMedium, textAlign: TextAlign.left, ), @@ -167,7 +172,7 @@ class BugReportFormState extends State { )), Expanded( child: DropdownButton( - hint: const Text('Tipo de ocorrência'), + hint: Text(S.of(context).occurrence_type), items: bugList, value: _selectedBug, onChanged: (value) { @@ -191,7 +196,7 @@ class BugReportFormState extends State { contentPadding: const EdgeInsets.all(0), child: CheckboxListTile( title: Text( - '''Consinto que esta informação seja revista pelo NIAEFEUP, podendo ser eliminada a meu pedido.''', + S.of(context).consent, style: Theme.of(context).textTheme.bodyMedium, textAlign: TextAlign.left), value: _isConsentGiven, @@ -218,9 +223,9 @@ class BugReportFormState extends State { submitBugReport(); } }, - child: const Text( - 'Enviar', - style: TextStyle(/*color: Colors.white*/ fontSize: 20.0), + child: Text( + S.of(context).send, + style: const TextStyle(/*color: Colors.white*/ fontSize: 20.0), ), ); } @@ -252,11 +257,13 @@ class BugReportFormState extends State { throw Exception('Network error'); } Logger().i('Successfully submitted bug report.'); - toastMsg = 'Enviado com sucesso'; + // ignore: use_build_context_synchronously + toastMsg = S.of(context).success; status = true; } catch (e) { Logger().e('Error while posting bug report:$e'); - toastMsg = 'Ocorreu um erro no envio'; + // ignore: use_build_context_synchronously + toastMsg = S.of(context).sent_error; status = false; } diff --git a/uni/lib/view/bug_report/widgets/text_field.dart b/uni/lib/view/bug_report/widgets/text_field.dart index ae021e20c..71c50876b 100644 --- a/uni/lib/view/bug_report/widgets/text_field.dart +++ b/uni/lib/view/bug_report/widgets/text_field.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:uni/generated/l10n.dart'; class FormTextField extends StatelessWidget { final TextEditingController controller; @@ -19,7 +20,7 @@ class FormTextField extends StatelessWidget { this.maxLines = 1, this.labelText = '', this.hintText = '', - this.emptyText = 'Por favor preenche este campo', + this.emptyText = '', this.bottomMargin = 0, this.isOptional = false, this.formatValidator, @@ -59,7 +60,7 @@ class FormTextField extends StatelessWidget { controller: controller, validator: (value) { if (value!.isEmpty) { - return isOptional ? null : emptyText; + return isOptional ? null : S.of(context).empty_text; } return formatValidator != null ? formatValidator!(value) : null; }, diff --git a/uni/lib/view/bus_stop_next_arrivals/bus_stop_next_arrivals.dart b/uni/lib/view/bus_stop_next_arrivals/bus_stop_next_arrivals.dart index 10ace51cb..b35d1f84d 100644 --- a/uni/lib/view/bus_stop_next_arrivals/bus_stop_next_arrivals.dart +++ b/uni/lib/view/bus_stop_next_arrivals/bus_stop_next_arrivals.dart @@ -86,7 +86,7 @@ class NextArrivalsState extends State { if (widget.buses.isNotEmpty) { result.addAll(getContent(context)); } else { - result.add(Text('Não existe nenhuma paragem configurada', + result.add(Text(S.of(context).no_bus_stops, style: Theme.of(context).textTheme.titleLarge)); } diff --git a/uni/lib/view/restaurant/restaurant_page_view.dart b/uni/lib/view/restaurant/restaurant_page_view.dart index 5cdd61b5b..c47129ddf 100644 --- a/uni/lib/view/restaurant/restaurant_page_view.dart +++ b/uni/lib/view/restaurant/restaurant_page_view.dart @@ -94,7 +94,7 @@ class _CanteenPageState extends GeneralPageViewState for (var i = 0; i < DayOfWeek.values.length; i++) { tabs.add(Container( - color: Theme.of(context).backgroundColor, + color: Theme.of(context).colorScheme.background, child: Tab(key: Key('cantine-page-tab-$i'), text: daysOfTheWeek[i]), )); } From 095168db6e19bd472e5ddc043a441b09fd1b0d83 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Sun, 25 Jun 2023 16:05:10 +0100 Subject: [PATCH 10/50] Translation button --- .../local_storage/app_shared_preferences.dart | 12 +++ uni/lib/generated/intl/messages_all.dart | 10 +- uni/lib/generated/intl/messages_en.dart | 16 +++ uni/lib/generated/intl/messages_pt-PT.dart | 15 +++ uni/lib/generated/l10n.dart | 102 +++++++++++++++++- uni/lib/l10n/intl_en.arb | 20 ++++ uni/lib/l10n/intl_pt_PT.arb | 20 ++++ uni/lib/main.dart | 4 +- .../general/widgets/navigation_drawer.dart | 41 ++++++- uni/lib/view/home/widgets/schedule_card.dart | 2 +- .../profile/widgets/course_info_card.dart | 23 ++-- uni/lib/view/schedule/schedule.dart | 2 +- uni/lib/view/theme_notifier.dart | 24 ++++- 13 files changed, 269 insertions(+), 22 deletions(-) diff --git a/uni/lib/controller/local_storage/app_shared_preferences.dart b/uni/lib/controller/local_storage/app_shared_preferences.dart index 9134e9ef4..e9c49d2e3 100644 --- a/uni/lib/controller/local_storage/app_shared_preferences.dart +++ b/uni/lib/controller/local_storage/app_shared_preferences.dart @@ -19,6 +19,7 @@ class AppSharedPreferences { static const String areTermsAndConditionsAcceptedKey = 'is_t&c_accepted'; static const String tuitionNotificationsToggleKey = "tuition_notification_toogle"; static const String themeMode = 'theme_mode'; + static const String locale = 'app_locale'; static const int keyLength = 32; static const int ivLength = 16; static final iv = encrypt.IV.fromLength(ivLength); @@ -87,6 +88,17 @@ class AppSharedPreferences { return prefs.setInt(themeMode, (themeIndex + 1) % 3); } + static setLocale(Locale app_locale) async { + final prefs = await SharedPreferences.getInstance(); + prefs.setString(locale, app_locale.toString()); + } + + static Future getLocale() async { + final prefs = await SharedPreferences.getInstance(); + final test = prefs.getString(locale) ?? 'en_US'; + return Locale.fromSubtags(languageCode: test.substring(0,3), countryCode: test.substring(0,3)); + } + /// Deletes the user's student number and password. static Future removePersistentUserInfo() async { final prefs = await SharedPreferences.getInstance(); diff --git a/uni/lib/generated/intl/messages_all.dart b/uni/lib/generated/intl/messages_all.dart index 525f677ec..171385879 100644 --- a/uni/lib/generated/intl/messages_all.dart +++ b/uni/lib/generated/intl/messages_all.dart @@ -16,8 +16,8 @@ import 'package:intl/intl.dart'; import 'package:intl/message_lookup_by_library.dart'; import 'package:intl/src/intl_helpers.dart'; -import 'package:uni/generated/intl/messages_en.dart' as messages_en; -import 'package:uni/generated/intl/messages_pt-PT.dart' as messages_pt_pt; +import 'messages_en.dart' as messages_en; +import 'messages_pt-PT.dart' as messages_pt_pt; typedef Future LibraryLoader(); Map _deferredLibraries = { @@ -38,13 +38,13 @@ MessageLookupByLibrary? _findExact(String localeName) { /// User programs should call this before using [localeName] for messages. Future initializeMessages(String localeName) { - final availableLocale = Intl.verifiedLocale( + var availableLocale = Intl.verifiedLocale( localeName, (locale) => _deferredLibraries[locale] != null, onFailure: (_) => null); if (availableLocale == null) { return new SynchronousFuture(false); } - final lib = _deferredLibraries[availableLocale]; + var lib = _deferredLibraries[availableLocale]; lib == null ? new SynchronousFuture(false) : lib(); initializeInternalMessageLookup(() => new CompositeMessageLookup()); messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); @@ -60,7 +60,7 @@ bool _messagesExistFor(String locale) { } MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { - final actualLocale = + var actualLocale = Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); if (actualLocale == null) return null; return _findExact(actualLocale); diff --git a/uni/lib/generated/intl/messages_en.dart b/uni/lib/generated/intl/messages_en.dart index 961f762bb..880c8856e 100644 --- a/uni/lib/generated/intl/messages_en.dart +++ b/uni/lib/generated/intl/messages_en.dart @@ -51,6 +51,7 @@ class MessageLookup extends MessageLookupByLibrary { "add_widget": MessageLookupByLibrary.simpleMessage("Add widget"), "all_widgets_added": MessageLookupByLibrary.simpleMessage( "All available widgets have already been added to your personal area!"), + "average": MessageLookupByLibrary.simpleMessage("Average: "), "balance": MessageLookupByLibrary.simpleMessage("Balance:"), "bs_description": MessageLookupByLibrary.simpleMessage( "Did you find any bugs in the application?\\nDo you have any suggestions for the app?\\nTell us so we can improve!"), @@ -67,6 +68,7 @@ class MessageLookup extends MessageLookupByLibrary { "cancel": MessageLookupByLibrary.simpleMessage("Cancel"), "class_registration": MessageLookupByLibrary.simpleMessage("Class Registration"), + "college": MessageLookupByLibrary.simpleMessage("College: "), "conclude": MessageLookupByLibrary.simpleMessage("Done"), "configured_buses": MessageLookupByLibrary.simpleMessage("Configured Buses"), @@ -77,6 +79,10 @@ class MessageLookup extends MessageLookupByLibrary { "copy_center": MessageLookupByLibrary.simpleMessage("Copy center"), "copy_center_building": MessageLookupByLibrary.simpleMessage( "Floor -1 of building B | AEFEUP building"), + "current_state": + MessageLookupByLibrary.simpleMessage("Current state: "), + "current_year": + MessageLookupByLibrary.simpleMessage("Current academic year: "), "description": MessageLookupByLibrary.simpleMessage("Description"), "desired_email": MessageLookupByLibrary.simpleMessage( "Email where you want to be contacted"), @@ -84,6 +90,7 @@ class MessageLookup extends MessageLookupByLibrary { "D. Beatriz\'s stationery store"), "dona_bia_building": MessageLookupByLibrary.simpleMessage( "Floor -1 of building B (B-142)"), + "ects": MessageLookupByLibrary.simpleMessage("ECTs performed: "), "edit_off": MessageLookupByLibrary.simpleMessage("Edit"), "edit_on": MessageLookupByLibrary.simpleMessage("Finish editing"), "empty_text": @@ -94,6 +101,8 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Deadline for next fee:"), "fee_notification": MessageLookupByLibrary.simpleMessage("Notify next deadline:"), + "first_year_registration": MessageLookupByLibrary.simpleMessage( + "Year of first registration: "), "floor": MessageLookupByLibrary.simpleMessage("Floor"), "floors": MessageLookupByLibrary.simpleMessage("Floors"), "geral_registration": @@ -114,6 +123,10 @@ class MessageLookup extends MessageLookupByLibrary { "news": MessageLookupByLibrary.simpleMessage("News"), "no_bus_stops": MessageLookupByLibrary.simpleMessage("No configured stops"), + "no_classes": + MessageLookupByLibrary.simpleMessage("No classes to present"), + "no_classes_on": + MessageLookupByLibrary.simpleMessage("You don\'t have classes on"), "no_course_units": MessageLookupByLibrary.simpleMessage( "No course units in the selected period"), "no_data": MessageLookupByLibrary.simpleMessage( @@ -124,6 +137,8 @@ class MessageLookup extends MessageLookupByLibrary { "There is no information available about meals"), "no_menus": MessageLookupByLibrary.simpleMessage( "There are no meals available"), + "no_name_course": + MessageLookupByLibrary.simpleMessage("Unnamed course"), "no_results": MessageLookupByLibrary.simpleMessage("No match"), "no_selected_courses": MessageLookupByLibrary.simpleMessage( "There are no course units to display"), @@ -153,6 +168,7 @@ class MessageLookup extends MessageLookupByLibrary { "Face-to-face and telephone assistance"), "telephone": MessageLookupByLibrary.simpleMessage("Telephone"), "title": MessageLookupByLibrary.simpleMessage("Title"), + "unavailable": MessageLookupByLibrary.simpleMessage("Unavailable"), "valid_email": MessageLookupByLibrary.simpleMessage("Please enter a valid email"), "widget_prompt": MessageLookupByLibrary.simpleMessage( diff --git a/uni/lib/generated/intl/messages_pt-PT.dart b/uni/lib/generated/intl/messages_pt-PT.dart index c119ccd93..787b2fe25 100644 --- a/uni/lib/generated/intl/messages_pt-PT.dart +++ b/uni/lib/generated/intl/messages_pt-PT.dart @@ -51,6 +51,7 @@ class MessageLookup extends MessageLookupByLibrary { "add_widget": MessageLookupByLibrary.simpleMessage("Adicionar widget"), "all_widgets_added": MessageLookupByLibrary.simpleMessage( "Todos os widgets disponíveis já foram adicionados à tua área pessoal!"), + "average": MessageLookupByLibrary.simpleMessage("Média: "), "balance": MessageLookupByLibrary.simpleMessage("Saldo:"), "bs_description": MessageLookupByLibrary.simpleMessage( "Encontraste algum bug na aplicação?\\nTens alguma sugestão para a app?\\nConta-nos para que possamos melhorar!"), @@ -67,6 +68,7 @@ class MessageLookup extends MessageLookupByLibrary { "cancel": MessageLookupByLibrary.simpleMessage("Cancelar\n"), "class_registration": MessageLookupByLibrary.simpleMessage("Inscrição de Turmas"), + "college": MessageLookupByLibrary.simpleMessage("Faculdade: "), "conclude": MessageLookupByLibrary.simpleMessage("Concluído"), "configured_buses": MessageLookupByLibrary.simpleMessage("Autocarros Configurados"), @@ -77,6 +79,9 @@ class MessageLookup extends MessageLookupByLibrary { "copy_center": MessageLookupByLibrary.simpleMessage("Centro de cópias"), "copy_center_building": MessageLookupByLibrary.simpleMessage( "Piso -1 do edifício B | Edifício da AEFEUP"), + "current_state": MessageLookupByLibrary.simpleMessage("Estado atual: "), + "current_year": + MessageLookupByLibrary.simpleMessage("Ano curricular atual: "), "description": MessageLookupByLibrary.simpleMessage("Descrição"), "desired_email": MessageLookupByLibrary.simpleMessage( "Email em que desejas ser contactado"), @@ -84,6 +89,7 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Papelaria D. Beatriz"), "dona_bia_building": MessageLookupByLibrary.simpleMessage( "Piso -1 do edifício B (B-142)"), + "ects": MessageLookupByLibrary.simpleMessage("ECTs realizados: "), "edit_off": MessageLookupByLibrary.simpleMessage("Editar\n"), "edit_on": MessageLookupByLibrary.simpleMessage("Concluir edição"), "empty_text": MessageLookupByLibrary.simpleMessage( @@ -94,6 +100,8 @@ class MessageLookup extends MessageLookupByLibrary { "Data limite próxima prestação:"), "fee_notification": MessageLookupByLibrary.simpleMessage( "Notificar próxima data limite:"), + "first_year_registration": + MessageLookupByLibrary.simpleMessage("Ano da primeira inscrição: "), "floor": MessageLookupByLibrary.simpleMessage("Piso"), "floors": MessageLookupByLibrary.simpleMessage("Pisos"), "geral_registration": @@ -114,6 +122,10 @@ class MessageLookup extends MessageLookupByLibrary { "news": MessageLookupByLibrary.simpleMessage("Notícias"), "no_bus_stops": MessageLookupByLibrary.simpleMessage( "Não existe nenhuma paragem configurada"), + "no_classes": MessageLookupByLibrary.simpleMessage( + "Não existem aulas para apresentar"), + "no_classes_on": + MessageLookupByLibrary.simpleMessage("Não possui aulas à"), "no_course_units": MessageLookupByLibrary.simpleMessage( "Sem cadeiras no período selecionado"), "no_data": MessageLookupByLibrary.simpleMessage( @@ -124,6 +136,8 @@ class MessageLookup extends MessageLookupByLibrary { "Não há informação disponível sobre refeições"), "no_menus": MessageLookupByLibrary.simpleMessage( "Não há refeições disponíveis"), + "no_name_course": + MessageLookupByLibrary.simpleMessage("Curso sem nome"), "no_results": MessageLookupByLibrary.simpleMessage("Sem resultados"), "no_selected_courses": MessageLookupByLibrary.simpleMessage( "Não existem cadeiras para apresentar"), @@ -153,6 +167,7 @@ class MessageLookup extends MessageLookupByLibrary { "Atendimento presencial e telefónico"), "telephone": MessageLookupByLibrary.simpleMessage("Telefone"), "title": MessageLookupByLibrary.simpleMessage("Título"), + "unavailable": MessageLookupByLibrary.simpleMessage("Indisponível"), "valid_email": MessageLookupByLibrary.simpleMessage( "Por favor insere um email válido"), "widget_prompt": MessageLookupByLibrary.simpleMessage( diff --git a/uni/lib/generated/l10n.dart b/uni/lib/generated/l10n.dart index 0181657c7..cdfe2989d 100644 --- a/uni/lib/generated/l10n.dart +++ b/uni/lib/generated/l10n.dart @@ -1,7 +1,7 @@ // GENERATED CODE - DO NOT MODIFY BY HAND import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; -import 'package:uni/generated/intl/messages_all.dart'; +import 'intl/messages_all.dart'; // ************************************************************************** // Generator: Flutter Intl IDE plugin @@ -100,6 +100,16 @@ class S { ); } + /// `Average: ` + String get average { + return Intl.message( + 'Average: ', + name: 'average', + desc: '', + args: [], + ); + } + /// `Balance:` String get balance { return Intl.message( @@ -190,6 +200,16 @@ class S { ); } + /// `College: ` + String get college { + return Intl.message( + 'College: ', + name: 'college', + desc: '', + args: [], + ); + } + /// `Done` String get conclude { return Intl.message( @@ -260,6 +280,26 @@ class S { ); } + /// `Current state: ` + String get current_state { + return Intl.message( + 'Current state: ', + name: 'current_state', + desc: '', + args: [], + ); + } + + /// `Current academic year: ` + String get current_year { + return Intl.message( + 'Current academic year: ', + name: 'current_year', + desc: '', + args: [], + ); + } + /// `Description` String get description { return Intl.message( @@ -300,6 +340,16 @@ class S { ); } + /// `ECTs performed: ` + String get ects { + return Intl.message( + 'ECTs performed: ', + name: 'ects', + desc: '', + args: [], + ); + } + /// `Edit` String get edit_off { return Intl.message( @@ -360,6 +410,16 @@ class S { ); } + /// `Year of first registration: ` + String get first_year_registration { + return Intl.message( + 'Year of first registration: ', + name: 'first_year_registration', + desc: '', + args: [], + ); + } + /// `Floor` String get floor { return Intl.message( @@ -518,6 +578,26 @@ class S { ); } + /// `No classes to present` + String get no_classes { + return Intl.message( + 'No classes to present', + name: 'no_classes', + desc: '', + args: [], + ); + } + + /// `You don't have classes on` + String get no_classes_on { + return Intl.message( + 'You don\'t have classes on', + name: 'no_classes_on', + desc: '', + args: [], + ); + } + /// `No course units in the selected period` String get no_course_units { return Intl.message( @@ -568,6 +648,16 @@ class S { ); } + /// `Unnamed course` + String get no_name_course { + return Intl.message( + 'Unnamed course', + name: 'no_name_course', + desc: '', + args: [], + ); + } + /// `No match` String get no_results { return Intl.message( @@ -758,6 +848,16 @@ class S { ); } + /// `Unavailable` + String get unavailable { + return Intl.message( + 'Unavailable', + name: 'unavailable', + desc: '', + args: [], + ); + } + /// `Please enter a valid email` String get valid_email { return Intl.message( diff --git a/uni/lib/l10n/intl_en.arb b/uni/lib/l10n/intl_en.arb index 5778da1f5..b27b0c251 100644 --- a/uni/lib/l10n/intl_en.arb +++ b/uni/lib/l10n/intl_en.arb @@ -10,6 +10,8 @@ "@add_widget": {}, "all_widgets_added": "All available widgets have already been added to your personal area!", "@all_widgets_added": {}, + "average": "Average: ", + "@average": {}, "balance": "Balance:", "@balance": {}, "bs_description": "Did you find any bugs in the application?\\nDo you have any suggestions for the app?\\nTell us so we can improve!", @@ -28,6 +30,8 @@ "@cancel": {}, "class_registration": "Class Registration", "@class_registration": {}, + "college": "College: ", + "@college": {}, "conclude": "Done", "@conclude": {}, "configured_buses": "Configured Buses", @@ -42,6 +46,10 @@ "@copy_center": {}, "copy_center_building": "Floor -1 of building B | AEFEUP building", "@copy_center_building": {}, + "current_state": "Current state: ", + "@current_state": {}, + "current_year": "Current academic year: ", + "@current_year": {}, "description": "Description", "@description": {}, "desired_email": "Email where you want to be contacted", @@ -50,6 +58,8 @@ "@dona_bia": {}, "dona_bia_building": "Floor -1 of building B (B-142)", "@dona_bia_building": {}, + "ects": "ECTs performed: ", + "@ects": {}, "edit_off": "Edit", "@edit_off": {}, "edit_on": "Finish editing", @@ -62,6 +72,8 @@ "@fee_date": {}, "fee_notification": "Notify next deadline:", "@fee_notification": {}, + "first_year_registration": "Year of first registration: ", + "@first_year_registration": {}, "floor": "Floor", "@floor": {}, "floors": "Floors", @@ -98,6 +110,10 @@ "@news": {}, "no_bus_stops": "No configured stops", "@no_bus_stops": {}, + "no_classes": "No classes to present", + "@no_classes": {}, + "no_classes_on": "You don't have classes on", + "@no_classes_on": {}, "no_course_units": "No course units in the selected period", "@no_course_units": {}, "no_data": "There is no data to show at this time", @@ -108,6 +124,8 @@ "@no_menu_info": {}, "no_menus": "There are no meals available", "@no_menus": {}, + "no_name_course": "Unnamed course", + "@no_name_course": {}, "no_results": "No match", "@no_results": {}, "no_selected_courses": "There are no course units to display", @@ -146,6 +164,8 @@ "@telephone": {}, "title": "Title", "@title": {}, + "unavailable": "Unavailable", + "@unavailable": {}, "valid_email": "Please enter a valid email", "@valid_email": {}, "widget_prompt": "Choose a widget to add to your personal area:", diff --git a/uni/lib/l10n/intl_pt_PT.arb b/uni/lib/l10n/intl_pt_PT.arb index 4a6c48c60..103ec3056 100644 --- a/uni/lib/l10n/intl_pt_PT.arb +++ b/uni/lib/l10n/intl_pt_PT.arb @@ -10,6 +10,8 @@ "@add_widget": {}, "all_widgets_added": "Todos os widgets disponíveis já foram adicionados à tua área pessoal!", "@all_widgets_added": {}, + "average": "Média: ", + "@average": {}, "balance": "Saldo:", "@balance": {}, "bs_description": "Encontraste algum bug na aplicação?\\nTens alguma sugestão para a app?\\nConta-nos para que possamos melhorar!", @@ -28,6 +30,8 @@ "@cancel": {}, "class_registration": "Inscrição de Turmas", "@class_registration": {}, + "college": "Faculdade: ", + "@college": {}, "conclude": "Concluído", "@conclude": {}, "configured_buses": "Autocarros Configurados", @@ -42,6 +46,10 @@ "@copy_center": {}, "copy_center_building": "Piso -1 do edifício B | Edifício da AEFEUP", "@copy_center_building": {}, + "current_state": "Estado atual: ", + "@current_state": {}, + "current_year": "Ano curricular atual: ", + "@current_year": {}, "description": "Descrição", "@description": {}, "desired_email": "Email em que desejas ser contactado", @@ -50,6 +58,8 @@ "@dona_bia": {}, "dona_bia_building": "Piso -1 do edifício B (B-142)", "@dona_bia_building": {}, + "ects": "ECTs realizados: ", + "@ects": {}, "edit_off": "Editar\n", "@edit_off": {}, "edit_on": "Concluir edição", @@ -62,6 +72,8 @@ "@fee_date": {}, "fee_notification": "Notificar próxima data limite:", "@fee_notification": {}, + "first_year_registration": "Ano da primeira inscrição: ", + "@first_year_registration": {}, "floor": "Piso", "@floor": {}, "floors": "Pisos", @@ -98,6 +110,10 @@ "@news": {}, "no_bus_stops": "Não existe nenhuma paragem configurada", "@no_bus_stops": {}, + "no_classes": "Não existem aulas para apresentar", + "@no_classes": {}, + "no_classes_on": "Não possui aulas à", + "@no_classes_on": {}, "no_course_units": "Sem cadeiras no período selecionado", "@no_course_units": {}, "no_data": "Não há dados a mostrar neste momento", @@ -108,6 +124,8 @@ "@no_menu_info": {}, "no_menus": "Não há refeições disponíveis", "@no_menus": {}, + "no_name_course": "Curso sem nome", + "@no_name_course": {}, "no_results": "Sem resultados", "@no_results": {}, "no_selected_courses": "Não existem cadeiras para apresentar", @@ -146,6 +164,8 @@ "@telephone": {}, "title": "Título", "@title": {}, + "unavailable": "Indisponível", + "@unavailable": {}, "valid_email": "Por favor insere um email válido", "@valid_email": {}, "widget_prompt": "Escolhe um widget para adicionares à tua área pessoal:", diff --git a/uni/lib/main.dart b/uni/lib/main.dart index 353ac3a0c..712e9e1f9 100644 --- a/uni/lib/main.dart +++ b/uni/lib/main.dart @@ -74,6 +74,7 @@ Future main() async { final savedTheme = await AppSharedPreferences.getThemeMode(); + final savedLocale = await AppSharedPreferences.getLocale(); await SentryFlutter.init((options) { options.dsn = 'https://a2661645df1c4992b24161010c5e0ecb@o553498.ingest.sentry.io/5680848'; @@ -113,7 +114,7 @@ Future main() async { create: (context) => stateProviders.homePageEditingMode), ], child: ChangeNotifierProvider( - create: (_) => ThemeNotifier(savedTheme), + create: (_) => ThemeNotifier(savedTheme, savedLocale), child: const MyApp(), ))) }); @@ -143,6 +144,7 @@ class MyAppState extends State { theme: applicationLightTheme, darkTheme: applicationDarkTheme, themeMode: themeNotifier.getTheme(), + locale: themeNotifier.getLocale(), home: const SplashScreen(), localizationsDelegates: const [ S.delegate, diff --git a/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart b/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart index 9099973ec..8f0909836 100644 --- a/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart +++ b/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart @@ -4,6 +4,7 @@ import 'package:uni/model/providers/session_provider.dart'; import 'package:uni/utils/drawer_items.dart'; import 'package:uni/view/theme_notifier.dart'; import 'package:uni/generated/l10n.dart'; +import 'package:uni/main.dart'; class AppNavigationDrawer extends StatefulWidget { final BuildContext parentContext; @@ -84,6 +85,37 @@ class AppNavigationDrawerState extends State { ); } + Widget createLocaleBtn() { + String getLocaleText(String locale) { + switch (locale) { + case 'pt_PT': + return 'PT'; + default: + return 'EN'; + } + } + + return Consumer( + builder: (context, themeNotifier, _) { + return TextButton( + onPressed: () => themeNotifier.setNextLocale(), + style: TextButton.styleFrom( + elevation: 0, + padding: const EdgeInsets.symmetric(vertical: 0.0, horizontal: 5.0), + ), + child: Container( + padding: const EdgeInsets.all(15.0), + child: Text(getLocaleText(themeNotifier.getLocale().toString()), + style: Theme.of(context) + .textTheme + .titleLarge! + .copyWith(color: Theme.of(context).primaryColor)), + ), + ); + }, + ); + } + Widget createThemeSwitchBtn() { Icon getThemeIcon(ThemeMode theme) { switch (theme) { @@ -146,7 +178,14 @@ class AppNavigationDrawerState extends State { ), )), Row(children: [ - Expanded(child: createLogoutBtn()), + Expanded(child: Align( + alignment: Alignment.center, + child: createLogoutBtn(), + )), + Align( + alignment: Alignment.centerRight, + child: createLocaleBtn(), + ), createThemeSwitchBtn() ]) ], diff --git a/uni/lib/view/home/widgets/schedule_card.dart b/uni/lib/view/home/widgets/schedule_card.dart index 1fc8280ff..c49a71485 100644 --- a/uni/lib/view/home/widgets/schedule_card.dart +++ b/uni/lib/view/home/widgets/schedule_card.dart @@ -32,7 +32,7 @@ class ScheduleCard extends GenericCard { content: lectureProvider.lectures, contentChecker: lectureProvider.lectures.isNotEmpty, onNullContent: Center( - child: Text('Não existem aulas para apresentar', + child: Text(S.of(context).no_classes, style: Theme.of(context).textTheme.titleLarge, textAlign: TextAlign.center)), contentLoadingWidget: const ScheduleCardShimmer().build(context)) diff --git a/uni/lib/view/profile/widgets/course_info_card.dart b/uni/lib/view/profile/widgets/course_info_card.dart index ca6c4a9f3..435ce30a5 100644 --- a/uni/lib/view/profile/widgets/course_info_card.dart +++ b/uni/lib/view/profile/widgets/course_info_card.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:uni/model/entities/course.dart'; import 'package:uni/view/common_widgets/generic_card.dart'; +import 'package:uni/generated/l10n.dart'; /// Manages the courses info (course name, atual year, state and year of /// first enrolment) on the user personal page. @@ -17,31 +18,31 @@ class CourseInfoCard extends GenericCard { TableRow(children: [ Container( margin: const EdgeInsets.only(top: 20.0, bottom: 8.0, left: 20.0), - child: Text('Ano curricular atual: ', + child: Text(S.of(context).current_year, style: Theme.of(context).textTheme.titleSmall), ), Container( margin: const EdgeInsets.only(top: 20.0, bottom: 8.0, right: 20.0), - child: getInfoText(course.currYear ?? 'Indisponível', context), + child: getInfoText(course.currYear ?? S.of(context).unavailable, context), ) ]), TableRow(children: [ Container( margin: const EdgeInsets.only(top: 10.0, bottom: 8.0, left: 20.0), - child: Text('Estado atual: ', + child: Text(S.of(context).current_state, style: Theme.of(context).textTheme.titleSmall), ), Container( margin: const EdgeInsets.only(top: 10.0, bottom: 8.0, right: 20.0), - child: getInfoText(course.state ?? 'Indisponível', context), + child: getInfoText(course.state ?? S.of(context).unavailable, context), ) ]), TableRow(children: [ Container( margin: const EdgeInsets.only(top: 10.0, bottom: 8.0, left: 20.0), - child: Text('Ano da primeira inscrição: ', + child: Text(S.of(context).first_year_registration, style: Theme.of(context).textTheme.titleSmall), ), Container( @@ -56,33 +57,33 @@ class CourseInfoCard extends GenericCard { TableRow(children: [ Container( margin: const EdgeInsets.only(top: 10.0, bottom: 8.0, left: 20.0), - child: Text('Faculdade: ', + child: Text(S.of(context).college, style: Theme.of(context).textTheme.titleSmall), ), Container( margin: const EdgeInsets.only(top: 10.0, bottom: 8.0, right: 20.0), child: getInfoText( - course.faculty?.toUpperCase() ?? 'Indisponível', context)) + course.faculty?.toUpperCase() ?? S.of(context).unavailable, context)) ]), TableRow(children: [ Container( margin: const EdgeInsets.only(top: 10.0, bottom: 8.0, left: 20.0), - child: Text('Média: ', + child: Text(S.of(context).average, style: Theme.of(context).textTheme.titleSmall), ), Container( margin: const EdgeInsets.only(top: 10.0, bottom: 8.0, right: 20.0), child: getInfoText( - course.currentAverage?.toString() ?? 'Indisponível', + course.currentAverage?.toString() ?? S.of(context).unavailable, context)) ]), TableRow(children: [ Container( margin: const EdgeInsets.only(top: 10.0, bottom: 20.0, left: 20.0), - child: Text('ECTs realizados: ', + child: Text(S.of(context).ects, style: Theme.of(context).textTheme.titleSmall), ), Container( @@ -98,7 +99,7 @@ class CourseInfoCard extends GenericCard { @override String getTitle(context) { - return course.name ?? 'Curso sem nome'; + return course.name ?? S.of(context).no_course_units; } @override diff --git a/uni/lib/view/schedule/schedule.dart b/uni/lib/view/schedule/schedule.dart index 3c61d3ec5..b2181b969 100644 --- a/uni/lib/view/schedule/schedule.dart +++ b/uni/lib/view/schedule/schedule.dart @@ -181,7 +181,7 @@ class SchedulePageViewState extends GeneralPageViewState contentChecker: aggLectures[day].isNotEmpty, onNullContent: Center( child: Text( - 'Não possui aulas à ${SchedulePageView.daysOfTheWeek[day]}.')), + '${S.of(context).no_classes_on} ${SchedulePageView.daysOfTheWeek[day]}.')), ); } } diff --git a/uni/lib/view/theme_notifier.dart b/uni/lib/view/theme_notifier.dart index 626a55ba8..ff2005c19 100644 --- a/uni/lib/view/theme_notifier.dart +++ b/uni/lib/view/theme_notifier.dart @@ -1,13 +1,17 @@ import 'package:flutter/material.dart'; +import 'dart:io'; import 'package:uni/controller/local_storage/app_shared_preferences.dart'; class ThemeNotifier with ChangeNotifier { - ThemeNotifier(this._themeMode); + ThemeNotifier(this._themeMode, this._locale); ThemeMode _themeMode; + Locale _locale; getTheme() => _themeMode; + getLocale() => _locale; + setNextTheme() { final nextThemeMode = (_themeMode.index + 1) % 3; setTheme(ThemeMode.values[nextThemeMode]); @@ -18,4 +22,22 @@ class ThemeNotifier with ChangeNotifier { AppSharedPreferences.setThemeMode(themeMode); notifyListeners(); } + + setNextLocale() { + final nextLocale; + if(_locale == Locale('pt', 'PT')) nextLocale = Locale('en', 'US'); + else nextLocale = Locale('pt', 'PT'); + setLocale(nextLocale); + } + + setLocale(Locale locale) { + _locale = locale; + AppSharedPreferences.setLocale(locale); + notifyListeners(); + } } + + + + + From f8999bb51b010e933d7a8aab40f573d04bc4325e Mon Sep 17 00:00:00 2001 From: Bruno Mendes Date: Mon, 3 Jul 2023 14:28:08 +0100 Subject: [PATCH 11/50] Fix locale offline storage --- .../local_storage/app_shared_preferences.dart | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/uni/lib/controller/local_storage/app_shared_preferences.dart b/uni/lib/controller/local_storage/app_shared_preferences.dart index e9c49d2e3..b806a87ff 100644 --- a/uni/lib/controller/local_storage/app_shared_preferences.dart +++ b/uni/lib/controller/local_storage/app_shared_preferences.dart @@ -17,7 +17,8 @@ class AppSharedPreferences { static const String userFaculties = 'user_faculties'; static const String termsAndConditions = 'terms_and_conditions'; static const String areTermsAndConditionsAcceptedKey = 'is_t&c_accepted'; - static const String tuitionNotificationsToggleKey = "tuition_notification_toogle"; + static const String tuitionNotificationsToggleKey = + "tuition_notification_toogle"; static const String themeMode = 'theme_mode'; static const String locale = 'app_locale'; static const int keyLength = 32; @@ -88,15 +89,15 @@ class AppSharedPreferences { return prefs.setInt(themeMode, (themeIndex + 1) % 3); } - static setLocale(Locale app_locale) async { + static setLocale(Locale appLocale) async { final prefs = await SharedPreferences.getInstance(); - prefs.setString(locale, app_locale.toString()); + prefs.setString(locale, appLocale.languageCode); } static Future getLocale() async { final prefs = await SharedPreferences.getInstance(); - final test = prefs.getString(locale) ?? 'en_US'; - return Locale.fromSubtags(languageCode: test.substring(0,3), countryCode: test.substring(0,3)); + final appLocale = prefs.getString(locale) ?? 'en'; + return Locale(appLocale); } /// Deletes the user's student number and password. @@ -215,14 +216,13 @@ class AppSharedPreferences { return encrypt.Encrypter(encrypt.AES(key)); } - static Future getTuitionNotificationToggle() async{ + static Future getTuitionNotificationToggle() async { final prefs = await SharedPreferences.getInstance(); return prefs.getBool(tuitionNotificationsToggleKey) ?? true; } - static setTuitionNotificationToggle(bool value) async{ + static setTuitionNotificationToggle(bool value) async { final prefs = await SharedPreferences.getInstance(); prefs.setBool(tuitionNotificationsToggleKey, value); } - } From d307477edd0ec39253af525c2ca3c09cffad597f Mon Sep 17 00:00:00 2001 From: DGoiana Date: Wed, 5 Jul 2023 03:26:22 +0100 Subject: [PATCH 12/50] Login page translated, button error fix, new locale notifier --- .../local_storage/app_shared_preferences.dart | 4 +- uni/lib/generated/intl/messages_all.dart | 10 +- uni/lib/generated/intl/messages_en.dart | 18 +++ uni/lib/generated/intl/messages_pt-PT.dart | 19 +++ uni/lib/generated/l10n.dart | 122 +++++++++++++++++- uni/lib/l10n/intl_en.arb | 24 ++++ uni/lib/l10n/intl_pt_PT.arb | 24 ++++ uni/lib/main.dart | 16 ++- uni/lib/model/entities/time_utilities.dart | 5 +- .../general/widgets/navigation_drawer.dart | 26 ++-- .../widgets/library_occupation_card.dart | 2 +- uni/lib/view/locale_notifier.dart | 27 ++++ uni/lib/view/login/login.dart | 9 +- .../login/widgets/faculties_multiselect.dart | 7 +- .../widgets/faculties_selection_form.dart | 9 +- uni/lib/view/login/widgets/inputs.dart | 27 ++-- uni/lib/view/theme_notifier.dart | 19 +-- 17 files changed, 293 insertions(+), 75 deletions(-) create mode 100644 uni/lib/view/locale_notifier.dart diff --git a/uni/lib/controller/local_storage/app_shared_preferences.dart b/uni/lib/controller/local_storage/app_shared_preferences.dart index b806a87ff..f7fad291d 100644 --- a/uni/lib/controller/local_storage/app_shared_preferences.dart +++ b/uni/lib/controller/local_storage/app_shared_preferences.dart @@ -89,9 +89,9 @@ class AppSharedPreferences { return prefs.setInt(themeMode, (themeIndex + 1) % 3); } - static setLocale(Locale appLocale) async { + static setLocale(String appLocale) async { final prefs = await SharedPreferences.getInstance(); - prefs.setString(locale, appLocale.languageCode); + prefs.setString(locale, appLocale); } static Future getLocale() async { diff --git a/uni/lib/generated/intl/messages_all.dart b/uni/lib/generated/intl/messages_all.dart index 171385879..525f677ec 100644 --- a/uni/lib/generated/intl/messages_all.dart +++ b/uni/lib/generated/intl/messages_all.dart @@ -16,8 +16,8 @@ import 'package:intl/intl.dart'; import 'package:intl/message_lookup_by_library.dart'; import 'package:intl/src/intl_helpers.dart'; -import 'messages_en.dart' as messages_en; -import 'messages_pt-PT.dart' as messages_pt_pt; +import 'package:uni/generated/intl/messages_en.dart' as messages_en; +import 'package:uni/generated/intl/messages_pt-PT.dart' as messages_pt_pt; typedef Future LibraryLoader(); Map _deferredLibraries = { @@ -38,13 +38,13 @@ MessageLookupByLibrary? _findExact(String localeName) { /// User programs should call this before using [localeName] for messages. Future initializeMessages(String localeName) { - var availableLocale = Intl.verifiedLocale( + final availableLocale = Intl.verifiedLocale( localeName, (locale) => _deferredLibraries[locale] != null, onFailure: (_) => null); if (availableLocale == null) { return new SynchronousFuture(false); } - var lib = _deferredLibraries[availableLocale]; + final lib = _deferredLibraries[availableLocale]; lib == null ? new SynchronousFuture(false) : lib(); initializeInternalMessageLookup(() => new CompositeMessageLookup()); messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); @@ -60,7 +60,7 @@ bool _messagesExistFor(String locale) { } MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { - var actualLocale = + final actualLocale = Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); if (actualLocale == null) return null; return _findExact(actualLocale); diff --git a/uni/lib/generated/intl/messages_en.dart b/uni/lib/generated/intl/messages_en.dart index 880c8856e..e27c996c1 100644 --- a/uni/lib/generated/intl/messages_en.dart +++ b/uni/lib/generated/intl/messages_en.dart @@ -49,8 +49,12 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Checking account"), "add": MessageLookupByLibrary.simpleMessage("Add"), "add_widget": MessageLookupByLibrary.simpleMessage("Add widget"), + "agree_terms": MessageLookupByLibrary.simpleMessage( + "By entering you confirm that you agree with these Terms and Conditions"), "all_widgets_added": MessageLookupByLibrary.simpleMessage( "All available widgets have already been added to your personal area!"), + "at_least_one_college": + MessageLookupByLibrary.simpleMessage("Select at least one college"), "average": MessageLookupByLibrary.simpleMessage("Average: "), "balance": MessageLookupByLibrary.simpleMessage("Balance:"), "bs_description": MessageLookupByLibrary.simpleMessage( @@ -69,6 +73,8 @@ class MessageLookup extends MessageLookupByLibrary { "class_registration": MessageLookupByLibrary.simpleMessage("Class Registration"), "college": MessageLookupByLibrary.simpleMessage("College: "), + "college_select": + MessageLookupByLibrary.simpleMessage("select your college(s)"), "conclude": MessageLookupByLibrary.simpleMessage("Done"), "configured_buses": MessageLookupByLibrary.simpleMessage("Configured Buses"), @@ -97,6 +103,7 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Please fill in this field"), "exams_filter": MessageLookupByLibrary.simpleMessage("Exam Filter Settings"), + "failed_login": MessageLookupByLibrary.simpleMessage("Login failed"), "fee_date": MessageLookupByLibrary.simpleMessage("Deadline for next fee:"), "fee_notification": @@ -105,16 +112,20 @@ class MessageLookup extends MessageLookupByLibrary { "Year of first registration: "), "floor": MessageLookupByLibrary.simpleMessage("Floor"), "floors": MessageLookupByLibrary.simpleMessage("Floors"), + "forgot_password": + MessageLookupByLibrary.simpleMessage("Forgot password?"), "geral_registration": MessageLookupByLibrary.simpleMessage("General Registration"), "improvement_registration": MessageLookupByLibrary.simpleMessage("Enrollment for Improvement"), + "keep_login": MessageLookupByLibrary.simpleMessage("Stay signed in"), "last_refresh_time": m0, "last_timestamp": m1, "library_occupation": MessageLookupByLibrary.simpleMessage("Library Occupation"), "loading_terms": MessageLookupByLibrary.simpleMessage( "Loading Terms and Conditions..."), + "login": MessageLookupByLibrary.simpleMessage("Login"), "logout": MessageLookupByLibrary.simpleMessage("Log out"), "menus": MessageLookupByLibrary.simpleMessage("Menus"), "multimedia_center": @@ -127,6 +138,7 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("No classes to present"), "no_classes_on": MessageLookupByLibrary.simpleMessage("You don\'t have classes on"), + "no_college": MessageLookupByLibrary.simpleMessage("no college"), "no_course_units": MessageLookupByLibrary.simpleMessage( "No course units in the selected period"), "no_data": MessageLookupByLibrary.simpleMessage( @@ -147,8 +159,11 @@ class MessageLookup extends MessageLookupByLibrary { "occurrence_type": MessageLookupByLibrary.simpleMessage("Type of occurrence"), "other_links": MessageLookupByLibrary.simpleMessage("Other links"), + "password": MessageLookupByLibrary.simpleMessage("password"), "personal_assistance": MessageLookupByLibrary.simpleMessage("Face-to-face assistance"), + "press_again": + MessageLookupByLibrary.simpleMessage("Press again to exit"), "print": MessageLookupByLibrary.simpleMessage("Print"), "problem_id": MessageLookupByLibrary.simpleMessage( "Brief identification of the problem"), @@ -161,12 +176,15 @@ class MessageLookup extends MessageLookupByLibrary { "An error occurred in sending"), "stcp_stops": MessageLookupByLibrary.simpleMessage("STCP - Upcoming Trips"), + "student_number": + MessageLookupByLibrary.simpleMessage("student number"), "success": MessageLookupByLibrary.simpleMessage("Sent with success"), "tele_assistance": MessageLookupByLibrary.simpleMessage("Telephone assistance"), "tele_personal_assistance": MessageLookupByLibrary.simpleMessage( "Face-to-face and telephone assistance"), "telephone": MessageLookupByLibrary.simpleMessage("Telephone"), + "terms": MessageLookupByLibrary.simpleMessage("Terms and Conditions"), "title": MessageLookupByLibrary.simpleMessage("Title"), "unavailable": MessageLookupByLibrary.simpleMessage("Unavailable"), "valid_email": diff --git a/uni/lib/generated/intl/messages_pt-PT.dart b/uni/lib/generated/intl/messages_pt-PT.dart index 787b2fe25..eaa1d5c99 100644 --- a/uni/lib/generated/intl/messages_pt-PT.dart +++ b/uni/lib/generated/intl/messages_pt-PT.dart @@ -49,8 +49,12 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Conta Corrente"), "add": MessageLookupByLibrary.simpleMessage("Adicionar"), "add_widget": MessageLookupByLibrary.simpleMessage("Adicionar widget"), + "agree_terms": MessageLookupByLibrary.simpleMessage( + "Ao entrares confirmas que concordas com estes Termos e Condições"), "all_widgets_added": MessageLookupByLibrary.simpleMessage( "Todos os widgets disponíveis já foram adicionados à tua área pessoal!"), + "at_least_one_college": MessageLookupByLibrary.simpleMessage( + "Seleciona pelo menos uma faculdade"), "average": MessageLookupByLibrary.simpleMessage("Média: "), "balance": MessageLookupByLibrary.simpleMessage("Saldo:"), "bs_description": MessageLookupByLibrary.simpleMessage( @@ -69,6 +73,8 @@ class MessageLookup extends MessageLookupByLibrary { "class_registration": MessageLookupByLibrary.simpleMessage("Inscrição de Turmas"), "college": MessageLookupByLibrary.simpleMessage("Faculdade: "), + "college_select": MessageLookupByLibrary.simpleMessage( + "seleciona a(s) tua(s) faculdade(s)"), "conclude": MessageLookupByLibrary.simpleMessage("Concluído"), "configured_buses": MessageLookupByLibrary.simpleMessage("Autocarros Configurados"), @@ -96,6 +102,7 @@ class MessageLookup extends MessageLookupByLibrary { "Por favor preenche este campo"), "exams_filter": MessageLookupByLibrary.simpleMessage("Definições Filtro de Exames"), + "failed_login": MessageLookupByLibrary.simpleMessage("O login falhou"), "fee_date": MessageLookupByLibrary.simpleMessage( "Data limite próxima prestação:"), "fee_notification": MessageLookupByLibrary.simpleMessage( @@ -104,16 +111,21 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Ano da primeira inscrição: "), "floor": MessageLookupByLibrary.simpleMessage("Piso"), "floors": MessageLookupByLibrary.simpleMessage("Pisos"), + "forgot_password": + MessageLookupByLibrary.simpleMessage("Esqueceu a palavra-passe?"), "geral_registration": MessageLookupByLibrary.simpleMessage("Inscrição Geral"), "improvement_registration": MessageLookupByLibrary.simpleMessage("Inscrição para Melhoria"), + "keep_login": + MessageLookupByLibrary.simpleMessage("Manter sessão iniciada"), "last_refresh_time": m0, "last_timestamp": m1, "library_occupation": MessageLookupByLibrary.simpleMessage("Ocupação da Biblioteca"), "loading_terms": MessageLookupByLibrary.simpleMessage( "Carregando os Termos e Condições..."), + "login": MessageLookupByLibrary.simpleMessage("Entrar"), "logout": MessageLookupByLibrary.simpleMessage("Terminar sessão"), "menus": MessageLookupByLibrary.simpleMessage("Ementas"), "multimedia_center": @@ -126,6 +138,7 @@ class MessageLookup extends MessageLookupByLibrary { "Não existem aulas para apresentar"), "no_classes_on": MessageLookupByLibrary.simpleMessage("Não possui aulas à"), + "no_college": MessageLookupByLibrary.simpleMessage("sem faculdade"), "no_course_units": MessageLookupByLibrary.simpleMessage( "Sem cadeiras no período selecionado"), "no_data": MessageLookupByLibrary.simpleMessage( @@ -146,8 +159,11 @@ class MessageLookup extends MessageLookupByLibrary { "occurrence_type": MessageLookupByLibrary.simpleMessage("Tipo de ocorrência"), "other_links": MessageLookupByLibrary.simpleMessage("Outros links"), + "password": MessageLookupByLibrary.simpleMessage("palavra-passe"), "personal_assistance": MessageLookupByLibrary.simpleMessage("Atendimento presencial"), + "press_again": MessageLookupByLibrary.simpleMessage( + "Pressione novamente para sair"), "print": MessageLookupByLibrary.simpleMessage("Impressão"), "problem_id": MessageLookupByLibrary.simpleMessage( "Breve identificação do problema"), @@ -160,12 +176,15 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Ocorreu um erro no envio"), "stcp_stops": MessageLookupByLibrary.simpleMessage("STCP - Próximas Viagens"), + "student_number": + MessageLookupByLibrary.simpleMessage("número de estudante"), "success": MessageLookupByLibrary.simpleMessage("Enviado com sucesso"), "tele_assistance": MessageLookupByLibrary.simpleMessage("Atendimento telefónico"), "tele_personal_assistance": MessageLookupByLibrary.simpleMessage( "Atendimento presencial e telefónico"), "telephone": MessageLookupByLibrary.simpleMessage("Telefone"), + "terms": MessageLookupByLibrary.simpleMessage("Termos e Condições"), "title": MessageLookupByLibrary.simpleMessage("Título"), "unavailable": MessageLookupByLibrary.simpleMessage("Indisponível"), "valid_email": MessageLookupByLibrary.simpleMessage( diff --git a/uni/lib/generated/l10n.dart b/uni/lib/generated/l10n.dart index cdfe2989d..347c23271 100644 --- a/uni/lib/generated/l10n.dart +++ b/uni/lib/generated/l10n.dart @@ -1,7 +1,7 @@ // GENERATED CODE - DO NOT MODIFY BY HAND import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; -import 'intl/messages_all.dart'; +import 'package:uni/generated/intl/messages_all.dart'; // ************************************************************************** // Generator: Flutter Intl IDE plugin @@ -90,6 +90,16 @@ class S { ); } + /// `By entering you confirm that you agree with these Terms and Conditions` + String get agree_terms { + return Intl.message( + 'By entering you confirm that you agree with these Terms and Conditions', + name: 'agree_terms', + desc: '', + args: [], + ); + } + /// `All available widgets have already been added to your personal area!` String get all_widgets_added { return Intl.message( @@ -100,6 +110,16 @@ class S { ); } + /// `Select at least one college` + String get at_least_one_college { + return Intl.message( + 'Select at least one college', + name: 'at_least_one_college', + desc: '', + args: [], + ); + } + /// `Average: ` String get average { return Intl.message( @@ -210,6 +230,16 @@ class S { ); } + /// `select your college(s)` + String get college_select { + return Intl.message( + 'select your college(s)', + name: 'college_select', + desc: '', + args: [], + ); + } + /// `Done` String get conclude { return Intl.message( @@ -390,6 +420,16 @@ class S { ); } + /// `Login failed` + String get failed_login { + return Intl.message( + 'Login failed', + name: 'failed_login', + desc: '', + args: [], + ); + } + /// `Deadline for next fee:` String get fee_date { return Intl.message( @@ -440,6 +480,16 @@ class S { ); } + /// `Forgot password?` + String get forgot_password { + return Intl.message( + 'Forgot password?', + name: 'forgot_password', + desc: '', + args: [], + ); + } + /// `General Registration` String get geral_registration { return Intl.message( @@ -460,6 +510,16 @@ class S { ); } + /// `Stay signed in` + String get keep_login { + return Intl.message( + 'Stay signed in', + name: 'keep_login', + desc: '', + args: [], + ); + } + /// `last refresh at {time}` String last_refresh_time(Object time) { return Intl.message( @@ -503,6 +563,16 @@ class S { ); } + /// `Login` + String get login { + return Intl.message( + 'Login', + name: 'login', + desc: '', + args: [], + ); + } + /// `Log out` String get logout { return Intl.message( @@ -598,6 +668,16 @@ class S { ); } + /// `no college` + String get no_college { + return Intl.message( + 'no college', + name: 'no_college', + desc: '', + args: [], + ); + } + /// `No course units in the selected period` String get no_course_units { return Intl.message( @@ -708,6 +788,16 @@ class S { ); } + /// `password` + String get password { + return Intl.message( + 'password', + name: 'password', + desc: '', + args: [], + ); + } + /// `Face-to-face assistance` String get personal_assistance { return Intl.message( @@ -718,6 +808,16 @@ class S { ); } + /// `Press again to exit` + String get press_again { + return Intl.message( + 'Press again to exit', + name: 'press_again', + desc: '', + args: [], + ); + } + /// `Print` String get print { return Intl.message( @@ -798,6 +898,16 @@ class S { ); } + /// `student number` + String get student_number { + return Intl.message( + 'student number', + name: 'student_number', + desc: '', + args: [], + ); + } + /// `Sent with success` String get success { return Intl.message( @@ -838,6 +948,16 @@ class S { ); } + /// `Terms and Conditions` + String get terms { + return Intl.message( + 'Terms and Conditions', + name: 'terms', + desc: '', + args: [], + ); + } + /// `Title` String get title { return Intl.message( diff --git a/uni/lib/l10n/intl_en.arb b/uni/lib/l10n/intl_en.arb index b27b0c251..04087fe44 100644 --- a/uni/lib/l10n/intl_en.arb +++ b/uni/lib/l10n/intl_en.arb @@ -8,8 +8,12 @@ "@add": {}, "add_widget": "Add widget", "@add_widget": {}, + "agree_terms": "By entering you confirm that you agree with these Terms and Conditions", + "@agree_terms": {}, "all_widgets_added": "All available widgets have already been added to your personal area!", "@all_widgets_added": {}, + "at_least_one_college": "Select at least one college", + "@at_least_one_college": {}, "average": "Average: ", "@average": {}, "balance": "Balance:", @@ -32,6 +36,8 @@ "@class_registration": {}, "college": "College: ", "@college": {}, + "college_select": "select your college(s)", + "@college_select": {}, "conclude": "Done", "@conclude": {}, "configured_buses": "Configured Buses", @@ -68,6 +74,8 @@ "@empty_text": {}, "exams_filter": "Exam Filter Settings", "@exams_filter": {}, + "failed_login": "Login failed", + "@failed_login": {}, "fee_date": "Deadline for next fee:", "@fee_date": {}, "fee_notification": "Notify next deadline:", @@ -78,10 +86,14 @@ "@floor": {}, "floors": "Floors", "@floors": {}, + "forgot_password": "Forgot password?", + "@forgot_password": {}, "geral_registration": "General Registration", "@geral_registration": {}, "improvement_registration": "Enrollment for Improvement", "@improvement_registration": {}, + "keep_login": "Stay signed in", + "@keep_login": {}, "last_refresh_time": "last refresh at {time}", "@last_refresh_time": { "placeholders": { @@ -98,6 +110,8 @@ "@library_occupation": {}, "loading_terms": "Loading Terms and Conditions...", "@loading_terms": {}, + "login": "Login", + "@login": {}, "logout": "Log out", "@logout": {}, "menus": "Menus", @@ -114,6 +128,8 @@ "@no_classes": {}, "no_classes_on": "You don't have classes on", "@no_classes_on": {}, + "no_college": "no college", + "@no_college": {}, "no_course_units": "No course units in the selected period", "@no_course_units": {}, "no_data": "There is no data to show at this time", @@ -136,8 +152,12 @@ "@occurrence_type": {}, "other_links": "Other links", "@other_links": {}, + "password": "password", + "@password": {}, "personal_assistance": "Face-to-face assistance", "@personal_assistance": {}, + "press_again": "Press again to exit", + "@press_again": {}, "print": "Print", "@print": {}, "problem_id": "Brief identification of the problem", @@ -154,6 +174,8 @@ "@sent_error": {}, "stcp_stops": "STCP - Upcoming Trips", "@stcp_stops": {}, + "student_number": "student number", + "@student_number": {}, "success": "Sent with success", "@success": {}, "tele_assistance": "Telephone assistance", @@ -162,6 +184,8 @@ "@tele_personal_assistance": {}, "telephone": "Telephone", "@telephone": {}, + "terms": "Terms and Conditions", + "@terms": {}, "title": "Title", "@title": {}, "unavailable": "Unavailable", diff --git a/uni/lib/l10n/intl_pt_PT.arb b/uni/lib/l10n/intl_pt_PT.arb index 103ec3056..529e103f0 100644 --- a/uni/lib/l10n/intl_pt_PT.arb +++ b/uni/lib/l10n/intl_pt_PT.arb @@ -8,8 +8,12 @@ "@add": {}, "add_widget": "Adicionar widget", "@add_widget": {}, + "agree_terms": "Ao entrares confirmas que concordas com estes Termos e Condições", + "@agree_terms": {}, "all_widgets_added": "Todos os widgets disponíveis já foram adicionados à tua área pessoal!", "@all_widgets_added": {}, + "at_least_one_college": "Seleciona pelo menos uma faculdade", + "@at_least_one_college": {}, "average": "Média: ", "@average": {}, "balance": "Saldo:", @@ -32,6 +36,8 @@ "@class_registration": {}, "college": "Faculdade: ", "@college": {}, + "college_select": "seleciona a(s) tua(s) faculdade(s)", + "@college_select": {}, "conclude": "Concluído", "@conclude": {}, "configured_buses": "Autocarros Configurados", @@ -68,6 +74,8 @@ "@empty_text": {}, "exams_filter": "Definições Filtro de Exames", "@exams_filter": {}, + "failed_login": "O login falhou", + "@failed_login": {}, "fee_date": "Data limite próxima prestação:", "@fee_date": {}, "fee_notification": "Notificar próxima data limite:", @@ -78,10 +86,14 @@ "@floor": {}, "floors": "Pisos", "@floors": {}, + "forgot_password": "Esqueceu a palavra-passe?", + "@forgot_password": {}, "geral_registration": "Inscrição Geral", "@geral_registration": {}, "improvement_registration": "Inscrição para Melhoria", "@improvement_registration": {}, + "keep_login": "Manter sessão iniciada", + "@keep_login": {}, "last_refresh_time": "última atualização às {time}", "@last_refresh_time": { "placeholders": { @@ -98,6 +110,8 @@ "@library_occupation": {}, "loading_terms": "Carregando os Termos e Condições...", "@loading_terms": {}, + "login": "Entrar", + "@login": {}, "logout": "Terminar sessão", "@logout": {}, "menus": "Ementas", @@ -114,6 +128,8 @@ "@no_classes": {}, "no_classes_on": "Não possui aulas à", "@no_classes_on": {}, + "no_college": "sem faculdade", + "@no_college": {}, "no_course_units": "Sem cadeiras no período selecionado", "@no_course_units": {}, "no_data": "Não há dados a mostrar neste momento", @@ -136,8 +152,12 @@ "@occurrence_type": {}, "other_links": "Outros links", "@other_links": {}, + "password": "palavra-passe", + "@password": {}, "personal_assistance": "Atendimento presencial", "@personal_assistance": {}, + "press_again": "Pressione novamente para sair", + "@press_again": {}, "print": "Impressão", "@print": {}, "problem_id": "Breve identificação do problema", @@ -154,6 +174,8 @@ "@sent_error": {}, "stcp_stops": "STCP - Próximas Viagens", "@stcp_stops": {}, + "student_number": "número de estudante", + "@student_number": {}, "success": "Enviado com sucesso", "@success": {}, "tele_assistance": "Atendimento telefónico", @@ -162,6 +184,8 @@ "@tele_personal_assistance": {}, "telephone": "Telefone", "@telephone": {}, + "terms": "Termos e Condições", + "@terms": {}, "title": "Título", "@title": {}, "unavailable": "Indisponível", diff --git a/uni/lib/main.dart b/uni/lib/main.dart index 712e9e1f9..c83bd1079 100644 --- a/uni/lib/main.dart +++ b/uni/lib/main.dart @@ -33,6 +33,7 @@ import 'package:uni/view/common_widgets/page_transition.dart'; import 'package:uni/view/course_units/course_units.dart'; import 'package:uni/view/exams/exams.dart'; import 'package:uni/view/home/home.dart'; +import 'package:uni/view/locale_notifier.dart'; import 'package:uni/view/locations/locations.dart'; import 'package:uni/view/logout_route.dart'; import 'package:uni/view/navigation_service.dart'; @@ -113,9 +114,12 @@ Future main() async { ChangeNotifierProvider( create: (context) => stateProviders.homePageEditingMode), ], - child: ChangeNotifierProvider( - create: (_) => ThemeNotifier(savedTheme, savedLocale), - child: const MyApp(), + child: ChangeNotifierProvider( + create: (_) => LocaleNotifier(savedLocale), + child: ChangeNotifierProvider( + create: (_) => ThemeNotifier(savedTheme), + child: const MyApp(), + ), ))) }); } @@ -138,13 +142,13 @@ class MyAppState extends State { SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, ]); - return Consumer( - builder: (context, themeNotifier, _) => MaterialApp( + return Consumer2( + builder: (context, themeNotifier, localeNotifier, _) => MaterialApp( title: 'uni', theme: applicationLightTheme, darkTheme: applicationDarkTheme, themeMode: themeNotifier.getTheme(), - locale: themeNotifier.getLocale(), + locale: localeNotifier.getLocale(), home: const SplashScreen(), localizationsDelegates: const [ S.delegate, diff --git a/uni/lib/model/entities/time_utilities.dart b/uni/lib/model/entities/time_utilities.dart index 45072ba4e..e36599eb7 100644 --- a/uni/lib/model/entities/time_utilities.dart +++ b/uni/lib/model/entities/time_utilities.dart @@ -1,4 +1,3 @@ -import 'dart:io'; import 'package:flutter/material.dart'; extension TimeString on DateTime { @@ -28,8 +27,6 @@ extension TimeString on DateTime { 'Sunday' ]; - final String locale = Platform.localeName; - if (!startMonday) { weekdaysPT.removeAt(6); weekdaysEN.removeAt(6); @@ -37,7 +34,7 @@ extension TimeString on DateTime { weekdaysEN.insert(0, 'Sunday'); } - if(locale == 'pt_PT') return includeWeekend ? weekdaysPT : weekdaysPT.sublist(0, 5); + // TODO migration i18n return includeWeekend ? weekdaysEN : weekdaysEN.sublist(0, 5); diff --git a/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart b/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart index 8f0909836..86fc01a76 100644 --- a/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart +++ b/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart @@ -3,8 +3,8 @@ import 'package:provider/provider.dart'; import 'package:uni/model/providers/session_provider.dart'; import 'package:uni/utils/drawer_items.dart'; import 'package:uni/view/theme_notifier.dart'; +import 'package:uni/view/locale_notifier.dart'; import 'package:uni/generated/l10n.dart'; -import 'package:uni/main.dart'; class AppNavigationDrawer extends StatefulWidget { final BuildContext parentContext; @@ -67,7 +67,7 @@ class AppNavigationDrawerState extends State { } Widget createLogoutBtn() { - final String logOutText = S.of(context).logout; + const String logOutText = "Terminar sessão"; return TextButton( onPressed: () => _onLogOut(logOutText), style: TextButton.styleFrom( @@ -76,7 +76,7 @@ class AppNavigationDrawerState extends State { ), child: Container( padding: const EdgeInsets.all(15.0), - child: Text(logOutText, + child: Text(S.of(context).logout, style: Theme.of(context) .textTheme .titleLarge! @@ -86,26 +86,24 @@ class AppNavigationDrawerState extends State { } Widget createLocaleBtn() { - String getLocaleText(String locale) { - switch (locale) { - case 'pt_PT': - return 'PT'; - default: - return 'EN'; - } + String getLocaleText(Locale locale) { + final String appLocale; + locale == const Locale('pt') ? appLocale = 'PT' : appLocale = 'EN'; + return appLocale; } - return Consumer( - builder: (context, themeNotifier, _) { + return Consumer( + builder: (context, localeNotifier, _) { + return TextButton( - onPressed: () => themeNotifier.setNextLocale(), + onPressed: () => localeNotifier.setNextLocale(), style: TextButton.styleFrom( elevation: 0, padding: const EdgeInsets.symmetric(vertical: 0.0, horizontal: 5.0), ), child: Container( padding: const EdgeInsets.all(15.0), - child: Text(getLocaleText(themeNotifier.getLocale().toString()), + child: Text(getLocaleText(localeNotifier.getLocale()), style: Theme.of(context) .textTheme .titleLarge! diff --git a/uni/lib/view/library/widgets/library_occupation_card.dart b/uni/lib/view/library/widgets/library_occupation_card.dart index 8afc4431d..e277a0cf3 100644 --- a/uni/lib/view/library/widgets/library_occupation_card.dart +++ b/uni/lib/view/library/widgets/library_occupation_card.dart @@ -40,7 +40,7 @@ class LibraryOccupationCard extends GenericCard { Widget generateOccupation(occupation, context) { if (occupation == null || occupation.capacity == 0) { return Center( - child: Text('Não existem dados para apresentar', + child: Text(S.of(context).no_data, style: Theme.of(context).textTheme.titleLarge, textAlign: TextAlign.center)); } diff --git a/uni/lib/view/locale_notifier.dart b/uni/lib/view/locale_notifier.dart new file mode 100644 index 000000000..70b0ccd10 --- /dev/null +++ b/uni/lib/view/locale_notifier.dart @@ -0,0 +1,27 @@ +import 'package:flutter/material.dart'; +import 'package:uni/controller/local_storage/app_shared_preferences.dart'; + +class LocaleNotifier with ChangeNotifier { + LocaleNotifier(this._locale); + + Locale _locale; + + getLocale() => _locale; + + setNextLocale() { + final Locale nextLocale; + _locale == const Locale('pt') ? nextLocale = const Locale('en') : nextLocale = const Locale('pt'); + setLocale(nextLocale); + } + + setLocale(Locale locale) { + _locale = locale; + AppSharedPreferences.setLocale(locale.languageCode); + notifyListeners(); + } +} + + + + + diff --git a/uni/lib/view/login/login.dart b/uni/lib/view/login/login.dart index 571e6b2a4..a59ac69dc 100644 --- a/uni/lib/view/login/login.dart +++ b/uni/lib/view/login/login.dart @@ -9,6 +9,7 @@ import 'package:uni/model/providers/state_providers.dart'; import 'package:uni/view/common_widgets/toast_message.dart'; import 'package:uni/view/login/widgets/inputs.dart'; import 'package:uni/utils/drawer_items.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:uni/view/theme.dart'; @@ -147,7 +148,7 @@ class LoginPageViewState extends State { if (_exitApp) { return Future.value(true); } - ToastMessage.info(context, 'Pressione novamente para sair'); + ToastMessage.info(context, S.of(context).press_again); exitAppWaiter(); return Future.value(false); } @@ -189,7 +190,7 @@ class LoginPageViewState extends State { _toggleObscurePasswordInput, () => _login(context)), Padding(padding: EdgeInsets.only(bottom: queryData.size.height / 35)), - createSaveDataCheckBox(_keepSignedIn, _setKeepSignedIn), + createSaveDataCheckBox(context, _keepSignedIn, _setKeepSignedIn), ]), ), ); @@ -199,7 +200,7 @@ class LoginPageViewState extends State { Widget createForgetPasswordLink(BuildContext context) { return InkWell( child: Center( - child: Text("Esqueceu a palavra-passe?", + child: Text(S.of(context).forgot_password, style: Theme.of(context).textTheme.bodyLarge!.copyWith( decoration: TextDecoration.underline, color: Colors.white))), @@ -231,7 +232,7 @@ class LoginPageViewState extends State { Navigator.pushReplacementNamed( context, '/${DrawerItem.navPersonalArea.title}'); } else if (status == RequestStatus.failed) { - ToastMessage.error(context, 'O login falhou'); + ToastMessage.error(context, S.of(context).failed_login); } } } diff --git a/uni/lib/view/login/widgets/faculties_multiselect.dart b/uni/lib/view/login/widgets/faculties_multiselect.dart index ce315d539..3f77d0dd2 100644 --- a/uni/lib/view/login/widgets/faculties_multiselect.dart +++ b/uni/lib/view/login/widgets/faculties_multiselect.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:uni/view/login/widgets/faculties_selection_form.dart'; +import 'package:uni/generated/l10n.dart'; class FacultiesMultiselect extends StatelessWidget { final List selectedFaculties; @@ -39,7 +40,7 @@ class FacultiesMultiselect extends StatelessWidget { child: Row(children: [ Expanded( child: Text( - _facultiesListText(), + _facultiesListText(context), style: const TextStyle(color: Colors.white), ), ), @@ -50,9 +51,9 @@ class FacultiesMultiselect extends StatelessWidget { ])); } - String _facultiesListText() { + String _facultiesListText(BuildContext context) { if (selectedFaculties.isEmpty) { - return 'sem faculdade'; + return S.of(context).no_college; } String facultiesText = ''; for (String faculty in selectedFaculties) { diff --git a/uni/lib/view/login/widgets/faculties_selection_form.dart b/uni/lib/view/login/widgets/faculties_selection_form.dart index 7ce700eb8..dfa5870f2 100644 --- a/uni/lib/view/login/widgets/faculties_selection_form.dart +++ b/uni/lib/view/login/widgets/faculties_selection_form.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:uni/utils/constants.dart' as constants; import 'package:uni/view/common_widgets/toast_message.dart'; +import 'package:uni/generated/l10n.dart'; class FacultiesSelectionForm extends StatefulWidget { final List selectedFaculties; @@ -18,7 +19,7 @@ class _FacultiesSelectionFormState extends State { Widget build(BuildContext context) { return AlertDialog( backgroundColor: const Color.fromARGB(255, 0x75, 0x17, 0x1e), - title: const Text('seleciona a(s) tua(s) faculdade(s)'), + title: Text(S.of(context).college_select), titleTextStyle: const TextStyle( color: Color.fromARGB(255, 0xfa, 0xfa, 0xfa), fontSize: 18), content: SizedBox( @@ -30,7 +31,7 @@ class _FacultiesSelectionFormState extends State { return [ TextButton( onPressed: () => Navigator.pop(context), - child: const Text('Cancelar', style: TextStyle(color: Colors.white))), + child: Text(S.of(context).cancel, style: const TextStyle(color: Colors.white))), ElevatedButton( style: ElevatedButton.styleFrom( foregroundColor: Theme.of(context).primaryColor, @@ -38,13 +39,13 @@ class _FacultiesSelectionFormState extends State { onPressed: () { if (widget.selectedFaculties.isEmpty) { ToastMessage.warning( - context, 'Seleciona pelo menos uma faculdade'); + context, S.of(context).at_least_one_college); return; } Navigator.pop(context); widget.setFaculties(widget.selectedFaculties); }, - child: const Text('Confirmar')) + child: Text(S.of(context).confirm)) ]; } diff --git a/uni/lib/view/login/widgets/inputs.dart b/uni/lib/view/login/widgets/inputs.dart index b40da8720..40da926af 100644 --- a/uni/lib/view/login/widgets/inputs.dart +++ b/uni/lib/view/login/widgets/inputs.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:uni/view/login/widgets/faculties_multiselect.dart'; import 'package:uni/view/about/widgets/terms_and_conditions.dart'; +import 'package:uni/generated/l10n.dart'; /// Creates the widget for the user to choose their faculty Widget createFacultyInput( @@ -27,8 +28,8 @@ Widget createUsernameInput( }, textInputAction: TextInputAction.next, textAlign: TextAlign.left, - decoration: textFieldDecoration('número de estudante'), - validator: (String? value) => value!.isEmpty ? 'Preenche este campo' : null, + decoration: textFieldDecoration(S.of(context).student_number), + validator: (String? value) => value!.isEmpty ? S.of(context).empty_text : null, ); } @@ -54,20 +55,20 @@ Widget createPasswordInput( obscureText: obscurePasswordInput, textAlign: TextAlign.left, decoration: passwordFieldDecoration( - 'palavra-passe', obscurePasswordInput, toggleObscurePasswordInput), + S.of(context).password, obscurePasswordInput, toggleObscurePasswordInput), validator: (String? value) => - value != null && value.isEmpty ? 'Preenche este campo' : null); + value != null && value.isEmpty ? S.of(context).empty_text : null); } /// Creates the widget for the user to keep signed in (save his data). -Widget createSaveDataCheckBox(bool keepSignedIn, setKeepSignedIn) { +Widget createSaveDataCheckBox(BuildContext context, bool keepSignedIn, setKeepSignedIn) { return CheckboxListTile( value: keepSignedIn, onChanged: setKeepSignedIn, - title: const Text( - 'Manter sessão iniciada', + title: Text( + S.of(context).keep_login, textAlign: TextAlign.center, - style: TextStyle( + style: const TextStyle( color: Colors.white, fontSize: 17.0, fontWeight: FontWeight.w300), ), ); @@ -93,7 +94,7 @@ Widget createLogInButton(queryData, BuildContext context, login) { } login(context); }, - child: Text('Entrar', + child: Text(S.of(context).login, style: TextStyle( color: Theme.of(context).primaryColor, fontWeight: FontWeight.w400, @@ -149,10 +150,10 @@ createSafeLoginButton(BuildContext context) { highlightColor: Colors.transparent, child: Container( padding: const EdgeInsets.all(8), - child: const Text( - '''Ao entrares confirmas que concordas com estes Termos e Condições''', + child: Text( + S.of(context).agree_terms, textAlign: TextAlign.center, - style: TextStyle( + style: const TextStyle( decoration: TextDecoration.underline, color: Colors.white, fontSize: 17.0, @@ -166,7 +167,7 @@ Future _showLoginDetails(BuildContext context) async { context: context, builder: (BuildContext context) { return AlertDialog( - title: const Text('Termos e Condições'), + title: Text(S.of(context).terms), content: const SingleChildScrollView(child: TermsAndConditions()), actions: [ SimpleDialogOption( diff --git a/uni/lib/view/theme_notifier.dart b/uni/lib/view/theme_notifier.dart index ff2005c19..028e9d28e 100644 --- a/uni/lib/view/theme_notifier.dart +++ b/uni/lib/view/theme_notifier.dart @@ -1,17 +1,13 @@ import 'package:flutter/material.dart'; -import 'dart:io'; import 'package:uni/controller/local_storage/app_shared_preferences.dart'; class ThemeNotifier with ChangeNotifier { - ThemeNotifier(this._themeMode, this._locale); + ThemeNotifier(this._themeMode); ThemeMode _themeMode; - Locale _locale; getTheme() => _themeMode; - getLocale() => _locale; - setNextTheme() { final nextThemeMode = (_themeMode.index + 1) % 3; setTheme(ThemeMode.values[nextThemeMode]); @@ -22,19 +18,6 @@ class ThemeNotifier with ChangeNotifier { AppSharedPreferences.setThemeMode(themeMode); notifyListeners(); } - - setNextLocale() { - final nextLocale; - if(_locale == Locale('pt', 'PT')) nextLocale = Locale('en', 'US'); - else nextLocale = Locale('pt', 'PT'); - setLocale(nextLocale); - } - - setLocale(Locale locale) { - _locale = locale; - AppSharedPreferences.setLocale(locale); - notifyListeners(); - } } From 11b865daf5b0db7deb17ed651e9c321ebddaaff1 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Wed, 5 Jul 2023 23:48:22 +0100 Subject: [PATCH 13/50] Weekdays translation --- uni/lib/generated/intl/messages_en.dart | 2 +- uni/lib/generated/l10n.dart | 4 +-- uni/lib/l10n/intl_en.arb | 2 +- uni/lib/model/entities/time_utilities.dart | 35 ------------------- .../general/widgets/navigation_drawer.dart | 7 +--- uni/lib/view/home/widgets/schedule_card.dart | 6 ++-- uni/lib/view/locale_notifier.dart | 11 ++++++ .../view/restaurant/restaurant_page_view.dart | 4 +-- uni/lib/view/schedule/schedule.dart | 19 +++++----- 9 files changed, 29 insertions(+), 61 deletions(-) diff --git a/uni/lib/generated/intl/messages_en.dart b/uni/lib/generated/intl/messages_en.dart index e27c996c1..479bd937e 100644 --- a/uni/lib/generated/intl/messages_en.dart +++ b/uni/lib/generated/intl/messages_en.dart @@ -37,7 +37,7 @@ class MessageLookup extends MessageLookupByLibrary { 'biblioteca': 'Library', 'uteis': 'Utils', 'sobre': 'About', - 'bugs': 'Bugs/ Suggestions', + 'bugs': 'Bugs and Suggestions', 'other': 'Other', })}"; diff --git a/uni/lib/generated/l10n.dart b/uni/lib/generated/l10n.dart index 347c23271..6ab20c517 100644 --- a/uni/lib/generated/l10n.dart +++ b/uni/lib/generated/l10n.dart @@ -603,7 +603,7 @@ class S { ); } - /// `{title, select, horario{Schedule} exames{Exams} area{Personal Area} cadeiras{Course Units} autocarros{Buses} locais{Places} restaurantes{Restaurants} calendario{Calendar} biblioteca{Library} uteis{Utils} sobre{About} bugs{Bugs/ Suggestions} other{Other}}` + /// `{title, select, horario{Schedule} exames{Exams} area{Personal Area} cadeiras{Course Units} autocarros{Buses} locais{Places} restaurantes{Restaurants} calendario{Calendar} biblioteca{Library} uteis{Utils} sobre{About} bugs{Bugs and Suggestions} other{Other}}` String nav_title(Object title) { return Intl.select( title, @@ -619,7 +619,7 @@ class S { 'biblioteca': 'Library', 'uteis': 'Utils', 'sobre': 'About', - 'bugs': 'Bugs/ Suggestions', + 'bugs': 'Bugs and Suggestions', 'other': 'Other', }, name: 'nav_title', diff --git a/uni/lib/l10n/intl_en.arb b/uni/lib/l10n/intl_en.arb index 04087fe44..4e2742689 100644 --- a/uni/lib/l10n/intl_en.arb +++ b/uni/lib/l10n/intl_en.arb @@ -118,7 +118,7 @@ "@menus": {}, "multimedia_center": "Multimedia center", "@multimedia_center": {}, - "nav_title": "{title, select, horario{Schedule} exames{Exams} area{Personal Area} cadeiras{Course Units} autocarros{Buses} locais{Places} restaurantes{Restaurants} calendario{Calendar} biblioteca{Library} uteis{Utils} sobre{About} bugs{Bugs/ Suggestions} other{Other}}", + "nav_title": "{title, select, horario{Schedule} exames{Exams} area{Personal Area} cadeiras{Course Units} autocarros{Buses} locais{Places} restaurantes{Restaurants} calendario{Calendar} biblioteca{Library} uteis{Utils} sobre{About} bugs{Bugs and Suggestions} other{Other}}", "@nav_title": {}, "news": "News", "@news": {}, diff --git a/uni/lib/model/entities/time_utilities.dart b/uni/lib/model/entities/time_utilities.dart index e36599eb7..1d4ae066a 100644 --- a/uni/lib/model/entities/time_utilities.dart +++ b/uni/lib/model/entities/time_utilities.dart @@ -4,41 +4,6 @@ extension TimeString on DateTime { String toTimeHourMinString() { return '${hour.toString().padLeft(2, '0')}:${minute.toString().padLeft(2, '0')}'; } - - static List getWeekdaysStrings({bool startMonday = true, bool includeWeekend = true}) { - - final List weekdaysPT = [ - 'Segunda-Feira', - 'Terça-Feira', - 'Quarta-Feira', - 'Quinta-Feira', - 'Sexta-Feira', - 'Sábado', - 'Domingo' - ]; - - final List weekdaysEN = [ - 'Monday', - 'Tuesday', - 'Wednesday', - 'Thursday', - 'Friday', - 'Saturday', - 'Sunday' - ]; - - if (!startMonday) { - weekdaysPT.removeAt(6); - weekdaysEN.removeAt(6); - weekdaysPT.insert(0, 'Domingo'); - weekdaysEN.insert(0, 'Sunday'); - } - - // TODO migration i18n - return includeWeekend ? weekdaysEN : weekdaysEN.sublist(0, 5); - - - } } extension ClosestMonday on DateTime{ diff --git a/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart b/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart index 86fc01a76..579bb9028 100644 --- a/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart +++ b/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart @@ -86,11 +86,6 @@ class AppNavigationDrawerState extends State { } Widget createLocaleBtn() { - String getLocaleText(Locale locale) { - final String appLocale; - locale == const Locale('pt') ? appLocale = 'PT' : appLocale = 'EN'; - return appLocale; - } return Consumer( builder: (context, localeNotifier, _) { @@ -103,7 +98,7 @@ class AppNavigationDrawerState extends State { ), child: Container( padding: const EdgeInsets.all(15.0), - child: Text(getLocaleText(localeNotifier.getLocale()), + child: Text(localeNotifier.getLocale().languageCode.toUpperCase(), style: Theme.of(context) .textTheme .titleLarge! diff --git a/uni/lib/view/home/widgets/schedule_card.dart b/uni/lib/view/home/widgets/schedule_card.dart index c49a71485..ea9fc3f7e 100644 --- a/uni/lib/view/home/widgets/schedule_card.dart +++ b/uni/lib/view/home/widgets/schedule_card.dart @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:uni/model/entities/lecture.dart'; -import 'package:uni/model/entities/time_utilities.dart'; import 'package:uni/generated/l10n.dart'; import 'package:uni/model/providers/lecture_provider.dart'; import 'package:uni/view/common_widgets/date_rectangle.dart'; import 'package:uni/view/common_widgets/request_dependent_widget_builder.dart'; import 'package:uni/view/common_widgets/generic_card.dart'; +import 'package:uni/view/locale_notifier.dart'; import 'package:uni/view/schedule/widgets/schedule_slot.dart'; import 'package:uni/view/home/widgets/schedule_card_shimmer.dart'; import 'package:uni/utils/drawer_items.dart'; @@ -59,7 +59,7 @@ class ScheduleCard extends GenericCard { if (now.compareTo(lectures[i].endTime) < 0) { if (lastAddedLectureDate.weekday != lectures[i].startTime.weekday && lastAddedLectureDate.compareTo(lectures[i].startTime) <= 0) { - rows.add(DateRectangle(date: TimeString.getWeekdaysStrings()[(lectures[i].startTime.weekday-1) % 7])); + rows.add(DateRectangle(date: Provider.of(context).getWeekdaysWithLocale()[(lectures[i].startTime.weekday-1) % 7])); } rows.add(createRowFromLecture(context, lectures[i])); @@ -69,7 +69,7 @@ class ScheduleCard extends GenericCard { } if (rows.isEmpty) { - rows.add(DateRectangle(date: TimeString.getWeekdaysStrings()[lectures[0].startTime.weekday % 7])); + rows.add(DateRectangle(date: Provider.of(context).getWeekdaysWithLocale()[lectures[0].startTime.weekday % 7])); rows.add(createRowFromLecture(context, lectures[0])); } return rows; diff --git a/uni/lib/view/locale_notifier.dart b/uni/lib/view/locale_notifier.dart index 70b0ccd10..dceb20fdc 100644 --- a/uni/lib/view/locale_notifier.dart +++ b/uni/lib/view/locale_notifier.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:uni/controller/local_storage/app_shared_preferences.dart'; +import 'package:intl/intl.dart'; class LocaleNotifier with ChangeNotifier { LocaleNotifier(this._locale); @@ -19,6 +20,16 @@ class LocaleNotifier with ChangeNotifier { AppSharedPreferences.setLocale(locale.languageCode); notifyListeners(); } + + getWeekdaysWithLocale() { + final List weekdays = []; + for(String weekday in DateFormat.EEEE(_locale.languageCode).dateSymbols.WEEKDAYS){ + weekdays.add(weekday[0].toUpperCase() + weekday.substring(1)); + } + weekdays.removeAt(0); + weekdays[5] == 'Saturday' ? weekdays.add('Sunday') : weekdays.add('Domingo'); + return weekdays; + } } diff --git a/uni/lib/view/restaurant/restaurant_page_view.dart b/uni/lib/view/restaurant/restaurant_page_view.dart index c47129ddf..afb352a8f 100644 --- a/uni/lib/view/restaurant/restaurant_page_view.dart +++ b/uni/lib/view/restaurant/restaurant_page_view.dart @@ -3,7 +3,6 @@ import 'package:uni/model/entities/meal.dart'; import 'package:flutter/material.dart'; import 'package:uni/model/providers/restaurant_provider.dart'; import 'package:uni/model/request_status.dart'; -import 'package:uni/model/entities/time_utilities.dart'; import 'package:uni/view/common_widgets/page_title.dart'; import 'package:uni/view/common_widgets/pages_layouts/general/general.dart'; import 'package:uni/model/utils/day_of_week.dart'; @@ -11,6 +10,7 @@ import 'package:uni/generated/l10n.dart'; import 'package:uni/model/entities/restaurant.dart'; import 'package:uni/view/common_widgets/request_dependent_widget_builder.dart'; +import 'package:uni/view/locale_notifier.dart'; import 'package:uni/view/restaurant/widgets/restaurant_page_card.dart'; import 'package:uni/view/restaurant/widgets/restaurant_slot.dart'; @@ -89,7 +89,7 @@ class _CanteenPageState extends GeneralPageViewState } List createTabs(BuildContext context) { - final List daysOfTheWeek = TimeString.getWeekdaysStrings(includeWeekend: true); + final List daysOfTheWeek = Provider.of(context).getWeekdaysWithLocale(); final List tabs = []; for (var i = 0; i < DayOfWeek.values.length; i++) { diff --git a/uni/lib/view/schedule/schedule.dart b/uni/lib/view/schedule/schedule.dart index b2181b969..9d0b96783 100644 --- a/uni/lib/view/schedule/schedule.dart +++ b/uni/lib/view/schedule/schedule.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:uni/model/request_status.dart'; import 'package:uni/model/entities/lecture.dart'; -import 'package:uni/model/entities/time_utilities.dart'; import 'package:uni/model/providers/lecture_provider.dart'; import 'package:uni/generated/l10n.dart'; import 'package:uni/utils/drawer_items.dart'; @@ -10,6 +9,7 @@ import 'package:uni/view/common_widgets/page_title.dart'; import 'package:uni/view/common_widgets/pages_layouts/general/general.dart'; import 'package:uni/view/common_widgets/request_dependent_widget_builder.dart'; import 'package:uni/view/schedule/widgets/schedule_slot.dart'; +import 'package:uni/view/locale_notifier.dart'; class SchedulePage extends StatefulWidget { const SchedulePage({Key? key}) : super(key: key); @@ -43,13 +43,10 @@ class SchedulePageView extends StatefulWidget { final int weekDay = DateTime.now().weekday; - static final List daysOfTheWeek = - TimeString.getWeekdaysStrings(includeWeekend: false); - static List> groupLecturesByDay(schedule) { final aggLectures = >[]; - for (int i = 0; i < daysOfTheWeek.length; i++) { + for (int i = 0; i < 5; i++) { final Set lectures = {}; for (int j = 0; j < schedule.length; j++) { if (schedule[j].startTime.weekday-1 == i) lectures.add(schedule[j]); @@ -72,10 +69,10 @@ class SchedulePageViewState extends GeneralPageViewState void initState() { super.initState(); tabController = TabController( - vsync: this, length: SchedulePageView.daysOfTheWeek.length); + vsync: this, length: 5); final offset = (widget.weekDay > 5) ? 0 - : (widget.weekDay - 1) % SchedulePageView.daysOfTheWeek.length; + : (widget.weekDay - 1) % 5; tabController?.animateTo((tabController!.index + offset)); } @@ -115,12 +112,12 @@ class SchedulePageViewState extends GeneralPageViewState /// Returns a list of widgets empty with tabs for each day of the week. List createTabs(queryData, BuildContext context) { final List tabs = []; - for (var i = 0; i < SchedulePageView.daysOfTheWeek.length; i++) { + for (var i = 0; i < 5; i++) { tabs.add(SizedBox( width: queryData.size.width * 1 / 4, child: Tab( key: Key('schedule-page-tab-$i'), - text: SchedulePageView.daysOfTheWeek[i]), + text: Provider.of(context).getWeekdaysWithLocale()[i]), )); } return tabs; @@ -129,7 +126,7 @@ class SchedulePageViewState extends GeneralPageViewState List createSchedule( context, List? lectures, RequestStatus? scheduleStatus) { final List tabBarViewContent = []; - for (int i = 0; i < SchedulePageView.daysOfTheWeek.length; i++) { + for (int i = 0; i < 5; i++) { tabBarViewContent .add(createScheduleByDay(context, i, lectures, scheduleStatus)); } @@ -181,7 +178,7 @@ class SchedulePageViewState extends GeneralPageViewState contentChecker: aggLectures[day].isNotEmpty, onNullContent: Center( child: Text( - '${S.of(context).no_classes_on} ${SchedulePageView.daysOfTheWeek[day]}.')), + '${S.of(context).no_classes_on} ${Provider.of(context).getWeekdaysWithLocale()[day]}.')), ); } } From 651a538edb0e1eb2976fd9bc6d26f964230063ee Mon Sep 17 00:00:00 2001 From: DGoiana Date: Thu, 6 Jul 2023 21:31:41 +0100 Subject: [PATCH 14/50] Lint and test fixing --- uni/pubspec.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/uni/pubspec.yaml b/uni/pubspec.yaml index a9d5e52e8..443e343c2 100644 --- a/uni/pubspec.yaml +++ b/uni/pubspec.yaml @@ -167,8 +167,4 @@ flutter_icons: image_path: "assets/icon/icon.png" adaptive_icon_background: "#75171E" adaptive_icon_foreground: "assets/icon/android_icon_foreground.png" -flutter_intl: - enabled: true - localizely: - project_id: 788a209d-5f55-4f7d-ad09-6033b2b65fc1 From 5766b157df4450521bd9d0f6f7e7a7459b710940 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Thu, 6 Jul 2023 23:34:19 +0100 Subject: [PATCH 15/50] Test fixing --- uni/test/test_widget.dart | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/uni/test/test_widget.dart b/uni/test/test_widget.dart index 012869d06..d3c1ecc61 100644 --- a/uni/test/test_widget.dart +++ b/uni/test/test_widget.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:uni/generated/l10n.dart'; Widget testableWidget(Widget widget, {List providers = const []}) { @@ -11,6 +12,12 @@ Widget testableWidget(Widget widget, Widget wrapWidget(Widget widget) { return MaterialApp( home: Scaffold( - body: widget, + body: Localizations( + delegates: const [ + S.delegate, + ], + locale: const Locale('pt'), + child: widget, + ), )); } From 1a44005d3fc074ad3ae84ac468943ff29bcb1964 Mon Sep 17 00:00:00 2001 From: Diogo Martins <81827192+DGoiana@users.noreply.github.com> Date: Sat, 19 Aug 2023 19:38:21 +0100 Subject: [PATCH 16/50] Delete Generated 2.xcconfig --- uni/ios/Flutter/Generated 2.xcconfig | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 uni/ios/Flutter/Generated 2.xcconfig diff --git a/uni/ios/Flutter/Generated 2.xcconfig b/uni/ios/Flutter/Generated 2.xcconfig deleted file mode 100644 index 27458b7ca..000000000 --- a/uni/ios/Flutter/Generated 2.xcconfig +++ /dev/null @@ -1,14 +0,0 @@ -// This is a generated file; do not edit or check into version control. -FLUTTER_ROOT=/Users/goiana/Desktop/flutter -FLUTTER_APPLICATION_PATH=/Users/goiana/Desktop/project-schrodinger/uni -COCOAPODS_PARALLEL_CODE_SIGN=true -FLUTTER_TARGET=lib/main.dart -FLUTTER_BUILD_DIR=build -FLUTTER_BUILD_NAME=1.5.27 -FLUTTER_BUILD_NUMBER=145 -EXCLUDED_ARCHS[sdk=iphonesimulator*]=i386 -EXCLUDED_ARCHS[sdk=iphoneos*]=armv7 -DART_OBFUSCATION=false -TRACK_WIDGET_CREATION=true -TREE_SHAKE_ICONS=false -PACKAGE_CONFIG=.dart_tool/package_config.json From cec375a60987ca519cdaa0eacc67b681dabc3ec7 Mon Sep 17 00:00:00 2001 From: Diogo Martins <81827192+DGoiana@users.noreply.github.com> Date: Sat, 19 Aug 2023 19:38:35 +0100 Subject: [PATCH 17/50] Delete flutter_export_environment 2.sh --- uni/ios/Flutter/flutter_export_environment 2.sh | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100755 uni/ios/Flutter/flutter_export_environment 2.sh diff --git a/uni/ios/Flutter/flutter_export_environment 2.sh b/uni/ios/Flutter/flutter_export_environment 2.sh deleted file mode 100755 index b127a469d..000000000 --- a/uni/ios/Flutter/flutter_export_environment 2.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/Users/goiana/Desktop/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/goiana/Desktop/project-schrodinger/uni" -export "COCOAPODS_PARALLEL_CODE_SIGN=true" -export "FLUTTER_TARGET=lib/main.dart" -export "FLUTTER_BUILD_DIR=build" -export "FLUTTER_BUILD_NAME=1.5.27" -export "FLUTTER_BUILD_NUMBER=145" -export "DART_OBFUSCATION=false" -export "TRACK_WIDGET_CREATION=true" -export "TREE_SHAKE_ICONS=false" -export "PACKAGE_CONFIG=.dart_tool/package_config.json" From e067dc19606484ebf27ed646e5675ffcc0f0b73f Mon Sep 17 00:00:00 2001 From: DGoiana Date: Sun, 20 Aug 2023 00:36:30 +0100 Subject: [PATCH 18/50] Fix version error --- uni/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uni/pubspec.yaml b/uni/pubspec.yaml index 7dfbbb2d1..56be0e829 100644 --- a/uni/pubspec.yaml +++ b/uni/pubspec.yaml @@ -3,7 +3,7 @@ description: A UP no teu bolso. publish_to: 'none' # We do not publish to pub.dev -version: 1.5.48+166 +version: 1.5.49+167 environment: sdk: ">=2.17.1 <3.0.0" From ec4bd5404a65249d26cd47e25b5f9931bde7406e Mon Sep 17 00:00:00 2001 From: DGoiana Date: Sun, 20 Aug 2023 00:52:16 +0100 Subject: [PATCH 19/50] Multiprovider change --- uni/lib/main.dart | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/uni/lib/main.dart b/uni/lib/main.dart index e833c6808..d0666a51a 100644 --- a/uni/lib/main.dart +++ b/uni/lib/main.dart @@ -127,14 +127,14 @@ Future main() async { ChangeNotifierProvider( create: (context) => stateProviders.referenceProvider, ), - ], - child: ChangeNotifierProvider( - create: (_) => LocaleNotifier(savedLocale), - child: ChangeNotifierProvider( + ChangeNotifierProvider( + create: (_) => LocaleNotifier(savedLocale), + ), + ChangeNotifierProvider( create: (_) => ThemeNotifier(savedTheme), - child: const MyApp(), ), - ), + ], + child: const MyApp(), ), ) }, From 2fec68084a8fc2b7bd4e92dd8171caedeeced1fa Mon Sep 17 00:00:00 2001 From: DGoiana Date: Thu, 24 Aug 2023 19:47:58 +0100 Subject: [PATCH 20/50] Widget testing changes --- uni/test/test_widget.dart | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/uni/test/test_widget.dart b/uni/test/test_widget.dart index fc8798227..66f48f95d 100644 --- a/uni/test/test_widget.dart +++ b/uni/test/test_widget.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:provider/provider.dart'; import 'package:uni/generated/l10n.dart'; @@ -13,14 +14,13 @@ Widget testableWidget( Widget wrapWidget(Widget widget) { return MaterialApp( - home: Scaffold( - body: Localizations( - delegates: const [ - S.delegate, - ], - locale: const Locale('pt'), - child: widget, - ), - ), + localizationsDelegates: const [ + S.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalMaterialLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], + supportedLocales: S.delegate.supportedLocales, + home: widget, ); } From 8b8f5ab996ca4d98895e2fc160013b7af0e4d5ac Mon Sep 17 00:00:00 2001 From: DGoiana Date: Fri, 25 Aug 2023 14:32:10 +0100 Subject: [PATCH 21/50] Testable widget changes --- uni/test/test_widget.dart | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/uni/test/test_widget.dart b/uni/test/test_widget.dart index 66f48f95d..67a4b27eb 100644 --- a/uni/test/test_widget.dart +++ b/uni/test/test_widget.dart @@ -2,14 +2,21 @@ import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:provider/provider.dart'; import 'package:uni/generated/l10n.dart'; +import 'package:uni/view/locale_notifier.dart'; Widget testableWidget( Widget widget, { List providers = const [], }) { - if (providers.isEmpty) return wrapWidget(widget); - - return MultiProvider(providers: providers, child: wrapWidget(widget)); + return MultiProvider( + providers: [ + ChangeNotifierProvider( + create: (_) => LocaleNotifier(const Locale('pt')), + ), + ...providers + ], + child: wrapWidget(widget), + ); } Widget wrapWidget(Widget widget) { @@ -21,6 +28,8 @@ Widget wrapWidget(Widget widget) { GlobalCupertinoLocalizations.delegate, ], supportedLocales: S.delegate.supportedLocales, - home: widget, + home: Scaffold( + body: widget, + ), ); } From 4418be70774d6f9fdf16c32e5c1cab1a8538708b Mon Sep 17 00:00:00 2001 From: DGoiana Date: Fri, 25 Aug 2023 20:17:24 +0100 Subject: [PATCH 22/50] Fixed tests errors --- uni/test/integration/src/schedule_page_test.dart | 1 + uni/test/unit/view/Pages/exams_page_view_test.dart | 6 ++++++ uni/test/unit/view/Widgets/exam_row_test.dart | 4 ++++ uni/test/unit/view/Widgets/schedule_slot_test.dart | 3 +++ 4 files changed, 14 insertions(+) diff --git a/uni/test/integration/src/schedule_page_test.dart b/uni/test/integration/src/schedule_page_test.dart index c01bf08e2..6787a98bc 100644 --- a/uni/test/integration/src/schedule_page_test.dart +++ b/uni/test/integration/src/schedule_page_test.dart @@ -63,6 +63,7 @@ void main() { ]; await tester.pumpWidget(testableWidget(widget, providers: providers)); + await tester.pump(); const scheduleSlotTimeKey1 = 'schedule-slot-time-11:00-13:00'; const scheduleSlotTimeKey2 = 'schedule-slot-time-14:00-16:00'; diff --git a/uni/test/unit/view/Pages/exams_page_view_test.dart b/uni/test/unit/view/Pages/exams_page_view_test.dart index 119e408c2..d4e3a227f 100644 --- a/uni/test/unit/view/Pages/exams_page_view_test.dart +++ b/uni/test/unit/view/Pages/exams_page_view_test.dart @@ -48,6 +48,7 @@ void main() { final providers = [ChangeNotifierProvider(create: (_) => examProvider)]; await tester.pumpWidget(testableWidget(widget, providers: providers)); + await tester.pump(); expect(find.byKey(Key(firstExam.toString())), findsOneWidget); expect(find.byKey(Key('$firstExam-exam')), findsOneWidget); @@ -90,6 +91,7 @@ void main() { final providers = [ChangeNotifierProvider(create: (_) => examProvider)]; await tester.pumpWidget(testableWidget(widget, providers: providers)); + await tester.pump(); expect( find.byKey(Key(examList.map((ex) => ex.toString()).join())), @@ -135,6 +137,8 @@ void main() { final providers = [ChangeNotifierProvider(create: (_) => examProvider)]; await tester.pumpWidget(testableWidget(widget, providers: providers)); + await tester.pump(); + expect(find.byKey(Key(firstExam.toString())), findsOneWidget); expect(find.byKey(Key(secondExam.toString())), findsOneWidget); expect(find.byKey(Key('$firstExam-exam')), findsOneWidget); @@ -202,6 +206,8 @@ void main() { final providers = [ChangeNotifierProvider(create: (_) => examProvider)]; await tester.pumpWidget(testableWidget(widget, providers: providers)); + await tester.pump(); + expect(find.byKey(Key(firstDayKey)), findsOneWidget); expect(find.byKey(Key(secondDayKey)), findsOneWidget); expect(find.byKey(Key('$firstExam-exam')), findsOneWidget); diff --git a/uni/test/unit/view/Widgets/exam_row_test.dart b/uni/test/unit/view/Widgets/exam_row_test.dart index 47ea0bac1..02b547631 100644 --- a/uni/test/unit/view/Widgets/exam_row_test.dart +++ b/uni/test/unit/view/Widgets/exam_row_test.dart @@ -35,6 +35,8 @@ void main() { ChangeNotifierProvider(create: (_) => ExamProvider()) ]; await tester.pumpWidget(testableWidget(widget, providers: providers)); + await tester.pump(); + final roomsKey = '$subject-$rooms-$beginTime-$endTime'; expect( @@ -56,6 +58,8 @@ void main() { ]; await tester.pumpWidget(testableWidget(widget, providers: providers)); + await tester.pump(); + final roomsKey = '$subject-$rooms-$beginTime-$endTime'; expect( diff --git a/uni/test/unit/view/Widgets/schedule_slot_test.dart b/uni/test/unit/view/Widgets/schedule_slot_test.dart index 2a85c7c3a..ab664da90 100644 --- a/uni/test/unit/view/Widgets/schedule_slot_test.dart +++ b/uni/test/unit/view/Widgets/schedule_slot_test.dart @@ -29,6 +29,7 @@ void main() { ); await tester.pumpWidget(testableWidget(widget)); + await tester.pump(); testScheduleSlot(subject, beginText, endText, rooms, typeClass, teacher); }); @@ -50,6 +51,8 @@ void testScheduleSlot( matching: find.text(begin), ), findsOneWidget, + reason: + 'Expected to find widget with text $begin and key $scheduleSlotTimeKey', ); expect( find.descendant( From 161bb92cd78b904ba87d57a3961006e0ca9eabe3 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Thu, 31 Aug 2023 23:11:56 +0100 Subject: [PATCH 23/50] Missed translations, inefficient enums removal --- uni/analysis_options.yaml | 1 + .../local_storage/app_shared_preferences.dart | 3 +- uni/lib/generated/intl/messages_all.dart | 7 +- uni/lib/generated/intl/messages_en.dart | 61 ++++-- uni/lib/generated/intl/messages_pt_PT.dart | 168 +++++++------- uni/lib/generated/l10n.dart | 205 ++++++++++++++++-- uni/lib/l10n/intl_en.arb | 34 +++ uni/lib/l10n/intl_pt_PT.arb | 34 +++ uni/lib/model/entities/exam.dart | 45 +--- uni/lib/view/bug_report/widgets/form.dart | 25 +-- .../course_unit_info/course_unit_info.dart | 16 +- .../view/home/widgets/restaurant_card.dart | 8 +- uni/lib/view/login/login.dart | 13 +- .../widgets/create_print_mb_dialog.dart | 21 +- 14 files changed, 430 insertions(+), 211 deletions(-) diff --git a/uni/analysis_options.yaml b/uni/analysis_options.yaml index 92d895f92..6df16fd8f 100644 --- a/uni/analysis_options.yaml +++ b/uni/analysis_options.yaml @@ -4,6 +4,7 @@ analyzer: # Exclude auto-generated files from dart analysis exclude: - "**.g.dart" + - "/lib/generated/**.dart" # Custom linter rules. A list of all rules can be found at # https://dart-lang.github.io/linter/lints/options/options.html diff --git a/uni/lib/controller/local_storage/app_shared_preferences.dart b/uni/lib/controller/local_storage/app_shared_preferences.dart index e3a6478da..bd8206faf 100644 --- a/uni/lib/controller/local_storage/app_shared_preferences.dart +++ b/uni/lib/controller/local_storage/app_shared_preferences.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:io'; import 'package:encrypt/encrypt.dart' as encrypt; import 'package:flutter/material.dart'; @@ -125,7 +126,7 @@ class AppSharedPreferences { static Future getLocale() async { final prefs = await SharedPreferences.getInstance(); - final appLocale = prefs.getString(locale) ?? 'en'; + final appLocale = prefs.getString(locale) ?? Platform.localeName; return Locale(appLocale); } diff --git a/uni/lib/generated/intl/messages_all.dart b/uni/lib/generated/intl/messages_all.dart index de96ef7c8..5c2bef3d1 100644 --- a/uni/lib/generated/intl/messages_all.dart +++ b/uni/lib/generated/intl/messages_all.dart @@ -61,8 +61,11 @@ bool _messagesExistFor(String locale) { } MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { - final actualLocale = - Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); + final actualLocale = Intl.verifiedLocale( + locale, + _messagesExistFor, + onFailure: (_) => null, + ); if (actualLocale == null) return null; return _findExact(actualLocale); } diff --git a/uni/lib/generated/intl/messages_en.dart b/uni/lib/generated/intl/messages_en.dart index 58c300a64..6cb2f58f8 100644 --- a/uni/lib/generated/intl/messages_en.dart +++ b/uni/lib/generated/intl/messages_en.dart @@ -51,19 +51,20 @@ class MessageLookup extends MessageLookupByLibrary { "account_card_title": MessageLookupByLibrary.simpleMessage("Checking account"), "add": MessageLookupByLibrary.simpleMessage("Add"), + "add_quota": MessageLookupByLibrary.simpleMessage("Add quota"), "add_widget": MessageLookupByLibrary.simpleMessage("Add widget"), - "agree_terms": - MessageLookupByLibrary.simpleMessage("By entering you confirm that " - "you agree with these Terms and Conditions"), - "all_widgets_added": - MessageLookupByLibrary.simpleMessage("All available widgets have " - "already been added to your personal area!"), + "agree_terms": MessageLookupByLibrary.simpleMessage( + "By entering you confirm that you agree with these Terms and Conditions", + ), + "all_widgets_added": MessageLookupByLibrary.simpleMessage( + "All available widgets have already been added to your personal area!", + ), "at_least_one_college": MessageLookupByLibrary.simpleMessage("Select at least one college"), "average": MessageLookupByLibrary.simpleMessage("Average: "), "balance": MessageLookupByLibrary.simpleMessage("Balance:"), "bs_description": MessageLookupByLibrary.simpleMessage( - r"Did you find any bugs in the application?\nDo you have any suggestions for the app?\nTell us so we can improve!", + "Did you find any bugs in the application?\\nDo you have any suggestions for the app?\\nTell us so we can improve!", ), "bug_description": MessageLookupByLibrary.simpleMessage( "Bug found, how to reproduce it, etc.", @@ -76,9 +77,13 @@ class MessageLookup extends MessageLookupByLibrary { "buses_personalize": MessageLookupByLibrary.simpleMessage("Personalize your buses here"), "buses_text": MessageLookupByLibrary.simpleMessage( - "Favorite buses will be displayed in the favorites 'Bus' widget. " - "The remaining ones will only be displayed on the page."), + "Favorite buses will be displayed in the favorites \'Bus\' widget. The remaining ones will only be displayed on the page.", + ), "cancel": MessageLookupByLibrary.simpleMessage("Cancel"), + "change": MessageLookupByLibrary.simpleMessage("Change"), + "change_prompt": MessageLookupByLibrary.simpleMessage( + "Do you want to change the password?", + ), "class_registration": MessageLookupByLibrary.simpleMessage("Class Registration"), "college": MessageLookupByLibrary.simpleMessage("College: "), @@ -89,23 +94,26 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Configured Buses"), "confirm": MessageLookupByLibrary.simpleMessage("Confirm"), "consent": MessageLookupByLibrary.simpleMessage( - "I consent to this information being reviewed by " - "NIAEFEUP and may be deleted at my request."), + "I consent to this information being reviewed by NIAEFEUP and may be deleted at my request.", + ), "contact": MessageLookupByLibrary.simpleMessage("Contact (optional)"), "copy_center": MessageLookupByLibrary.simpleMessage("Copy center"), "copy_center_building": MessageLookupByLibrary.simpleMessage( "Floor -1 of building B | AEFEUP building", ), + "course_class": MessageLookupByLibrary.simpleMessage("Classes"), + "course_info": MessageLookupByLibrary.simpleMessage("Info"), "current_state": MessageLookupByLibrary.simpleMessage("Current state: "), "current_year": MessageLookupByLibrary.simpleMessage("Current academic year: "), + "decrement": MessageLookupByLibrary.simpleMessage("Decrement 1,00€"), "description": MessageLookupByLibrary.simpleMessage("Description"), "desired_email": MessageLookupByLibrary.simpleMessage( "Email where you want to be contacted", ), "dona_bia": MessageLookupByLibrary.simpleMessage( - "D. Beatriz's stationery store", + "D. Beatriz\'s stationery store", ), "dona_bia_building": MessageLookupByLibrary.simpleMessage( "Floor -1 of building B (B-142)", @@ -117,6 +125,8 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Please fill in this field"), "exams_filter": MessageLookupByLibrary.simpleMessage("Exam Filter Settings"), + "expired_password": + MessageLookupByLibrary.simpleMessage("Your password has expired"), "failed_login": MessageLookupByLibrary.simpleMessage("Login failed"), "fee_date": MessageLookupByLibrary.simpleMessage("Deadline for next fee:"), @@ -129,10 +139,13 @@ class MessageLookup extends MessageLookupByLibrary { "floors": MessageLookupByLibrary.simpleMessage("Floors"), "forgot_password": MessageLookupByLibrary.simpleMessage("Forgot password?"), + "generate_reference": + MessageLookupByLibrary.simpleMessage("Generate reference"), "geral_registration": MessageLookupByLibrary.simpleMessage("General Registration"), "improvement_registration": MessageLookupByLibrary.simpleMessage("Enrollment for Improvement"), + "increment": MessageLookupByLibrary.simpleMessage("Increment 1,00€"), "keep_login": MessageLookupByLibrary.simpleMessage("Stay signed in"), "last_refresh_time": m0, "last_timestamp": m1, @@ -144,17 +157,22 @@ class MessageLookup extends MessageLookupByLibrary { "login": MessageLookupByLibrary.simpleMessage("Login"), "logout": MessageLookupByLibrary.simpleMessage("Log out"), "menus": MessageLookupByLibrary.simpleMessage("Menus"), + "min_value_reference": + MessageLookupByLibrary.simpleMessage("Minimum value: 1,00 €"), "multimedia_center": MessageLookupByLibrary.simpleMessage("Multimedia center"), "nav_title": m2, "news": MessageLookupByLibrary.simpleMessage("News"), - "no_bus": MessageLookupByLibrary.simpleMessage("Don't miss any bus!"), + "no_bus": MessageLookupByLibrary.simpleMessage("Don\'t miss any bus!"), "no_bus_stops": MessageLookupByLibrary.simpleMessage("No configured stops"), + "no_class": MessageLookupByLibrary.simpleMessage( + "There are no classes to display", + ), "no_classes": MessageLookupByLibrary.simpleMessage("No classes to present"), "no_classes_on": - MessageLookupByLibrary.simpleMessage("You don't have classes on"), + MessageLookupByLibrary.simpleMessage("You don\'t have classes on"), "no_college": MessageLookupByLibrary.simpleMessage("no college"), "no_course_units": MessageLookupByLibrary.simpleMessage( "No course units in the selected period", @@ -169,6 +187,11 @@ class MessageLookup extends MessageLookupByLibrary { "no_exams_label": MessageLookupByLibrary.simpleMessage( "Looks like you are on vacation!", ), + "no_favorite_restaurants": + MessageLookupByLibrary.simpleMessage("No favorite restaurants"), + "no_info": MessageLookupByLibrary.simpleMessage( + "There is no information to display", + ), "no_menu_info": MessageLookupByLibrary.simpleMessage( "There is no information available about meals", ), @@ -190,6 +213,9 @@ class MessageLookup extends MessageLookupByLibrary { "occurrence_type": MessageLookupByLibrary.simpleMessage("Type of occurrence"), "other_links": MessageLookupByLibrary.simpleMessage("Other links"), + "pass_change_request": MessageLookupByLibrary.simpleMessage( + "For security reasons, passwords must be changed periodically.", + ), "password": MessageLookupByLibrary.simpleMessage("password"), "pendent_references": MessageLookupByLibrary.simpleMessage("Pending references"), @@ -201,6 +227,12 @@ class MessageLookup extends MessageLookupByLibrary { "problem_id": MessageLookupByLibrary.simpleMessage( "Brief identification of the problem", ), + "reference_sigarra_help": MessageLookupByLibrary.simpleMessage( + "The generated reference data will appear in Sigarra, checking account.\\nProfile > Checking Account", + ), + "reference_success": MessageLookupByLibrary.simpleMessage( + "Reference created successfully!", + ), "remove": MessageLookupByLibrary.simpleMessage("Delete"), "room": MessageLookupByLibrary.simpleMessage("Room"), "school_calendar": @@ -210,6 +242,7 @@ class MessageLookup extends MessageLookupByLibrary { "sent_error": MessageLookupByLibrary.simpleMessage( "An error occurred in sending", ), + "some_error": MessageLookupByLibrary.simpleMessage("Some error!"), "stcp_stops": MessageLookupByLibrary.simpleMessage("STCP - Upcoming Trips"), "student_number": diff --git a/uni/lib/generated/intl/messages_pt_PT.dart b/uni/lib/generated/intl/messages_pt_PT.dart index 4b09319f9..297fff62c 100644 --- a/uni/lib/generated/intl/messages_pt_PT.dart +++ b/uni/lib/generated/intl/messages_pt_PT.dart @@ -19,30 +19,26 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'pt_PT'; - static String m0(dynamic time) => "última atualização às ${time}"; + static m0(time) => "última atualização às ${time}"; - static String m1(dynamic time) => Intl.plural( - time as num, - zero: 'Atualizado há ${time} minutos', - one: 'Atualizado há ${time} minuto', - other: 'Atualizado há ${time} minutos', - ); + static m1(time) => + "${Intl.plural(time as num, zero: 'Atualizado há ${time} minutos', one: 'Atualizado há ${time} minuto', other: 'Atualizado há ${time} minutos')}"; - static String m2(String title) => Intl.select(title, { - 'horario': 'Horário', - 'exames': 'Exames', - 'area': 'Área Pessoal', - 'cadeiras': 'Cadeiras', - 'autocarros': 'Autocarros', - 'locais': 'Locais', - 'restaurantes': 'Restaurantes', - 'calendario': 'Calendário', - 'biblioteca': 'Biblioteca', - 'uteis': 'Úteis', - 'sobre': 'Sobre', - 'bugs': 'Bugs e Sugestões', - 'other': 'Outros', - }); + static m2(String title) => "${Intl.select(title, { + 'horario': 'Horário', + 'exames': 'Exames', + 'area': 'Área Pessoal', + 'cadeiras': 'Cadeiras', + 'autocarros': 'Autocarros', + 'locais': 'Locais', + 'restaurantes': 'Restaurantes', + 'calendario': 'Calendário', + 'biblioteca': 'Biblioteca', + 'uteis': 'Úteis', + 'sobre': 'Sobre', + 'bugs': 'Bugs e Sugestões', + 'other': 'Outros', + })}"; final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { @@ -51,94 +47,87 @@ class MessageLookup extends MessageLookupByLibrary { "account_card_title": MessageLookupByLibrary.simpleMessage("Conta Corrente"), "add": MessageLookupByLibrary.simpleMessage("Adicionar"), + "add_quota": MessageLookupByLibrary.simpleMessage("Adicionar quota"), "add_widget": MessageLookupByLibrary.simpleMessage("Adicionar widget"), "agree_terms": MessageLookupByLibrary.simpleMessage( - "Ao entrares confirmas que concordas " - "com estes Termos e Condições", - ), + "Ao entrares confirmas que concordas com estes Termos e Condições"), "all_widgets_added": MessageLookupByLibrary.simpleMessage( - "Todos os widgets disponíveis já foram adicionados à tua " - "área pessoal!"), + "Todos os widgets disponíveis já foram adicionados à tua área pessoal!"), "at_least_one_college": MessageLookupByLibrary.simpleMessage( - "Seleciona pelo menos uma faculdade", - ), + "Seleciona pelo menos uma faculdade"), "average": MessageLookupByLibrary.simpleMessage("Média: "), "balance": MessageLookupByLibrary.simpleMessage("Saldo:"), "bs_description": MessageLookupByLibrary.simpleMessage( - r"Encontraste algum bug na aplicação?\nTens alguma sugestão para a app?\nConta-nos para que possamos melhorar!", - ), + "Encontraste algum bug na aplicação?\\nTens alguma sugestão para a app?\\nConta-nos para que possamos melhorar!"), "bug_description": MessageLookupByLibrary.simpleMessage( - "Bug encontrado, como o reproduzir, etc", - ), + "Bug encontrado, como o reproduzir, etc"), "bus_error": MessageLookupByLibrary.simpleMessage( - "Não foi possível obter informação", - ), + "Não foi possível obter informação"), "bus_information": MessageLookupByLibrary.simpleMessage( - "Seleciona os autocarros dos quais queres informação:", - ), + "Seleciona os autocarros dos quais queres informação:"), "buses_personalize": MessageLookupByLibrary.simpleMessage( - "Configura aqui os teus autocarros", - ), + "Configura aqui os teus autocarros"), "buses_text": MessageLookupByLibrary.simpleMessage( - "Os autocarros favoritos serão apresentados no widget " - "'Autocarros' dos favoritos. " - "Os restantes serão apresentados apenas na página."), + "Os autocarros favoritos serão apresentados no widget \'Autocarros\' dos favoritos. Os restantes serão apresentados apenas na página."), "cancel": MessageLookupByLibrary.simpleMessage("Cancelar\n"), + "change": MessageLookupByLibrary.simpleMessage("Alterar"), + "change_prompt": MessageLookupByLibrary.simpleMessage( + "Deseja alterar a palavra-passe?"), "class_registration": MessageLookupByLibrary.simpleMessage("Inscrição de Turmas"), "college": MessageLookupByLibrary.simpleMessage("Faculdade: "), "college_select": MessageLookupByLibrary.simpleMessage( - "seleciona a(s) tua(s) faculdade(s)", - ), + "seleciona a(s) tua(s) faculdade(s)"), "conclude": MessageLookupByLibrary.simpleMessage("Concluído"), "configured_buses": MessageLookupByLibrary.simpleMessage("Autocarros Configurados"), "confirm": MessageLookupByLibrary.simpleMessage("Confirmar"), "consent": MessageLookupByLibrary.simpleMessage( - "Consinto que esta informação seja revista pelo NIAEFEUP, " - "podendo ser eliminada a meu pedido."), + "Consinto que esta informação seja revista pelo NIAEFEUP, podendo ser eliminada a meu pedido."), "contact": MessageLookupByLibrary.simpleMessage("Contacto (opcional)"), "copy_center": MessageLookupByLibrary.simpleMessage("Centro de cópias"), "copy_center_building": MessageLookupByLibrary.simpleMessage( - "Piso -1 do edifício B | Edifício da AEFEUP", - ), + "Piso -1 do edifício B | Edifício da AEFEUP"), + "course_class": MessageLookupByLibrary.simpleMessage("Turmas"), + "course_info": MessageLookupByLibrary.simpleMessage("Ficha"), "current_state": MessageLookupByLibrary.simpleMessage("Estado atual: "), "current_year": MessageLookupByLibrary.simpleMessage("Ano curricular atual: "), + "decrement": MessageLookupByLibrary.simpleMessage("Decrementar 1,00€"), "description": MessageLookupByLibrary.simpleMessage("Descrição"), "desired_email": MessageLookupByLibrary.simpleMessage( - "Email em que desejas ser contactado", - ), + "Email em que desejas ser contactado"), "dona_bia": MessageLookupByLibrary.simpleMessage("Papelaria D. Beatriz"), "dona_bia_building": MessageLookupByLibrary.simpleMessage( - "Piso -1 do edifício B (B-142)", - ), + "Piso -1 do edifício B (B-142)"), "ects": MessageLookupByLibrary.simpleMessage("ECTs realizados: "), "edit_off": MessageLookupByLibrary.simpleMessage("Editar\n"), "edit_on": MessageLookupByLibrary.simpleMessage("Concluir edição"), "empty_text": MessageLookupByLibrary.simpleMessage( - "Por favor preenche este campo", - ), + "Por favor preenche este campo"), "exams_filter": MessageLookupByLibrary.simpleMessage("Definições Filtro de Exames"), + "expired_password": + MessageLookupByLibrary.simpleMessage("A tua palavra-passe expirou"), "failed_login": MessageLookupByLibrary.simpleMessage("O login falhou"), "fee_date": MessageLookupByLibrary.simpleMessage( - "Data limite próxima prestação:", - ), + "Data limite próxima prestação:"), "fee_notification": MessageLookupByLibrary.simpleMessage( - "Notificar próxima data limite:", - ), + "Notificar próxima data limite:"), "first_year_registration": MessageLookupByLibrary.simpleMessage("Ano da primeira inscrição: "), "floor": MessageLookupByLibrary.simpleMessage("Piso"), "floors": MessageLookupByLibrary.simpleMessage("Pisos"), "forgot_password": MessageLookupByLibrary.simpleMessage("Esqueceu a palavra-passe?"), + "generate_reference": + MessageLookupByLibrary.simpleMessage("Gerar referência"), "geral_registration": MessageLookupByLibrary.simpleMessage("Inscrição Geral"), "improvement_registration": MessageLookupByLibrary.simpleMessage("Inscrição para Melhoria"), + "increment": MessageLookupByLibrary.simpleMessage("Incrementar 1,00€"), "keep_login": MessageLookupByLibrary.simpleMessage("Manter sessão iniciada"), "last_refresh_time": m0, @@ -146,71 +135,72 @@ class MessageLookup extends MessageLookupByLibrary { "library_occupation": MessageLookupByLibrary.simpleMessage("Ocupação da Biblioteca"), "loading_terms": MessageLookupByLibrary.simpleMessage( - "Carregando os Termos e Condições...", - ), + "Carregando os Termos e Condições..."), "login": MessageLookupByLibrary.simpleMessage("Entrar"), "logout": MessageLookupByLibrary.simpleMessage("Terminar sessão"), "menus": MessageLookupByLibrary.simpleMessage("Ementas"), + "min_value_reference": + MessageLookupByLibrary.simpleMessage("Valor mínimo: 1,00 €"), "multimedia_center": MessageLookupByLibrary.simpleMessage("Centro de multimédia"), "nav_title": m2, "news": MessageLookupByLibrary.simpleMessage("Notícias"), "no_bus": MessageLookupByLibrary.simpleMessage( - "Não percas nenhum autocarro!", - ), + "Não percas nenhum autocarro!"), "no_bus_stops": MessageLookupByLibrary.simpleMessage( - "Não existe nenhuma paragem configurada", - ), + "Não existe nenhuma paragem configurada"), + "no_class": MessageLookupByLibrary.simpleMessage( + "Não existem turmas para apresentar"), "no_classes": MessageLookupByLibrary.simpleMessage( - "Não existem aulas para apresentar", - ), + "Não existem aulas para apresentar"), "no_classes_on": MessageLookupByLibrary.simpleMessage("Não possui aulas à"), "no_college": MessageLookupByLibrary.simpleMessage("sem faculdade"), "no_course_units": MessageLookupByLibrary.simpleMessage( - "Sem cadeiras no período selecionado", - ), + "Sem cadeiras no período selecionado"), "no_data": MessageLookupByLibrary.simpleMessage( - "Não há dados a mostrar neste momento", - ), + "Não há dados a mostrar neste momento"), "no_date": MessageLookupByLibrary.simpleMessage("Sem data"), "no_exams": MessageLookupByLibrary.simpleMessage("Não possui exames marcados"), "no_exams_label": MessageLookupByLibrary.simpleMessage("Parece que estás de férias!"), + "no_favorite_restaurants": + MessageLookupByLibrary.simpleMessage("Sem restaurantes favoritos"), + "no_info": MessageLookupByLibrary.simpleMessage( + "Não existem informações para apresentar"), "no_menu_info": MessageLookupByLibrary.simpleMessage( - "Não há informação disponível sobre refeições", - ), + "Não há informação disponível sobre refeições"), "no_menus": MessageLookupByLibrary.simpleMessage( - "Não há refeições disponíveis", - ), + "Não há refeições disponíveis"), "no_name_course": MessageLookupByLibrary.simpleMessage("Curso sem nome"), "no_references": MessageLookupByLibrary.simpleMessage( - "Não existem referências a pagar", - ), + "Não existem referências a pagar"), "no_results": MessageLookupByLibrary.simpleMessage("Sem resultados"), "no_selected_courses": MessageLookupByLibrary.simpleMessage( - "Não existem cadeiras para apresentar", - ), + "Não existem cadeiras para apresentar"), "no_selected_exams": MessageLookupByLibrary.simpleMessage( - "Não existem exames para apresentar", - ), + "Não existem exames para apresentar"), "occurrence_type": MessageLookupByLibrary.simpleMessage("Tipo de ocorrência"), "other_links": MessageLookupByLibrary.simpleMessage("Outros links"), + "pass_change_request": MessageLookupByLibrary.simpleMessage( + "Por razões de segurança, as palavras-passe têm de ser alteradas periodicamente."), "password": MessageLookupByLibrary.simpleMessage("palavra-passe"), "pendent_references": MessageLookupByLibrary.simpleMessage("Referências pendentes"), "personal_assistance": MessageLookupByLibrary.simpleMessage("Atendimento presencial"), "press_again": MessageLookupByLibrary.simpleMessage( - "Pressione novamente para sair", - ), + "Pressione novamente para sair"), "print": MessageLookupByLibrary.simpleMessage("Impressão"), "problem_id": MessageLookupByLibrary.simpleMessage( - "Breve identificação do problema", - ), + "Breve identificação do problema"), + "reference_sigarra_help": MessageLookupByLibrary.simpleMessage( + "Os dados da referência gerada aparecerão no Sigarra, conta corrente.\\nPerfil > Conta Corrente"), + "reference_success": MessageLookupByLibrary.simpleMessage( + "Referência criada com sucesso!"), "remove": MessageLookupByLibrary.simpleMessage("Remover"), "room": MessageLookupByLibrary.simpleMessage("Sala"), "school_calendar": @@ -219,6 +209,7 @@ class MessageLookup extends MessageLookupByLibrary { "send": MessageLookupByLibrary.simpleMessage("Enviar"), "sent_error": MessageLookupByLibrary.simpleMessage("Ocorreu um erro no envio"), + "some_error": MessageLookupByLibrary.simpleMessage("Algum erro!"), "stcp_stops": MessageLookupByLibrary.simpleMessage("STCP - Próximas Viagens"), "student_number": @@ -227,18 +218,15 @@ class MessageLookup extends MessageLookupByLibrary { "tele_assistance": MessageLookupByLibrary.simpleMessage("Atendimento telefónico"), "tele_personal_assistance": MessageLookupByLibrary.simpleMessage( - "Atendimento presencial e telefónico", - ), + "Atendimento presencial e telefónico"), "telephone": MessageLookupByLibrary.simpleMessage("Telefone"), "terms": MessageLookupByLibrary.simpleMessage("Termos e Condições"), "title": MessageLookupByLibrary.simpleMessage("Título"), "unavailable": MessageLookupByLibrary.simpleMessage("Indisponível"), "valid_email": MessageLookupByLibrary.simpleMessage( - "Por favor insere um email válido", - ), + "Por favor insere um email válido"), "widget_prompt": MessageLookupByLibrary.simpleMessage( - "Escolhe um widget para adicionares à tua área pessoal:", - ), + "Escolhe um widget para adicionares à tua área pessoal:"), "year": MessageLookupByLibrary.simpleMessage("Ano") }; } diff --git a/uni/lib/generated/l10n.dart b/uni/lib/generated/l10n.dart index 50d0fbcdf..a0ac95cfd 100644 --- a/uni/lib/generated/l10n.dart +++ b/uni/lib/generated/l10n.dart @@ -1,7 +1,7 @@ // GENERATED CODE - DO NOT MODIFY BY HAND import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; -import 'package:uni/generated/intl/messages_all.dart'; +import 'intl/messages_all.dart'; // ************************************************************************** // Generator: Flutter Intl IDE plugin @@ -18,35 +18,28 @@ class S { static S? _current; static S get current { - assert( - _current != null, - 'No instance of S was loaded. Try to initialize the S delegate before accessing S.current.', - ); + assert(_current != null, 'No instance of S was loaded. Try to initialize the S delegate before accessing S.current.'); return _current!; } - static const AppLocalizationDelegate delegate = AppLocalizationDelegate(); + static const AppLocalizationDelegate delegate = + AppLocalizationDelegate(); static Future load(Locale locale) { - final name = (locale.countryCode?.isEmpty ?? false) - ? locale.languageCode - : locale.toString(); - final localeName = Intl.canonicalizedLocale(name); + final name = (locale.countryCode?.isEmpty ?? false) ? locale.languageCode : locale.toString(); + final localeName = Intl.canonicalizedLocale(name); return initializeMessages(localeName).then((_) { Intl.defaultLocale = localeName; final instance = S(); S._current = instance; - + return instance; }); - } + } static S of(BuildContext context) { final instance = S.maybeOf(context); - assert( - instance != null, - 'No instance of S present in the widget tree. Did you add S.delegate in localizationsDelegates?', - ); + assert(instance != null, 'No instance of S present in the widget tree. Did you add S.delegate in localizationsDelegates?'); return instance!; } @@ -84,6 +77,16 @@ class S { ); } + /// `Add quota` + String get add_quota { + return Intl.message( + 'Add quota', + name: 'add_quota', + desc: '', + args: [], + ); + } + /// `Add widget` String get add_widget { return Intl.message( @@ -187,7 +190,7 @@ class S { /// `Favorite buses will be displayed in the favorites 'Bus' widget. The remaining ones will only be displayed on the page.` String get buses_text { return Intl.message( - "Favorite buses will be displayed in the favorites 'Bus' widget. The remaining ones will only be displayed on the page.", + 'Favorite buses will be displayed in the favorites \'Bus\' widget. The remaining ones will only be displayed on the page.', name: 'buses_text', desc: '', args: [], @@ -214,6 +217,36 @@ class S { ); } + /// `Change` + String get change { + return Intl.message( + 'Change', + name: 'change', + desc: '', + args: [], + ); + } + + /// `Do you want to change the password?` + String get change_prompt { + return Intl.message( + 'Do you want to change the password?', + name: 'change_prompt', + desc: '', + args: [], + ); + } + + /// `Classes` + String get course_class { + return Intl.message( + 'Classes', + name: 'course_class', + desc: '', + args: [], + ); + } + /// `Class Registration` String get class_registration { return Intl.message( @@ -314,6 +347,16 @@ class S { ); } + /// `Info` + String get course_info { + return Intl.message( + 'Info', + name: 'course_info', + desc: '', + args: [], + ); + } + /// `Current state: ` String get current_state { return Intl.message( @@ -334,6 +377,16 @@ class S { ); } + /// `Decrement 1,00€` + String get decrement { + return Intl.message( + 'Decrement 1,00€', + name: 'decrement', + desc: '', + args: [], + ); + } + /// `Description` String get description { return Intl.message( @@ -357,7 +410,7 @@ class S { /// `D. Beatriz's stationery store` String get dona_bia { return Intl.message( - "D. Beatriz's stationery store", + 'D. Beatriz\'s stationery store', name: 'dona_bia', desc: '', args: [], @@ -424,6 +477,16 @@ class S { ); } + /// `Your password has expired` + String get expired_password { + return Intl.message( + 'Your password has expired', + name: 'expired_password', + desc: '', + args: [], + ); + } + /// `Login failed` String get failed_login { return Intl.message( @@ -494,6 +557,16 @@ class S { ); } + /// `Generate reference` + String get generate_reference { + return Intl.message( + 'Generate reference', + name: 'generate_reference', + desc: '', + args: [], + ); + } + /// `General Registration` String get geral_registration { return Intl.message( @@ -514,6 +587,16 @@ class S { ); } + /// `Increment 1,00€` + String get increment { + return Intl.message( + 'Increment 1,00€', + name: 'increment', + desc: '', + args: [], + ); + } + /// `Stay signed in` String get keep_login { return Intl.message( @@ -597,6 +680,16 @@ class S { ); } + /// `Minimum value: 1,00 €` + String get min_value_reference { + return Intl.message( + 'Minimum value: 1,00 €', + name: 'min_value_reference', + desc: '', + args: [], + ); + } + /// `Multimedia center` String get multimedia_center { return Intl.message( @@ -645,7 +738,7 @@ class S { /// `Don't miss any bus!` String get no_bus { return Intl.message( - "Don't miss any bus!", + 'Don\'t miss any bus!', name: 'no_bus', desc: '', args: [], @@ -662,6 +755,16 @@ class S { ); } + /// `There are no classes to display` + String get no_class { + return Intl.message( + 'There are no classes to display', + name: 'no_class', + desc: '', + args: [], + ); + } + /// `No classes to present` String get no_classes { return Intl.message( @@ -675,7 +778,7 @@ class S { /// `You don't have classes on` String get no_classes_on { return Intl.message( - "You don't have classes on", + 'You don\'t have classes on', name: 'no_classes_on', desc: '', args: [], @@ -742,6 +845,26 @@ class S { ); } + /// `No favorite restaurants` + String get no_favorite_restaurants { + return Intl.message( + 'No favorite restaurants', + name: 'no_favorite_restaurants', + desc: '', + args: [], + ); + } + + /// `There is no information to display` + String get no_info { + return Intl.message( + 'There is no information to display', + name: 'no_info', + desc: '', + args: [], + ); + } + /// `There is no information available about meals` String get no_menu_info { return Intl.message( @@ -832,6 +955,16 @@ class S { ); } + /// `For security reasons, passwords must be changed periodically.` + String get pass_change_request { + return Intl.message( + 'For security reasons, passwords must be changed periodically.', + name: 'pass_change_request', + desc: '', + args: [], + ); + } + /// `password` String get password { return Intl.message( @@ -892,6 +1025,26 @@ class S { ); } + /// `The generated reference data will appear in Sigarra, checking account.\nProfile > Checking Account` + String get reference_sigarra_help { + return Intl.message( + 'The generated reference data will appear in Sigarra, checking account.\nProfile > Checking Account', + name: 'reference_sigarra_help', + desc: '', + args: [], + ); + } + + /// `Reference created successfully!` + String get reference_success { + return Intl.message( + 'Reference created successfully!', + name: 'reference_success', + desc: '', + args: [], + ); + } + /// `Delete` String get remove { return Intl.message( @@ -952,6 +1105,16 @@ class S { ); } + /// `Some error!` + String get some_error { + return Intl.message( + 'Some error!', + name: 'some_error', + desc: '', + args: [], + ); + } + /// `STCP - Upcoming Trips` String get stcp_stops { return Intl.message( @@ -1098,4 +1261,4 @@ class AppLocalizationDelegate extends LocalizationsDelegate { } return false; } -} +} \ No newline at end of file diff --git a/uni/lib/l10n/intl_en.arb b/uni/lib/l10n/intl_en.arb index 5dc250b90..d96cf6deb 100644 --- a/uni/lib/l10n/intl_en.arb +++ b/uni/lib/l10n/intl_en.arb @@ -6,6 +6,8 @@ "@account_card_title": {}, "add": "Add", "@add": {}, + "add_quota": "Add quota", + "@add_quota": {}, "add_widget": "Add widget", "@add_widget": {}, "agree_terms": "By entering you confirm that you agree with these Terms and Conditions", @@ -32,6 +34,12 @@ "@bus_information": {}, "cancel": "Cancel", "@cancel": {}, + "change": "Change", + "@change": {}, + "change_prompt": "Do you want to change the password?", + "@change_prompt": {}, + "course_class": "Classes", + "@course_class": {}, "class_registration": "Class Registration", "@class_registration": {}, "college": "College: ", @@ -52,10 +60,14 @@ "@copy_center": {}, "copy_center_building": "Floor -1 of building B | AEFEUP building", "@copy_center_building": {}, + "course_info": "Info", + "@course_info": {}, "current_state": "Current state: ", "@current_state": {}, "current_year": "Current academic year: ", "@current_year": {}, + "decrement": "Decrement 1,00€", + "@decrement": {}, "description": "Description", "@description": {}, "desired_email": "Email where you want to be contacted", @@ -74,6 +86,8 @@ "@empty_text": {}, "exams_filter": "Exam Filter Settings", "@exams_filter": {}, + "expired_password": "Your password has expired", + "@expired_password": {}, "failed_login": "Login failed", "@failed_login": {}, "fee_date": "Deadline for next fee:", @@ -88,10 +102,14 @@ "@floors": {}, "forgot_password": "Forgot password?", "@forgot_password": {}, + "generate_reference": "Generate reference", + "@generate_reference": {}, "geral_registration": "General Registration", "@geral_registration": {}, "improvement_registration": "Enrollment for Improvement", "@improvement_registration": {}, + "increment": "Increment 1,00€", + "@increment": {}, "keep_login": "Stay signed in", "@keep_login": {}, "last_refresh_time": "last refresh at {time}", @@ -116,6 +134,8 @@ "@logout": {}, "menus": "Menus", "@menus": {}, + "min_value_reference": "Minimum value: 1,00 €", + "@min_value_reference": {}, "multimedia_center": "Multimedia center", "@multimedia_center": {}, "nav_title": "{title, select, horario{Schedule} exames{Exams} area{Personal Area} cadeiras{Course Units} autocarros{Buses} locais{Places} restaurantes{Restaurants} calendario{Calendar} biblioteca{Library} uteis{Utils} sobre{About} bugs{Bugs/ Suggestions} other{Other}}", @@ -126,6 +146,8 @@ "@no_bus": {}, "no_bus_stops": "No configured stops", "@no_bus_stops": {}, + "no_class": "There are no classes to display", + "@no_class": {}, "no_classes": "No classes to present", "@no_classes": {}, "no_classes_on": "You don't have classes on", @@ -142,6 +164,10 @@ "@no_exams": {}, "no_exams_label": "Looks like you are on vacation!", "@no_exams_label": {}, + "no_favorite_restaurants": "No favorite restaurants", + "@no_favorite_restaurants": {}, + "no_info": "There is no information to display", + "@no_info": {}, "no_menu_info": "There is no information available about meals", "@no_menu_info": {}, "no_menus": "There are no meals available", @@ -160,6 +186,8 @@ "@occurrence_type": {}, "other_links": "Other links", "@other_links": {}, + "pass_change_request": "For security reasons, passwords must be changed periodically.", + "@pass_change_request": {}, "password": "password", "@password": {}, "pendent_references": "Pending references", @@ -172,6 +200,10 @@ "@print": {}, "problem_id": "Brief identification of the problem", "@problem_id": {}, + "reference_sigarra_help": "The generated reference data will appear in Sigarra, checking account.\\nProfile > Checking Account", + "@reference_sigarra_help": {}, + "reference_success": "Reference created successfully!", + "@reference_success": {}, "remove": "Delete", "@remove": {}, "room": "Room", @@ -184,6 +216,8 @@ "@send": {}, "sent_error": "An error occurred in sending", "@sent_error": {}, + "some_error": "Some error!", + "@some_error": {}, "stcp_stops": "STCP - Upcoming Trips", "@stcp_stops": {}, "student_number": "student number", diff --git a/uni/lib/l10n/intl_pt_PT.arb b/uni/lib/l10n/intl_pt_PT.arb index fcb473fc8..e25bfbea9 100644 --- a/uni/lib/l10n/intl_pt_PT.arb +++ b/uni/lib/l10n/intl_pt_PT.arb @@ -6,6 +6,8 @@ "@account_card_title": {}, "add": "Adicionar", "@add": {}, + "add_quota": "Adicionar quota", + "@add_quota": {}, "add_widget": "Adicionar widget", "@add_widget": {}, "agree_terms": "Ao entrares confirmas que concordas com estes Termos e Condições", @@ -32,6 +34,12 @@ "@bus_information": {}, "cancel": "Cancelar\n", "@cancel": {}, + "change": "Alterar", + "@change": {}, + "change_prompt": "Deseja alterar a palavra-passe?", + "@change_prompt": {}, + "course_class": "Turmas", + "@course_class": {}, "class_registration": "Inscrição de Turmas", "@class_registration": {}, "college": "Faculdade: ", @@ -52,10 +60,14 @@ "@copy_center": {}, "copy_center_building": "Piso -1 do edifício B | Edifício da AEFEUP", "@copy_center_building": {}, + "course_info": "Ficha", + "@course_info": {}, "current_state": "Estado atual: ", "@current_state": {}, "current_year": "Ano curricular atual: ", "@current_year": {}, + "decrement": "Decrementar 1,00€", + "@decrement": {}, "description": "Descrição", "@description": {}, "desired_email": "Email em que desejas ser contactado", @@ -74,6 +86,8 @@ "@empty_text": {}, "exams_filter": "Definições Filtro de Exames", "@exams_filter": {}, + "expired_password": "A tua palavra-passe expirou", + "@expired_password": {}, "failed_login": "O login falhou", "@failed_login": {}, "fee_date": "Data limite próxima prestação:", @@ -88,10 +102,14 @@ "@floors": {}, "forgot_password": "Esqueceu a palavra-passe?", "@forgot_password": {}, + "generate_reference": "Gerar referência", + "@generate_reference": {}, "geral_registration": "Inscrição Geral", "@geral_registration": {}, "improvement_registration": "Inscrição para Melhoria", "@improvement_registration": {}, + "increment": "Incrementar 1,00€", + "@increment": {}, "keep_login": "Manter sessão iniciada", "@keep_login": {}, "last_refresh_time": "última atualização às {time}", @@ -116,6 +134,8 @@ "@logout": {}, "menus": "Ementas", "@menus": {}, + "min_value_reference": "Valor mínimo: 1,00 €", + "@min_value_reference": {}, "multimedia_center": "Centro de multimédia", "@multimedia_center": {}, "nav_title": "{title, select, horario{Horário} exames{Exames} area{Área Pessoal} cadeiras{Cadeiras} autocarros{Autocarros} locais{Locais} restaurantes{Restaurantes} calendario{Calendário} biblioteca{Biblioteca} uteis{Úteis} sobre{Sobre} bugs{Bugs e Sugestões} other{Outros}}", @@ -126,6 +146,8 @@ "@no_bus": {}, "no_bus_stops": "Não existe nenhuma paragem configurada", "@no_bus_stops": {}, + "no_class": "Não existem turmas para apresentar", + "@no_class": {}, "no_classes": "Não existem aulas para apresentar", "@no_classes": {}, "no_classes_on": "Não possui aulas à", @@ -142,6 +164,10 @@ "@no_exams": {}, "no_exams_label": "Parece que estás de férias!", "@no_exams_label": {}, + "no_favorite_restaurants": "Sem restaurantes favoritos", + "@no_favorite_restaurants": {}, + "no_info": "Não existem informações para apresentar", + "@no_info": {}, "no_menu_info": "Não há informação disponível sobre refeições", "@no_menu_info": {}, "no_menus": "Não há refeições disponíveis", @@ -160,6 +186,8 @@ "@occurrence_type": {}, "other_links": "Outros links", "@other_links": {}, + "pass_change_request": "Por razões de segurança, as palavras-passe têm de ser alteradas periodicamente.", + "@pass_change_request": {}, "password": "palavra-passe", "@password": {}, "pendent_references": "Referências pendentes", @@ -172,6 +200,10 @@ "@print": {}, "problem_id": "Breve identificação do problema", "@problem_id": {}, + "reference_sigarra_help": "Os dados da referência gerada aparecerão no Sigarra, conta corrente.\\nPerfil > Conta Corrente", + "@reference_sigarra_help": {}, + "reference_success": "Referência criada com sucesso!", + "@reference_success": {}, "remove": "Remover", "@remove": {}, "room": "Sala", @@ -184,6 +216,8 @@ "@send": {}, "sent_error": "Ocorreu um erro no envio", "@sent_error": {}, + "some_error": "Algum erro!", + "@some_error": {}, "stcp_stops": "STCP - Próximas Viagens", "@stcp_stops": {}, "student_number": "número de estudante", diff --git a/uni/lib/model/entities/exam.dart b/uni/lib/model/entities/exam.dart index 67ac88576..0d4c61b8b 100644 --- a/uni/lib/model/entities/exam.dart +++ b/uni/lib/model/entities/exam.dart @@ -1,39 +1,6 @@ import 'package:intl/intl.dart'; import 'package:logger/logger.dart'; -enum WeekDays { - monday('Segunda', 'Monday'), - tuesday('Terça', 'Tuesday'), - wednesday('Quarta', 'Wednesday'), - thursday('Quinta', 'Thursday'), - friday('Sexta', 'Friday'), - saturday('Sábado', 'Saturday'), - sunday('Domingo', 'Sunday'); - - const WeekDays(this.dayPT, this.dayEN); - final String dayPT; - final String dayEN; -} - -enum Months { - january('janeiro', 'January'), - february('fevereiro', 'February'), - march('março', 'March'), - april('abril', 'April'), - may('maio', 'May'), - june('junho', 'June'), - july('julho', 'July'), - august('agosto', 'August'), - september('setembro', 'September'), - october('outubro', 'October'), - november('novembro', 'November'), - december('dezembro', 'December'); - - const Months(this.monthPT, this.monthEN); - final String monthPT; - final String monthEN; -} - /// Manages a generic Exam. /// /// The information stored is: @@ -99,19 +66,11 @@ class Exam { String locale = Intl.getCurrentLocale(); String get weekDay { - if (locale == 'pt_PT') { - return WeekDays.values[begin.weekday - 1].dayPT; - } else { - return WeekDays.values[begin.weekday - 1].dayEN; - } + return DateFormat.EEEE(locale).dateSymbols.WEEKDAYS[begin.weekday - 1]; } String get month { - if (locale == 'pt_PT') { - return Months.values[begin.month - 1].monthPT; - } else { - return Months.values[begin.weekday - 1].monthEN; - } + return DateFormat.EEEE(locale).dateSymbols.MONTHS[begin.month - 1]; } String get beginTime => formatTime(begin); diff --git a/uni/lib/view/bug_report/widgets/form.dart b/uni/lib/view/bug_report/widgets/form.dart index c4186d98c..96eccb6c1 100644 --- a/uni/lib/view/bug_report/widgets/form.dart +++ b/uni/lib/view/bug_report/widgets/form.dart @@ -60,16 +60,17 @@ class BugReportFormState extends State { bool _isConsentGiven = false; void loadBugClassList() { - bugList = []; final locale = Intl.getCurrentLocale(); - bugDescriptions.forEach((int key, Tuple2 tup) { - if (locale == 'pt_PT') { - bugList.add(DropdownMenuItem(value: key, child: Text(tup.item1))); - } else { - bugList.add(DropdownMenuItem(value: key, child: Text(tup.item2))); - } - }); + bugList = bugDescriptions.entries + .map( + (entry) => DropdownMenuItem( + value: entry.key, + child: + Text(locale == 'pt_PT' ? entry.value.item1 : entry.value.item2), + ), + ) + .toList(); } @override @@ -264,7 +265,7 @@ class BugReportFormState extends State { bugDescriptions[_selectedBug], faculties, ).toMap(); - String toastMsg; + var toastMsg = ''; bool status; try { final sentryId = await submitSentryEvent(bugReport); @@ -273,13 +274,11 @@ class BugReportFormState extends State { throw Exception('Network error'); } Logger().i('Successfully submitted bug report.'); - // ignore: use_build_context_synchronously - toastMsg = S.of(context).success; + if (context.mounted) toastMsg = S.of(context).success; status = true; } catch (e) { Logger().e('Error while posting bug report:$e'); - // ignore: use_build_context_synchronously - toastMsg = S.of(context).sent_error; + if (context.mounted) toastMsg = S.of(context).sent_error; status = false; } diff --git a/uni/lib/view/course_unit_info/course_unit_info.dart b/uni/lib/view/course_unit_info/course_unit_info.dart index 7c0d61596..ade00b29d 100644 --- a/uni/lib/view/course_unit_info/course_unit_info.dart +++ b/uni/lib/view/course_unit_info/course_unit_info.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/model/entities/course_units/course_unit.dart'; import 'package:uni/model/providers/lazy/course_units_info_provider.dart'; import 'package:uni/model/providers/startup/session_provider.dart'; @@ -67,8 +68,11 @@ class CourseUnitDetailPageViewState center: false, name: widget.courseUnit.name, ), - const TabBar( - tabs: [Tab(text: 'Ficha'), Tab(text: 'Turmas')], + TabBar( + tabs: [ + Tab(text: S.of(context).course_info), + Tab(text: S.of(context).course_class) + ], ), Expanded( child: Padding( @@ -90,9 +94,9 @@ class CourseUnitDetailPageViewState return LazyConsumer( builder: (context, courseUnitsInfoProvider) { return RequestDependentWidgetBuilder( - onNullContent: const Center( + onNullContent: Center( child: Text( - 'Não existem informações para apresentar', + S.of(context).no_info, textAlign: TextAlign.center, ), ), @@ -114,9 +118,9 @@ class CourseUnitDetailPageViewState return LazyConsumer( builder: (context, courseUnitsInfoProvider) { return RequestDependentWidgetBuilder( - onNullContent: const Center( + onNullContent: Center( child: Text( - 'Não existem turmas para apresentar', + S.of(context).no_class, textAlign: TextAlign.center, ), ), diff --git a/uni/lib/view/home/widgets/restaurant_card.dart b/uni/lib/view/home/widgets/restaurant_card.dart index 67d8e583e..77eacada5 100644 --- a/uni/lib/view/home/widgets/restaurant_card.dart +++ b/uni/lib/view/home/widgets/restaurant_card.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/model/entities/meal.dart'; import 'package:uni/model/entities/restaurant.dart'; import 'package:uni/model/providers/lazy/restaurant_provider.dart'; @@ -21,7 +22,8 @@ class RestaurantCard extends GenericCard { }) : super.fromEditingInformation(); @override - String getTitle(BuildContext context) => 'Restaurantes'; + String getTitle(BuildContext context) => + S.of(context).nav_title(DrawerItem.navRestaurants.title); @override Future onClick(BuildContext context) => @@ -53,7 +55,7 @@ class RestaurantCard extends GenericCard { padding: const EdgeInsets.only(top: 15, bottom: 10), child: Center( child: Text( - 'Sem restaurantes favoritos', + S.of(context).no_favorite_restaurants, style: Theme.of(context).textTheme.titleMedium, ), ), @@ -63,7 +65,7 @@ class RestaurantCard extends GenericCard { context, '/${DrawerItem.navRestaurants.title}', ), - child: const Text('Adicionar'), + child: Text(S.of(context).add), ) ], ), diff --git a/uni/lib/view/login/login.dart b/uni/lib/view/login/login.dart index 0663b9d90..600c9498c 100644 --- a/uni/lib/view/login/login.dart +++ b/uni/lib/view/login/login.dart @@ -294,21 +294,20 @@ class LoginPageViewState extends State { context: context, builder: (BuildContext context) { return AlertDialog( - title: const Text('A tua palavra-passe expirou'), + title: Text(S.of(context).expired_password), content: Column( mainAxisSize: MainAxisSize.min, children: [ Text( - 'Por razões de segurança, as palavras-passe têm de ser ' - 'alteradas periodicamente.', + S.of(context).pass_change_request, textAlign: TextAlign.start, style: Theme.of(context).textTheme.titleSmall, ), const SizedBox(height: 20), - const Align( + Align( alignment: Alignment.centerLeft, child: Text( - 'Deseja alterar a palavra-passe?', + S.of(context).change_prompt, textAlign: TextAlign.start, ), ), @@ -316,13 +315,13 @@ class LoginPageViewState extends State { ), actions: [ TextButton( - child: const Text('Cancelar'), + child: Text(S.of(context).cancel), onPressed: () { Navigator.of(context).pop(); }, ), ElevatedButton( - child: const Text('Alterar'), + child: Text(S.of(context).change), onPressed: () async { const url = 'https://self-id.up.pt/password'; if (await canLaunchUrl(Uri.parse(url))) { diff --git a/uni/lib/view/profile/widgets/create_print_mb_dialog.dart b/uni/lib/view/profile/widgets/create_print_mb_dialog.dart index f2fb513e5..51ddddd4a 100644 --- a/uni/lib/view/profile/widgets/create_print_mb_dialog.dart +++ b/uni/lib/view/profile/widgets/create_print_mb_dialog.dart @@ -2,6 +2,7 @@ import 'package:currency_text_input_formatter/currency_text_input_formatter.dart import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:uni/controller/fetchers/print_fetcher.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/model/providers/startup/session_provider.dart'; import 'package:uni/view/common_widgets/toast_message.dart'; @@ -32,9 +33,7 @@ Future addMoneyDialog(BuildContext context) async { Padding( padding: const EdgeInsets.only(top: 5, bottom: 10), child: Text( - 'Os dados da referência gerada aparecerão no Sigarra, ' - 'conta corrente. \n' - 'Perfil > Conta Corrente', + S.of(context).reference_sigarra_help, textAlign: TextAlign.start, style: Theme.of(context).textTheme.titleSmall, ), @@ -43,7 +42,7 @@ Future addMoneyDialog(BuildContext context) async { children: [ IconButton( icon: const Icon(Icons.indeterminate_check_box), - tooltip: 'Decrementar 1,00€', + tooltip: S.of(context).decrement, onPressed: () { final decreasedValue = valueTextToNumber(controller.text) - 1; @@ -83,7 +82,7 @@ Future addMoneyDialog(BuildContext context) async { ), IconButton( icon: const Icon(Icons.add_box), - tooltip: 'Incrementar 1,00€', + tooltip: S.of(context).increment, onPressed: () { controller.value = TextEditingValue( text: numberToValueText( @@ -98,20 +97,20 @@ Future addMoneyDialog(BuildContext context) async { ), ), title: Text( - 'Adicionar quota', + S.of(context).add_quota, style: Theme.of(context).textTheme.headlineSmall, ), actions: [ TextButton( child: Text( - 'Cancelar', + S.of(context).cancel, style: Theme.of(context).textTheme.bodyMedium, ), onPressed: () => Navigator.pop(context), ), ElevatedButton( onPressed: () => generateReference(context, value), - child: const Text('Gerar referência'), + child: Text(S.of(context).generate_reference), ) ], ); @@ -132,7 +131,7 @@ String numberToValueText(double number) => Future generateReference(BuildContext context, double amount) async { if (amount < 1) { - await ToastMessage.warning(context, 'Valor mínimo: 1,00 €'); + await ToastMessage.warning(context, S.of(context).min_value_reference); return; } @@ -142,8 +141,8 @@ Future generateReference(BuildContext context, double amount) async { if (response.statusCode == 200 && context.mounted) { Navigator.of(context).pop(false); - await ToastMessage.success(context, 'Referência criada com sucesso!'); + await ToastMessage.success(context, S.of(context).reference_success); } else { - await ToastMessage.error(context, 'Algum erro!'); + await ToastMessage.error(context, S.of(context).some_error); } } From 707f75a1676a32600a93173bc044ef5495788e37 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Thu, 31 Aug 2023 23:22:12 +0100 Subject: [PATCH 24/50] Login exceptions translation --- uni/ios/Flutter/AppFrameworkInfo.plist | 26 ---- uni/ios/Flutter/Debug.xcconfig | 2 - uni/ios/Flutter/Release.xcconfig | 2 - uni/lib/generated/intl/messages_all.dart | 27 ++-- uni/lib/generated/intl/messages_en.dart | 142 +++++++------------ uni/lib/generated/intl/messages_pt_PT.dart | 8 +- uni/lib/generated/l10n.dart | 41 ++++-- uni/lib/l10n/intl_en.arb | 4 + uni/lib/l10n/intl_pt_PT.arb | 4 + uni/lib/main.dart | 4 +- uni/lib/model/entities/login_exceptions.dart | 7 +- 11 files changed, 120 insertions(+), 147 deletions(-) delete mode 100644 uni/ios/Flutter/AppFrameworkInfo.plist delete mode 100644 uni/ios/Flutter/Debug.xcconfig delete mode 100644 uni/ios/Flutter/Release.xcconfig diff --git a/uni/ios/Flutter/AppFrameworkInfo.plist b/uni/ios/Flutter/AppFrameworkInfo.plist deleted file mode 100644 index 9625e105d..000000000 --- a/uni/ios/Flutter/AppFrameworkInfo.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - App - CFBundleIdentifier - io.flutter.flutter.app - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - App - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1.0 - MinimumOSVersion - 11.0 - - diff --git a/uni/ios/Flutter/Debug.xcconfig b/uni/ios/Flutter/Debug.xcconfig deleted file mode 100644 index ec97fc6f3..000000000 --- a/uni/ios/Flutter/Debug.xcconfig +++ /dev/null @@ -1,2 +0,0 @@ -#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" -#include "Generated.xcconfig" diff --git a/uni/ios/Flutter/Release.xcconfig b/uni/ios/Flutter/Release.xcconfig deleted file mode 100644 index c4855bfe2..000000000 --- a/uni/ios/Flutter/Release.xcconfig +++ /dev/null @@ -1,2 +0,0 @@ -#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" -#include "Generated.xcconfig" diff --git a/uni/lib/generated/intl/messages_all.dart b/uni/lib/generated/intl/messages_all.dart index 5c2bef3d1..6b3ebeae5 100644 --- a/uni/lib/generated/intl/messages_all.dart +++ b/uni/lib/generated/intl/messages_all.dart @@ -15,13 +15,13 @@ import 'package:intl/intl.dart'; import 'package:intl/message_lookup_by_library.dart'; import 'package:intl/src/intl_helpers.dart'; -import 'package:uni/generated/intl/messages_en.dart' as messages_en; -import 'package:uni/generated/intl/messages_pt_PT.dart' as messages_pt_pt; +import 'messages_en.dart' as messages_en; +import 'messages_pt_PT.dart' as messages_pt_pt; typedef Future LibraryLoader(); Map _deferredLibraries = { - 'en': Future.value, - 'pt_PT': Future.value, + 'en': () => new Future.value(null), + 'pt_PT': () => new Future.value(null), }; MessageLookupByLibrary? _findExact(String localeName) { @@ -37,17 +37,15 @@ MessageLookupByLibrary? _findExact(String localeName) { /// User programs should call this before using [localeName] for messages. Future initializeMessages(String localeName) async { - final availableLocale = Intl.verifiedLocale( - localeName, - (locale) => _deferredLibraries[locale] != null, - onFailure: (_) => null, - ); + var availableLocale = Intl.verifiedLocale( + localeName, (locale) => _deferredLibraries[locale] != null, + onFailure: (_) => null); if (availableLocale == null) { return new Future.value(false); } - final lib = _deferredLibraries[availableLocale]; + var lib = _deferredLibraries[availableLocale]; await (lib == null ? new Future.value(false) : lib()); - initializeInternalMessageLookup(CompositeMessageLookup.new); + initializeInternalMessageLookup(() => new CompositeMessageLookup()); messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); return new Future.value(true); } @@ -61,11 +59,8 @@ bool _messagesExistFor(String locale) { } MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { - final actualLocale = Intl.verifiedLocale( - locale, - _messagesExistFor, - onFailure: (_) => null, - ); + var actualLocale = + Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); if (actualLocale == null) return null; return _findExact(actualLocale); } diff --git a/uni/lib/generated/intl/messages_en.dart b/uni/lib/generated/intl/messages_en.dart index 6cb2f58f8..9d5c4f6d3 100644 --- a/uni/lib/generated/intl/messages_en.dart +++ b/uni/lib/generated/intl/messages_en.dart @@ -19,33 +19,29 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'en'; - static String m0(dynamic time) => "last refresh at ${time}"; + static m0(time) => "last refresh at ${time}"; - static String m1(dynamic time) => Intl.plural( - time as num, - zero: 'Refreshed ${time} minutes ago', - one: 'Refreshed ${time} minute ago', - other: 'Refreshed ${time} minutes ago', - ); + static m1(time) => + "${Intl.plural(time as num, zero: 'Refreshed ${time} minutes ago', one: 'Refreshed ${time} minute ago', other: 'Refreshed ${time} minutes ago')}"; - static String m2(String title) => Intl.select(title, { - 'horario': 'Schedule', - 'exames': 'Exams', - 'area': 'Personal Area', - 'cadeiras': 'Course Units', - 'autocarros': 'Buses', - 'locais': 'Places', - 'restaurantes': 'Restaurants', - 'calendario': 'Calendar', - 'biblioteca': 'Library', - 'uteis': 'Utils', - 'sobre': 'About', - 'bugs': 'Bugs/ Suggestions', - 'other': 'Other', - }); + static m2(title) => "${Intl.select(title, { + 'horario': 'Schedule', + 'exames': 'Exams', + 'area': 'Personal Area', + 'cadeiras': 'Course Units', + 'autocarros': 'Buses', + 'locais': 'Places', + 'restaurantes': 'Restaurants', + 'calendario': 'Calendar', + 'biblioteca': 'Library', + 'uteis': 'Utils', + 'sobre': 'About', + 'bugs': 'Bugs/ Suggestions', + 'other': 'Other', + })}"; final messages = _notInlinedMessages(_notInlinedMessages); - static Map _notInlinedMessages(_) => { + static _notInlinedMessages(_) => { "academic_services": MessageLookupByLibrary.simpleMessage("Academic services"), "account_card_title": @@ -54,36 +50,31 @@ class MessageLookup extends MessageLookupByLibrary { "add_quota": MessageLookupByLibrary.simpleMessage("Add quota"), "add_widget": MessageLookupByLibrary.simpleMessage("Add widget"), "agree_terms": MessageLookupByLibrary.simpleMessage( - "By entering you confirm that you agree with these Terms and Conditions", - ), + "By entering you confirm that you agree with these Terms and Conditions"), "all_widgets_added": MessageLookupByLibrary.simpleMessage( - "All available widgets have already been added to your personal area!", - ), + "All available widgets have already been added to your personal area!"), "at_least_one_college": MessageLookupByLibrary.simpleMessage("Select at least one college"), "average": MessageLookupByLibrary.simpleMessage("Average: "), "balance": MessageLookupByLibrary.simpleMessage("Balance:"), "bs_description": MessageLookupByLibrary.simpleMessage( - "Did you find any bugs in the application?\\nDo you have any suggestions for the app?\\nTell us so we can improve!", - ), + "Did you find any bugs in the application?\\nDo you have any suggestions for the app?\\nTell us so we can improve!"), "bug_description": MessageLookupByLibrary.simpleMessage( - "Bug found, how to reproduce it, etc.", - ), + "Bug found, how to reproduce it, etc."), "bus_error": MessageLookupByLibrary.simpleMessage("Unable to get information"), "bus_information": MessageLookupByLibrary.simpleMessage( - "Select the buses you want information about:", - ), + "Select the buses you want information about:"), "buses_personalize": MessageLookupByLibrary.simpleMessage("Personalize your buses here"), "buses_text": MessageLookupByLibrary.simpleMessage( - "Favorite buses will be displayed in the favorites \'Bus\' widget. The remaining ones will only be displayed on the page.", - ), + "Favorite buses will be displayed in the favorites \'Bus\' widget. The remaining ones will only be displayed on the page."), "cancel": MessageLookupByLibrary.simpleMessage("Cancel"), "change": MessageLookupByLibrary.simpleMessage("Change"), "change_prompt": MessageLookupByLibrary.simpleMessage( - "Do you want to change the password?", - ), + "Do you want to change the password?"), + "check_internet": MessageLookupByLibrary.simpleMessage( + "Check your internet connection"), "class_registration": MessageLookupByLibrary.simpleMessage("Class Registration"), "college": MessageLookupByLibrary.simpleMessage("College: "), @@ -94,13 +85,11 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Configured Buses"), "confirm": MessageLookupByLibrary.simpleMessage("Confirm"), "consent": MessageLookupByLibrary.simpleMessage( - "I consent to this information being reviewed by NIAEFEUP and may be deleted at my request.", - ), + "I consent to this information being reviewed by NIAEFEUP and may be deleted at my request."), "contact": MessageLookupByLibrary.simpleMessage("Contact (optional)"), "copy_center": MessageLookupByLibrary.simpleMessage("Copy center"), "copy_center_building": MessageLookupByLibrary.simpleMessage( - "Floor -1 of building B | AEFEUP building", - ), + "Floor -1 of building B | AEFEUP building"), "course_class": MessageLookupByLibrary.simpleMessage("Classes"), "course_info": MessageLookupByLibrary.simpleMessage("Info"), "current_state": @@ -110,14 +99,11 @@ class MessageLookup extends MessageLookupByLibrary { "decrement": MessageLookupByLibrary.simpleMessage("Decrement 1,00€"), "description": MessageLookupByLibrary.simpleMessage("Description"), "desired_email": MessageLookupByLibrary.simpleMessage( - "Email where you want to be contacted", - ), + "Email where you want to be contacted"), "dona_bia": MessageLookupByLibrary.simpleMessage( - "D. Beatriz\'s stationery store", - ), + "D. Beatriz\'s stationery store"), "dona_bia_building": MessageLookupByLibrary.simpleMessage( - "Floor -1 of building B (B-142)", - ), + "Floor -1 of building B (B-142)"), "ects": MessageLookupByLibrary.simpleMessage("ECTs performed: "), "edit_off": MessageLookupByLibrary.simpleMessage("Edit"), "edit_on": MessageLookupByLibrary.simpleMessage("Finish editing"), @@ -133,8 +119,7 @@ class MessageLookup extends MessageLookupByLibrary { "fee_notification": MessageLookupByLibrary.simpleMessage("Notify next deadline:"), "first_year_registration": MessageLookupByLibrary.simpleMessage( - "Year of first registration: ", - ), + "Year of first registration: "), "floor": MessageLookupByLibrary.simpleMessage("Floor"), "floors": MessageLookupByLibrary.simpleMessage("Floors"), "forgot_password": @@ -146,14 +131,15 @@ class MessageLookup extends MessageLookupByLibrary { "improvement_registration": MessageLookupByLibrary.simpleMessage("Enrollment for Improvement"), "increment": MessageLookupByLibrary.simpleMessage("Increment 1,00€"), + "invalid_credentials": + MessageLookupByLibrary.simpleMessage("Invalid credentials"), "keep_login": MessageLookupByLibrary.simpleMessage("Stay signed in"), "last_refresh_time": m0, "last_timestamp": m1, "library_occupation": MessageLookupByLibrary.simpleMessage("Library Occupation"), "loading_terms": MessageLookupByLibrary.simpleMessage( - "Loading Terms and Conditions...", - ), + "Loading Terms and Conditions..."), "login": MessageLookupByLibrary.simpleMessage("Login"), "logout": MessageLookupByLibrary.simpleMessage("Log out"), "menus": MessageLookupByLibrary.simpleMessage("Menus"), @@ -167,55 +153,43 @@ class MessageLookup extends MessageLookupByLibrary { "no_bus_stops": MessageLookupByLibrary.simpleMessage("No configured stops"), "no_class": MessageLookupByLibrary.simpleMessage( - "There are no classes to display", - ), + "There are no classes to display"), "no_classes": MessageLookupByLibrary.simpleMessage("No classes to present"), "no_classes_on": MessageLookupByLibrary.simpleMessage("You don\'t have classes on"), "no_college": MessageLookupByLibrary.simpleMessage("no college"), "no_course_units": MessageLookupByLibrary.simpleMessage( - "No course units in the selected period", - ), + "No course units in the selected period"), "no_data": MessageLookupByLibrary.simpleMessage( - "There is no data to show at this time", - ), + "There is no data to show at this time"), "no_date": MessageLookupByLibrary.simpleMessage("No date"), "no_exams": MessageLookupByLibrary.simpleMessage( - "You have no exams scheduled\n", - ), + "You have no exams scheduled\n"), "no_exams_label": MessageLookupByLibrary.simpleMessage( - "Looks like you are on vacation!", - ), + "Looks like you are on vacation!"), "no_favorite_restaurants": MessageLookupByLibrary.simpleMessage("No favorite restaurants"), "no_info": MessageLookupByLibrary.simpleMessage( - "There is no information to display", - ), + "There is no information to display"), "no_menu_info": MessageLookupByLibrary.simpleMessage( - "There is no information available about meals", - ), + "There is no information available about meals"), "no_menus": MessageLookupByLibrary.simpleMessage( - "There are no meals available", - ), + "There are no meals available"), "no_name_course": MessageLookupByLibrary.simpleMessage("Unnamed course"), "no_references": MessageLookupByLibrary.simpleMessage( - "There are no references to pay", - ), + "There are no references to pay"), "no_results": MessageLookupByLibrary.simpleMessage("No match"), "no_selected_courses": MessageLookupByLibrary.simpleMessage( - "There are no course units to display", - ), + "There are no course units to display"), "no_selected_exams": MessageLookupByLibrary.simpleMessage( - "There are no exams to present", - ), + "There are no exams to present"), "occurrence_type": MessageLookupByLibrary.simpleMessage("Type of occurrence"), "other_links": MessageLookupByLibrary.simpleMessage("Other links"), "pass_change_request": MessageLookupByLibrary.simpleMessage( - "For security reasons, passwords must be changed periodically.", - ), + "For security reasons, passwords must be changed periodically."), "password": MessageLookupByLibrary.simpleMessage("password"), "pendent_references": MessageLookupByLibrary.simpleMessage("Pending references"), @@ -225,14 +199,11 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Press again to exit"), "print": MessageLookupByLibrary.simpleMessage("Print"), "problem_id": MessageLookupByLibrary.simpleMessage( - "Brief identification of the problem", - ), + "Brief identification of the problem"), "reference_sigarra_help": MessageLookupByLibrary.simpleMessage( - "The generated reference data will appear in Sigarra, checking account.\\nProfile > Checking Account", - ), + "The generated reference data will appear in Sigarra, checking account.\\nProfile > Checking Account"), "reference_success": MessageLookupByLibrary.simpleMessage( - "Reference created successfully!", - ), + "Reference created successfully!"), "remove": MessageLookupByLibrary.simpleMessage("Delete"), "room": MessageLookupByLibrary.simpleMessage("Room"), "school_calendar": @@ -240,8 +211,7 @@ class MessageLookup extends MessageLookupByLibrary { "semester": MessageLookupByLibrary.simpleMessage("Semester"), "send": MessageLookupByLibrary.simpleMessage("Send"), "sent_error": MessageLookupByLibrary.simpleMessage( - "An error occurred in sending", - ), + "An error occurred in sending"), "some_error": MessageLookupByLibrary.simpleMessage("Some error!"), "stcp_stops": MessageLookupByLibrary.simpleMessage("STCP - Upcoming Trips"), @@ -251,8 +221,7 @@ class MessageLookup extends MessageLookupByLibrary { "tele_assistance": MessageLookupByLibrary.simpleMessage("Telephone assistance"), "tele_personal_assistance": MessageLookupByLibrary.simpleMessage( - "Face-to-face and telephone assistance", - ), + "Face-to-face and telephone assistance"), "telephone": MessageLookupByLibrary.simpleMessage("Telephone"), "terms": MessageLookupByLibrary.simpleMessage("Terms and Conditions"), "title": MessageLookupByLibrary.simpleMessage("Title"), @@ -260,8 +229,7 @@ class MessageLookup extends MessageLookupByLibrary { "valid_email": MessageLookupByLibrary.simpleMessage("Please enter a valid email"), "widget_prompt": MessageLookupByLibrary.simpleMessage( - "Choose a widget to add to your personal area:", - ), + "Choose a widget to add to your personal area:"), "year": MessageLookupByLibrary.simpleMessage("Year") }; } diff --git a/uni/lib/generated/intl/messages_pt_PT.dart b/uni/lib/generated/intl/messages_pt_PT.dart index 297fff62c..d47d3f4d9 100644 --- a/uni/lib/generated/intl/messages_pt_PT.dart +++ b/uni/lib/generated/intl/messages_pt_PT.dart @@ -24,7 +24,7 @@ class MessageLookup extends MessageLookupByLibrary { static m1(time) => "${Intl.plural(time as num, zero: 'Atualizado há ${time} minutos', one: 'Atualizado há ${time} minuto', other: 'Atualizado há ${time} minutos')}"; - static m2(String title) => "${Intl.select(title, { + static m2(title) => "${Intl.select(title, { 'horario': 'Horário', 'exames': 'Exames', 'area': 'Área Pessoal', @@ -41,7 +41,7 @@ class MessageLookup extends MessageLookupByLibrary { })}"; final messages = _notInlinedMessages(_notInlinedMessages); - static Map _notInlinedMessages(_) => { + static _notInlinedMessages(_) => { "academic_services": MessageLookupByLibrary.simpleMessage("Serviços académicos"), "account_card_title": @@ -73,6 +73,8 @@ class MessageLookup extends MessageLookupByLibrary { "change": MessageLookupByLibrary.simpleMessage("Alterar"), "change_prompt": MessageLookupByLibrary.simpleMessage( "Deseja alterar a palavra-passe?"), + "check_internet": MessageLookupByLibrary.simpleMessage( + "Verifica a tua ligação à internet"), "class_registration": MessageLookupByLibrary.simpleMessage("Inscrição de Turmas"), "college": MessageLookupByLibrary.simpleMessage("Faculdade: "), @@ -128,6 +130,8 @@ class MessageLookup extends MessageLookupByLibrary { "improvement_registration": MessageLookupByLibrary.simpleMessage("Inscrição para Melhoria"), "increment": MessageLookupByLibrary.simpleMessage("Incrementar 1,00€"), + "invalid_credentials": + MessageLookupByLibrary.simpleMessage("Credenciais inválidas"), "keep_login": MessageLookupByLibrary.simpleMessage("Manter sessão iniciada"), "last_refresh_time": m0, diff --git a/uni/lib/generated/l10n.dart b/uni/lib/generated/l10n.dart index a0ac95cfd..7b45c0e86 100644 --- a/uni/lib/generated/l10n.dart +++ b/uni/lib/generated/l10n.dart @@ -18,28 +18,31 @@ class S { static S? _current; static S get current { - assert(_current != null, 'No instance of S was loaded. Try to initialize the S delegate before accessing S.current.'); + assert(_current != null, + 'No instance of S was loaded. Try to initialize the S delegate before accessing S.current.'); return _current!; } - static const AppLocalizationDelegate delegate = - AppLocalizationDelegate(); + static const AppLocalizationDelegate delegate = AppLocalizationDelegate(); static Future load(Locale locale) { - final name = (locale.countryCode?.isEmpty ?? false) ? locale.languageCode : locale.toString(); - final localeName = Intl.canonicalizedLocale(name); + final name = (locale.countryCode?.isEmpty ?? false) + ? locale.languageCode + : locale.toString(); + final localeName = Intl.canonicalizedLocale(name); return initializeMessages(localeName).then((_) { Intl.defaultLocale = localeName; final instance = S(); S._current = instance; - + return instance; }); - } + } static S of(BuildContext context) { final instance = S.maybeOf(context); - assert(instance != null, 'No instance of S present in the widget tree. Did you add S.delegate in localizationsDelegates?'); + assert(instance != null, + 'No instance of S present in the widget tree. Did you add S.delegate in localizationsDelegates?'); return instance!; } @@ -237,6 +240,16 @@ class S { ); } + /// `Check your internet connection` + String get check_internet { + return Intl.message( + 'Check your internet connection', + name: 'check_internet', + desc: '', + args: [], + ); + } + /// `Classes` String get course_class { return Intl.message( @@ -597,6 +610,16 @@ class S { ); } + /// `Invalid credentials` + String get invalid_credentials { + return Intl.message( + 'Invalid credentials', + name: 'invalid_credentials', + desc: '', + args: [], + ); + } + /// `Stay signed in` String get keep_login { return Intl.message( @@ -1261,4 +1284,4 @@ class AppLocalizationDelegate extends LocalizationsDelegate { } return false; } -} \ No newline at end of file +} diff --git a/uni/lib/l10n/intl_en.arb b/uni/lib/l10n/intl_en.arb index d96cf6deb..d63ce3056 100644 --- a/uni/lib/l10n/intl_en.arb +++ b/uni/lib/l10n/intl_en.arb @@ -38,6 +38,8 @@ "@change": {}, "change_prompt": "Do you want to change the password?", "@change_prompt": {}, + "check_internet": "Check your internet connection", + "@check_internet": {}, "course_class": "Classes", "@course_class": {}, "class_registration": "Class Registration", @@ -110,6 +112,8 @@ "@improvement_registration": {}, "increment": "Increment 1,00€", "@increment": {}, + "invalid_credentials": "Invalid credentials", + "@invalid_credentials": {}, "keep_login": "Stay signed in", "@keep_login": {}, "last_refresh_time": "last refresh at {time}", diff --git a/uni/lib/l10n/intl_pt_PT.arb b/uni/lib/l10n/intl_pt_PT.arb index e25bfbea9..eaf6e2829 100644 --- a/uni/lib/l10n/intl_pt_PT.arb +++ b/uni/lib/l10n/intl_pt_PT.arb @@ -38,6 +38,8 @@ "@change": {}, "change_prompt": "Deseja alterar a palavra-passe?", "@change_prompt": {}, + "check_internet": "Verifica a tua ligação à internet", + "@check_internet": {}, "course_class": "Turmas", "@course_class": {}, "class_registration": "Inscrição de Turmas", @@ -110,6 +112,8 @@ "@improvement_registration": {}, "increment": "Incrementar 1,00€", "@increment": {}, + "invalid_credentials": "Credenciais inválidas", + "@invalid_credentials": {}, "keep_login": "Manter sessão iniciada", "@keep_login": {}, "last_refresh_time": "última atualização às {time}", diff --git a/uni/lib/main.dart b/uni/lib/main.dart index c576d4b55..66d95888c 100644 --- a/uni/lib/main.dart +++ b/uni/lib/main.dart @@ -170,6 +170,8 @@ class MyApp extends StatefulWidget { State createState() => MyAppState(); } +final GlobalKey navigatorKey = GlobalKey(); + /// Manages the app depending on its current state class MyAppState extends State { @override @@ -192,7 +194,7 @@ class MyAppState extends State { ], supportedLocales: S.delegate.supportedLocales, initialRoute: widget.initialRoute, - navigatorKey: NavigationService.navigatorKey, + navigatorKey: navigatorKey, onGenerateRoute: (RouteSettings settings) { final transitions = { '/${DrawerItem.navPersonalArea.title}': diff --git a/uni/lib/model/entities/login_exceptions.dart b/uni/lib/model/entities/login_exceptions.dart index c170f6405..74ab67a01 100644 --- a/uni/lib/model/entities/login_exceptions.dart +++ b/uni/lib/model/entities/login_exceptions.dart @@ -1,13 +1,16 @@ +import 'package:uni/generated/l10n.dart'; +import 'package:uni/main.dart'; + class ExpiredCredentialsException implements Exception { ExpiredCredentialsException(); } class InternetStatusException implements Exception { InternetStatusException(); - String message = 'Verifica a tua ligação à internet'; + String message = S.of(navigatorKey.currentContext!).check_internet; } class WrongCredentialsException implements Exception { WrongCredentialsException(); - String message = 'Credenciais inválidas'; + String message = S.of(navigatorKey.currentContext!).invalid_credentials; } From 5b16bd0c9b596e0d5abf05df64d3a3db2135a735 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Thu, 31 Aug 2023 23:25:16 +0100 Subject: [PATCH 25/50] Commit error fix --- uni/ios/Flutter/AppFrameworkInfo.plist | 26 ++++++++++++++++++++++++++ uni/ios/Flutter/Debug.xcconfig | 2 ++ uni/ios/Flutter/Release.xcconfig | 2 ++ 3 files changed, 30 insertions(+) create mode 100644 uni/ios/Flutter/AppFrameworkInfo.plist create mode 100644 uni/ios/Flutter/Debug.xcconfig create mode 100644 uni/ios/Flutter/Release.xcconfig diff --git a/uni/ios/Flutter/AppFrameworkInfo.plist b/uni/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 000000000..9625e105d --- /dev/null +++ b/uni/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 11.0 + + diff --git a/uni/ios/Flutter/Debug.xcconfig b/uni/ios/Flutter/Debug.xcconfig new file mode 100644 index 000000000..ec97fc6f3 --- /dev/null +++ b/uni/ios/Flutter/Debug.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include "Generated.xcconfig" diff --git a/uni/ios/Flutter/Release.xcconfig b/uni/ios/Flutter/Release.xcconfig new file mode 100644 index 000000000..c4855bfe2 --- /dev/null +++ b/uni/ios/Flutter/Release.xcconfig @@ -0,0 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include "Generated.xcconfig" From 9172bc69eee534ae6b2e0a4e7986c97eabc32e2c Mon Sep 17 00:00:00 2001 From: DGoiana Date: Sun, 3 Sep 2023 21:31:12 +0100 Subject: [PATCH 26/50] Code cleaning --- uni/analysis_options.yaml | 2 +- uni/lib/generated/intl/messages_en.dart | 4 ++-- uni/lib/generated/intl/messages_pt_PT.dart | 4 ++-- uni/lib/view/locale_notifier.dart | 16 +++++++--------- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/uni/analysis_options.yaml b/uni/analysis_options.yaml index 6df16fd8f..f66e9c4bf 100644 --- a/uni/analysis_options.yaml +++ b/uni/analysis_options.yaml @@ -4,7 +4,7 @@ analyzer: # Exclude auto-generated files from dart analysis exclude: - "**.g.dart" - - "/lib/generated/**.dart" + - "uni/lib/generated/**.dart" # Custom linter rules. A list of all rules can be found at # https://dart-lang.github.io/linter/lints/options/options.html diff --git a/uni/lib/generated/intl/messages_en.dart b/uni/lib/generated/intl/messages_en.dart index 9d5c4f6d3..7ca67d707 100644 --- a/uni/lib/generated/intl/messages_en.dart +++ b/uni/lib/generated/intl/messages_en.dart @@ -24,7 +24,7 @@ class MessageLookup extends MessageLookupByLibrary { static m1(time) => "${Intl.plural(time as num, zero: 'Refreshed ${time} minutes ago', one: 'Refreshed ${time} minute ago', other: 'Refreshed ${time} minutes ago')}"; - static m2(title) => "${Intl.select(title, { + static m2(String title) => "${Intl.select(title, { 'horario': 'Schedule', 'exames': 'Exams', 'area': 'Personal Area', @@ -41,7 +41,7 @@ class MessageLookup extends MessageLookupByLibrary { })}"; final messages = _notInlinedMessages(_notInlinedMessages); - static _notInlinedMessages(_) => { + static Map _notInlinedMessages(_) => { "academic_services": MessageLookupByLibrary.simpleMessage("Academic services"), "account_card_title": diff --git a/uni/lib/generated/intl/messages_pt_PT.dart b/uni/lib/generated/intl/messages_pt_PT.dart index d47d3f4d9..38e5b71e0 100644 --- a/uni/lib/generated/intl/messages_pt_PT.dart +++ b/uni/lib/generated/intl/messages_pt_PT.dart @@ -24,7 +24,7 @@ class MessageLookup extends MessageLookupByLibrary { static m1(time) => "${Intl.plural(time as num, zero: 'Atualizado há ${time} minutos', one: 'Atualizado há ${time} minuto', other: 'Atualizado há ${time} minutos')}"; - static m2(title) => "${Intl.select(title, { + static m2(String title) => "${Intl.select(title, { 'horario': 'Horário', 'exames': 'Exames', 'area': 'Área Pessoal', @@ -41,7 +41,7 @@ class MessageLookup extends MessageLookupByLibrary { })}"; final messages = _notInlinedMessages(_notInlinedMessages); - static _notInlinedMessages(_) => { + static Map _notInlinedMessages(_) => { "academic_services": MessageLookupByLibrary.simpleMessage("Serviços académicos"), "account_card_title": diff --git a/uni/lib/view/locale_notifier.dart b/uni/lib/view/locale_notifier.dart index 109c9c4d2..6e8df082e 100644 --- a/uni/lib/view/locale_notifier.dart +++ b/uni/lib/view/locale_notifier.dart @@ -24,15 +24,13 @@ class LocaleNotifier with ChangeNotifier { } List getWeekdaysWithLocale() { - final weekdays = []; - for (final weekday - in DateFormat.EEEE(_locale.languageCode).dateSymbols.WEEKDAYS) { - weekdays.add(weekday[0].toUpperCase() + weekday.substring(1)); - } - weekdays.removeAt(0); - weekdays[5] == 'Saturday' - ? weekdays.add('Sunday') - : weekdays.add('Domingo'); + final weekdays = DateFormat.EEEE(_locale.languageCode) + .dateSymbols + .WEEKDAYS + .skip(1) + .map((weekday) => weekday[0].toUpperCase() + weekday.substring(1)) + .toList() + ..add(_locale.languageCode == 'en' ? 'Sunday' : 'Domingo'); return weekdays; } } From 38b958efbd3fc2ac863154d3fc3df0f21341960f Mon Sep 17 00:00:00 2001 From: DGoiana Date: Sun, 3 Sep 2023 21:40:05 +0100 Subject: [PATCH 27/50] Lint fixing --- uni/analysis_options.yaml | 1 - uni/lib/generated/intl/messages_all.dart | 22 +-- uni/lib/generated/intl/messages_en.dart | 145 +++++++++++------- uni/lib/generated/intl/messages_pt_PT.dart | 162 +++++++++++++-------- uni/lib/generated/l10n.dart | 22 +-- 5 files changed, 219 insertions(+), 133 deletions(-) diff --git a/uni/analysis_options.yaml b/uni/analysis_options.yaml index f66e9c4bf..92d895f92 100644 --- a/uni/analysis_options.yaml +++ b/uni/analysis_options.yaml @@ -4,7 +4,6 @@ analyzer: # Exclude auto-generated files from dart analysis exclude: - "**.g.dart" - - "uni/lib/generated/**.dart" # Custom linter rules. A list of all rules can be found at # https://dart-lang.github.io/linter/lints/options/options.html diff --git a/uni/lib/generated/intl/messages_all.dart b/uni/lib/generated/intl/messages_all.dart index 6b3ebeae5..de96ef7c8 100644 --- a/uni/lib/generated/intl/messages_all.dart +++ b/uni/lib/generated/intl/messages_all.dart @@ -15,13 +15,13 @@ import 'package:intl/intl.dart'; import 'package:intl/message_lookup_by_library.dart'; import 'package:intl/src/intl_helpers.dart'; -import 'messages_en.dart' as messages_en; -import 'messages_pt_PT.dart' as messages_pt_pt; +import 'package:uni/generated/intl/messages_en.dart' as messages_en; +import 'package:uni/generated/intl/messages_pt_PT.dart' as messages_pt_pt; typedef Future LibraryLoader(); Map _deferredLibraries = { - 'en': () => new Future.value(null), - 'pt_PT': () => new Future.value(null), + 'en': Future.value, + 'pt_PT': Future.value, }; MessageLookupByLibrary? _findExact(String localeName) { @@ -37,15 +37,17 @@ MessageLookupByLibrary? _findExact(String localeName) { /// User programs should call this before using [localeName] for messages. Future initializeMessages(String localeName) async { - var availableLocale = Intl.verifiedLocale( - localeName, (locale) => _deferredLibraries[locale] != null, - onFailure: (_) => null); + final availableLocale = Intl.verifiedLocale( + localeName, + (locale) => _deferredLibraries[locale] != null, + onFailure: (_) => null, + ); if (availableLocale == null) { return new Future.value(false); } - var lib = _deferredLibraries[availableLocale]; + final lib = _deferredLibraries[availableLocale]; await (lib == null ? new Future.value(false) : lib()); - initializeInternalMessageLookup(() => new CompositeMessageLookup()); + initializeInternalMessageLookup(CompositeMessageLookup.new); messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); return new Future.value(true); } @@ -59,7 +61,7 @@ bool _messagesExistFor(String locale) { } MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { - var actualLocale = + final actualLocale = Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); if (actualLocale == null) return null; return _findExact(actualLocale); diff --git a/uni/lib/generated/intl/messages_en.dart b/uni/lib/generated/intl/messages_en.dart index 7ca67d707..908784164 100644 --- a/uni/lib/generated/intl/messages_en.dart +++ b/uni/lib/generated/intl/messages_en.dart @@ -4,7 +4,7 @@ // function name. // Ignore issues from commonly used lints in this file. -// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new +// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new, lines_longer_than_80_chars // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases // ignore_for_file:unused_import, file_names @@ -19,26 +19,30 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'en'; - static m0(time) => "last refresh at ${time}"; + static String m0(dynamic time) => "last refresh at ${time}"; - static m1(time) => - "${Intl.plural(time as num, zero: 'Refreshed ${time} minutes ago', one: 'Refreshed ${time} minute ago', other: 'Refreshed ${time} minutes ago')}"; + static String m1(dynamic time) => Intl.plural( + time as num, + zero: 'Refreshed ${time} minutes ago', + one: 'Refreshed ${time} minute ago', + other: 'Refreshed ${time} minutes ago', + ); - static m2(String title) => "${Intl.select(title, { - 'horario': 'Schedule', - 'exames': 'Exams', - 'area': 'Personal Area', - 'cadeiras': 'Course Units', - 'autocarros': 'Buses', - 'locais': 'Places', - 'restaurantes': 'Restaurants', - 'calendario': 'Calendar', - 'biblioteca': 'Library', - 'uteis': 'Utils', - 'sobre': 'About', - 'bugs': 'Bugs/ Suggestions', - 'other': 'Other', - })}"; + static String m2(String title) => Intl.select(title, { + 'horario': 'Schedule', + 'exames': 'Exams', + 'area': 'Personal Area', + 'cadeiras': 'Course Units', + 'autocarros': 'Buses', + 'locais': 'Places', + 'restaurantes': 'Restaurants', + 'calendario': 'Calendar', + 'biblioteca': 'Library', + 'uteis': 'Utils', + 'sobre': 'About', + 'bugs': 'Bugs/ Suggestions', + 'other': 'Other', + }); final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { @@ -50,31 +54,39 @@ class MessageLookup extends MessageLookupByLibrary { "add_quota": MessageLookupByLibrary.simpleMessage("Add quota"), "add_widget": MessageLookupByLibrary.simpleMessage("Add widget"), "agree_terms": MessageLookupByLibrary.simpleMessage( - "By entering you confirm that you agree with these Terms and Conditions"), + "By entering you confirm that you agree with these Terms and Conditions", + ), "all_widgets_added": MessageLookupByLibrary.simpleMessage( - "All available widgets have already been added to your personal area!"), + "All available widgets have already been added to your personal area!", + ), "at_least_one_college": MessageLookupByLibrary.simpleMessage("Select at least one college"), "average": MessageLookupByLibrary.simpleMessage("Average: "), "balance": MessageLookupByLibrary.simpleMessage("Balance:"), "bs_description": MessageLookupByLibrary.simpleMessage( - "Did you find any bugs in the application?\\nDo you have any suggestions for the app?\\nTell us so we can improve!"), + r"Did you find any bugs in the application?\nDo you have any suggestions for the app?\nTell us so we can improve!", + ), "bug_description": MessageLookupByLibrary.simpleMessage( - "Bug found, how to reproduce it, etc."), + "Bug found, how to reproduce it, etc.", + ), "bus_error": MessageLookupByLibrary.simpleMessage("Unable to get information"), "bus_information": MessageLookupByLibrary.simpleMessage( - "Select the buses you want information about:"), + "Select the buses you want information about:", + ), "buses_personalize": MessageLookupByLibrary.simpleMessage("Personalize your buses here"), "buses_text": MessageLookupByLibrary.simpleMessage( - "Favorite buses will be displayed in the favorites \'Bus\' widget. The remaining ones will only be displayed on the page."), + "Favorite buses will be displayed in the favorites 'Bus' widget. The remaining ones will only be displayed on the page.", + ), "cancel": MessageLookupByLibrary.simpleMessage("Cancel"), "change": MessageLookupByLibrary.simpleMessage("Change"), "change_prompt": MessageLookupByLibrary.simpleMessage( - "Do you want to change the password?"), + "Do you want to change the password?", + ), "check_internet": MessageLookupByLibrary.simpleMessage( - "Check your internet connection"), + "Check your internet connection", + ), "class_registration": MessageLookupByLibrary.simpleMessage("Class Registration"), "college": MessageLookupByLibrary.simpleMessage("College: "), @@ -85,11 +97,13 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Configured Buses"), "confirm": MessageLookupByLibrary.simpleMessage("Confirm"), "consent": MessageLookupByLibrary.simpleMessage( - "I consent to this information being reviewed by NIAEFEUP and may be deleted at my request."), + "I consent to this information being reviewed by NIAEFEUP and may be deleted at my request.", + ), "contact": MessageLookupByLibrary.simpleMessage("Contact (optional)"), "copy_center": MessageLookupByLibrary.simpleMessage("Copy center"), "copy_center_building": MessageLookupByLibrary.simpleMessage( - "Floor -1 of building B | AEFEUP building"), + "Floor -1 of building B | AEFEUP building", + ), "course_class": MessageLookupByLibrary.simpleMessage("Classes"), "course_info": MessageLookupByLibrary.simpleMessage("Info"), "current_state": @@ -99,11 +113,14 @@ class MessageLookup extends MessageLookupByLibrary { "decrement": MessageLookupByLibrary.simpleMessage("Decrement 1,00€"), "description": MessageLookupByLibrary.simpleMessage("Description"), "desired_email": MessageLookupByLibrary.simpleMessage( - "Email where you want to be contacted"), + "Email where you want to be contacted", + ), "dona_bia": MessageLookupByLibrary.simpleMessage( - "D. Beatriz\'s stationery store"), + "D. Beatriz's stationery store", + ), "dona_bia_building": MessageLookupByLibrary.simpleMessage( - "Floor -1 of building B (B-142)"), + "Floor -1 of building B (B-142)", + ), "ects": MessageLookupByLibrary.simpleMessage("ECTs performed: "), "edit_off": MessageLookupByLibrary.simpleMessage("Edit"), "edit_on": MessageLookupByLibrary.simpleMessage("Finish editing"), @@ -119,7 +136,8 @@ class MessageLookup extends MessageLookupByLibrary { "fee_notification": MessageLookupByLibrary.simpleMessage("Notify next deadline:"), "first_year_registration": MessageLookupByLibrary.simpleMessage( - "Year of first registration: "), + "Year of first registration: ", + ), "floor": MessageLookupByLibrary.simpleMessage("Floor"), "floors": MessageLookupByLibrary.simpleMessage("Floors"), "forgot_password": @@ -139,7 +157,8 @@ class MessageLookup extends MessageLookupByLibrary { "library_occupation": MessageLookupByLibrary.simpleMessage("Library Occupation"), "loading_terms": MessageLookupByLibrary.simpleMessage( - "Loading Terms and Conditions..."), + "Loading Terms and Conditions...", + ), "login": MessageLookupByLibrary.simpleMessage("Login"), "logout": MessageLookupByLibrary.simpleMessage("Log out"), "menus": MessageLookupByLibrary.simpleMessage("Menus"), @@ -149,47 +168,59 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Multimedia center"), "nav_title": m2, "news": MessageLookupByLibrary.simpleMessage("News"), - "no_bus": MessageLookupByLibrary.simpleMessage("Don\'t miss any bus!"), + "no_bus": MessageLookupByLibrary.simpleMessage("Don't miss any bus!"), "no_bus_stops": MessageLookupByLibrary.simpleMessage("No configured stops"), "no_class": MessageLookupByLibrary.simpleMessage( - "There are no classes to display"), + "There are no classes to display", + ), "no_classes": MessageLookupByLibrary.simpleMessage("No classes to present"), "no_classes_on": - MessageLookupByLibrary.simpleMessage("You don\'t have classes on"), + MessageLookupByLibrary.simpleMessage("You don't have classes on"), "no_college": MessageLookupByLibrary.simpleMessage("no college"), "no_course_units": MessageLookupByLibrary.simpleMessage( - "No course units in the selected period"), + "No course units in the selected period", + ), "no_data": MessageLookupByLibrary.simpleMessage( - "There is no data to show at this time"), + "There is no data to show at this time", + ), "no_date": MessageLookupByLibrary.simpleMessage("No date"), "no_exams": MessageLookupByLibrary.simpleMessage( - "You have no exams scheduled\n"), + "You have no exams scheduled\n", + ), "no_exams_label": MessageLookupByLibrary.simpleMessage( - "Looks like you are on vacation!"), + "Looks like you are on vacation!", + ), "no_favorite_restaurants": MessageLookupByLibrary.simpleMessage("No favorite restaurants"), "no_info": MessageLookupByLibrary.simpleMessage( - "There is no information to display"), + "There is no information to display", + ), "no_menu_info": MessageLookupByLibrary.simpleMessage( - "There is no information available about meals"), + "There is no information available about meals", + ), "no_menus": MessageLookupByLibrary.simpleMessage( - "There are no meals available"), + "There are no meals available", + ), "no_name_course": MessageLookupByLibrary.simpleMessage("Unnamed course"), "no_references": MessageLookupByLibrary.simpleMessage( - "There are no references to pay"), + "There are no references to pay", + ), "no_results": MessageLookupByLibrary.simpleMessage("No match"), "no_selected_courses": MessageLookupByLibrary.simpleMessage( - "There are no course units to display"), + "There are no course units to display", + ), "no_selected_exams": MessageLookupByLibrary.simpleMessage( - "There are no exams to present"), + "There are no exams to present", + ), "occurrence_type": MessageLookupByLibrary.simpleMessage("Type of occurrence"), "other_links": MessageLookupByLibrary.simpleMessage("Other links"), "pass_change_request": MessageLookupByLibrary.simpleMessage( - "For security reasons, passwords must be changed periodically."), + "For security reasons, passwords must be changed periodically.", + ), "password": MessageLookupByLibrary.simpleMessage("password"), "pendent_references": MessageLookupByLibrary.simpleMessage("Pending references"), @@ -199,11 +230,14 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Press again to exit"), "print": MessageLookupByLibrary.simpleMessage("Print"), "problem_id": MessageLookupByLibrary.simpleMessage( - "Brief identification of the problem"), + "Brief identification of the problem", + ), "reference_sigarra_help": MessageLookupByLibrary.simpleMessage( - "The generated reference data will appear in Sigarra, checking account.\\nProfile > Checking Account"), + r"The generated reference data will appear in Sigarra, checking account.\nProfile > Checking Account", + ), "reference_success": MessageLookupByLibrary.simpleMessage( - "Reference created successfully!"), + "Reference created successfully!", + ), "remove": MessageLookupByLibrary.simpleMessage("Delete"), "room": MessageLookupByLibrary.simpleMessage("Room"), "school_calendar": @@ -211,7 +245,8 @@ class MessageLookup extends MessageLookupByLibrary { "semester": MessageLookupByLibrary.simpleMessage("Semester"), "send": MessageLookupByLibrary.simpleMessage("Send"), "sent_error": MessageLookupByLibrary.simpleMessage( - "An error occurred in sending"), + "An error occurred in sending", + ), "some_error": MessageLookupByLibrary.simpleMessage("Some error!"), "stcp_stops": MessageLookupByLibrary.simpleMessage("STCP - Upcoming Trips"), @@ -221,7 +256,8 @@ class MessageLookup extends MessageLookupByLibrary { "tele_assistance": MessageLookupByLibrary.simpleMessage("Telephone assistance"), "tele_personal_assistance": MessageLookupByLibrary.simpleMessage( - "Face-to-face and telephone assistance"), + "Face-to-face and telephone assistance", + ), "telephone": MessageLookupByLibrary.simpleMessage("Telephone"), "terms": MessageLookupByLibrary.simpleMessage("Terms and Conditions"), "title": MessageLookupByLibrary.simpleMessage("Title"), @@ -229,7 +265,8 @@ class MessageLookup extends MessageLookupByLibrary { "valid_email": MessageLookupByLibrary.simpleMessage("Please enter a valid email"), "widget_prompt": MessageLookupByLibrary.simpleMessage( - "Choose a widget to add to your personal area:"), + "Choose a widget to add to your personal area:", + ), "year": MessageLookupByLibrary.simpleMessage("Year") }; } diff --git a/uni/lib/generated/intl/messages_pt_PT.dart b/uni/lib/generated/intl/messages_pt_PT.dart index 38e5b71e0..8a36505af 100644 --- a/uni/lib/generated/intl/messages_pt_PT.dart +++ b/uni/lib/generated/intl/messages_pt_PT.dart @@ -4,7 +4,7 @@ // function name. // Ignore issues from commonly used lints in this file. -// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new +// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new, lines_longer_than_80_chars // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases // ignore_for_file:unused_import, file_names @@ -19,26 +19,30 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'pt_PT'; - static m0(time) => "última atualização às ${time}"; + static String m0(dynamic time) => "última atualização às ${time}"; - static m1(time) => - "${Intl.plural(time as num, zero: 'Atualizado há ${time} minutos', one: 'Atualizado há ${time} minuto', other: 'Atualizado há ${time} minutos')}"; + static String m1(dynamic time) => Intl.plural( + time as num, + zero: 'Atualizado há ${time} minutos', + one: 'Atualizado há ${time} minuto', + other: 'Atualizado há ${time} minutos', + ); - static m2(String title) => "${Intl.select(title, { - 'horario': 'Horário', - 'exames': 'Exames', - 'area': 'Área Pessoal', - 'cadeiras': 'Cadeiras', - 'autocarros': 'Autocarros', - 'locais': 'Locais', - 'restaurantes': 'Restaurantes', - 'calendario': 'Calendário', - 'biblioteca': 'Biblioteca', - 'uteis': 'Úteis', - 'sobre': 'Sobre', - 'bugs': 'Bugs e Sugestões', - 'other': 'Outros', - })}"; + static String m2(String title) => Intl.select(title, { + 'horario': 'Horário', + 'exames': 'Exames', + 'area': 'Área Pessoal', + 'cadeiras': 'Cadeiras', + 'autocarros': 'Autocarros', + 'locais': 'Locais', + 'restaurantes': 'Restaurantes', + 'calendario': 'Calendário', + 'biblioteca': 'Biblioteca', + 'uteis': 'Úteis', + 'sobre': 'Sobre', + 'bugs': 'Bugs e Sugestões', + 'other': 'Outros', + }); final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { @@ -50,46 +54,60 @@ class MessageLookup extends MessageLookupByLibrary { "add_quota": MessageLookupByLibrary.simpleMessage("Adicionar quota"), "add_widget": MessageLookupByLibrary.simpleMessage("Adicionar widget"), "agree_terms": MessageLookupByLibrary.simpleMessage( - "Ao entrares confirmas que concordas com estes Termos e Condições"), + "Ao entrares confirmas que concordas com estes Termos e Condições", + ), "all_widgets_added": MessageLookupByLibrary.simpleMessage( - "Todos os widgets disponíveis já foram adicionados à tua área pessoal!"), + "Todos os widgets disponíveis já foram adicionados à tua área pessoal!", + ), "at_least_one_college": MessageLookupByLibrary.simpleMessage( - "Seleciona pelo menos uma faculdade"), + "Seleciona pelo menos uma faculdade", + ), "average": MessageLookupByLibrary.simpleMessage("Média: "), "balance": MessageLookupByLibrary.simpleMessage("Saldo:"), "bs_description": MessageLookupByLibrary.simpleMessage( - "Encontraste algum bug na aplicação?\\nTens alguma sugestão para a app?\\nConta-nos para que possamos melhorar!"), + r"Encontraste algum bug na aplicação?\nTens alguma sugestão para a app?\nConta-nos para que possamos melhorar!", + ), "bug_description": MessageLookupByLibrary.simpleMessage( - "Bug encontrado, como o reproduzir, etc"), + "Bug encontrado, como o reproduzir, etc", + ), "bus_error": MessageLookupByLibrary.simpleMessage( - "Não foi possível obter informação"), + "Não foi possível obter informação", + ), "bus_information": MessageLookupByLibrary.simpleMessage( - "Seleciona os autocarros dos quais queres informação:"), + "Seleciona os autocarros dos quais queres informação:", + ), "buses_personalize": MessageLookupByLibrary.simpleMessage( - "Configura aqui os teus autocarros"), + "Configura aqui os teus autocarros", + ), "buses_text": MessageLookupByLibrary.simpleMessage( - "Os autocarros favoritos serão apresentados no widget \'Autocarros\' dos favoritos. Os restantes serão apresentados apenas na página."), + "Os autocarros favoritos serão apresentados no widget 'Autocarros' dos favoritos. Os restantes serão apresentados apenas na página.", + ), "cancel": MessageLookupByLibrary.simpleMessage("Cancelar\n"), "change": MessageLookupByLibrary.simpleMessage("Alterar"), "change_prompt": MessageLookupByLibrary.simpleMessage( - "Deseja alterar a palavra-passe?"), + "Deseja alterar a palavra-passe?", + ), "check_internet": MessageLookupByLibrary.simpleMessage( - "Verifica a tua ligação à internet"), + "Verifica a tua ligação à internet", + ), "class_registration": MessageLookupByLibrary.simpleMessage("Inscrição de Turmas"), "college": MessageLookupByLibrary.simpleMessage("Faculdade: "), "college_select": MessageLookupByLibrary.simpleMessage( - "seleciona a(s) tua(s) faculdade(s)"), + "seleciona a(s) tua(s) faculdade(s)", + ), "conclude": MessageLookupByLibrary.simpleMessage("Concluído"), "configured_buses": MessageLookupByLibrary.simpleMessage("Autocarros Configurados"), "confirm": MessageLookupByLibrary.simpleMessage("Confirmar"), "consent": MessageLookupByLibrary.simpleMessage( - "Consinto que esta informação seja revista pelo NIAEFEUP, podendo ser eliminada a meu pedido."), + "Consinto que esta informação seja revista pelo NIAEFEUP, podendo ser eliminada a meu pedido.", + ), "contact": MessageLookupByLibrary.simpleMessage("Contacto (opcional)"), "copy_center": MessageLookupByLibrary.simpleMessage("Centro de cópias"), "copy_center_building": MessageLookupByLibrary.simpleMessage( - "Piso -1 do edifício B | Edifício da AEFEUP"), + "Piso -1 do edifício B | Edifício da AEFEUP", + ), "course_class": MessageLookupByLibrary.simpleMessage("Turmas"), "course_info": MessageLookupByLibrary.simpleMessage("Ficha"), "current_state": MessageLookupByLibrary.simpleMessage("Estado atual: "), @@ -98,25 +116,30 @@ class MessageLookup extends MessageLookupByLibrary { "decrement": MessageLookupByLibrary.simpleMessage("Decrementar 1,00€"), "description": MessageLookupByLibrary.simpleMessage("Descrição"), "desired_email": MessageLookupByLibrary.simpleMessage( - "Email em que desejas ser contactado"), + "Email em que desejas ser contactado", + ), "dona_bia": MessageLookupByLibrary.simpleMessage("Papelaria D. Beatriz"), "dona_bia_building": MessageLookupByLibrary.simpleMessage( - "Piso -1 do edifício B (B-142)"), + "Piso -1 do edifício B (B-142)", + ), "ects": MessageLookupByLibrary.simpleMessage("ECTs realizados: "), "edit_off": MessageLookupByLibrary.simpleMessage("Editar\n"), "edit_on": MessageLookupByLibrary.simpleMessage("Concluir edição"), "empty_text": MessageLookupByLibrary.simpleMessage( - "Por favor preenche este campo"), + "Por favor preenche este campo", + ), "exams_filter": MessageLookupByLibrary.simpleMessage("Definições Filtro de Exames"), "expired_password": MessageLookupByLibrary.simpleMessage("A tua palavra-passe expirou"), "failed_login": MessageLookupByLibrary.simpleMessage("O login falhou"), "fee_date": MessageLookupByLibrary.simpleMessage( - "Data limite próxima prestação:"), + "Data limite próxima prestação:", + ), "fee_notification": MessageLookupByLibrary.simpleMessage( - "Notificar próxima data limite:"), + "Notificar próxima data limite:", + ), "first_year_registration": MessageLookupByLibrary.simpleMessage("Ano da primeira inscrição: "), "floor": MessageLookupByLibrary.simpleMessage("Piso"), @@ -139,7 +162,8 @@ class MessageLookup extends MessageLookupByLibrary { "library_occupation": MessageLookupByLibrary.simpleMessage("Ocupação da Biblioteca"), "loading_terms": MessageLookupByLibrary.simpleMessage( - "Carregando os Termos e Condições..."), + "Carregando os Termos e Condições...", + ), "login": MessageLookupByLibrary.simpleMessage("Entrar"), "logout": MessageLookupByLibrary.simpleMessage("Terminar sessão"), "menus": MessageLookupByLibrary.simpleMessage("Ementas"), @@ -150,20 +174,26 @@ class MessageLookup extends MessageLookupByLibrary { "nav_title": m2, "news": MessageLookupByLibrary.simpleMessage("Notícias"), "no_bus": MessageLookupByLibrary.simpleMessage( - "Não percas nenhum autocarro!"), + "Não percas nenhum autocarro!", + ), "no_bus_stops": MessageLookupByLibrary.simpleMessage( - "Não existe nenhuma paragem configurada"), + "Não existe nenhuma paragem configurada", + ), "no_class": MessageLookupByLibrary.simpleMessage( - "Não existem turmas para apresentar"), + "Não existem turmas para apresentar", + ), "no_classes": MessageLookupByLibrary.simpleMessage( - "Não existem aulas para apresentar"), + "Não existem aulas para apresentar", + ), "no_classes_on": MessageLookupByLibrary.simpleMessage("Não possui aulas à"), "no_college": MessageLookupByLibrary.simpleMessage("sem faculdade"), "no_course_units": MessageLookupByLibrary.simpleMessage( - "Sem cadeiras no período selecionado"), + "Sem cadeiras no período selecionado", + ), "no_data": MessageLookupByLibrary.simpleMessage( - "Não há dados a mostrar neste momento"), + "Não há dados a mostrar neste momento", + ), "no_date": MessageLookupByLibrary.simpleMessage("Sem data"), "no_exams": MessageLookupByLibrary.simpleMessage("Não possui exames marcados"), @@ -172,39 +202,50 @@ class MessageLookup extends MessageLookupByLibrary { "no_favorite_restaurants": MessageLookupByLibrary.simpleMessage("Sem restaurantes favoritos"), "no_info": MessageLookupByLibrary.simpleMessage( - "Não existem informações para apresentar"), + "Não existem informações para apresentar", + ), "no_menu_info": MessageLookupByLibrary.simpleMessage( - "Não há informação disponível sobre refeições"), + "Não há informação disponível sobre refeições", + ), "no_menus": MessageLookupByLibrary.simpleMessage( - "Não há refeições disponíveis"), + "Não há refeições disponíveis", + ), "no_name_course": MessageLookupByLibrary.simpleMessage("Curso sem nome"), "no_references": MessageLookupByLibrary.simpleMessage( - "Não existem referências a pagar"), + "Não existem referências a pagar", + ), "no_results": MessageLookupByLibrary.simpleMessage("Sem resultados"), "no_selected_courses": MessageLookupByLibrary.simpleMessage( - "Não existem cadeiras para apresentar"), + "Não existem cadeiras para apresentar", + ), "no_selected_exams": MessageLookupByLibrary.simpleMessage( - "Não existem exames para apresentar"), + "Não existem exames para apresentar", + ), "occurrence_type": MessageLookupByLibrary.simpleMessage("Tipo de ocorrência"), "other_links": MessageLookupByLibrary.simpleMessage("Outros links"), "pass_change_request": MessageLookupByLibrary.simpleMessage( - "Por razões de segurança, as palavras-passe têm de ser alteradas periodicamente."), + "Por razões de segurança, as palavras-passe têm de ser alteradas periodicamente.", + ), "password": MessageLookupByLibrary.simpleMessage("palavra-passe"), "pendent_references": MessageLookupByLibrary.simpleMessage("Referências pendentes"), "personal_assistance": MessageLookupByLibrary.simpleMessage("Atendimento presencial"), "press_again": MessageLookupByLibrary.simpleMessage( - "Pressione novamente para sair"), + "Pressione novamente para sair", + ), "print": MessageLookupByLibrary.simpleMessage("Impressão"), "problem_id": MessageLookupByLibrary.simpleMessage( - "Breve identificação do problema"), + "Breve identificação do problema", + ), "reference_sigarra_help": MessageLookupByLibrary.simpleMessage( - "Os dados da referência gerada aparecerão no Sigarra, conta corrente.\\nPerfil > Conta Corrente"), + r"Os dados da referência gerada aparecerão no Sigarra, conta corrente.\nPerfil > Conta Corrente", + ), "reference_success": MessageLookupByLibrary.simpleMessage( - "Referência criada com sucesso!"), + "Referência criada com sucesso!", + ), "remove": MessageLookupByLibrary.simpleMessage("Remover"), "room": MessageLookupByLibrary.simpleMessage("Sala"), "school_calendar": @@ -222,15 +263,18 @@ class MessageLookup extends MessageLookupByLibrary { "tele_assistance": MessageLookupByLibrary.simpleMessage("Atendimento telefónico"), "tele_personal_assistance": MessageLookupByLibrary.simpleMessage( - "Atendimento presencial e telefónico"), + "Atendimento presencial e telefónico", + ), "telephone": MessageLookupByLibrary.simpleMessage("Telefone"), "terms": MessageLookupByLibrary.simpleMessage("Termos e Condições"), "title": MessageLookupByLibrary.simpleMessage("Título"), "unavailable": MessageLookupByLibrary.simpleMessage("Indisponível"), "valid_email": MessageLookupByLibrary.simpleMessage( - "Por favor insere um email válido"), + "Por favor insere um email válido", + ), "widget_prompt": MessageLookupByLibrary.simpleMessage( - "Escolhe um widget para adicionares à tua área pessoal:"), + "Escolhe um widget para adicionares à tua área pessoal:", + ), "year": MessageLookupByLibrary.simpleMessage("Ano") }; } diff --git a/uni/lib/generated/l10n.dart b/uni/lib/generated/l10n.dart index 7b45c0e86..7704df1ae 100644 --- a/uni/lib/generated/l10n.dart +++ b/uni/lib/generated/l10n.dart @@ -1,7 +1,7 @@ // GENERATED CODE - DO NOT MODIFY BY HAND import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; -import 'intl/messages_all.dart'; +import 'package:uni/generated/intl/messages_all.dart'; // ************************************************************************** // Generator: Flutter Intl IDE plugin @@ -18,8 +18,10 @@ class S { static S? _current; static S get current { - assert(_current != null, - 'No instance of S was loaded. Try to initialize the S delegate before accessing S.current.'); + assert( + _current != null, + 'No instance of S was loaded. Try to initialize the S delegate before accessing S.current.', + ); return _current!; } @@ -41,8 +43,10 @@ class S { static S of(BuildContext context) { final instance = S.maybeOf(context); - assert(instance != null, - 'No instance of S present in the widget tree. Did you add S.delegate in localizationsDelegates?'); + assert( + instance != null, + 'No instance of S present in the widget tree. Did you add S.delegate in localizationsDelegates?', + ); return instance!; } @@ -193,7 +197,7 @@ class S { /// `Favorite buses will be displayed in the favorites 'Bus' widget. The remaining ones will only be displayed on the page.` String get buses_text { return Intl.message( - 'Favorite buses will be displayed in the favorites \'Bus\' widget. The remaining ones will only be displayed on the page.', + "Favorite buses will be displayed in the favorites 'Bus' widget. The remaining ones will only be displayed on the page.", name: 'buses_text', desc: '', args: [], @@ -423,7 +427,7 @@ class S { /// `D. Beatriz's stationery store` String get dona_bia { return Intl.message( - 'D. Beatriz\'s stationery store', + "D. Beatriz's stationery store", name: 'dona_bia', desc: '', args: [], @@ -761,7 +765,7 @@ class S { /// `Don't miss any bus!` String get no_bus { return Intl.message( - 'Don\'t miss any bus!', + "Don't miss any bus!", name: 'no_bus', desc: '', args: [], @@ -801,7 +805,7 @@ class S { /// `You don't have classes on` String get no_classes_on { return Intl.message( - 'You don\'t have classes on', + "You don't have classes on", name: 'no_classes_on', desc: '', args: [], From ca9479a38e1b16a923157954ff69c01859bb4e35 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Tue, 5 Sep 2023 16:02:06 +0100 Subject: [PATCH 28/50] AppLocale model implementation --- .../local_storage/app_shared_preferences.dart | 6 ++++-- uni/lib/main.dart | 9 ++++---- uni/lib/model/entities/app_locale.dart | 15 +++++++++++++ uni/lib/model/entities/exam.dart | 14 ++++++++++--- uni/lib/model/entities/login_exceptions.dart | 4 ++-- uni/lib/view/bug_report/widgets/form.dart | 14 +++++++++---- .../general/widgets/navigation_drawer.dart | 2 +- uni/lib/view/home/widgets/exam_card.dart | 7 ++++--- uni/lib/view/locale_notifier.dart | 21 ++++++++++--------- uni/lib/view/schedule/schedule.dart | 12 ++++++----- uni/test/test_widget.dart | 3 ++- 11 files changed, 72 insertions(+), 35 deletions(-) create mode 100644 uni/lib/model/entities/app_locale.dart diff --git a/uni/lib/controller/local_storage/app_shared_preferences.dart b/uni/lib/controller/local_storage/app_shared_preferences.dart index 7efd46986..5a8b08b79 100644 --- a/uni/lib/controller/local_storage/app_shared_preferences.dart +++ b/uni/lib/controller/local_storage/app_shared_preferences.dart @@ -5,6 +5,7 @@ import 'package:encrypt/encrypt.dart' as encrypt; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:tuple/tuple.dart'; +import 'package:uni/model/entities/app_locale.dart'; import 'package:uni/model/entities/exam.dart'; import 'package:uni/utils/favorite_widget_type.dart'; @@ -124,10 +125,11 @@ class AppSharedPreferences { await prefs.setString(locale, appLocale); } - static Future getLocale() async { + static Future getLocale() async { final prefs = await SharedPreferences.getInstance(); final appLocale = prefs.getString(locale) ?? Platform.localeName; - return Locale(appLocale); + + return appLocale == 'pt' ? AppLocale.pt : AppLocale.en; } /// Deletes the user's student number and password. diff --git a/uni/lib/main.dart b/uni/lib/main.dart index 66d95888c..b21a0ccc6 100644 --- a/uni/lib/main.dart +++ b/uni/lib/main.dart @@ -166,12 +166,13 @@ class MyApp extends StatefulWidget { final String initialRoute; + static final GlobalKey navigatorKey = + GlobalKey(); + @override State createState() => MyAppState(); } -final GlobalKey navigatorKey = GlobalKey(); - /// Manages the app depending on its current state class MyAppState extends State { @override @@ -185,7 +186,7 @@ class MyAppState extends State { theme: applicationLightTheme, darkTheme: applicationDarkTheme, themeMode: themeNotifier.getTheme(), - locale: localeNotifier.getLocale(), + locale: localeNotifier.getLocale().localeCode, localizationsDelegates: const [ S.delegate, GlobalMaterialLocalizations.delegate, @@ -194,7 +195,7 @@ class MyAppState extends State { ], supportedLocales: S.delegate.supportedLocales, initialRoute: widget.initialRoute, - navigatorKey: navigatorKey, + navigatorKey: MyApp.navigatorKey, onGenerateRoute: (RouteSettings settings) { final transitions = { '/${DrawerItem.navPersonalArea.title}': diff --git a/uni/lib/model/entities/app_locale.dart b/uni/lib/model/entities/app_locale.dart new file mode 100644 index 000000000..9f6cd2958 --- /dev/null +++ b/uni/lib/model/entities/app_locale.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +enum AppLocale { + en, + pt; + + Locale get localeCode { + switch (this) { + case AppLocale.en: + return const Locale('en'); + case AppLocale.pt: + return const Locale('pt'); + } + } +} diff --git a/uni/lib/model/entities/exam.dart b/uni/lib/model/entities/exam.dart index 0d4c61b8b..1d60fe37d 100644 --- a/uni/lib/model/entities/exam.dart +++ b/uni/lib/model/entities/exam.dart @@ -1,5 +1,8 @@ import 'package:intl/intl.dart'; import 'package:logger/logger.dart'; +import 'package:provider/provider.dart'; +import 'package:uni/main.dart'; +import 'package:uni/view/locale_notifier.dart'; /// Manages a generic Exam. /// @@ -63,14 +66,19 @@ class Exam { /// Returns whether or not this exam has already ended. bool hasEnded() => DateTime.now().compareTo(end) >= 0; - String locale = Intl.getCurrentLocale(); + final locale = Provider.of(MyApp.navigatorKey.currentContext!) + .getLocale(); String get weekDay { - return DateFormat.EEEE(locale).dateSymbols.WEEKDAYS[begin.weekday - 1]; + return DateFormat.EEEE(locale.localeCode.languageCode) + .dateSymbols + .WEEKDAYS[begin.weekday - 1]; } String get month { - return DateFormat.EEEE(locale).dateSymbols.MONTHS[begin.month - 1]; + return DateFormat.EEEE(locale.localeCode.languageCode) + .dateSymbols + .MONTHS[begin.month - 1]; } String get beginTime => formatTime(begin); diff --git a/uni/lib/model/entities/login_exceptions.dart b/uni/lib/model/entities/login_exceptions.dart index 74ab67a01..ea368c4c5 100644 --- a/uni/lib/model/entities/login_exceptions.dart +++ b/uni/lib/model/entities/login_exceptions.dart @@ -7,10 +7,10 @@ class ExpiredCredentialsException implements Exception { class InternetStatusException implements Exception { InternetStatusException(); - String message = S.of(navigatorKey.currentContext!).check_internet; + String message = S.of(MyApp.navigatorKey.currentContext!).check_internet; } class WrongCredentialsException implements Exception { WrongCredentialsException(); - String message = S.of(navigatorKey.currentContext!).invalid_credentials; + String message = S.of(MyApp.navigatorKey.currentContext!).invalid_credentials; } diff --git a/uni/lib/view/bug_report/widgets/form.dart b/uni/lib/view/bug_report/widgets/form.dart index 96eccb6c1..386fc8089 100644 --- a/uni/lib/view/bug_report/widgets/form.dart +++ b/uni/lib/view/bug_report/widgets/form.dart @@ -4,17 +4,20 @@ import 'package:email_validator/email_validator.dart'; import 'package:flutter/material.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:http/http.dart' as http; -import 'package:intl/intl.dart'; import 'package:logger/logger.dart'; +import 'package:provider/provider.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:tuple/tuple.dart'; import 'package:uni/controller/local_storage/app_shared_preferences.dart'; import 'package:uni/generated/l10n.dart'; +import 'package:uni/main.dart'; +import 'package:uni/model/entities/app_locale.dart'; import 'package:uni/model/entities/bug_report.dart'; import 'package:uni/utils/drawer_items.dart'; import 'package:uni/view/bug_report/widgets/text_field.dart'; import 'package:uni/view/common_widgets/page_title.dart'; import 'package:uni/view/common_widgets/toast_message.dart'; +import 'package:uni/view/locale_notifier.dart'; class BugReportForm extends StatefulWidget { const BugReportForm({super.key}); @@ -60,14 +63,17 @@ class BugReportFormState extends State { bool _isConsentGiven = false; void loadBugClassList() { - final locale = Intl.getCurrentLocale(); + final locale = + Provider.of(MyApp.navigatorKey.currentContext!) + .getLocale(); bugList = bugDescriptions.entries .map( (entry) => DropdownMenuItem( value: entry.key, - child: - Text(locale == 'pt_PT' ? entry.value.item1 : entry.value.item2), + child: Text( + locale == AppLocale.pt ? entry.value.item1 : entry.value.item2, + ), ), ) .toList(); diff --git a/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart b/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart index 6c5817968..5560d5611 100644 --- a/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart +++ b/uni/lib/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart @@ -101,7 +101,7 @@ class AppNavigationDrawerState extends State { child: Container( padding: const EdgeInsets.all(15), child: Text( - localeNotifier.getLocale().languageCode.toUpperCase(), + localeNotifier.getLocale().localeCode.languageCode.toUpperCase(), style: Theme.of(context) .textTheme .titleLarge! diff --git a/uni/lib/view/home/widgets/exam_card.dart b/uni/lib/view/home/widgets/exam_card.dart index a1b682102..3aeb60cf4 100644 --- a/uni/lib/view/home/widgets/exam_card.dart +++ b/uni/lib/view/home/widgets/exam_card.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; import 'package:uni/generated/l10n.dart'; +import 'package:uni/model/entities/app_locale.dart'; import 'package:uni/model/entities/exam.dart'; import 'package:uni/model/providers/lazy/exam_provider.dart'; import 'package:uni/utils/drawer_items.dart'; @@ -13,6 +13,7 @@ import 'package:uni/view/exams/widgets/exam_row.dart'; import 'package:uni/view/exams/widgets/exam_title.dart'; import 'package:uni/view/home/widgets/exam_card_shimmer.dart'; import 'package:uni/view/lazy_consumer.dart'; +import 'package:uni/view/locale_notifier.dart'; /// Manages the exam card section inside the personal area. class ExamCard extends GenericCard { @@ -106,10 +107,10 @@ class ExamCard extends GenericCard { /// Creates a row with the closest exam (which appears separated from the /// others in the card). Widget createRowFromExam(BuildContext context, Exam exam) { - final locale = Intl.getCurrentLocale(); + final locale = Provider.of(context).getLocale(); return Column( children: [ - if (locale == 'pt_PT') ...[ + if (locale == AppLocale.pt) ...[ DateRectangle( date: '${exam.weekDay}, ${exam.begin.day} de ${exam.month}', ) diff --git a/uni/lib/view/locale_notifier.dart b/uni/lib/view/locale_notifier.dart index 6e8df082e..7fb5684a8 100644 --- a/uni/lib/view/locale_notifier.dart +++ b/uni/lib/view/locale_notifier.dart @@ -1,36 +1,37 @@ import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:uni/controller/local_storage/app_shared_preferences.dart'; +import 'package:uni/model/entities/app_locale.dart'; class LocaleNotifier with ChangeNotifier { LocaleNotifier(this._locale); - Locale _locale; + AppLocale _locale; - Locale getLocale() => _locale; + AppLocale getLocale() => _locale; void setNextLocale() { - final Locale nextLocale; - _locale == const Locale('pt') - ? nextLocale = const Locale('en') - : nextLocale = const Locale('pt'); + final AppLocale nextLocale; + _locale == AppLocale.pt + ? nextLocale = AppLocale.en + : nextLocale = AppLocale.pt; setLocale(nextLocale); } - void setLocale(Locale locale) { + void setLocale(AppLocale locale) { _locale = locale; - AppSharedPreferences.setLocale(locale.languageCode); + AppSharedPreferences.setLocale(locale.localeCode.languageCode); notifyListeners(); } List getWeekdaysWithLocale() { - final weekdays = DateFormat.EEEE(_locale.languageCode) + final weekdays = DateFormat.EEEE(_locale.localeCode.languageCode) .dateSymbols .WEEKDAYS .skip(1) .map((weekday) => weekday[0].toUpperCase() + weekday.substring(1)) .toList() - ..add(_locale.languageCode == 'en' ? 'Sunday' : 'Domingo'); + ..add(_locale == AppLocale.en ? 'Sunday' : 'Domingo'); return weekdays; } } diff --git a/uni/lib/view/schedule/schedule.dart b/uni/lib/view/schedule/schedule.dart index f18283688..084a9d856 100644 --- a/uni/lib/view/schedule/schedule.dart +++ b/uni/lib/view/schedule/schedule.dart @@ -124,18 +124,20 @@ class SchedulePageViewState extends GeneralPageViewState /// Returns a list of widgets empty with tabs for each day of the week. List createTabs(MediaQueryData queryData, BuildContext context) { final tabs = []; - for (var i = 0; i < 5; i++) { + final workWeekDays = Provider.of(context) + .getWeekdaysWithLocale() + .sublist(0, 5); + workWeekDays.asMap().forEach((index, day) { tabs.add( SizedBox( width: (queryData.size.width * 1) / 4, child: Tab( - key: Key('schedule-page-tab-$i'), - text: - Provider.of(context).getWeekdaysWithLocale()[i], + key: Key('schedule-page-tab-$index'), + text: day, ), ), ); - } + }); return tabs; } diff --git a/uni/test/test_widget.dart b/uni/test/test_widget.dart index 67a4b27eb..7cdac440c 100644 --- a/uni/test/test_widget.dart +++ b/uni/test/test_widget.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:provider/provider.dart'; import 'package:uni/generated/l10n.dart'; +import 'package:uni/model/entities/app_locale.dart'; import 'package:uni/view/locale_notifier.dart'; Widget testableWidget( @@ -11,7 +12,7 @@ Widget testableWidget( return MultiProvider( providers: [ ChangeNotifierProvider( - create: (_) => LocaleNotifier(const Locale('pt')), + create: (_) => LocaleNotifier(AppLocale.pt), ), ...providers ], From 13a13b9448c7854213ff2b39a394795b6d84ccb1 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Wed, 6 Sep 2023 20:54:16 +0100 Subject: [PATCH 29/50] Locale tweaks --- .../local_storage/app_shared_preferences.dart | 7 ++++--- uni/lib/view/locale_notifier.dart | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/uni/lib/controller/local_storage/app_shared_preferences.dart b/uni/lib/controller/local_storage/app_shared_preferences.dart index 5a8b08b79..5921e5fdd 100644 --- a/uni/lib/controller/local_storage/app_shared_preferences.dart +++ b/uni/lib/controller/local_storage/app_shared_preferences.dart @@ -120,16 +120,17 @@ class AppSharedPreferences { return prefs.setInt(themeMode, (themeIndex + 1) % 3); } - static Future setLocale(String appLocale) async { + static Future setLocale(AppLocale appLocale) async { final prefs = await SharedPreferences.getInstance(); - await prefs.setString(locale, appLocale); + await prefs.setString(locale, appLocale.name); } static Future getLocale() async { final prefs = await SharedPreferences.getInstance(); final appLocale = prefs.getString(locale) ?? Platform.localeName; - return appLocale == 'pt' ? AppLocale.pt : AppLocale.en; + return AppLocale.values + .firstWhere((e) => e.toString() == 'AppLocale.$appLocale'); } /// Deletes the user's student number and password. diff --git a/uni/lib/view/locale_notifier.dart b/uni/lib/view/locale_notifier.dart index 7fb5684a8..36cf71bc7 100644 --- a/uni/lib/view/locale_notifier.dart +++ b/uni/lib/view/locale_notifier.dart @@ -11,16 +11,16 @@ class LocaleNotifier with ChangeNotifier { AppLocale getLocale() => _locale; void setNextLocale() { - final AppLocale nextLocale; - _locale == AppLocale.pt - ? nextLocale = AppLocale.en - : nextLocale = AppLocale.pt; + const availableLocales = AppLocale.values; + final currentIndex = availableLocales.indexOf(_locale); + final nextLocale = + availableLocales[(currentIndex + 1) % availableLocales.length]; setLocale(nextLocale); } void setLocale(AppLocale locale) { _locale = locale; - AppSharedPreferences.setLocale(locale.localeCode.languageCode); + AppSharedPreferences.setLocale(locale); notifyListeners(); } From 30c78f190806d886fb6bfb8dc83acf311b1aa75d Mon Sep 17 00:00:00 2001 From: DGoiana Date: Wed, 6 Sep 2023 22:44:41 +0100 Subject: [PATCH 30/50] Tests and bug fix --- .../local_storage/app_shared_preferences.dart | 3 ++- uni/lib/model/entities/exam.dart | 11 +++-------- uni/lib/view/exams/exams.dart | 6 ++++-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/uni/lib/controller/local_storage/app_shared_preferences.dart b/uni/lib/controller/local_storage/app_shared_preferences.dart index 5921e5fdd..fab87b249 100644 --- a/uni/lib/controller/local_storage/app_shared_preferences.dart +++ b/uni/lib/controller/local_storage/app_shared_preferences.dart @@ -127,7 +127,8 @@ class AppSharedPreferences { static Future getLocale() async { final prefs = await SharedPreferences.getInstance(); - final appLocale = prefs.getString(locale) ?? Platform.localeName; + final appLocale = + prefs.getString(locale) ?? Platform.localeName.substring(0, 2); return AppLocale.values .firstWhere((e) => e.toString() == 'AppLocale.$appLocale'); diff --git a/uni/lib/model/entities/exam.dart b/uni/lib/model/entities/exam.dart index 1d60fe37d..fb29f704a 100644 --- a/uni/lib/model/entities/exam.dart +++ b/uni/lib/model/entities/exam.dart @@ -1,8 +1,6 @@ import 'package:intl/intl.dart'; import 'package:logger/logger.dart'; -import 'package:provider/provider.dart'; -import 'package:uni/main.dart'; -import 'package:uni/view/locale_notifier.dart'; +import 'package:uni/model/entities/app_locale.dart'; /// Manages a generic Exam. /// @@ -66,16 +64,13 @@ class Exam { /// Returns whether or not this exam has already ended. bool hasEnded() => DateTime.now().compareTo(end) >= 0; - final locale = Provider.of(MyApp.navigatorKey.currentContext!) - .getLocale(); - - String get weekDay { + String weekDay(AppLocale locale) { return DateFormat.EEEE(locale.localeCode.languageCode) .dateSymbols .WEEKDAYS[begin.weekday - 1]; } - String get month { + String month(AppLocale locale) { return DateFormat.EEEE(locale.localeCode.languageCode) .dateSymbols .MONTHS[begin.month - 1]; diff --git a/uni/lib/view/exams/exams.dart b/uni/lib/view/exams/exams.dart index 175e359fb..0731720e9 100644 --- a/uni/lib/view/exams/exams.dart +++ b/uni/lib/view/exams/exams.dart @@ -10,6 +10,7 @@ import 'package:uni/view/exams/widgets/day_title.dart'; import 'package:uni/view/exams/widgets/exam_page_title.dart'; import 'package:uni/view/exams/widgets/exam_row.dart'; import 'package:uni/view/lazy_consumer.dart'; +import 'package:uni/view/locale_notifier.dart'; class ExamsPageView extends StatefulWidget { const ExamsPageView({super.key}); @@ -108,11 +109,12 @@ class ExamsPageViewState extends GeneralPageViewState { } Widget createExamsCards(BuildContext context, List exams) { + final locale = Provider.of(context).getLocale(); final examCards = [ DayTitle( day: exams[0].begin.day.toString(), - weekDay: exams[0].weekDay, - month: exams[0].month, + weekDay: exams[0].weekDay(locale), + month: exams[0].month(locale), ), ]; for (var i = 0; i < exams.length; i++) { From 0ac99e9ad658b03b60f44ac522e8771e1cfe2990 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Fri, 8 Sep 2023 23:10:04 +0100 Subject: [PATCH 31/50] Optimizing --- .../local_storage/app_shared_preferences.dart | 6 ++++-- uni/lib/model/entities/login_exceptions.dart | 21 +++++++++++++------ .../providers/startup/session_provider.dart | 14 ++++++++++--- uni/lib/view/bug_report/widgets/form.dart | 14 ++++++++----- .../view/bug_report/widgets/text_field.dart | 4 ++-- uni/lib/view/login/login.dart | 1 + 6 files changed, 42 insertions(+), 18 deletions(-) diff --git a/uni/lib/controller/local_storage/app_shared_preferences.dart b/uni/lib/controller/local_storage/app_shared_preferences.dart index fab87b249..d5da1a7c4 100644 --- a/uni/lib/controller/local_storage/app_shared_preferences.dart +++ b/uni/lib/controller/local_storage/app_shared_preferences.dart @@ -130,8 +130,10 @@ class AppSharedPreferences { final appLocale = prefs.getString(locale) ?? Platform.localeName.substring(0, 2); - return AppLocale.values - .firstWhere((e) => e.toString() == 'AppLocale.$appLocale'); + return AppLocale.values.firstWhere( + (e) => e.toString() == 'AppLocale.$appLocale', + orElse: () => AppLocale.en, + ); } /// Deletes the user's student number and password. diff --git a/uni/lib/model/entities/login_exceptions.dart b/uni/lib/model/entities/login_exceptions.dart index ea368c4c5..a6a129f80 100644 --- a/uni/lib/model/entities/login_exceptions.dart +++ b/uni/lib/model/entities/login_exceptions.dart @@ -1,16 +1,25 @@ -import 'package:uni/generated/l10n.dart'; -import 'package:uni/main.dart'; +import 'package:uni/model/entities/app_locale.dart'; class ExpiredCredentialsException implements Exception { ExpiredCredentialsException(); } class InternetStatusException implements Exception { - InternetStatusException(); - String message = S.of(MyApp.navigatorKey.currentContext!).check_internet; + InternetStatusException(this.locale) + : message = locale == AppLocale.en + ? 'Check your internet connection' + : 'Verifique sua conexão com a internet'; + + final AppLocale locale; + final String message; } class WrongCredentialsException implements Exception { - WrongCredentialsException(); - String message = S.of(MyApp.navigatorKey.currentContext!).invalid_credentials; + WrongCredentialsException(this.locale) + : message = locale == AppLocale.en + ? 'Invalid credentials' + : 'Credenciais inválidas'; + + final AppLocale locale; + final String message; } diff --git a/uni/lib/model/providers/startup/session_provider.dart b/uni/lib/model/providers/startup/session_provider.dart index 2126f0679..e4b006ea6 100644 --- a/uni/lib/model/providers/startup/session_provider.dart +++ b/uni/lib/model/providers/startup/session_provider.dart @@ -1,5 +1,7 @@ import 'dart:async'; +import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import 'package:uni/controller/background_workers/notifications.dart'; import 'package:uni/controller/load_static/terms_and_conditions.dart'; import 'package:uni/controller/local_storage/app_shared_preferences.dart'; @@ -10,6 +12,7 @@ import 'package:uni/model/entities/profile.dart'; import 'package:uni/model/entities/session.dart'; import 'package:uni/model/providers/state_provider_notifier.dart'; import 'package:uni/model/request_status.dart'; +import 'package:uni/view/locale_notifier.dart'; class SessionProvider extends StateProviderNotifier { SessionProvider() @@ -59,6 +62,7 @@ class SessionProvider extends StateProviderNotifier { } Future postAuthentication( + BuildContext context, String username, String password, List faculties, { @@ -76,7 +80,9 @@ class SessionProvider extends StateProviderNotifier { ); } catch (e) { updateStatus(RequestStatus.failed); - throw InternetStatusException(); + throw InternetStatusException( + Provider.of(context).getLocale(), + ); } if (session == null) { @@ -85,10 +91,12 @@ class SessionProvider extends StateProviderNotifier { updateStatus(RequestStatus.failed); - if (isPasswordExpired(responseHtml)) { + if (isPasswordExpired(responseHtml) && context.mounted) { throw ExpiredCredentialsException(); } else { - throw WrongCredentialsException(); + throw WrongCredentialsException( + Provider.of(context).getLocale(), + ); } } diff --git a/uni/lib/view/bug_report/widgets/form.dart b/uni/lib/view/bug_report/widgets/form.dart index 386fc8089..6c5e1cfda 100644 --- a/uni/lib/view/bug_report/widgets/form.dart +++ b/uni/lib/view/bug_report/widgets/form.dart @@ -10,7 +10,6 @@ import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:tuple/tuple.dart'; import 'package:uni/controller/local_storage/app_shared_preferences.dart'; import 'package:uni/generated/l10n.dart'; -import 'package:uni/main.dart'; import 'package:uni/model/entities/app_locale.dart'; import 'package:uni/model/entities/bug_report.dart'; import 'package:uni/utils/drawer_items.dart'; @@ -63,16 +62,21 @@ class BugReportFormState extends State { bool _isConsentGiven = false; void loadBugClassList() { - final locale = - Provider.of(MyApp.navigatorKey.currentContext!) - .getLocale(); + final locale = Provider.of(context).getLocale(); bugList = bugDescriptions.entries .map( (entry) => DropdownMenuItem( value: entry.key, child: Text( - locale == AppLocale.pt ? entry.value.item1 : entry.value.item2, + () { + switch (locale) { + case AppLocale.pt: + return entry.value.item1; + case AppLocale.en: + return entry.value.item2; + } + }(), ), ), ) diff --git a/uni/lib/view/bug_report/widgets/text_field.dart b/uni/lib/view/bug_report/widgets/text_field.dart index d01b076a7..037b5e3db 100644 --- a/uni/lib/view/bug_report/widgets/text_field.dart +++ b/uni/lib/view/bug_report/widgets/text_field.dart @@ -62,8 +62,8 @@ class FormTextField extends StatelessWidget { labelStyle: Theme.of(context).textTheme.bodyMedium, ), controller: controller, - validator: (value) { - if (value!.isEmpty) { + validator: (String? value) { + if (value == null || value.isEmpty) { return isOptional ? null : S.of(context).empty_text; } return formatValidator?.call(value); diff --git a/uni/lib/view/login/login.dart b/uni/lib/view/login/login.dart index 600c9498c..544e6cf3a 100644 --- a/uni/lib/view/login/login.dart +++ b/uni/lib/view/login/login.dart @@ -50,6 +50,7 @@ class LoginPageViewState extends State { try { await sessionProvider.postAuthentication( + context, user, pass, faculties, From c04676f1d34a2a2dcaf055cadefb2b2393ba7ae6 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Sat, 9 Sep 2023 11:10:13 +0100 Subject: [PATCH 32/50] Some missed translations --- uni/lib/generated/intl/messages_all.dart | 7 +++++-- uni/lib/generated/intl/messages_en.dart | 18 ++++++++++++----- uni/lib/generated/intl/messages_pt_PT.dart | 18 ++++++++++++----- uni/lib/generated/l10n.dart | 20 +++++++++++++++++++ uni/lib/l10n/intl_en.arb | 4 ++++ uni/lib/l10n/intl_pt_PT.arb | 4 ++++ .../request_dependent_widget_builder.dart | 7 ++++--- uni/lib/view/login/login.dart | 2 +- 8 files changed, 64 insertions(+), 16 deletions(-) diff --git a/uni/lib/generated/intl/messages_all.dart b/uni/lib/generated/intl/messages_all.dart index de96ef7c8..5c2bef3d1 100644 --- a/uni/lib/generated/intl/messages_all.dart +++ b/uni/lib/generated/intl/messages_all.dart @@ -61,8 +61,11 @@ bool _messagesExistFor(String locale) { } MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { - final actualLocale = - Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); + final actualLocale = Intl.verifiedLocale( + locale, + _messagesExistFor, + onFailure: (_) => null, + ); if (actualLocale == null) return null; return _findExact(actualLocale); } diff --git a/uni/lib/generated/intl/messages_en.dart b/uni/lib/generated/intl/messages_en.dart index 908784164..6c7f8c46a 100644 --- a/uni/lib/generated/intl/messages_en.dart +++ b/uni/lib/generated/intl/messages_en.dart @@ -4,7 +4,7 @@ // function name. // Ignore issues from commonly used lints in this file. -// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new, lines_longer_than_80_chars +// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases // ignore_for_file:unused_import, file_names @@ -54,10 +54,12 @@ class MessageLookup extends MessageLookupByLibrary { "add_quota": MessageLookupByLibrary.simpleMessage("Add quota"), "add_widget": MessageLookupByLibrary.simpleMessage("Add widget"), "agree_terms": MessageLookupByLibrary.simpleMessage( - "By entering you confirm that you agree with these Terms and Conditions", + "By entering you confirm that you agree with these Terms " + "and Conditions", ), "all_widgets_added": MessageLookupByLibrary.simpleMessage( - "All available widgets have already been added to your personal area!", + "All available widgets have already been added to your personal " + "area!", ), "at_least_one_college": MessageLookupByLibrary.simpleMessage("Select at least one college"), @@ -77,7 +79,8 @@ class MessageLookup extends MessageLookupByLibrary { "buses_personalize": MessageLookupByLibrary.simpleMessage("Personalize your buses here"), "buses_text": MessageLookupByLibrary.simpleMessage( - "Favorite buses will be displayed in the favorites 'Bus' widget. The remaining ones will only be displayed on the page.", + "Favorite buses will be displayed in the favorites 'Bus' widget. " + "The remaining ones will only be displayed on the page.", ), "cancel": MessageLookupByLibrary.simpleMessage("Cancel"), "change": MessageLookupByLibrary.simpleMessage("Change"), @@ -97,7 +100,8 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Configured Buses"), "confirm": MessageLookupByLibrary.simpleMessage("Confirm"), "consent": MessageLookupByLibrary.simpleMessage( - "I consent to this information being reviewed by NIAEFEUP and may be deleted at my request.", + "I consent to this information being reviewed by NIAEFEUP " + "and may be deleted at my request.", ), "contact": MessageLookupByLibrary.simpleMessage("Contact (optional)"), "copy_center": MessageLookupByLibrary.simpleMessage("Copy center"), @@ -156,6 +160,9 @@ class MessageLookup extends MessageLookupByLibrary { "last_timestamp": m1, "library_occupation": MessageLookupByLibrary.simpleMessage("Library Occupation"), + "load_error": MessageLookupByLibrary.simpleMessage( + "Error loading the information", + ), "loading_terms": MessageLookupByLibrary.simpleMessage( "Loading Terms and Conditions...", ), @@ -239,6 +246,7 @@ class MessageLookup extends MessageLookupByLibrary { "Reference created successfully!", ), "remove": MessageLookupByLibrary.simpleMessage("Delete"), + "report_error": MessageLookupByLibrary.simpleMessage("Report error"), "room": MessageLookupByLibrary.simpleMessage("Room"), "school_calendar": MessageLookupByLibrary.simpleMessage("School Calendar"), diff --git a/uni/lib/generated/intl/messages_pt_PT.dart b/uni/lib/generated/intl/messages_pt_PT.dart index 8a36505af..9107d6c45 100644 --- a/uni/lib/generated/intl/messages_pt_PT.dart +++ b/uni/lib/generated/intl/messages_pt_PT.dart @@ -4,7 +4,7 @@ // function name. // Ignore issues from commonly used lints in this file. -// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new, lines_longer_than_80_chars +// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases // ignore_for_file:unused_import, file_names @@ -57,7 +57,8 @@ class MessageLookup extends MessageLookupByLibrary { "Ao entrares confirmas que concordas com estes Termos e Condições", ), "all_widgets_added": MessageLookupByLibrary.simpleMessage( - "Todos os widgets disponíveis já foram adicionados à tua área pessoal!", + "Todos os widgets disponíveis já foram adicionados à tua " + "área pessoal!", ), "at_least_one_college": MessageLookupByLibrary.simpleMessage( "Seleciona pelo menos uma faculdade", @@ -80,7 +81,8 @@ class MessageLookup extends MessageLookupByLibrary { "Configura aqui os teus autocarros", ), "buses_text": MessageLookupByLibrary.simpleMessage( - "Os autocarros favoritos serão apresentados no widget 'Autocarros' dos favoritos. Os restantes serão apresentados apenas na página.", + "Os autocarros favoritos serão apresentados no widget 'Autocarros' " + "dos favoritos. Os restantes serão apresentados apenas na página.", ), "cancel": MessageLookupByLibrary.simpleMessage("Cancelar\n"), "change": MessageLookupByLibrary.simpleMessage("Alterar"), @@ -101,7 +103,8 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Autocarros Configurados"), "confirm": MessageLookupByLibrary.simpleMessage("Confirmar"), "consent": MessageLookupByLibrary.simpleMessage( - "Consinto que esta informação seja revista pelo NIAEFEUP, podendo ser eliminada a meu pedido.", + "Consinto que esta informação seja revista pelo NIAEFEUP, " + "podendo ser eliminada a meu pedido.", ), "contact": MessageLookupByLibrary.simpleMessage("Contacto (opcional)"), "copy_center": MessageLookupByLibrary.simpleMessage("Centro de cópias"), @@ -161,6 +164,9 @@ class MessageLookup extends MessageLookupByLibrary { "last_timestamp": m1, "library_occupation": MessageLookupByLibrary.simpleMessage("Ocupação da Biblioteca"), + "load_error": MessageLookupByLibrary.simpleMessage( + "Aconteceu um erro ao carregar os dados", + ), "loading_terms": MessageLookupByLibrary.simpleMessage( "Carregando os Termos e Condições...", ), @@ -226,7 +232,8 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Tipo de ocorrência"), "other_links": MessageLookupByLibrary.simpleMessage("Outros links"), "pass_change_request": MessageLookupByLibrary.simpleMessage( - "Por razões de segurança, as palavras-passe têm de ser alteradas periodicamente.", + "Por razões de segurança, as palavras-passe têm de ser " + "alteradas periodicamente.", ), "password": MessageLookupByLibrary.simpleMessage("palavra-passe"), "pendent_references": @@ -247,6 +254,7 @@ class MessageLookup extends MessageLookupByLibrary { "Referência criada com sucesso!", ), "remove": MessageLookupByLibrary.simpleMessage("Remover"), + "report_error": MessageLookupByLibrary.simpleMessage("Reportar erro"), "room": MessageLookupByLibrary.simpleMessage("Sala"), "school_calendar": MessageLookupByLibrary.simpleMessage("Calendário Escolar"), diff --git a/uni/lib/generated/l10n.dart b/uni/lib/generated/l10n.dart index 7704df1ae..bf85c2c4b 100644 --- a/uni/lib/generated/l10n.dart +++ b/uni/lib/generated/l10n.dart @@ -667,6 +667,16 @@ class S { ); } + /// `Error loading the information` + String get load_error { + return Intl.message( + 'Error loading the information', + name: 'load_error', + desc: '', + args: [], + ); + } + /// `Loading Terms and Conditions...` String get loading_terms { return Intl.message( @@ -1082,6 +1092,16 @@ class S { ); } + /// `Report error` + String get report_error { + return Intl.message( + 'Report error', + name: 'report_error', + desc: '', + args: [], + ); + } + /// `Room` String get room { return Intl.message( diff --git a/uni/lib/l10n/intl_en.arb b/uni/lib/l10n/intl_en.arb index d63ce3056..770f69290 100644 --- a/uni/lib/l10n/intl_en.arb +++ b/uni/lib/l10n/intl_en.arb @@ -130,6 +130,8 @@ }, "library_occupation": "Library Occupation", "@library_occupation": {}, + "load_error": "Error loading the information", + "@load_error": {}, "loading_terms": "Loading Terms and Conditions...", "@loading_terms": {}, "login": "Login", @@ -210,6 +212,8 @@ "@reference_success": {}, "remove": "Delete", "@remove": {}, + "report_error": "Report error", + "@report_error": {}, "room": "Room", "@room": {}, "school_calendar": "School Calendar", diff --git a/uni/lib/l10n/intl_pt_PT.arb b/uni/lib/l10n/intl_pt_PT.arb index eaf6e2829..cda6d8639 100644 --- a/uni/lib/l10n/intl_pt_PT.arb +++ b/uni/lib/l10n/intl_pt_PT.arb @@ -130,6 +130,8 @@ }, "library_occupation": "Ocupação da Biblioteca", "@library_occupation": {}, + "load_error": "Aconteceu um erro ao carregar os dados", + "@load_error": {}, "loading_terms": "Carregando os Termos e Condições...", "@loading_terms": {}, "login": "Entrar", @@ -210,6 +212,8 @@ "@reference_success": {}, "remove": "Remover", "@remove": {}, + "report_error": "Reportar erro", + "@report_error": {}, "room": "Sala", "@room": {}, "school_calendar": "Calendário Escolar", diff --git a/uni/lib/view/common_widgets/request_dependent_widget_builder.dart b/uni/lib/view/common_widgets/request_dependent_widget_builder.dart index 170203fdb..899de33a1 100644 --- a/uni/lib/view/common_widgets/request_dependent_widget_builder.dart +++ b/uni/lib/view/common_widgets/request_dependent_widget_builder.dart @@ -1,6 +1,7 @@ import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:flutter/material.dart'; import 'package:shimmer/shimmer.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/model/request_status.dart'; import 'package:uni/utils/drawer_items.dart'; @@ -74,7 +75,7 @@ class RequestDependentWidgetBuilder extends StatelessWidget { return Center( heightFactor: 3, child: Text( - 'Sem ligação à internet', + S.of(context).check_internet, style: Theme.of(context).textTheme.titleMedium, ), ); @@ -86,7 +87,7 @@ class RequestDependentWidgetBuilder extends StatelessWidget { padding: const EdgeInsets.only(top: 15, bottom: 10), child: Center( child: Text( - 'Aconteceu um erro ao carregar os dados', + S.of(context).load_error, style: Theme.of(context).textTheme.titleMedium, ), ), @@ -96,7 +97,7 @@ class RequestDependentWidgetBuilder extends StatelessWidget { context, '/${DrawerItem.navBugReport.title}', ), - child: const Text('Reportar erro'), + child: Text(S.of(context).report_error), ) ], ); diff --git a/uni/lib/view/login/login.dart b/uni/lib/view/login/login.dart index 544e6cf3a..5a05df5f2 100644 --- a/uni/lib/view/login/login.dart +++ b/uni/lib/view/login/login.dart @@ -67,7 +67,7 @@ class LoginPageViewState extends State { } else if (error is WrongCredentialsException) { unawaited(ToastMessage.error(context, error.message)); } else { - unawaited(ToastMessage.error(context, 'Erro no login')); + unawaited(ToastMessage.error(context, S.of(context).failed_login)); } } } From da2afdb5a9e5ab3701b0be11cad68684f7434f3f Mon Sep 17 00:00:00 2001 From: DGoiana Date: Sun, 10 Sep 2023 10:57:07 +0100 Subject: [PATCH 33/50] Translations and context fix --- uni/lib/generated/intl/messages_en.dart | 17 ++++++++-------- uni/lib/generated/intl/messages_pt_PT.dart | 17 ++++++++-------- uni/lib/generated/l10n.dart | 20 +++++++++++++++++++ uni/lib/l10n/intl_en.arb | 4 ++++ uni/lib/l10n/intl_pt_PT.arb | 4 ++++ uni/lib/view/bug_report/widgets/form.dart | 5 ++++- uni/lib/view/locale_notifier.dart | 12 +++++------ .../view/profile/widgets/print_info_card.dart | 5 +++-- 8 files changed, 56 insertions(+), 28 deletions(-) diff --git a/uni/lib/generated/intl/messages_en.dart b/uni/lib/generated/intl/messages_en.dart index 6c7f8c46a..eccb8f146 100644 --- a/uni/lib/generated/intl/messages_en.dart +++ b/uni/lib/generated/intl/messages_en.dart @@ -4,7 +4,7 @@ // function name. // Ignore issues from commonly used lints in this file. -// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new +// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new, lines_longer_than_80_chars // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases // ignore_for_file:unused_import, file_names @@ -54,15 +54,15 @@ class MessageLookup extends MessageLookupByLibrary { "add_quota": MessageLookupByLibrary.simpleMessage("Add quota"), "add_widget": MessageLookupByLibrary.simpleMessage("Add widget"), "agree_terms": MessageLookupByLibrary.simpleMessage( - "By entering you confirm that you agree with these Terms " - "and Conditions", + "By entering you confirm that you agree with these Terms and Conditions", ), "all_widgets_added": MessageLookupByLibrary.simpleMessage( - "All available widgets have already been added to your personal " - "area!", + "All available widgets have already been added to your personal area!", ), "at_least_one_college": MessageLookupByLibrary.simpleMessage("Select at least one college"), + "available_amount": + MessageLookupByLibrary.simpleMessage("Available amount"), "average": MessageLookupByLibrary.simpleMessage("Average: "), "balance": MessageLookupByLibrary.simpleMessage("Balance:"), "bs_description": MessageLookupByLibrary.simpleMessage( @@ -79,8 +79,7 @@ class MessageLookup extends MessageLookupByLibrary { "buses_personalize": MessageLookupByLibrary.simpleMessage("Personalize your buses here"), "buses_text": MessageLookupByLibrary.simpleMessage( - "Favorite buses will be displayed in the favorites 'Bus' widget. " - "The remaining ones will only be displayed on the page.", + "Favorite buses will be displayed in the favorites 'Bus' widget. The remaining ones will only be displayed on the page.", ), "cancel": MessageLookupByLibrary.simpleMessage("Cancel"), "change": MessageLookupByLibrary.simpleMessage("Change"), @@ -100,8 +99,7 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Configured Buses"), "confirm": MessageLookupByLibrary.simpleMessage("Confirm"), "consent": MessageLookupByLibrary.simpleMessage( - "I consent to this information being reviewed by NIAEFEUP " - "and may be deleted at my request.", + "I consent to this information being reviewed by NIAEFEUP and may be deleted at my request.", ), "contact": MessageLookupByLibrary.simpleMessage("Contact (optional)"), "copy_center": MessageLookupByLibrary.simpleMessage("Copy center"), @@ -236,6 +234,7 @@ class MessageLookup extends MessageLookupByLibrary { "press_again": MessageLookupByLibrary.simpleMessage("Press again to exit"), "print": MessageLookupByLibrary.simpleMessage("Print"), + "prints": MessageLookupByLibrary.simpleMessage("Prints"), "problem_id": MessageLookupByLibrary.simpleMessage( "Brief identification of the problem", ), diff --git a/uni/lib/generated/intl/messages_pt_PT.dart b/uni/lib/generated/intl/messages_pt_PT.dart index 9107d6c45..800ef819f 100644 --- a/uni/lib/generated/intl/messages_pt_PT.dart +++ b/uni/lib/generated/intl/messages_pt_PT.dart @@ -4,7 +4,7 @@ // function name. // Ignore issues from commonly used lints in this file. -// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new +// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new, lines_longer_than_80_chars // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases // ignore_for_file:unused_import, file_names @@ -57,12 +57,13 @@ class MessageLookup extends MessageLookupByLibrary { "Ao entrares confirmas que concordas com estes Termos e Condições", ), "all_widgets_added": MessageLookupByLibrary.simpleMessage( - "Todos os widgets disponíveis já foram adicionados à tua " - "área pessoal!", + "Todos os widgets disponíveis já foram adicionados à tua área pessoal!", ), "at_least_one_college": MessageLookupByLibrary.simpleMessage( "Seleciona pelo menos uma faculdade", ), + "available_amount": + MessageLookupByLibrary.simpleMessage("Valor disponível"), "average": MessageLookupByLibrary.simpleMessage("Média: "), "balance": MessageLookupByLibrary.simpleMessage("Saldo:"), "bs_description": MessageLookupByLibrary.simpleMessage( @@ -81,8 +82,7 @@ class MessageLookup extends MessageLookupByLibrary { "Configura aqui os teus autocarros", ), "buses_text": MessageLookupByLibrary.simpleMessage( - "Os autocarros favoritos serão apresentados no widget 'Autocarros' " - "dos favoritos. Os restantes serão apresentados apenas na página.", + "Os autocarros favoritos serão apresentados no widget 'Autocarros' dos favoritos. Os restantes serão apresentados apenas na página.", ), "cancel": MessageLookupByLibrary.simpleMessage("Cancelar\n"), "change": MessageLookupByLibrary.simpleMessage("Alterar"), @@ -103,8 +103,7 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Autocarros Configurados"), "confirm": MessageLookupByLibrary.simpleMessage("Confirmar"), "consent": MessageLookupByLibrary.simpleMessage( - "Consinto que esta informação seja revista pelo NIAEFEUP, " - "podendo ser eliminada a meu pedido.", + "Consinto que esta informação seja revista pelo NIAEFEUP, podendo ser eliminada a meu pedido.", ), "contact": MessageLookupByLibrary.simpleMessage("Contacto (opcional)"), "copy_center": MessageLookupByLibrary.simpleMessage("Centro de cópias"), @@ -232,8 +231,7 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Tipo de ocorrência"), "other_links": MessageLookupByLibrary.simpleMessage("Outros links"), "pass_change_request": MessageLookupByLibrary.simpleMessage( - "Por razões de segurança, as palavras-passe têm de ser " - "alteradas periodicamente.", + "Por razões de segurança, as palavras-passe têm de ser alteradas periodicamente.", ), "password": MessageLookupByLibrary.simpleMessage("palavra-passe"), "pendent_references": @@ -244,6 +242,7 @@ class MessageLookup extends MessageLookupByLibrary { "Pressione novamente para sair", ), "print": MessageLookupByLibrary.simpleMessage("Impressão"), + "prints": MessageLookupByLibrary.simpleMessage("Impressões"), "problem_id": MessageLookupByLibrary.simpleMessage( "Breve identificação do problema", ), diff --git a/uni/lib/generated/l10n.dart b/uni/lib/generated/l10n.dart index bf85c2c4b..3a2aec795 100644 --- a/uni/lib/generated/l10n.dart +++ b/uni/lib/generated/l10n.dart @@ -134,6 +134,16 @@ class S { ); } + /// `Available amount` + String get available_amount { + return Intl.message( + 'Available amount', + name: 'available_amount', + desc: '', + args: [], + ); + } + /// `Average: ` String get average { return Intl.message( @@ -1052,6 +1062,16 @@ class S { ); } + /// `Prints` + String get prints { + return Intl.message( + 'Prints', + name: 'prints', + desc: '', + args: [], + ); + } + /// `Brief identification of the problem` String get problem_id { return Intl.message( diff --git a/uni/lib/l10n/intl_en.arb b/uni/lib/l10n/intl_en.arb index 770f69290..12a47bfbc 100644 --- a/uni/lib/l10n/intl_en.arb +++ b/uni/lib/l10n/intl_en.arb @@ -16,6 +16,8 @@ "@all_widgets_added": {}, "at_least_one_college": "Select at least one college", "@at_least_one_college": {}, + "available_amount": "Available amount", + "@available_amount": {}, "average": "Average: ", "@average": {}, "balance": "Balance:", @@ -204,6 +206,8 @@ "@press_again": {}, "print": "Print", "@print": {}, + "prints": "Prints", + "@prints": {}, "problem_id": "Brief identification of the problem", "@problem_id": {}, "reference_sigarra_help": "The generated reference data will appear in Sigarra, checking account.\\nProfile > Checking Account", diff --git a/uni/lib/l10n/intl_pt_PT.arb b/uni/lib/l10n/intl_pt_PT.arb index cda6d8639..ad8d0790d 100644 --- a/uni/lib/l10n/intl_pt_PT.arb +++ b/uni/lib/l10n/intl_pt_PT.arb @@ -16,6 +16,8 @@ "@all_widgets_added": {}, "at_least_one_college": "Seleciona pelo menos uma faculdade", "@at_least_one_college": {}, + "available_amount": "Valor disponível", + "@available_amount": {}, "average": "Média: ", "@average": {}, "balance": "Saldo:", @@ -204,6 +206,8 @@ "@press_again": {}, "print": "Impressão", "@print": {}, + "prints": "Impressões", + "@prints": {}, "problem_id": "Breve identificação do problema", "@problem_id": {}, "reference_sigarra_help": "Os dados da referência gerada aparecerão no Sigarra, conta corrente.\\nPerfil > Conta Corrente", diff --git a/uni/lib/view/bug_report/widgets/form.dart b/uni/lib/view/bug_report/widgets/form.dart index 6c5e1cfda..95888cb30 100644 --- a/uni/lib/view/bug_report/widgets/form.dart +++ b/uni/lib/view/bug_report/widgets/form.dart @@ -10,6 +10,7 @@ import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:tuple/tuple.dart'; import 'package:uni/controller/local_storage/app_shared_preferences.dart'; import 'package:uni/generated/l10n.dart'; +import 'package:uni/main.dart'; import 'package:uni/model/entities/app_locale.dart'; import 'package:uni/model/entities/bug_report.dart'; import 'package:uni/utils/drawer_items.dart'; @@ -62,7 +63,9 @@ class BugReportFormState extends State { bool _isConsentGiven = false; void loadBugClassList() { - final locale = Provider.of(context).getLocale(); + final locale = + Provider.of(MyApp.navigatorKey.currentContext!) + .getLocale(); bugList = bugDescriptions.entries .map( diff --git a/uni/lib/view/locale_notifier.dart b/uni/lib/view/locale_notifier.dart index 36cf71bc7..5ecbccda6 100644 --- a/uni/lib/view/locale_notifier.dart +++ b/uni/lib/view/locale_notifier.dart @@ -25,13 +25,11 @@ class LocaleNotifier with ChangeNotifier { } List getWeekdaysWithLocale() { - final weekdays = DateFormat.EEEE(_locale.localeCode.languageCode) - .dateSymbols - .WEEKDAYS - .skip(1) + final allWeekDays = DateFormat.EEEE().dateSymbols.WEEKDAYS; + final europeanWeekDays = allWeekDays.skip(1).toList() + ..add(allWeekDays.first); + return europeanWeekDays .map((weekday) => weekday[0].toUpperCase() + weekday.substring(1)) - .toList() - ..add(_locale == AppLocale.en ? 'Sunday' : 'Domingo'); - return weekdays; + .toList(); } } diff --git a/uni/lib/view/profile/widgets/print_info_card.dart b/uni/lib/view/profile/widgets/print_info_card.dart index 05b128f0e..fa26a3ebb 100644 --- a/uni/lib/view/profile/widgets/print_info_card.dart +++ b/uni/lib/view/profile/widgets/print_info_card.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/model/providers/startup/profile_provider.dart'; import 'package:uni/view/common_widgets/generic_card.dart'; import 'package:uni/view/lazy_consumer.dart'; @@ -38,7 +39,7 @@ class PrintInfoCard extends GenericCard { left: 20, ), child: Text( - 'Valor disponível: ', + S.of(context).available_amount, style: Theme.of(context).textTheme.titleSmall, ), ), @@ -76,7 +77,7 @@ class PrintInfoCard extends GenericCard { } @override - String getTitle(BuildContext context) => 'Impressões'; + String getTitle(BuildContext context) => S.of(context).prints; @override void onClick(BuildContext context) {} From c84ad695d09b630bf56ce63f84d73f5802ee108a Mon Sep 17 00:00:00 2001 From: DGoiana Date: Sun, 10 Sep 2023 12:24:33 +0100 Subject: [PATCH 34/50] Upgrading intl to 0.18.0 --- uni/lib/controller/local_storage/app_bus_stop_database.dart | 3 +-- uni/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/uni/lib/controller/local_storage/app_bus_stop_database.dart b/uni/lib/controller/local_storage/app_bus_stop_database.dart index a62476004..fa87d324d 100644 --- a/uni/lib/controller/local_storage/app_bus_stop_database.dart +++ b/uni/lib/controller/local_storage/app_bus_stop_database.dart @@ -38,8 +38,7 @@ class AppBusStopDatabase extends AppDatabase { } final stops = {}; - groupBy(buses, (stop) => (stop! as Map)['stopCode']) - .forEach( + groupBy(buses, (stop) => stop['stopCode']).forEach( (stopCode, busCodeList) => stops[stopCode as String] = BusStopData( configuredBuses: Set.from( busCodeList.map((busEntry) => busEntry['busCode']), diff --git a/uni/pubspec.yaml b/uni/pubspec.yaml index 0f7a15e56..3e0ffa867 100644 --- a/uni/pubspec.yaml +++ b/uni/pubspec.yaml @@ -38,7 +38,7 @@ dependencies: html: ^0.15.0 http: ^0.13.0 image: ^4.0.13 - intl: ^0.17.0 + intl: ^0.18.0 latlong2: ^0.8.1 logger: ^1.1.0 material_design_icons_flutter: ^7.0.7296 From ad377b89eb36f46747d38b0954d68b59dc25263d Mon Sep 17 00:00:00 2001 From: DGoiana Date: Sun, 10 Sep 2023 15:20:49 +0100 Subject: [PATCH 35/50] Removing navigator context --- uni/lib/main.dart | 4 ---- uni/lib/view/bug_report/widgets/form.dart | 8 ++++---- uni/lib/view/useful_info/widgets/other_links_card.dart | 4 ++-- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/uni/lib/main.dart b/uni/lib/main.dart index b21a0ccc6..6f2e29a30 100644 --- a/uni/lib/main.dart +++ b/uni/lib/main.dart @@ -166,9 +166,6 @@ class MyApp extends StatefulWidget { final String initialRoute; - static final GlobalKey navigatorKey = - GlobalKey(); - @override State createState() => MyAppState(); } @@ -195,7 +192,6 @@ class MyAppState extends State { ], supportedLocales: S.delegate.supportedLocales, initialRoute: widget.initialRoute, - navigatorKey: MyApp.navigatorKey, onGenerateRoute: (RouteSettings settings) { final transitions = { '/${DrawerItem.navPersonalArea.title}': diff --git a/uni/lib/view/bug_report/widgets/form.dart b/uni/lib/view/bug_report/widgets/form.dart index 95888cb30..b20cba429 100644 --- a/uni/lib/view/bug_report/widgets/form.dart +++ b/uni/lib/view/bug_report/widgets/form.dart @@ -10,7 +10,6 @@ import 'package:sentry_flutter/sentry_flutter.dart'; import 'package:tuple/tuple.dart'; import 'package:uni/controller/local_storage/app_shared_preferences.dart'; import 'package:uni/generated/l10n.dart'; -import 'package:uni/main.dart'; import 'package:uni/model/entities/app_locale.dart'; import 'package:uni/model/entities/bug_report.dart'; import 'package:uni/utils/drawer_items.dart'; @@ -30,7 +29,9 @@ class BugReportForm extends StatefulWidget { /// Manages the 'Bugs and Suggestions' section of the app class BugReportFormState extends State { - BugReportFormState() { + @override + void didChangeDependencies() { + super.didChangeDependencies(); loadBugClassList(); } @@ -64,8 +65,7 @@ class BugReportFormState extends State { void loadBugClassList() { final locale = - Provider.of(MyApp.navigatorKey.currentContext!) - .getLocale(); + Provider.of(context, listen: false).getLocale(); bugList = bugDescriptions.entries .map( diff --git a/uni/lib/view/useful_info/widgets/other_links_card.dart b/uni/lib/view/useful_info/widgets/other_links_card.dart index 42e7fd713..47ae82046 100644 --- a/uni/lib/view/useful_info/widgets/other_links_card.dart +++ b/uni/lib/view/useful_info/widgets/other_links_card.dart @@ -10,8 +10,8 @@ class OtherLinksCard extends GenericExpansionCard { @override Widget buildCardContent(BuildContext context) { - return Column( - children: const [ + return const Column( + children: [ // LinkButton(title: S.of(context).print, link: 'https://print.up.pt'), // TODO(Process-ing): Get fixed link LinkButton( From 1bc0faed41ccbd577aa6271a537646013de3336d Mon Sep 17 00:00:00 2001 From: DGoiana Date: Sun, 10 Sep 2023 19:22:19 +0100 Subject: [PATCH 36/50] Testable widget fix --- uni/test/test_widget.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/uni/test/test_widget.dart b/uni/test/test_widget.dart index 7cdac440c..a84960a72 100644 --- a/uni/test/test_widget.dart +++ b/uni/test/test_widget.dart @@ -3,6 +3,9 @@ import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:provider/provider.dart'; import 'package:uni/generated/l10n.dart'; import 'package:uni/model/entities/app_locale.dart'; + +import 'package:uni/model/providers/startup/profile_provider.dart'; +import 'package:uni/model/providers/startup/session_provider.dart'; import 'package:uni/view/locale_notifier.dart'; Widget testableWidget( @@ -11,6 +14,8 @@ Widget testableWidget( }) { return MultiProvider( providers: [ + ChangeNotifierProvider(create: (context) => SessionProvider()), + ChangeNotifierProvider(create: (context) => ProfileProvider()), ChangeNotifierProvider( create: (_) => LocaleNotifier(AppLocale.pt), ), From 552370165eaa1870160b900a0a94b7d8c9301c60 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Sun, 10 Sep 2023 19:32:47 +0100 Subject: [PATCH 37/50] Test fixing --- uni/test/mocks/integration/src/schedule_page_test.mocks.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/uni/test/mocks/integration/src/schedule_page_test.mocks.dart b/uni/test/mocks/integration/src/schedule_page_test.mocks.dart index c3259a73a..d46eb9577 100644 --- a/uni/test/mocks/integration/src/schedule_page_test.mocks.dart +++ b/uni/test/mocks/integration/src/schedule_page_test.mocks.dart @@ -9,6 +9,7 @@ import 'dart:typed_data' as _i6; import 'dart:ui' as _i11; import 'package:flutter/material.dart' as _i10; +import 'package:flutter/widgets.dart'; import 'package:http/http.dart' as _i2; import 'package:mockito/mockito.dart' as _i1; import 'package:uni/model/entities/profile.dart' as _i9; @@ -493,6 +494,7 @@ class MockSessionProvider extends _i1.Mock implements _i7.SessionProvider { ); @override _i4.Future postAuthentication( + BuildContext context, String? username, String? password, List? faculties, { From 5e1cb2c4361aa7f8d8bcc24ff7582b0cd1d623e7 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Sun, 10 Sep 2023 20:13:45 +0100 Subject: [PATCH 38/50] Generated mock file --- uni/test/mocks/integration/src/schedule_page_test.mocks.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uni/test/mocks/integration/src/schedule_page_test.mocks.dart b/uni/test/mocks/integration/src/schedule_page_test.mocks.dart index d46eb9577..e5e3b4548 100644 --- a/uni/test/mocks/integration/src/schedule_page_test.mocks.dart +++ b/uni/test/mocks/integration/src/schedule_page_test.mocks.dart @@ -9,7 +9,6 @@ import 'dart:typed_data' as _i6; import 'dart:ui' as _i11; import 'package:flutter/material.dart' as _i10; -import 'package:flutter/widgets.dart'; import 'package:http/http.dart' as _i2; import 'package:mockito/mockito.dart' as _i1; import 'package:uni/model/entities/profile.dart' as _i9; @@ -494,7 +493,7 @@ class MockSessionProvider extends _i1.Mock implements _i7.SessionProvider { ); @override _i4.Future postAuthentication( - BuildContext context, + _i10.BuildContext? context, String? username, String? password, List? faculties, { @@ -504,6 +503,7 @@ class MockSessionProvider extends _i1.Mock implements _i7.SessionProvider { Invocation.method( #postAuthentication, [ + context, username, password, faculties, From 1ff9249661cf425e3a85983c1f8526ae84c555ab Mon Sep 17 00:00:00 2001 From: thePeras Date: Mon, 11 Sep 2023 13:08:20 +0100 Subject: [PATCH 39/50] Update xcode project file --- uni/ios/Runner.xcodeproj/project.pbxproj | 3 ++- .../Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/uni/ios/Runner.xcodeproj/project.pbxproj b/uni/ios/Runner.xcodeproj/project.pbxproj index d9fdaf94b..ef55cd3bd 100644 --- a/uni/ios/Runner.xcodeproj/project.pbxproj +++ b/uni/ios/Runner.xcodeproj/project.pbxproj @@ -155,7 +155,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -204,6 +204,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/uni/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/uni/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index c87d15a33..a6b826db2 100644 --- a/uni/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/uni/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ Date: Wed, 13 Sep 2023 11:57:43 +0100 Subject: [PATCH 40/50] Removing session provider --- uni/test/test_widget.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/uni/test/test_widget.dart b/uni/test/test_widget.dart index a84960a72..1cae5ed12 100644 --- a/uni/test/test_widget.dart +++ b/uni/test/test_widget.dart @@ -5,7 +5,6 @@ import 'package:uni/generated/l10n.dart'; import 'package:uni/model/entities/app_locale.dart'; import 'package:uni/model/providers/startup/profile_provider.dart'; -import 'package:uni/model/providers/startup/session_provider.dart'; import 'package:uni/view/locale_notifier.dart'; Widget testableWidget( @@ -14,7 +13,6 @@ Widget testableWidget( }) { return MultiProvider( providers: [ - ChangeNotifierProvider(create: (context) => SessionProvider()), ChangeNotifierProvider(create: (context) => ProfileProvider()), ChangeNotifierProvider( create: (_) => LocaleNotifier(AppLocale.pt), From e7bae044207dabaf3e121848391ce9d2286176b7 Mon Sep 17 00:00:00 2001 From: Bruno Mendes Date: Wed, 13 Sep 2023 12:42:30 +0100 Subject: [PATCH 41/50] Do not log missing startup providers in testing mode --- uni/lib/view/lazy_consumer.dart | 13 +++++++++---- uni/test/integration/src/schedule_page_test.dart | 2 +- uni/test/test_widget.dart | 3 --- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/uni/lib/view/lazy_consumer.dart b/uni/lib/view/lazy_consumer.dart index c1a15dcb3..49b19d748 100644 --- a/uni/lib/view/lazy_consumer.dart +++ b/uni/lib/view/lazy_consumer.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:logger/logger.dart'; @@ -46,10 +47,14 @@ class LazyConsumer extends StatelessWidget { }) : Future(() {}); } catch (exception, stackTrace) { - Logger().e( - 'Failed to initialize startup providers: $exception', - ); - await Sentry.captureException(exception, stackTrace: stackTrace); + // In tests, it is ok to not find the startup providers: + // all provider data should be mocked by the test itself. + if (!Platform.environment.containsKey('FLUTTER_TEST')) { + Logger().e( + 'Failed to initialize startup providers: $exception', + ); + await Sentry.captureException(exception, stackTrace: stackTrace); + } } // Load data stored in the database immediately diff --git a/uni/test/integration/src/schedule_page_test.dart b/uni/test/integration/src/schedule_page_test.dart index 12906429f..e775c86b2 100644 --- a/uni/test/integration/src/schedule_page_test.dart +++ b/uni/test/integration/src/schedule_page_test.dart @@ -58,7 +58,7 @@ void main() { final providers = [ ChangeNotifierProvider(create: (_) => scheduleProvider), - ChangeNotifierProvider(create: (_) => sessionProvider), + ChangeNotifierProvider(create: (_) => sessionProvider), ]; await tester.pumpWidget(testableWidget(widget, providers: providers)); diff --git a/uni/test/test_widget.dart b/uni/test/test_widget.dart index 1cae5ed12..7cdac440c 100644 --- a/uni/test/test_widget.dart +++ b/uni/test/test_widget.dart @@ -3,8 +3,6 @@ import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:provider/provider.dart'; import 'package:uni/generated/l10n.dart'; import 'package:uni/model/entities/app_locale.dart'; - -import 'package:uni/model/providers/startup/profile_provider.dart'; import 'package:uni/view/locale_notifier.dart'; Widget testableWidget( @@ -13,7 +11,6 @@ Widget testableWidget( }) { return MultiProvider( providers: [ - ChangeNotifierProvider(create: (context) => ProfileProvider()), ChangeNotifierProvider( create: (_) => LocaleNotifier(AppLocale.pt), ), From 4c232c95b64cae5e9042ec3f95b2359f8a7aba34 Mon Sep 17 00:00:00 2001 From: Bruno Mendes Date: Wed, 13 Sep 2023 15:10:06 +0100 Subject: [PATCH 42/50] Fix untranslated page titles --- uni/analysis_options.yaml | 1 + uni/lib/generated/intl/messages_all.dart | 36 ++-- uni/lib/generated/intl/messages_en.dart | 153 ++++++---------- uni/lib/generated/intl/messages_pt_PT.dart | 168 +++++++----------- uni/lib/generated/l10n.dart | 34 ++-- uni/lib/l10n/intl_en.arb | 6 +- uni/lib/l10n/intl_pt_PT.arb | 2 +- uni/lib/view/calendar/calendar.dart | 7 +- .../view/exams/widgets/exam_filter_form.dart | 12 +- uni/lib/view/locations/locations.dart | 9 +- .../view/restaurant/restaurant_page_view.dart | 5 +- 11 files changed, 182 insertions(+), 251 deletions(-) diff --git a/uni/analysis_options.yaml b/uni/analysis_options.yaml index 6acf469de..540e952da 100644 --- a/uni/analysis_options.yaml +++ b/uni/analysis_options.yaml @@ -5,6 +5,7 @@ analyzer: exclude: - "**.g.dart" - "**.mocks.dart" + - "**generated/**" # Custom linter rules. A list of all rules can be found at # https://dart-lang.github.io/linter/lints/options/options.html diff --git a/uni/lib/generated/intl/messages_all.dart b/uni/lib/generated/intl/messages_all.dart index 5c2bef3d1..b77f94db2 100644 --- a/uni/lib/generated/intl/messages_all.dart +++ b/uni/lib/generated/intl/messages_all.dart @@ -11,17 +11,18 @@ import 'dart:async'; +import 'package:flutter/foundation.dart'; import 'package:intl/intl.dart'; import 'package:intl/message_lookup_by_library.dart'; import 'package:intl/src/intl_helpers.dart'; -import 'package:uni/generated/intl/messages_en.dart' as messages_en; -import 'package:uni/generated/intl/messages_pt_PT.dart' as messages_pt_pt; +import 'messages_en.dart' as messages_en; +import 'messages_pt_PT.dart' as messages_pt_pt; typedef Future LibraryLoader(); Map _deferredLibraries = { - 'en': Future.value, - 'pt_PT': Future.value, + 'en': () => new SynchronousFuture(null), + 'pt_PT': () => new SynchronousFuture(null), }; MessageLookupByLibrary? _findExact(String localeName) { @@ -36,20 +37,18 @@ MessageLookupByLibrary? _findExact(String localeName) { } /// User programs should call this before using [localeName] for messages. -Future initializeMessages(String localeName) async { - final availableLocale = Intl.verifiedLocale( - localeName, - (locale) => _deferredLibraries[locale] != null, - onFailure: (_) => null, - ); +Future initializeMessages(String localeName) { + var availableLocale = Intl.verifiedLocale( + localeName, (locale) => _deferredLibraries[locale] != null, + onFailure: (_) => null); if (availableLocale == null) { - return new Future.value(false); + return new SynchronousFuture(false); } - final lib = _deferredLibraries[availableLocale]; - await (lib == null ? new Future.value(false) : lib()); - initializeInternalMessageLookup(CompositeMessageLookup.new); + var lib = _deferredLibraries[availableLocale]; + lib == null ? new SynchronousFuture(false) : lib(); + initializeInternalMessageLookup(() => new CompositeMessageLookup()); messageLookup.addLocale(availableLocale, _findGeneratedMessagesFor); - return new Future.value(true); + return new SynchronousFuture(true); } bool _messagesExistFor(String locale) { @@ -61,11 +60,8 @@ bool _messagesExistFor(String locale) { } MessageLookupByLibrary? _findGeneratedMessagesFor(String locale) { - final actualLocale = Intl.verifiedLocale( - locale, - _messagesExistFor, - onFailure: (_) => null, - ); + var actualLocale = + Intl.verifiedLocale(locale, _messagesExistFor, onFailure: (_) => null); if (actualLocale == null) return null; return _findExact(actualLocale); } diff --git a/uni/lib/generated/intl/messages_en.dart b/uni/lib/generated/intl/messages_en.dart index eccb8f146..8df0e5ffd 100644 --- a/uni/lib/generated/intl/messages_en.dart +++ b/uni/lib/generated/intl/messages_en.dart @@ -4,10 +4,11 @@ // function name. // Ignore issues from commonly used lints in this file. -// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new, lines_longer_than_80_chars +// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases -// ignore_for_file:unused_import, file_names +// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes +// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes import 'package:intl/intl.dart'; import 'package:intl/message_lookup_by_library.dart'; @@ -19,30 +20,26 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'en'; - static String m0(dynamic time) => "last refresh at ${time}"; + static String m0(time) => "last refresh at ${time}"; - static String m1(dynamic time) => Intl.plural( - time as num, - zero: 'Refreshed ${time} minutes ago', - one: 'Refreshed ${time} minute ago', - other: 'Refreshed ${time} minutes ago', - ); + static String m1(time) => + "${Intl.plural(time, zero: 'Refreshed ${time} minutes ago', one: 'Refreshed ${time} minute ago', other: 'Refreshed ${time} minutes ago')}"; - static String m2(String title) => Intl.select(title, { - 'horario': 'Schedule', - 'exames': 'Exams', - 'area': 'Personal Area', - 'cadeiras': 'Course Units', - 'autocarros': 'Buses', - 'locais': 'Places', - 'restaurantes': 'Restaurants', - 'calendario': 'Calendar', - 'biblioteca': 'Library', - 'uteis': 'Utils', - 'sobre': 'About', - 'bugs': 'Bugs/ Suggestions', - 'other': 'Other', - }); + static String m2(title) => "${Intl.select(title, { + 'horario': 'Schedule', + 'exames': 'Exams', + 'area': 'Personal Area', + 'cadeiras': 'Course Units', + 'autocarros': 'Buses', + 'locais': 'Places', + 'restaurantes': 'Restaurants', + 'calendario': 'Calendar', + 'biblioteca': 'Library', + 'uteis': 'Utils', + 'sobre': 'About', + 'bugs': 'Bugs/Suggestions', + 'other': 'Other', + })}"; final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { @@ -54,11 +51,9 @@ class MessageLookup extends MessageLookupByLibrary { "add_quota": MessageLookupByLibrary.simpleMessage("Add quota"), "add_widget": MessageLookupByLibrary.simpleMessage("Add widget"), "agree_terms": MessageLookupByLibrary.simpleMessage( - "By entering you confirm that you agree with these Terms and Conditions", - ), + "By entering you confirm that you agree with these Terms and Conditions"), "all_widgets_added": MessageLookupByLibrary.simpleMessage( - "All available widgets have already been added to your personal area!", - ), + "All available widgets have already been added to your personal area!"), "at_least_one_college": MessageLookupByLibrary.simpleMessage("Select at least one college"), "available_amount": @@ -66,29 +61,23 @@ class MessageLookup extends MessageLookupByLibrary { "average": MessageLookupByLibrary.simpleMessage("Average: "), "balance": MessageLookupByLibrary.simpleMessage("Balance:"), "bs_description": MessageLookupByLibrary.simpleMessage( - r"Did you find any bugs in the application?\nDo you have any suggestions for the app?\nTell us so we can improve!", - ), + "Did you find any bugs in the application?\nDo you have any suggestions for the app?\nTell us so we can improve!"), "bug_description": MessageLookupByLibrary.simpleMessage( - "Bug found, how to reproduce it, etc.", - ), + "Bug found, how to reproduce it, etc."), "bus_error": MessageLookupByLibrary.simpleMessage("Unable to get information"), "bus_information": MessageLookupByLibrary.simpleMessage( - "Select the buses you want information about:", - ), + "Select the buses you want information about:"), "buses_personalize": MessageLookupByLibrary.simpleMessage("Personalize your buses here"), "buses_text": MessageLookupByLibrary.simpleMessage( - "Favorite buses will be displayed in the favorites 'Bus' widget. The remaining ones will only be displayed on the page.", - ), + "Favorite buses will be displayed in the favorites \'Bus\' widget. The remaining ones will only be displayed on the page."), "cancel": MessageLookupByLibrary.simpleMessage("Cancel"), "change": MessageLookupByLibrary.simpleMessage("Change"), "change_prompt": MessageLookupByLibrary.simpleMessage( - "Do you want to change the password?", - ), + "Do you want to change the password?"), "check_internet": MessageLookupByLibrary.simpleMessage( - "Check your internet connection", - ), + "Check your internet connection"), "class_registration": MessageLookupByLibrary.simpleMessage("Class Registration"), "college": MessageLookupByLibrary.simpleMessage("College: "), @@ -99,13 +88,11 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Configured Buses"), "confirm": MessageLookupByLibrary.simpleMessage("Confirm"), "consent": MessageLookupByLibrary.simpleMessage( - "I consent to this information being reviewed by NIAEFEUP and may be deleted at my request.", - ), + "I consent to this information being reviewed by NIAEFEUP and may be deleted at my request."), "contact": MessageLookupByLibrary.simpleMessage("Contact (optional)"), "copy_center": MessageLookupByLibrary.simpleMessage("Copy center"), "copy_center_building": MessageLookupByLibrary.simpleMessage( - "Floor -1 of building B | AEFEUP building", - ), + "Floor -1 of building B | AEFEUP building"), "course_class": MessageLookupByLibrary.simpleMessage("Classes"), "course_info": MessageLookupByLibrary.simpleMessage("Info"), "current_state": @@ -115,21 +102,18 @@ class MessageLookup extends MessageLookupByLibrary { "decrement": MessageLookupByLibrary.simpleMessage("Decrement 1,00€"), "description": MessageLookupByLibrary.simpleMessage("Description"), "desired_email": MessageLookupByLibrary.simpleMessage( - "Email where you want to be contacted", - ), + "Email where you want to be contacted"), "dona_bia": MessageLookupByLibrary.simpleMessage( - "D. Beatriz's stationery store", - ), + "D. Beatriz\'s stationery store"), "dona_bia_building": MessageLookupByLibrary.simpleMessage( - "Floor -1 of building B (B-142)", - ), + "Floor -1 of building B (B-142)"), "ects": MessageLookupByLibrary.simpleMessage("ECTs performed: "), "edit_off": MessageLookupByLibrary.simpleMessage("Edit"), "edit_on": MessageLookupByLibrary.simpleMessage("Finish editing"), "empty_text": MessageLookupByLibrary.simpleMessage("Please fill in this field"), "exams_filter": - MessageLookupByLibrary.simpleMessage("Exam Filter Settings"), + MessageLookupByLibrary.simpleMessage("Exams Filter Settings"), "expired_password": MessageLookupByLibrary.simpleMessage("Your password has expired"), "failed_login": MessageLookupByLibrary.simpleMessage("Login failed"), @@ -138,8 +122,7 @@ class MessageLookup extends MessageLookupByLibrary { "fee_notification": MessageLookupByLibrary.simpleMessage("Notify next deadline:"), "first_year_registration": MessageLookupByLibrary.simpleMessage( - "Year of first registration: ", - ), + "Year of first registration: "), "floor": MessageLookupByLibrary.simpleMessage("Floor"), "floors": MessageLookupByLibrary.simpleMessage("Floors"), "forgot_password": @@ -159,11 +142,9 @@ class MessageLookup extends MessageLookupByLibrary { "library_occupation": MessageLookupByLibrary.simpleMessage("Library Occupation"), "load_error": MessageLookupByLibrary.simpleMessage( - "Error loading the information", - ), + "Error loading the information"), "loading_terms": MessageLookupByLibrary.simpleMessage( - "Loading Terms and Conditions...", - ), + "Loading Terms and Conditions..."), "login": MessageLookupByLibrary.simpleMessage("Login"), "logout": MessageLookupByLibrary.simpleMessage("Log out"), "menus": MessageLookupByLibrary.simpleMessage("Menus"), @@ -173,59 +154,47 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Multimedia center"), "nav_title": m2, "news": MessageLookupByLibrary.simpleMessage("News"), - "no_bus": MessageLookupByLibrary.simpleMessage("Don't miss any bus!"), + "no_bus": MessageLookupByLibrary.simpleMessage("Don\'t miss any bus!"), "no_bus_stops": MessageLookupByLibrary.simpleMessage("No configured stops"), "no_class": MessageLookupByLibrary.simpleMessage( - "There are no classes to display", - ), + "There are no classes to display"), "no_classes": MessageLookupByLibrary.simpleMessage("No classes to present"), "no_classes_on": - MessageLookupByLibrary.simpleMessage("You don't have classes on"), + MessageLookupByLibrary.simpleMessage("You don\'t have classes on"), "no_college": MessageLookupByLibrary.simpleMessage("no college"), "no_course_units": MessageLookupByLibrary.simpleMessage( - "No course units in the selected period", - ), + "No course units in the selected period"), "no_data": MessageLookupByLibrary.simpleMessage( - "There is no data to show at this time", - ), + "There is no data to show at this time"), "no_date": MessageLookupByLibrary.simpleMessage("No date"), "no_exams": MessageLookupByLibrary.simpleMessage( - "You have no exams scheduled\n", - ), + "You have no exams scheduled\n"), "no_exams_label": MessageLookupByLibrary.simpleMessage( - "Looks like you are on vacation!", - ), + "Looks like you are on vacation!"), "no_favorite_restaurants": MessageLookupByLibrary.simpleMessage("No favorite restaurants"), "no_info": MessageLookupByLibrary.simpleMessage( - "There is no information to display", - ), + "There is no information to display"), "no_menu_info": MessageLookupByLibrary.simpleMessage( - "There is no information available about meals", - ), + "There is no information available about meals"), "no_menus": MessageLookupByLibrary.simpleMessage( - "There are no meals available", - ), + "There are no meals available"), "no_name_course": MessageLookupByLibrary.simpleMessage("Unnamed course"), "no_references": MessageLookupByLibrary.simpleMessage( - "There are no references to pay", - ), + "There are no references to pay"), "no_results": MessageLookupByLibrary.simpleMessage("No match"), "no_selected_courses": MessageLookupByLibrary.simpleMessage( - "There are no course units to display", - ), + "There are no course units to display"), "no_selected_exams": MessageLookupByLibrary.simpleMessage( - "There are no exams to present", - ), + "There are no exams to present"), "occurrence_type": MessageLookupByLibrary.simpleMessage("Type of occurrence"), "other_links": MessageLookupByLibrary.simpleMessage("Other links"), "pass_change_request": MessageLookupByLibrary.simpleMessage( - "For security reasons, passwords must be changed periodically.", - ), + "For security reasons, passwords must be changed periodically."), "password": MessageLookupByLibrary.simpleMessage("password"), "pendent_references": MessageLookupByLibrary.simpleMessage("Pending references"), @@ -236,14 +205,11 @@ class MessageLookup extends MessageLookupByLibrary { "print": MessageLookupByLibrary.simpleMessage("Print"), "prints": MessageLookupByLibrary.simpleMessage("Prints"), "problem_id": MessageLookupByLibrary.simpleMessage( - "Brief identification of the problem", - ), + "Brief identification of the problem"), "reference_sigarra_help": MessageLookupByLibrary.simpleMessage( - r"The generated reference data will appear in Sigarra, checking account.\nProfile > Checking Account", - ), + "The generated reference data will appear in Sigarra, checking account.\\nProfile > Checking Account"), "reference_success": MessageLookupByLibrary.simpleMessage( - "Reference created successfully!", - ), + "Reference created successfully!"), "remove": MessageLookupByLibrary.simpleMessage("Delete"), "report_error": MessageLookupByLibrary.simpleMessage("Report error"), "room": MessageLookupByLibrary.simpleMessage("Room"), @@ -252,8 +218,7 @@ class MessageLookup extends MessageLookupByLibrary { "semester": MessageLookupByLibrary.simpleMessage("Semester"), "send": MessageLookupByLibrary.simpleMessage("Send"), "sent_error": MessageLookupByLibrary.simpleMessage( - "An error occurred in sending", - ), + "An error occurred in sending"), "some_error": MessageLookupByLibrary.simpleMessage("Some error!"), "stcp_stops": MessageLookupByLibrary.simpleMessage("STCP - Upcoming Trips"), @@ -263,8 +228,7 @@ class MessageLookup extends MessageLookupByLibrary { "tele_assistance": MessageLookupByLibrary.simpleMessage("Telephone assistance"), "tele_personal_assistance": MessageLookupByLibrary.simpleMessage( - "Face-to-face and telephone assistance", - ), + "Face-to-face and telephone assistance"), "telephone": MessageLookupByLibrary.simpleMessage("Telephone"), "terms": MessageLookupByLibrary.simpleMessage("Terms and Conditions"), "title": MessageLookupByLibrary.simpleMessage("Title"), @@ -272,8 +236,7 @@ class MessageLookup extends MessageLookupByLibrary { "valid_email": MessageLookupByLibrary.simpleMessage("Please enter a valid email"), "widget_prompt": MessageLookupByLibrary.simpleMessage( - "Choose a widget to add to your personal area:", - ), + "Choose a widget to add to your personal area:"), "year": MessageLookupByLibrary.simpleMessage("Year") }; } diff --git a/uni/lib/generated/intl/messages_pt_PT.dart b/uni/lib/generated/intl/messages_pt_PT.dart index 800ef819f..34347734b 100644 --- a/uni/lib/generated/intl/messages_pt_PT.dart +++ b/uni/lib/generated/intl/messages_pt_PT.dart @@ -4,10 +4,11 @@ // function name. // Ignore issues from commonly used lints in this file. -// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new, lines_longer_than_80_chars +// ignore_for_file:unnecessary_brace_in_string_interps, unnecessary_new // ignore_for_file:prefer_single_quotes,comment_references, directives_ordering // ignore_for_file:annotate_overrides,prefer_generic_function_type_aliases -// ignore_for_file:unused_import, file_names +// ignore_for_file:unused_import, file_names, avoid_escaping_inner_quotes +// ignore_for_file:unnecessary_string_interpolations, unnecessary_string_escapes import 'package:intl/intl.dart'; import 'package:intl/message_lookup_by_library.dart'; @@ -19,30 +20,26 @@ typedef String MessageIfAbsent(String messageStr, List args); class MessageLookup extends MessageLookupByLibrary { String get localeName => 'pt_PT'; - static String m0(dynamic time) => "última atualização às ${time}"; + static String m0(time) => "última atualização às ${time}"; - static String m1(dynamic time) => Intl.plural( - time as num, - zero: 'Atualizado há ${time} minutos', - one: 'Atualizado há ${time} minuto', - other: 'Atualizado há ${time} minutos', - ); + static String m1(time) => + "${Intl.plural(time, zero: 'Atualizado há ${time} minutos', one: 'Atualizado há ${time} minuto', other: 'Atualizado há ${time} minutos')}"; - static String m2(String title) => Intl.select(title, { - 'horario': 'Horário', - 'exames': 'Exames', - 'area': 'Área Pessoal', - 'cadeiras': 'Cadeiras', - 'autocarros': 'Autocarros', - 'locais': 'Locais', - 'restaurantes': 'Restaurantes', - 'calendario': 'Calendário', - 'biblioteca': 'Biblioteca', - 'uteis': 'Úteis', - 'sobre': 'Sobre', - 'bugs': 'Bugs e Sugestões', - 'other': 'Outros', - }); + static String m2(title) => "${Intl.select(title, { + 'horario': 'Horário', + 'exames': 'Exames', + 'area': 'Área Pessoal', + 'cadeiras': 'Cadeiras', + 'autocarros': 'Autocarros', + 'locais': 'Locais', + 'restaurantes': 'Restaurantes', + 'calendario': 'Calendário', + 'biblioteca': 'Biblioteca', + 'uteis': 'Úteis', + 'sobre': 'Sobre', + 'bugs': 'Bugs e Sugestões', + 'other': 'Outros', + })}"; final messages = _notInlinedMessages(_notInlinedMessages); static Map _notInlinedMessages(_) => { @@ -54,62 +51,48 @@ class MessageLookup extends MessageLookupByLibrary { "add_quota": MessageLookupByLibrary.simpleMessage("Adicionar quota"), "add_widget": MessageLookupByLibrary.simpleMessage("Adicionar widget"), "agree_terms": MessageLookupByLibrary.simpleMessage( - "Ao entrares confirmas que concordas com estes Termos e Condições", - ), + "Ao entrares confirmas que concordas com estes Termos e Condições"), "all_widgets_added": MessageLookupByLibrary.simpleMessage( - "Todos os widgets disponíveis já foram adicionados à tua área pessoal!", - ), + "Todos os widgets disponíveis já foram adicionados à tua área pessoal!"), "at_least_one_college": MessageLookupByLibrary.simpleMessage( - "Seleciona pelo menos uma faculdade", - ), + "Seleciona pelo menos uma faculdade"), "available_amount": MessageLookupByLibrary.simpleMessage("Valor disponível"), "average": MessageLookupByLibrary.simpleMessage("Média: "), "balance": MessageLookupByLibrary.simpleMessage("Saldo:"), "bs_description": MessageLookupByLibrary.simpleMessage( - r"Encontraste algum bug na aplicação?\nTens alguma sugestão para a app?\nConta-nos para que possamos melhorar!", - ), + "Encontraste algum bug na aplicação?\nTens alguma sugestão para a app?\nConta-nos para que possamos melhorar!"), "bug_description": MessageLookupByLibrary.simpleMessage( - "Bug encontrado, como o reproduzir, etc", - ), + "Bug encontrado, como o reproduzir, etc"), "bus_error": MessageLookupByLibrary.simpleMessage( - "Não foi possível obter informação", - ), + "Não foi possível obter informação"), "bus_information": MessageLookupByLibrary.simpleMessage( - "Seleciona os autocarros dos quais queres informação:", - ), + "Seleciona os autocarros dos quais queres informação:"), "buses_personalize": MessageLookupByLibrary.simpleMessage( - "Configura aqui os teus autocarros", - ), + "Configura aqui os teus autocarros"), "buses_text": MessageLookupByLibrary.simpleMessage( - "Os autocarros favoritos serão apresentados no widget 'Autocarros' dos favoritos. Os restantes serão apresentados apenas na página.", - ), + "Os autocarros favoritos serão apresentados no widget \'Autocarros\' dos favoritos. Os restantes serão apresentados apenas na página."), "cancel": MessageLookupByLibrary.simpleMessage("Cancelar\n"), "change": MessageLookupByLibrary.simpleMessage("Alterar"), "change_prompt": MessageLookupByLibrary.simpleMessage( - "Deseja alterar a palavra-passe?", - ), + "Deseja alterar a palavra-passe?"), "check_internet": MessageLookupByLibrary.simpleMessage( - "Verifica a tua ligação à internet", - ), + "Verifica a tua ligação à internet"), "class_registration": MessageLookupByLibrary.simpleMessage("Inscrição de Turmas"), "college": MessageLookupByLibrary.simpleMessage("Faculdade: "), "college_select": MessageLookupByLibrary.simpleMessage( - "seleciona a(s) tua(s) faculdade(s)", - ), + "seleciona a(s) tua(s) faculdade(s)"), "conclude": MessageLookupByLibrary.simpleMessage("Concluído"), "configured_buses": MessageLookupByLibrary.simpleMessage("Autocarros Configurados"), "confirm": MessageLookupByLibrary.simpleMessage("Confirmar"), "consent": MessageLookupByLibrary.simpleMessage( - "Consinto que esta informação seja revista pelo NIAEFEUP, podendo ser eliminada a meu pedido.", - ), + "Consinto que esta informação seja revista pelo NIAEFEUP, podendo ser eliminada a meu pedido."), "contact": MessageLookupByLibrary.simpleMessage("Contacto (opcional)"), "copy_center": MessageLookupByLibrary.simpleMessage("Centro de cópias"), "copy_center_building": MessageLookupByLibrary.simpleMessage( - "Piso -1 do edifício B | Edifício da AEFEUP", - ), + "Piso -1 do edifício B | Edifício da AEFEUP"), "course_class": MessageLookupByLibrary.simpleMessage("Turmas"), "course_info": MessageLookupByLibrary.simpleMessage("Ficha"), "current_state": MessageLookupByLibrary.simpleMessage("Estado atual: "), @@ -118,30 +101,25 @@ class MessageLookup extends MessageLookupByLibrary { "decrement": MessageLookupByLibrary.simpleMessage("Decrementar 1,00€"), "description": MessageLookupByLibrary.simpleMessage("Descrição"), "desired_email": MessageLookupByLibrary.simpleMessage( - "Email em que desejas ser contactado", - ), + "Email em que desejas ser contactado"), "dona_bia": MessageLookupByLibrary.simpleMessage("Papelaria D. Beatriz"), "dona_bia_building": MessageLookupByLibrary.simpleMessage( - "Piso -1 do edifício B (B-142)", - ), + "Piso -1 do edifício B (B-142)"), "ects": MessageLookupByLibrary.simpleMessage("ECTs realizados: "), "edit_off": MessageLookupByLibrary.simpleMessage("Editar\n"), "edit_on": MessageLookupByLibrary.simpleMessage("Concluir edição"), "empty_text": MessageLookupByLibrary.simpleMessage( - "Por favor preenche este campo", - ), + "Por favor preenche este campo"), "exams_filter": MessageLookupByLibrary.simpleMessage("Definições Filtro de Exames"), "expired_password": MessageLookupByLibrary.simpleMessage("A tua palavra-passe expirou"), "failed_login": MessageLookupByLibrary.simpleMessage("O login falhou"), "fee_date": MessageLookupByLibrary.simpleMessage( - "Data limite próxima prestação:", - ), + "Data limite próxima prestação:"), "fee_notification": MessageLookupByLibrary.simpleMessage( - "Notificar próxima data limite:", - ), + "Notificar próxima data limite:"), "first_year_registration": MessageLookupByLibrary.simpleMessage("Ano da primeira inscrição: "), "floor": MessageLookupByLibrary.simpleMessage("Piso"), @@ -164,11 +142,9 @@ class MessageLookup extends MessageLookupByLibrary { "library_occupation": MessageLookupByLibrary.simpleMessage("Ocupação da Biblioteca"), "load_error": MessageLookupByLibrary.simpleMessage( - "Aconteceu um erro ao carregar os dados", - ), + "Aconteceu um erro ao carregar os dados"), "loading_terms": MessageLookupByLibrary.simpleMessage( - "Carregando os Termos e Condições...", - ), + "Carregando os Termos e Condições..."), "login": MessageLookupByLibrary.simpleMessage("Entrar"), "logout": MessageLookupByLibrary.simpleMessage("Terminar sessão"), "menus": MessageLookupByLibrary.simpleMessage("Ementas"), @@ -179,26 +155,20 @@ class MessageLookup extends MessageLookupByLibrary { "nav_title": m2, "news": MessageLookupByLibrary.simpleMessage("Notícias"), "no_bus": MessageLookupByLibrary.simpleMessage( - "Não percas nenhum autocarro!", - ), + "Não percas nenhum autocarro!"), "no_bus_stops": MessageLookupByLibrary.simpleMessage( - "Não existe nenhuma paragem configurada", - ), + "Não existe nenhuma paragem configurada"), "no_class": MessageLookupByLibrary.simpleMessage( - "Não existem turmas para apresentar", - ), + "Não existem turmas para apresentar"), "no_classes": MessageLookupByLibrary.simpleMessage( - "Não existem aulas para apresentar", - ), + "Não existem aulas para apresentar"), "no_classes_on": MessageLookupByLibrary.simpleMessage("Não possui aulas à"), "no_college": MessageLookupByLibrary.simpleMessage("sem faculdade"), "no_course_units": MessageLookupByLibrary.simpleMessage( - "Sem cadeiras no período selecionado", - ), + "Sem cadeiras no período selecionado"), "no_data": MessageLookupByLibrary.simpleMessage( - "Não há dados a mostrar neste momento", - ), + "Não há dados a mostrar neste momento"), "no_date": MessageLookupByLibrary.simpleMessage("Sem data"), "no_exams": MessageLookupByLibrary.simpleMessage("Não possui exames marcados"), @@ -207,51 +177,40 @@ class MessageLookup extends MessageLookupByLibrary { "no_favorite_restaurants": MessageLookupByLibrary.simpleMessage("Sem restaurantes favoritos"), "no_info": MessageLookupByLibrary.simpleMessage( - "Não existem informações para apresentar", - ), + "Não existem informações para apresentar"), "no_menu_info": MessageLookupByLibrary.simpleMessage( - "Não há informação disponível sobre refeições", - ), + "Não há informação disponível sobre refeições"), "no_menus": MessageLookupByLibrary.simpleMessage( - "Não há refeições disponíveis", - ), + "Não há refeições disponíveis"), "no_name_course": MessageLookupByLibrary.simpleMessage("Curso sem nome"), "no_references": MessageLookupByLibrary.simpleMessage( - "Não existem referências a pagar", - ), + "Não existem referências a pagar"), "no_results": MessageLookupByLibrary.simpleMessage("Sem resultados"), "no_selected_courses": MessageLookupByLibrary.simpleMessage( - "Não existem cadeiras para apresentar", - ), + "Não existem cadeiras para apresentar"), "no_selected_exams": MessageLookupByLibrary.simpleMessage( - "Não existem exames para apresentar", - ), + "Não existem exames para apresentar"), "occurrence_type": MessageLookupByLibrary.simpleMessage("Tipo de ocorrência"), "other_links": MessageLookupByLibrary.simpleMessage("Outros links"), "pass_change_request": MessageLookupByLibrary.simpleMessage( - "Por razões de segurança, as palavras-passe têm de ser alteradas periodicamente.", - ), + "Por razões de segurança, as palavras-passe têm de ser alteradas periodicamente."), "password": MessageLookupByLibrary.simpleMessage("palavra-passe"), "pendent_references": MessageLookupByLibrary.simpleMessage("Referências pendentes"), "personal_assistance": MessageLookupByLibrary.simpleMessage("Atendimento presencial"), "press_again": MessageLookupByLibrary.simpleMessage( - "Pressione novamente para sair", - ), + "Pressione novamente para sair"), "print": MessageLookupByLibrary.simpleMessage("Impressão"), "prints": MessageLookupByLibrary.simpleMessage("Impressões"), "problem_id": MessageLookupByLibrary.simpleMessage( - "Breve identificação do problema", - ), + "Breve identificação do problema"), "reference_sigarra_help": MessageLookupByLibrary.simpleMessage( - r"Os dados da referência gerada aparecerão no Sigarra, conta corrente.\nPerfil > Conta Corrente", - ), + "Os dados da referência gerada aparecerão no Sigarra, conta corrente.\\nPerfil > Conta Corrente"), "reference_success": MessageLookupByLibrary.simpleMessage( - "Referência criada com sucesso!", - ), + "Referência criada com sucesso!"), "remove": MessageLookupByLibrary.simpleMessage("Remover"), "report_error": MessageLookupByLibrary.simpleMessage("Reportar erro"), "room": MessageLookupByLibrary.simpleMessage("Sala"), @@ -270,18 +229,15 @@ class MessageLookup extends MessageLookupByLibrary { "tele_assistance": MessageLookupByLibrary.simpleMessage("Atendimento telefónico"), "tele_personal_assistance": MessageLookupByLibrary.simpleMessage( - "Atendimento presencial e telefónico", - ), + "Atendimento presencial e telefónico"), "telephone": MessageLookupByLibrary.simpleMessage("Telefone"), "terms": MessageLookupByLibrary.simpleMessage("Termos e Condições"), "title": MessageLookupByLibrary.simpleMessage("Título"), "unavailable": MessageLookupByLibrary.simpleMessage("Indisponível"), "valid_email": MessageLookupByLibrary.simpleMessage( - "Por favor insere um email válido", - ), + "Por favor insere um email válido"), "widget_prompt": MessageLookupByLibrary.simpleMessage( - "Escolhe um widget para adicionares à tua área pessoal:", - ), + "Escolhe um widget para adicionares à tua área pessoal:"), "year": MessageLookupByLibrary.simpleMessage("Ano") }; } diff --git a/uni/lib/generated/l10n.dart b/uni/lib/generated/l10n.dart index 3a2aec795..a1b6550a3 100644 --- a/uni/lib/generated/l10n.dart +++ b/uni/lib/generated/l10n.dart @@ -1,7 +1,7 @@ // GENERATED CODE - DO NOT MODIFY BY HAND import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; -import 'package:uni/generated/intl/messages_all.dart'; +import 'intl/messages_all.dart'; // ************************************************************************** // Generator: Flutter Intl IDE plugin @@ -10,7 +10,7 @@ import 'package:uni/generated/intl/messages_all.dart'; // ignore_for_file: non_constant_identifier_names, lines_longer_than_80_chars // ignore_for_file: join_return_with_assignment, prefer_final_in_for_each -// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_redundant_argument_values, avoid_escaping_inner_quotes class S { S(); @@ -18,10 +18,8 @@ class S { static S? _current; static S get current { - assert( - _current != null, - 'No instance of S was loaded. Try to initialize the S delegate before accessing S.current.', - ); + assert(_current != null, + 'No instance of S was loaded. Try to initialize the S delegate before accessing S.current.'); return _current!; } @@ -43,10 +41,8 @@ class S { static S of(BuildContext context) { final instance = S.maybeOf(context); - assert( - instance != null, - 'No instance of S present in the widget tree. Did you add S.delegate in localizationsDelegates?', - ); + assert(instance != null, + 'No instance of S present in the widget tree. Did you add S.delegate in localizationsDelegates?'); return instance!; } @@ -207,7 +203,7 @@ class S { /// `Favorite buses will be displayed in the favorites 'Bus' widget. The remaining ones will only be displayed on the page.` String get buses_text { return Intl.message( - "Favorite buses will be displayed in the favorites 'Bus' widget. The remaining ones will only be displayed on the page.", + 'Favorite buses will be displayed in the favorites \'Bus\' widget. The remaining ones will only be displayed on the page.', name: 'buses_text', desc: '', args: [], @@ -437,7 +433,7 @@ class S { /// `D. Beatriz's stationery store` String get dona_bia { return Intl.message( - "D. Beatriz's stationery store", + 'D. Beatriz\'s stationery store', name: 'dona_bia', desc: '', args: [], @@ -494,10 +490,10 @@ class S { ); } - /// `Exam Filter Settings` + /// `Exams Filter Settings` String get exams_filter { return Intl.message( - 'Exam Filter Settings', + 'Exams Filter Settings', name: 'exams_filter', desc: '', args: [], @@ -747,7 +743,7 @@ class S { ); } - /// `{title, select, horario{Schedule} exames{Exams} area{Personal Area} cadeiras{Course Units} autocarros{Buses} locais{Places} restaurantes{Restaurants} calendario{Calendar} biblioteca{Library} uteis{Utils} sobre{About} bugs{Bugs/ Suggestions} other{Other}}` + /// `{title, select, horario{Schedule} exames{Exams} area{Personal Area} cadeiras{Course Units} autocarros{Buses} locais{Places} restaurantes{Restaurants} calendario{Calendar} biblioteca{Library} uteis{Utils} sobre{About} bugs{Bugs/Suggestions} other{Other}}` String nav_title(Object title) { return Intl.select( title, @@ -763,7 +759,7 @@ class S { 'biblioteca': 'Library', 'uteis': 'Utils', 'sobre': 'About', - 'bugs': 'Bugs/ Suggestions', + 'bugs': 'Bugs/Suggestions', 'other': 'Other', }, name: 'nav_title', @@ -785,7 +781,7 @@ class S { /// `Don't miss any bus!` String get no_bus { return Intl.message( - "Don't miss any bus!", + 'Don\'t miss any bus!', name: 'no_bus', desc: '', args: [], @@ -825,7 +821,7 @@ class S { /// `You don't have classes on` String get no_classes_on { return Intl.message( - "You don't have classes on", + 'You don\'t have classes on', name: 'no_classes_on', desc: '', args: [], @@ -1085,7 +1081,7 @@ class S { /// `The generated reference data will appear in Sigarra, checking account.\nProfile > Checking Account` String get reference_sigarra_help { return Intl.message( - 'The generated reference data will appear in Sigarra, checking account.\nProfile > Checking Account', + 'The generated reference data will appear in Sigarra, checking account.\\nProfile > Checking Account', name: 'reference_sigarra_help', desc: '', args: [], diff --git a/uni/lib/l10n/intl_en.arb b/uni/lib/l10n/intl_en.arb index 12a47bfbc..e856e2123 100644 --- a/uni/lib/l10n/intl_en.arb +++ b/uni/lib/l10n/intl_en.arb @@ -22,7 +22,7 @@ "@average": {}, "balance": "Balance:", "@balance": {}, - "bs_description": "Did you find any bugs in the application?\\nDo you have any suggestions for the app?\\nTell us so we can improve!", + "bs_description": "Did you find any bugs in the application?\nDo you have any suggestions for the app?\nTell us so we can improve!", "@bs_description": {}, "bug_description": "Bug found, how to reproduce it, etc.", "@bug_description": {}, @@ -88,7 +88,7 @@ "@edit_on": {}, "empty_text": "Please fill in this field", "@empty_text": {}, - "exams_filter": "Exam Filter Settings", + "exams_filter": "Exams Filter Settings", "@exams_filter": {}, "expired_password": "Your password has expired", "@expired_password": {}, @@ -146,7 +146,7 @@ "@min_value_reference": {}, "multimedia_center": "Multimedia center", "@multimedia_center": {}, - "nav_title": "{title, select, horario{Schedule} exames{Exams} area{Personal Area} cadeiras{Course Units} autocarros{Buses} locais{Places} restaurantes{Restaurants} calendario{Calendar} biblioteca{Library} uteis{Utils} sobre{About} bugs{Bugs/ Suggestions} other{Other}}", + "nav_title": "{title, select, horario{Schedule} exames{Exams} area{Personal Area} cadeiras{Course Units} autocarros{Buses} locais{Places} restaurantes{Restaurants} calendario{Calendar} biblioteca{Library} uteis{Utils} sobre{About} bugs{Bugs/Suggestions} other{Other}}", "@nav_title": {}, "news": "News", "@news": {}, diff --git a/uni/lib/l10n/intl_pt_PT.arb b/uni/lib/l10n/intl_pt_PT.arb index ad8d0790d..16ac83f09 100644 --- a/uni/lib/l10n/intl_pt_PT.arb +++ b/uni/lib/l10n/intl_pt_PT.arb @@ -22,7 +22,7 @@ "@average": {}, "balance": "Saldo:", "@balance": {}, - "bs_description": "Encontraste algum bug na aplicação?\\nTens alguma sugestão para a app?\\nConta-nos para que possamos melhorar!", + "bs_description": "Encontraste algum bug na aplicação?\nTens alguma sugestão para a app?\nConta-nos para que possamos melhorar!", "@bs_description": {}, "bug_description": "Bug encontrado, como o reproduzir, etc", "@bug_description": {}, diff --git a/uni/lib/view/calendar/calendar.dart b/uni/lib/view/calendar/calendar.dart index 4e4f3ed83..90d5ce2ff 100644 --- a/uni/lib/view/calendar/calendar.dart +++ b/uni/lib/view/calendar/calendar.dart @@ -3,12 +3,15 @@ import 'package:provider/provider.dart'; import 'package:timelines/timelines.dart'; import 'package:uni/model/entities/calendar_event.dart'; import 'package:uni/model/providers/lazy/calendar_provider.dart'; +import 'package:uni/utils/drawer_items.dart'; import 'package:uni/view/calendar/widgets/calendar_tile.dart'; import 'package:uni/view/common_widgets/page_title.dart'; import 'package:uni/view/common_widgets/pages_layouts/general/general.dart'; import 'package:uni/view/common_widgets/request_dependent_widget_builder.dart'; import 'package:uni/view/lazy_consumer.dart'; +import '../../generated/l10n.dart'; + class CalendarPageView extends StatefulWidget { const CalendarPageView({super.key}); @@ -24,7 +27,9 @@ class CalendarPageViewState extends GeneralPageViewState { children: [ Container( padding: const EdgeInsets.only(bottom: 6), - child: const PageTitle(name: 'Calendário Escolar'), + child: PageTitle( + name: S.of(context).nav_title(DrawerItem.navCalendar.title), + ), ), RequestDependentWidgetBuilder( status: calendarProvider.status, diff --git a/uni/lib/view/exams/widgets/exam_filter_form.dart b/uni/lib/view/exams/widgets/exam_filter_form.dart index 91a1483aa..baf86edfb 100644 --- a/uni/lib/view/exams/widgets/exam_filter_form.dart +++ b/uni/lib/view/exams/widgets/exam_filter_form.dart @@ -1,10 +1,12 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/model/entities/exam.dart'; import 'package:uni/model/providers/lazy/exam_provider.dart'; class ExamFilterForm extends StatefulWidget { const ExamFilterForm(this.filteredExamsTypes, {super.key}); + final Map filteredExamsTypes; @override @@ -16,17 +18,19 @@ class ExamFilterFormState extends State { Widget build(BuildContext context) { return AlertDialog( title: Text( - 'Definições Filtro de Exames', + S.of(context).exams_filter, style: Theme.of(context).textTheme.headlineSmall, ), actions: [ TextButton( - child: - Text('Cancelar', style: Theme.of(context).textTheme.bodyMedium), + child: Text( + S.of(context).cancel, + style: Theme.of(context).textTheme.bodyMedium, + ), onPressed: () => Navigator.pop(context), ), ElevatedButton( - child: const Text('Confirmar'), + child: Text(S.of(context).confirm), onPressed: () { Provider.of(context, listen: false) .setFilteredExams(widget.filteredExamsTypes); diff --git a/uni/lib/view/locations/locations.dart b/uni/lib/view/locations/locations.dart index 777647ac2..b072e673b 100644 --- a/uni/lib/view/locations/locations.dart +++ b/uni/lib/view/locations/locations.dart @@ -8,6 +8,9 @@ import 'package:uni/view/common_widgets/request_dependent_widget_builder.dart'; import 'package:uni/view/lazy_consumer.dart'; import 'package:uni/view/locations/widgets/faculty_map.dart'; +import '../../generated/l10n.dart'; +import '../../utils/drawer_items.dart'; + class LocationsPage extends StatefulWidget { const LocationsPage({super.key}); @@ -46,6 +49,7 @@ class LocationsPageView extends StatelessWidget { required this.status, super.key, }); + final List locations; final RequestStatus status; @@ -56,7 +60,10 @@ class LocationsPageView extends StatelessWidget { Container( width: MediaQuery.of(context).size.width * 0.95, padding: const EdgeInsets.fromLTRB(0, 0, 0, 4), - child: PageTitle(name: 'Locais: ${getLocation()}'), + child: PageTitle( + name: '${S.of(context).nav_title(DrawerItem.navLocations.title)}:' + ' ${getLocation()}', + ), ), Container( padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), diff --git a/uni/lib/view/restaurant/restaurant_page_view.dart b/uni/lib/view/restaurant/restaurant_page_view.dart index 0d74bad07..80a1c96b5 100644 --- a/uni/lib/view/restaurant/restaurant_page_view.dart +++ b/uni/lib/view/restaurant/restaurant_page_view.dart @@ -5,6 +5,7 @@ import 'package:uni/model/entities/meal.dart'; import 'package:uni/model/entities/restaurant.dart'; import 'package:uni/model/providers/lazy/restaurant_provider.dart'; import 'package:uni/model/utils/day_of_week.dart'; +import 'package:uni/utils/drawer_items.dart'; import 'package:uni/view/common_widgets/page_title.dart'; import 'package:uni/view/common_widgets/pages_layouts/general/general.dart'; import 'package:uni/view/common_widgets/request_dependent_widget_builder.dart'; @@ -49,7 +50,9 @@ class _RestaurantPageViewState extends GeneralPageViewState padding: const EdgeInsets.fromLTRB(20, 20, 20, 10), alignment: Alignment.center, child: PageTitle( - name: S.of(context).menus, + name: S + .of(context) + .nav_title(DrawerItem.navRestaurants.title), center: false, pad: false, ), From a2865e8a11a22805fef55004b5e0db00d19ee91c Mon Sep 17 00:00:00 2001 From: Bruno Mendes Date: Wed, 13 Sep 2023 15:25:17 +0100 Subject: [PATCH 43/50] Add missing translations --- uni/lib/generated/intl/messages_en.dart | 8 +++- uni/lib/generated/intl/messages_pt_PT.dart | 8 +++- uni/lib/generated/l10n.dart | 40 +++++++++++++++++++ uni/lib/l10n/intl_en.arb | 8 ++++ uni/lib/l10n/intl_pt_PT.arb | 8 ++++ uni/lib/view/calendar/calendar.dart | 3 +- .../view/home/widgets/exit_app_dialog.dart | 7 ++-- .../view/home/widgets/restaurant_card.dart | 2 +- uni/lib/view/locations/locations.dart | 8 ++-- uni/lib/view/locations/widgets/map.dart | 3 +- .../view/locations/widgets/marker_popup.dart | 8 +++- 11 files changed, 88 insertions(+), 15 deletions(-) diff --git a/uni/lib/generated/intl/messages_en.dart b/uni/lib/generated/intl/messages_en.dart index 8df0e5ffd..7c9d65e6c 100644 --- a/uni/lib/generated/intl/messages_en.dart +++ b/uni/lib/generated/intl/messages_en.dart @@ -114,6 +114,8 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Please fill in this field"), "exams_filter": MessageLookupByLibrary.simpleMessage("Exams Filter Settings"), + "exit_confirm": + MessageLookupByLibrary.simpleMessage("Do you really want to exit?"), "expired_password": MessageLookupByLibrary.simpleMessage("Your password has expired"), "failed_login": MessageLookupByLibrary.simpleMessage("Login failed"), @@ -154,6 +156,7 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Multimedia center"), "nav_title": m2, "news": MessageLookupByLibrary.simpleMessage("News"), + "no": MessageLookupByLibrary.simpleMessage("No"), "no_bus": MessageLookupByLibrary.simpleMessage("Don\'t miss any bus!"), "no_bus_stops": MessageLookupByLibrary.simpleMessage("No configured stops"), @@ -183,6 +186,8 @@ class MessageLookup extends MessageLookupByLibrary { "There are no meals available"), "no_name_course": MessageLookupByLibrary.simpleMessage("Unnamed course"), + "no_places_info": MessageLookupByLibrary.simpleMessage( + "There is no information available about places"), "no_references": MessageLookupByLibrary.simpleMessage( "There are no references to pay"), "no_results": MessageLookupByLibrary.simpleMessage("No match"), @@ -237,6 +242,7 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Please enter a valid email"), "widget_prompt": MessageLookupByLibrary.simpleMessage( "Choose a widget to add to your personal area:"), - "year": MessageLookupByLibrary.simpleMessage("Year") + "year": MessageLookupByLibrary.simpleMessage("Year"), + "yes": MessageLookupByLibrary.simpleMessage("Yes") }; } diff --git a/uni/lib/generated/intl/messages_pt_PT.dart b/uni/lib/generated/intl/messages_pt_PT.dart index 34347734b..c86c90267 100644 --- a/uni/lib/generated/intl/messages_pt_PT.dart +++ b/uni/lib/generated/intl/messages_pt_PT.dart @@ -113,6 +113,8 @@ class MessageLookup extends MessageLookupByLibrary { "Por favor preenche este campo"), "exams_filter": MessageLookupByLibrary.simpleMessage("Definições Filtro de Exames"), + "exit_confirm": MessageLookupByLibrary.simpleMessage( + "Tem a certeza de que pretende sair?"), "expired_password": MessageLookupByLibrary.simpleMessage("A tua palavra-passe expirou"), "failed_login": MessageLookupByLibrary.simpleMessage("O login falhou"), @@ -154,6 +156,7 @@ class MessageLookup extends MessageLookupByLibrary { MessageLookupByLibrary.simpleMessage("Centro de multimédia"), "nav_title": m2, "news": MessageLookupByLibrary.simpleMessage("Notícias"), + "no": MessageLookupByLibrary.simpleMessage("Não"), "no_bus": MessageLookupByLibrary.simpleMessage( "Não percas nenhum autocarro!"), "no_bus_stops": MessageLookupByLibrary.simpleMessage( @@ -184,6 +187,8 @@ class MessageLookup extends MessageLookupByLibrary { "Não há refeições disponíveis"), "no_name_course": MessageLookupByLibrary.simpleMessage("Curso sem nome"), + "no_places_info": MessageLookupByLibrary.simpleMessage( + "Não há informação disponível sobre locais"), "no_references": MessageLookupByLibrary.simpleMessage( "Não existem referências a pagar"), "no_results": MessageLookupByLibrary.simpleMessage("Sem resultados"), @@ -238,6 +243,7 @@ class MessageLookup extends MessageLookupByLibrary { "Por favor insere um email válido"), "widget_prompt": MessageLookupByLibrary.simpleMessage( "Escolhe um widget para adicionares à tua área pessoal:"), - "year": MessageLookupByLibrary.simpleMessage("Ano") + "year": MessageLookupByLibrary.simpleMessage("Ano"), + "yes": MessageLookupByLibrary.simpleMessage("Sim") }; } diff --git a/uni/lib/generated/l10n.dart b/uni/lib/generated/l10n.dart index a1b6550a3..804bd1400 100644 --- a/uni/lib/generated/l10n.dart +++ b/uni/lib/generated/l10n.dart @@ -50,6 +50,36 @@ class S { return Localizations.of(context, S); } + /// `Do you really want to exit?` + String get exit_confirm { + return Intl.message( + 'Do you really want to exit?', + name: 'exit_confirm', + desc: '', + args: [], + ); + } + + /// `No` + String get no { + return Intl.message( + 'No', + name: 'no', + desc: '', + args: [], + ); + } + + /// `Yes` + String get yes { + return Intl.message( + 'Yes', + name: 'yes', + desc: '', + args: [], + ); + } + /// `Academic services` String get academic_services { return Intl.message( @@ -918,6 +948,16 @@ class S { ); } + /// `There is no information available about places` + String get no_places_info { + return Intl.message( + 'There is no information available about places', + name: 'no_places_info', + desc: '', + args: [], + ); + } + /// `There are no meals available` String get no_menus { return Intl.message( diff --git a/uni/lib/l10n/intl_en.arb b/uni/lib/l10n/intl_en.arb index e856e2123..acc5d7b7c 100644 --- a/uni/lib/l10n/intl_en.arb +++ b/uni/lib/l10n/intl_en.arb @@ -1,5 +1,11 @@ { "@@locale": "en", + "exit_confirm": "Do you really want to exit?", + "@exit_confirm": {}, + "no": "No", + "@no": {}, + "yes": "Yes", + "@yes": {}, "academic_services": "Academic services", "@academic_services": {}, "account_card_title": "Checking account", @@ -178,6 +184,8 @@ "@no_info": {}, "no_menu_info": "There is no information available about meals", "@no_menu_info": {}, + "no_places_info": "There is no information available about places", + "@no_places_info": {}, "no_menus": "There are no meals available", "@no_menus": {}, "no_name_course": "Unnamed course", diff --git a/uni/lib/l10n/intl_pt_PT.arb b/uni/lib/l10n/intl_pt_PT.arb index 16ac83f09..7552ae5c3 100644 --- a/uni/lib/l10n/intl_pt_PT.arb +++ b/uni/lib/l10n/intl_pt_PT.arb @@ -1,5 +1,11 @@ { "@@locale": "pt_PT", + "exit_confirm": "Tem a certeza de que pretende sair?", + "@exit_confirm": {}, + "no": "Não", + "@no": {}, + "yes": "Sim", + "@yes": {}, "academic_services": "Serviços académicos", "@academic_services": {}, "account_card_title": "Conta Corrente", @@ -178,6 +184,8 @@ "@no_info": {}, "no_menu_info": "Não há informação disponível sobre refeições", "@no_menu_info": {}, + "no_places_info": "Não há informação disponível sobre locais", + "@no_places_info": {}, "no_menus": "Não há refeições disponíveis", "@no_menus": {}, "no_name_course": "Curso sem nome", diff --git a/uni/lib/view/calendar/calendar.dart b/uni/lib/view/calendar/calendar.dart index 90d5ce2ff..5e5e79b68 100644 --- a/uni/lib/view/calendar/calendar.dart +++ b/uni/lib/view/calendar/calendar.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:timelines/timelines.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/model/entities/calendar_event.dart'; import 'package:uni/model/providers/lazy/calendar_provider.dart'; import 'package:uni/utils/drawer_items.dart'; @@ -10,8 +11,6 @@ import 'package:uni/view/common_widgets/pages_layouts/general/general.dart'; import 'package:uni/view/common_widgets/request_dependent_widget_builder.dart'; import 'package:uni/view/lazy_consumer.dart'; -import '../../generated/l10n.dart'; - class CalendarPageView extends StatefulWidget { const CalendarPageView({super.key}); diff --git a/uni/lib/view/home/widgets/exit_app_dialog.dart b/uni/lib/view/home/widgets/exit_app_dialog.dart index 58be3e236..fe6ed0ab5 100644 --- a/uni/lib/view/home/widgets/exit_app_dialog.dart +++ b/uni/lib/view/home/widgets/exit_app_dialog.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:uni/generated/l10n.dart'; /// Manages the app section displayed when the user presses the back button class BackButtonExitWrapper extends StatelessWidget { @@ -17,18 +18,18 @@ class BackButtonExitWrapper extends StatelessWidget { context: context, builder: (context) => AlertDialog( title: Text( - 'Tens a certeza de que pretendes sair?', + S.of(context).exit_confirm, style: Theme.of(context).textTheme.headlineSmall, ), actions: [ ElevatedButton( onPressed: () => Navigator.of(context).pop(false), - child: const Text('Não'), + child: Text(S.of(context).no), ), ElevatedButton( onPressed: () => SystemChannels.platform.invokeMethod('SystemNavigator.pop'), - child: const Text('Sim'), + child: Text(S.of(context).yes), ) ], ), diff --git a/uni/lib/view/home/widgets/restaurant_card.dart b/uni/lib/view/home/widgets/restaurant_card.dart index 77eacada5..ea23dc5be 100644 --- a/uni/lib/view/home/widgets/restaurant_card.dart +++ b/uni/lib/view/home/widgets/restaurant_card.dart @@ -139,7 +139,7 @@ class RestaurantCard extends GenericCard { child: Container( padding: const EdgeInsets.fromLTRB(9, 0, 0, 0), width: 400, - child: const Text('Não há refeições disponíveis'), + child: Text(S.of(context).no_menu_info), ), ), ) diff --git a/uni/lib/view/locations/locations.dart b/uni/lib/view/locations/locations.dart index b072e673b..f722cc7dd 100644 --- a/uni/lib/view/locations/locations.dart +++ b/uni/lib/view/locations/locations.dart @@ -1,16 +1,15 @@ import 'package:flutter/material.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/model/entities/location_group.dart'; import 'package:uni/model/providers/lazy/faculty_locations_provider.dart'; import 'package:uni/model/request_status.dart'; +import 'package:uni/utils/drawer_items.dart'; import 'package:uni/view/common_widgets/page_title.dart'; import 'package:uni/view/common_widgets/pages_layouts/general/general.dart'; import 'package:uni/view/common_widgets/request_dependent_widget_builder.dart'; import 'package:uni/view/lazy_consumer.dart'; import 'package:uni/view/locations/widgets/faculty_map.dart'; -import '../../generated/l10n.dart'; -import '../../utils/drawer_items.dart'; - class LocationsPage extends StatefulWidget { const LocationsPage({super.key}); @@ -73,8 +72,7 @@ class LocationsPageView extends StatelessWidget { status: status, builder: () => FacultyMap(faculty: 'FEUP', locations: locations), hasContentPredicate: locations.isNotEmpty, - onNullContent: - const Center(child: Text('Não existem locais disponíveis')), + onNullContent: Center(child: Text(S.of(context).no_places_info)), ), // TODO(bdmendes): add support for multiple faculties ) diff --git a/uni/lib/view/locations/widgets/map.dart b/uni/lib/view/locations/widgets/map.dart index f810d1a3a..1cb1b3365 100644 --- a/uni/lib/view/locations/widgets/map.dart +++ b/uni/lib/view/locations/widgets/map.dart @@ -17,6 +17,7 @@ class LocationsMap extends StatelessWidget { required this.locations, super.key, }); + final PopupController _popupLayerController = PopupController(); final List locations; final LatLng northEastBoundary; @@ -78,7 +79,7 @@ class LocationsMap extends StatelessWidget { ? FloorlessLocationMarkerPopup(marker.locationGroup) : LocationMarkerPopup(marker.locationGroup); } - return const Card(child: Text('undefined')); + return const Card(child: Text('')); }, ), ), diff --git a/uni/lib/view/locations/widgets/marker_popup.dart b/uni/lib/view/locations/widgets/marker_popup.dart index a683f613b..068bae2d6 100644 --- a/uni/lib/view/locations/widgets/marker_popup.dart +++ b/uni/lib/view/locations/widgets/marker_popup.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:uni/generated/l10n.dart'; import 'package:uni/model/entities/location.dart'; import 'package:uni/model/entities/location_group.dart'; import 'package:uni/view/locations/widgets/faculty_map.dart'; @@ -46,6 +47,7 @@ class LocationMarkerPopup extends StatelessWidget { class Floor extends StatelessWidget { const Floor({required this.locations, required this.floor, super.key}); + final List locations; final int floor; @@ -62,7 +64,10 @@ class Floor extends StatelessWidget { children: [ Container( padding: const EdgeInsets.fromLTRB(8, 0, 8, 0), - child: Text('Andar $floorString', style: TextStyle(color: fontColor)), + child: Text( + '${S.of(context).floor} $floorString', + style: TextStyle(color: fontColor), + ), ) ], ); @@ -86,6 +91,7 @@ class Floor extends StatelessWidget { class LocationRow extends StatelessWidget { const LocationRow({required this.location, required this.color, super.key}); + final Location location; final Color color; From c8ecb5d5212b73f1539093c04c45f8bda73f1ea5 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Wed, 13 Sep 2023 21:42:20 +0100 Subject: [PATCH 44/50] Add intl documentation --- uni/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/uni/README.md b/uni/README.md index 200d3c193..a4904acf7 100644 --- a/uni/README.md +++ b/uni/README.md @@ -46,6 +46,16 @@ But you can also watch for changes in `.dart` files and automatically run the `b dart run build_runner watch ``` +## Translation files + +Intl package allows the internationalization of the app, currently supporting Portuguese ('pt_PT') and English ('en_EN). This package creates `.arb` files (one for each language), mapping a key to the correspondent translated string. +In order to access those translations through getters, you must add the translations you want to the `.arb` files and run: +``` +dart pub global run intl_utils:generate +``` +This will generate `.dart` files with the getters you need to access the translations. +You must include `'package:uni/generated/l10n.dart'` and, depending on the locale of the application, `S.of(context).{key_of_translation}` will get you the translated string. + ## Project structure ### Overview From 10a3f33edb58442fbe097922a01955eac087a2d1 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Mon, 18 Sep 2023 16:08:07 +0100 Subject: [PATCH 45/50] Fixing test error --- uni/test/integration/src/exams_page_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uni/test/integration/src/exams_page_test.dart b/uni/test/integration/src/exams_page_test.dart index 44622790c..0035361dc 100644 --- a/uni/test/integration/src/exams_page_test.dart +++ b/uni/test/integration/src/exams_page_test.dart @@ -154,7 +154,7 @@ void main() { await tester.tap(find.byWidget(mtCheckboxTile)); await tester.pumpAndSettle(); - final okButton = find.widgetWithText(ElevatedButton, 'Confirmar'); + final okButton = find.widgetWithText(ElevatedButton, 'Confirm'); expect(okButton, findsOneWidget); await tester.tap(okButton); From 2e04b642a7a34ff9e0508a5c92e572e26ff2ec55 Mon Sep 17 00:00:00 2001 From: DGoiana Date: Mon, 18 Sep 2023 16:15:23 +0100 Subject: [PATCH 46/50] Changing testable widget locale --- uni/test/integration/src/exams_page_test.dart | 2 +- uni/test/test_widget.dart | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/uni/test/integration/src/exams_page_test.dart b/uni/test/integration/src/exams_page_test.dart index 0035361dc..44622790c 100644 --- a/uni/test/integration/src/exams_page_test.dart +++ b/uni/test/integration/src/exams_page_test.dart @@ -154,7 +154,7 @@ void main() { await tester.tap(find.byWidget(mtCheckboxTile)); await tester.pumpAndSettle(); - final okButton = find.widgetWithText(ElevatedButton, 'Confirm'); + final okButton = find.widgetWithText(ElevatedButton, 'Confirmar'); expect(okButton, findsOneWidget); await tester.tap(okButton); diff --git a/uni/test/test_widget.dart b/uni/test/test_widget.dart index 7cdac440c..b710b524a 100644 --- a/uni/test/test_widget.dart +++ b/uni/test/test_widget.dart @@ -28,6 +28,7 @@ Widget wrapWidget(Widget widget) { GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate, ], + locale: const Locale('pt'), supportedLocales: S.delegate.supportedLocales, home: Scaffold( body: widget, From 263f2d274f35154de231c8592026ae7510a690ac Mon Sep 17 00:00:00 2001 From: bdmendes Date: Tue, 19 Sep 2023 10:07:48 +0000 Subject: [PATCH 47/50] Bump app version [no ci] --- uni/app_version.txt | 2 +- uni/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/uni/app_version.txt b/uni/app_version.txt index adf98caa0..d280932d9 100644 --- a/uni/app_version.txt +++ b/uni/app_version.txt @@ -1 +1 @@ -1.5.62+180 \ No newline at end of file +1.5.63+181 \ No newline at end of file diff --git a/uni/pubspec.yaml b/uni/pubspec.yaml index de303dbde..d00c17a78 100644 --- a/uni/pubspec.yaml +++ b/uni/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: 'none' # We do not publish to pub.dev # To change it manually, override the value in app_version.txt. # The app version code is automatically also bumped by CI. # Do not change it manually. -version: 1.5.62+180 +version: 1.5.63+181 environment: sdk: '>=3.0.0 <4.0.0' From 4906c4688d6a200cf72b2ba22cf1d3715921c30d Mon Sep 17 00:00:00 2001 From: Bruno Mendes Date: Wed, 20 Sep 2023 16:15:29 +0100 Subject: [PATCH 48/50] Fix status parsing of multiple year UCs --- .../controller/parsers/parser_course_units.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/uni/lib/controller/parsers/parser_course_units.dart b/uni/lib/controller/parsers/parser_course_units.dart index 179ba7b77..bd103ad09 100644 --- a/uni/lib/controller/parsers/parser_course_units.dart +++ b/uni/lib/controller/parsers/parser_course_units.dart @@ -59,14 +59,19 @@ List parseCourseUnitsAndCourseAverage( if (row.children.length <= 6 + i) { break; } - yearIncrement++; - grade = row.children[6 + i].innerHtml.replaceAll(' ', ' ').trim(); - status = row.children[7 + i].innerHtml.replaceAll(' ', ' ').trim(); - if (status != '') { + final candidateStatus = + row.children[7 + i].innerHtml.replaceAll(' ', ' ').trim(); + if (status != null && candidateStatus.isEmpty) { break; } + yearIncrement++; + if (candidateStatus.isNotEmpty) { + grade = row.children[6 + i].innerHtml.replaceAll(' ', ' ').trim(); + status = candidateStatus; + } } - if (yearIncrement < 0) { + + if (status == null) { continue; } From b15861a97cb1ebf575eebf9331ddbe7fd244235d Mon Sep 17 00:00:00 2001 From: Bruno Mendes Date: Wed, 20 Sep 2023 17:44:15 +0100 Subject: [PATCH 49/50] Use different models for different occurrences --- .../parsers/parser_course_units.dart | 48 ++++++++----------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/uni/lib/controller/parsers/parser_course_units.dart b/uni/lib/controller/parsers/parser_course_units.dart index bd103ad09..8131dc51b 100644 --- a/uni/lib/controller/parsers/parser_course_units.dart +++ b/uni/lib/controller/parsers/parser_course_units.dart @@ -52,42 +52,36 @@ List parseCourseUnitsAndCourseAverage( final codeName = row.children[2].children[0].innerHtml; final name = row.children[3].children[0].innerHtml; final ects = row.children[5].innerHtml.replaceAll(',', '.'); - String? grade; - String? status; + var yearIncrement = -1; for (var i = 0;; i += 2) { if (row.children.length <= 6 + i) { break; } - final candidateStatus = - row.children[7 + i].innerHtml.replaceAll(' ', ' ').trim(); - if (status != null && candidateStatus.isEmpty) { - break; - } yearIncrement++; - if (candidateStatus.isNotEmpty) { - grade = row.children[6 + i].innerHtml.replaceAll(' ', ' ').trim(); - status = candidateStatus; + final status = + row.children[7 + i].innerHtml.replaceAll(' ', ' ').trim(); + final grade = + row.children[6 + i].innerHtml.replaceAll(' ', ' ').trim(); + + if (status.isEmpty) { + continue; } - } - if (status == null) { - continue; + final courseUnit = CourseUnit( + schoolYear: + '${firstSchoolYear + yearIncrement}/${firstSchoolYear + yearIncrement + 1}', + occurrId: int.parse(occurId), + abbreviation: codeName, + status: status, + grade: grade, + ects: double.parse(ects), + name: name, + curricularYear: int.parse(year), + semesterCode: semester, + ); + courseUnits.add(courseUnit); } - - final courseUnit = CourseUnit( - schoolYear: - '${firstSchoolYear + yearIncrement}/${firstSchoolYear + yearIncrement + 1}', - occurrId: int.parse(occurId), - abbreviation: codeName, - status: status, - grade: grade, - ects: double.parse(ects), - name: name, - curricularYear: int.parse(year), - semesterCode: semester, - ); - courseUnits.add(courseUnit); } return courseUnits; From 6e3ec9600912f5486ceeee9ce72d9c48f162fb8e Mon Sep 17 00:00:00 2001 From: LuisDuarte1 Date: Wed, 20 Sep 2023 19:20:13 +0000 Subject: [PATCH 50/50] Bump app version [no ci] --- uni/app_version.txt | 2 +- uni/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/uni/app_version.txt b/uni/app_version.txt index d280932d9..7ebc9097f 100644 --- a/uni/app_version.txt +++ b/uni/app_version.txt @@ -1 +1 @@ -1.5.63+181 \ No newline at end of file +1.5.64+182 \ No newline at end of file diff --git a/uni/pubspec.yaml b/uni/pubspec.yaml index d00c17a78..d1c137447 100644 --- a/uni/pubspec.yaml +++ b/uni/pubspec.yaml @@ -7,7 +7,7 @@ publish_to: 'none' # We do not publish to pub.dev # To change it manually, override the value in app_version.txt. # The app version code is automatically also bumped by CI. # Do not change it manually. -version: 1.5.63+181 +version: 1.5.64+182 environment: sdk: '>=3.0.0 <4.0.0'