fix labels

This commit is contained in:
J. A. Messias 2024-12-04 14:11:45 -03:00
parent 6e2ccc209b
commit d76668206a
8 changed files with 40 additions and 40 deletions

View File

@ -30,7 +30,7 @@ class _HomePageWidgetState extends State<HomePageWidget> {
create: (context) => MenuBloc(
style: MenuView.list_grid,
item: EnumMenuItem.button,
menuOptions: MenuEntry.getEntriesByType(MenuEntryType.Home),
entries: MenuEntry.getEntriesByType(MenuEntryType.Home),
)..add(MenuEvent()),
),
BlocProvider<HomeBloc>(

View File

@ -39,7 +39,7 @@ class MenuLocalDataSourceImpl implements MenuLocalDataSource {
@override
Future<bool> processDisplayDefault(EnumMenuItem item, MenuEntry opt, List<MenuItem?> 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;
}

View File

@ -14,23 +14,23 @@ class MenuRepositoryImpl implements MenuRepository {
@override
Future<List<MenuItem?>> generateMenuEntries(List<MenuEntry> menuOptions, EnumMenuItem item) async {
Future<List<MenuItem?>> generateMenuEntries(List<MenuEntry> menuEntries, EnumMenuItem item) async {
log('Generating menu entries for $item');
List<MenuItem?> 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);
}
}
}

View File

@ -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<List<MenuItem?>> generateMenuEntries(List<MenuEntry> menuOptions, EnumMenuItem item);
Future<List<MenuItem?>> generateMenuEntries(List<MenuEntry> menuEntries, EnumMenuItem item);
}

View File

@ -29,11 +29,11 @@ class MenuState {
class MenuBloc extends Bloc<MenuEvent, MenuState> {
final MenuView style;
final EnumMenuItem item;
final List<MenuEntry> menuOptions;
final List<MenuEntry> entries;
late StreamSubscription<void> _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<MenuEvent>(_onMenuEvent);
_completer = LicenseRemoteDataSourceImpl().streamCompleterController.listen((_) {
@ -43,7 +43,7 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> {
Future<void> _onMenuEvent(MenuEvent event, Emitter<MenuState> emit) async {
await LicenseRemoteDataSourceImpl().waitForSaveCompletion();
final entries = await MenuRepositoryImpl().generateMenuEntries(menuOptions, item);
final entries = await MenuRepositoryImpl().generateMenuEntries(entries, item);
emit(state.copyWith(menuEntries: entries));
}

View File

@ -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<MenuEntryType> 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<MenuEntry> 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',

View File

@ -48,7 +48,7 @@ class Menufactory extends StatelessWidget {
create: (context) => MenuBloc(
style: view,
item: item,
menuOptions: entry,
entries: entry,
)..add(MenuEvent()),
child: BlocBuilder<MenuBloc, MenuState>(
builder: (context, state) {

View File

@ -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;