From d76668206a931b97363b4d0477c56ff50485eae7 Mon Sep 17 00:00:00 2001 From: "J. A. Messias" Date: Wed, 4 Dec 2024 14:11:45 -0300 Subject: [PATCH] fix labels --- .../home/presentation/pages/home_page.dart | 2 +- .../data_sources/menu_local_data_source.dart | 8 ++-- .../repositories/menu_repository_impl.dart | 14 +++--- .../domain/respositories/menu_repository.dart | 2 +- .../menu/presentation/blocs/menu_bloc.dart | 6 +-- .../menu/presentation/mappers/menu_entry.dart | 44 +++++++++---------- .../presentation/widgets/menu_factory.dart | 2 +- .../modules/domain/entities/base_module.dart | 2 +- 8 files changed, 40 insertions(+), 40 deletions(-) diff --git a/lib/features/home/presentation/pages/home_page.dart b/lib/features/home/presentation/pages/home_page.dart index 4d0a12b7..20767d9f 100644 --- a/lib/features/home/presentation/pages/home_page.dart +++ b/lib/features/home/presentation/pages/home_page.dart @@ -30,7 +30,7 @@ class _HomePageWidgetState extends State { create: (context) => MenuBloc( style: MenuView.list_grid, item: EnumMenuItem.button, - menuOptions: MenuEntry.getEntriesByType(MenuEntryType.Home), + entries: MenuEntry.getEntriesByType(MenuEntryType.Home), )..add(MenuEvent()), ), BlocProvider( diff --git a/lib/shared/components/molecules/menu/data/data_sources/menu_local_data_source.dart b/lib/shared/components/molecules/menu/data/data_sources/menu_local_data_source.dart index f88d1c55..84c0ffa8 100644 --- a/lib/shared/components/molecules/menu/data/data_sources/menu_local_data_source.dart +++ b/lib/shared/components/molecules/menu/data/data_sources/menu_local_data_source.dart @@ -39,7 +39,7 @@ class MenuLocalDataSourceImpl implements MenuLocalDataSource { @override Future processDisplayDefault(EnumMenuItem item, MenuEntry opt, List entries) async { - if (opt.value == 'FRE-HUB-LOGOUT') { + if (opt.key == 'FRE-HUB-LOGOUT') { await addMenuEntry(item, entries, opt.icon, opt.name, () async { await AuthenticationService.signOut(navigatorKey.currentContext!); }); @@ -67,7 +67,7 @@ class MenuLocalDataSourceImpl implements MenuLocalDataSource { break; } } catch (e) { - log('Error processing display for module ${opt.value}: $e'); + log('Error processing display for module ${opt.key}: $e'); } } @@ -78,7 +78,7 @@ class MenuLocalDataSourceImpl implements MenuLocalDataSource { final start = DateTime.tryParse(startDate); return start != null && DateTime.now().isAfter(start); } catch (e) { - log('Error processing start date for module ${opt.value}: $e'); + log('Error processing start date for module ${opt.key}: $e'); } return false; } @@ -90,7 +90,7 @@ class MenuLocalDataSourceImpl implements MenuLocalDataSource { final expiration = DateTime.tryParse(expirationDate); return expiration != null && DateTime.now().isAfter(expiration); } catch (e) { - log('Error processing expiration date for module ${opt.value}: $e'); + log('Error processing expiration date for module ${opt.key}: $e'); } return false; } diff --git a/lib/shared/components/molecules/menu/data/repositories/menu_repository_impl.dart b/lib/shared/components/molecules/menu/data/repositories/menu_repository_impl.dart index 545553d3..1f5a0bb7 100644 --- a/lib/shared/components/molecules/menu/data/repositories/menu_repository_impl.dart +++ b/lib/shared/components/molecules/menu/data/repositories/menu_repository_impl.dart @@ -14,23 +14,23 @@ class MenuRepositoryImpl implements MenuRepository { @override - Future> generateMenuEntries(List menuOptions, EnumMenuItem item) async { + Future> generateMenuEntries(List menuEntries, EnumMenuItem item) async { log('Generating menu entries for $item'); List entries = []; try { - for (var opt in menuOptions) { - final bool isDefault = await menuDataSource.processDisplayDefault(item, opt, entries); + for (var entry in menuEntries) { + final bool isDefault = await menuDataSource.processDisplayDefault(item, entry, entries); if (isDefault) continue; - final licenseValue = await LicenseRepositoryImpl().getLicense(opt.key); + final licenseValue = await LicenseRepositoryImpl().getLicense(entry.key); if (licenseValue != null) { final licenseMap = await stringToMap(licenseValue); final display = EnumDisplay.fromString(licenseMap['display']); final startDate = licenseMap['startDate'] ?? ''; final expirationDate = licenseMap['expirationDate'] ?? ''; - final isStarted = await menuDataSource.processStartDate(startDate, opt); - final isExpired = await menuDataSource.processExpirationDate(expirationDate, opt); + final isStarted = await menuDataSource.processStartDate(startDate, entry); + final isExpired = await menuDataSource.processExpirationDate(expirationDate, entry); if (isStarted && !isExpired) { - await menuDataSource.processDisplay(item, display, opt, entries); + await menuDataSource.processDisplay(item, display, entry, entries); } } } diff --git a/lib/shared/components/molecules/menu/domain/respositories/menu_repository.dart b/lib/shared/components/molecules/menu/domain/respositories/menu_repository.dart index 1abf171d..495dc332 100644 --- a/lib/shared/components/molecules/menu/domain/respositories/menu_repository.dart +++ b/lib/shared/components/molecules/menu/domain/respositories/menu_repository.dart @@ -2,5 +2,5 @@ import 'package:hub/shared/components/molecules/menu/domain/entities/menu_item.d import 'package:hub/shared/components/molecules/menu/index.dart'; abstract class MenuRepository { - Future> generateMenuEntries(List menuOptions, EnumMenuItem item); + Future> generateMenuEntries(List menuEntries, EnumMenuItem item); } \ No newline at end of file diff --git a/lib/shared/components/molecules/menu/presentation/blocs/menu_bloc.dart b/lib/shared/components/molecules/menu/presentation/blocs/menu_bloc.dart index 14d434c5..0dd8431e 100644 --- a/lib/shared/components/molecules/menu/presentation/blocs/menu_bloc.dart +++ b/lib/shared/components/molecules/menu/presentation/blocs/menu_bloc.dart @@ -29,11 +29,11 @@ class MenuState { class MenuBloc extends Bloc { final MenuView style; final EnumMenuItem item; - final List menuOptions; + final List entries; late StreamSubscription _completer; - MenuBloc({required this.style, required this.item, required this.menuOptions}) : super(MenuState()) { + MenuBloc({required this.style, required this.item, required this.entries}) : super(MenuState()) { on(_onMenuEvent); _completer = LicenseRemoteDataSourceImpl().streamCompleterController.listen((_) { @@ -43,7 +43,7 @@ class MenuBloc extends Bloc { Future _onMenuEvent(MenuEvent event, Emitter emit) async { await LicenseRemoteDataSourceImpl().waitForSaveCompletion(); - final entries = await MenuRepositoryImpl().generateMenuEntries(menuOptions, item); + final entries = await MenuRepositoryImpl().generateMenuEntries(entries, item); emit(state.copyWith(menuEntries: entries)); } diff --git a/lib/shared/components/molecules/menu/presentation/mappers/menu_entry.dart b/lib/shared/components/molecules/menu/presentation/mappers/menu_entry.dart index c530952c..6097c501 100644 --- a/lib/shared/components/molecules/menu/presentation/mappers/menu_entry.dart +++ b/lib/shared/components/molecules/menu/presentation/mappers/menu_entry.dart @@ -6,14 +6,14 @@ import 'package:hub/shared/components/molecules/modules/domain/entities/base_mod enum MenuEntryType { Home, Drawer, Property } class MenuEntry implements BaseModule { - final String value; + final String key; final IconData icon; final String name; final String route; final List types; const MenuEntry({ - required this.value, + required this.key, required this.icon, required this.name, required this.route, @@ -22,7 +22,7 @@ class MenuEntry implements BaseModule { static List entries = [ MenuEntry( - value: 'FRE-HUB-AGE-PROV-PRESTADOR', + key: 'FRE-HUB-AGE-PROV-PRESTADOR', icon: Icons.engineering_outlined, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( ptText: 'Agendar Prestadores', @@ -32,7 +32,7 @@ class MenuEntry implements BaseModule { types: [MenuEntryType.Home, MenuEntryType.Drawer], ), MenuEntry( - value: 'FRE-HUB-AGE-PROV-DELIVERY', + key: 'FRE-HUB-AGE-PROV-DELIVERY', icon: Icons.sports_motorsports_outlined, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( ptText: 'Agendar Delivery', @@ -42,7 +42,7 @@ class MenuEntry implements BaseModule { types: [MenuEntryType.Home, MenuEntryType.Drawer], ), MenuEntry( - value: 'FRE-HUB-FASTPASS', + key: 'FRE-HUB-FASTPASS', icon: Icons.attach_email_outlined, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( ptText: 'Fast Pass', @@ -52,7 +52,7 @@ class MenuEntry implements BaseModule { types: [MenuEntryType.Home, MenuEntryType.Drawer], ), MenuEntry( - value: 'FRE-HUB-COMPLETE-SCHEDULE', + key: 'FRE-HUB-COMPLETE-SCHEDULE', icon: Icons.event, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( ptText: 'Agenda Completa', @@ -62,7 +62,7 @@ class MenuEntry implements BaseModule { types: [MenuEntryType.Home, MenuEntryType.Drawer], ), MenuEntry( - value: 'FRE-HUB-ORDERS', + key: 'FRE-HUB-ORDERS', icon: Icons.inventory_2_outlined, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( ptText: 'Minhas Encomendas', @@ -72,7 +72,7 @@ class MenuEntry implements BaseModule { types: [MenuEntryType.Home, MenuEntryType.Drawer], ), MenuEntry( - value: 'FRE-HUB-RESERVATIONS', + key: 'FRE-HUB-RESERVATIONS', icon: Icons.event_available, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( ptText: 'Reservas', @@ -82,7 +82,7 @@ class MenuEntry implements BaseModule { types: [MenuEntryType.Home, MenuEntryType.Drawer], ), MenuEntry( - value: 'FRE-HUB-VISITORS', + key: 'FRE-HUB-VISITORS', icon: Icons.person_add_alt_1_outlined, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( ptText: 'Cadastrar Visitantes', @@ -92,7 +92,7 @@ class MenuEntry implements BaseModule { types: [MenuEntryType.Home, MenuEntryType.Drawer], ), MenuEntry( - value: 'FRE-HUB-QRCODE', + key: 'FRE-HUB-QRCODE', icon: Icons.qr_code, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( ptText: 'QRCode de Acesso', @@ -102,7 +102,7 @@ class MenuEntry implements BaseModule { types: [MenuEntryType.Home, MenuEntryType.Drawer], ), MenuEntry( - value: 'FRE-HUB-PETS', + key: 'FRE-HUB-PETS', icon: Icons.pets, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( ptText: 'Pets', @@ -112,7 +112,7 @@ class MenuEntry implements BaseModule { types: [MenuEntryType.Home, MenuEntryType.Drawer], ), MenuEntry( - value: 'FRE-HUB-ACCESS', + key: 'FRE-HUB-ACCESS', icon: Icons.transfer_within_a_station_outlined, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( ptText: 'Consultar Acessos', @@ -122,7 +122,7 @@ class MenuEntry implements BaseModule { types: [MenuEntryType.Home, MenuEntryType.Drawer], ), MenuEntry( - value: 'FRE-HUB-LIBERATIONS', + key: 'FRE-HUB-LIBERATIONS', icon: Icons.how_to_reg_outlined, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( ptText: 'Consultar Liberações', @@ -132,7 +132,7 @@ class MenuEntry implements BaseModule { types: [MenuEntryType.Home, MenuEntryType.Drawer], ), MenuEntry( - value: 'FRE-HUB-MESSAGES', + key: 'FRE-HUB-MESSAGES', icon: Icons.chat_outlined, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( ptText: 'Consultar Mensagens', @@ -142,7 +142,7 @@ class MenuEntry implements BaseModule { types: [MenuEntryType.Home, MenuEntryType.Drawer], ), MenuEntry( - value: 'FRE-HUB-PROPERTY', + key: 'FRE-HUB-PROPERTY', icon: Icons.home, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( ptText: 'Sobre a Propriedade', @@ -153,7 +153,7 @@ class MenuEntry implements BaseModule { ), MenuEntry( - value: 'FRE-HUB-PEOPLE', + key: 'FRE-HUB-PEOPLE', icon: Icons.groups, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( ptText: 'Pessoas na Propriedade', @@ -163,7 +163,7 @@ class MenuEntry implements BaseModule { types: [MenuEntryType.Home, MenuEntryType.Drawer], ), MenuEntry( - value: 'FRE-HUB-SETTINGS', + key: 'FRE-HUB-SETTINGS', icon: Icons.settings, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( ptText: 'Configurações', @@ -173,7 +173,7 @@ class MenuEntry implements BaseModule { types: [MenuEntryType.Home, MenuEntryType.Drawer], ), MenuEntry( - value: 'FRE-HUB-LOGOUT', + key: 'FRE-HUB-LOGOUT', icon: Icons.exit_to_app, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( ptText: 'Sair', @@ -183,28 +183,28 @@ class MenuEntry implements BaseModule { types: [MenuEntryType.Drawer], ), MenuEntry( - value: 'FRE-HUB-RESIDENTS', + key: 'FRE-HUB-RESIDENTS', icon: Icons.groups, name: 'Residents', route: '/residentsOnThePropertyPage', types: [MenuEntryType.Property], ), MenuEntry( - value: 'FRE-HUB-VEHICLES', + key: 'FRE-HUB-VEHICLES', icon: Icons.directions_car, name: 'Vehicles', route: '/vehiclesOnThePropertyPage', types: [MenuEntryType.Property], ), MenuEntry( - value: 'FRE-HUB-OPENED-VISITS', + key: 'FRE-HUB-OPENED-VISITS', icon: Icons.perm_contact_calendar, name: 'Opened Visits', route: '/visitsOnThePropertyPage', types: [MenuEntryType.Property], ), MenuEntry( - value: 'FRE-HUB-PETS-HISTORY', + key: 'FRE-HUB-PETS-HISTORY', icon: Icons.pets, name: 'Pets History', route: '/petsOnThePropertyPage', diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_factory.dart b/lib/shared/components/molecules/menu/presentation/widgets/menu_factory.dart index c3c11fba..79bf3454 100644 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_factory.dart +++ b/lib/shared/components/molecules/menu/presentation/widgets/menu_factory.dart @@ -48,7 +48,7 @@ class Menufactory extends StatelessWidget { create: (context) => MenuBloc( style: view, item: item, - menuOptions: entry, + entries: entry, )..add(MenuEvent()), child: BlocBuilder( builder: (context, state) { diff --git a/lib/shared/components/molecules/modules/domain/entities/base_module.dart b/lib/shared/components/molecules/modules/domain/entities/base_module.dart index 662fa7b2..ef2c82a8 100644 --- a/lib/shared/components/molecules/modules/domain/entities/base_module.dart +++ b/lib/shared/components/molecules/modules/domain/entities/base_module.dart @@ -5,7 +5,7 @@ import 'package:hub/flutter_flow/nav/nav.dart'; abstract class BaseModule { - String get value; + String get key; String get name; IconData get icon; String get route;