From 3b7a33801f2633ed06c2e64849d0ae7387a89b4f Mon Sep 17 00:00:00 2001 From: "J. A. Messias" Date: Tue, 28 Jan 2025 11:29:42 -0300 Subject: [PATCH] licenes -> vehicle manager module --- .../menu/presentation/mappers/menu_entry.dart | 10 +++++ .../module/domain/entities/license.dart | 40 +++++++---------- .../vehicle_model.dart | 4 +- .../vehicles_on_the_property.dart | 44 +++++++++++++++++-- 4 files changed, 69 insertions(+), 29 deletions(-) diff --git a/lib/features/menu/presentation/mappers/menu_entry.dart b/lib/features/menu/presentation/mappers/menu_entry.dart index 7e1a4b00..79c5e770 100644 --- a/lib/features/menu/presentation/mappers/menu_entry.dart +++ b/lib/features/menu/presentation/mappers/menu_entry.dart @@ -72,6 +72,16 @@ class MenuEntry implements BaseModule { route: '/residentsOnThePropertyPage', types: [MenuEntryType.Property], ), + // MenuEntry( + // key: 'FRE-HUB-VEHICLES-MANAGER', + // icon: Icons.directions_car, + // name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( + // ptText: 'VeĆ­culos', + // enText: 'Vehicles', + // ), + // route: '/vehiclesOnThePropertyPage', + // types: [MenuEntryType.Property], + // ), MenuEntry( key: 'FRE-HUB-VEHICLES', icon: Icons.directions_car, diff --git a/lib/features/module/domain/entities/license.dart b/lib/features/module/domain/entities/license.dart index 17a70650..275776b9 100644 --- a/lib/features/module/domain/entities/license.dart +++ b/lib/features/module/domain/entities/license.dart @@ -10,6 +10,7 @@ enum LicenseKeys { access('FRE-HUB-ACCESS'), openedVisits('FRE-HUB-OPENED-VISITS'), vehicles('FRE-HUB-VEHICLES'), + vehiclesManager('FRE-HUB-VEHICLES-MANAGER'), residents('FRE-HUB-RESIDENTS'), about('FRE-HUB-ABOUT-SYSTEM'), pets('FRE-HUB-PETS'), @@ -60,9 +61,7 @@ class License { } static Future _precessWpp() async { - final bool whatsapp = await StorageHelper() - .get(LocalsStorageKey.whatsapp.key) - .then((v) => v.toBoolean()); + final bool whatsapp = await StorageHelper().get(LocalsStorageKey.whatsapp.key).then((v) => v.toBoolean()); if (whatsapp) return ModuleStatus.active.key; else @@ -70,9 +69,7 @@ class License { } static Future _processProvisional() async { - final bool provisional = await StorageHelper() - .get(LocalsStorageKey.provisional.key) - .then((v) => v.toBoolean()); + final bool provisional = await StorageHelper().get(LocalsStorageKey.provisional.key).then((v) => v.toBoolean()); if (provisional) return ModuleStatus.active.key; else @@ -80,9 +77,7 @@ class License { } static Future _processPets() async { - final bool pets = await StorageHelper() - .get(LocalsStorageKey.pets.key) - .then((v) => v.toBoolean()); + final bool pets = await StorageHelper().get(LocalsStorageKey.pets.key).then((v) => v.toBoolean()); if (pets) return ModuleStatus.active.key; else @@ -139,27 +134,28 @@ class License { ), Module( key: LicenseKeys.openedVisits.value, - display: isNewVersionWithModule - ? ModuleStatus.active.key - : ModuleStatus.inactive.key, + display: isNewVersionWithModule ? ModuleStatus.active.key : ModuleStatus.inactive.key, expirationDate: '', startDate: '', quantity: 0, ), Module( key: LicenseKeys.vehicles.value, - display: isNewVersionWithModule - ? ModuleStatus.active.key - : ModuleStatus.inactive.key, + display: isNewVersionWithModule ? ModuleStatus.active.key : ModuleStatus.inactive.key, + expirationDate: '', + startDate: '', + quantity: 0, + ), + Module( + key: LicenseKeys.vehicles.value, + display: ModuleStatus.inactive.key, expirationDate: '', startDate: '', quantity: 0, ), Module( key: LicenseKeys.residents.value, - display: isNewVersionWithModule - ? ModuleStatus.active.key - : ModuleStatus.inactive.key, + display: isNewVersionWithModule ? ModuleStatus.active.key : ModuleStatus.inactive.key, expirationDate: '', startDate: '', quantity: 0, @@ -222,18 +218,14 @@ class License { ), Module( key: LicenseKeys.property.value, - display: isNewVersionWithModule - ? ModuleStatus.active.key - : ModuleStatus.inactive.key, + display: isNewVersionWithModule ? ModuleStatus.active.key : ModuleStatus.inactive.key, expirationDate: '', startDate: '', quantity: 0, ), Module( key: LicenseKeys.people.value, - display: isNewVersionWithModule - ? ModuleStatus.inactive.key - : ModuleStatus.active.key, + display: isNewVersionWithModule ? ModuleStatus.inactive.key : ModuleStatus.active.key, expirationDate: '', startDate: '', quantity: 0, diff --git a/lib/pages/vehicles_on_the_property/vehicle_model.dart b/lib/pages/vehicles_on_the_property/vehicle_model.dart index 78d5fbaf..4732e9ba 100644 --- a/lib/pages/vehicles_on_the_property/vehicle_model.dart +++ b/lib/pages/vehicles_on_the_property/vehicle_model.dart @@ -107,7 +107,7 @@ class VehicleModel extends FlutterFlowModel { Future initAsync() async {} - Map generateStatusColorMap(dynamic uItem) { + Map? generateStatusColorMap(dynamic uItem) { final statusMap = { "ATI": { "text": FFLocalizations.of(context).getVariableText( @@ -162,7 +162,7 @@ class VehicleModel extends FlutterFlowModel { return {}; } - List generateActionButtons(dynamic item) { + List? generateActionButtons(dynamic item) { final Color iconButtonColor = FlutterFlowTheme.of(context).primaryText; final FFButtonOptions buttonOptions = FFButtonOptions( height: 40, diff --git a/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart b/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart index 2f087c22..468bd50f 100644 --- a/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart +++ b/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart @@ -7,9 +7,11 @@ import 'package:hub/components/atomic_components/shared_components_atoms/submit_ import 'package:hub/components/atomic_components/shared_components_atoms/tabview.dart'; import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; import 'package:hub/features/backend/index.dart'; +import 'package:hub/features/module/index.dart'; import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; +import 'package:hub/flutter_flow/index.dart'; import 'package:hub/pages/vehicles_on_the_property/vehicle_model.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; @@ -21,7 +23,6 @@ part 'vehicle_register_screen.dart'; part 'vehicle_update_screen.dart'; /// [VehiclePage] is a StatefulWidget that displays the vehicle screens. - class VehiclePage extends StatefulWidget { const VehiclePage({super.key}); @@ -65,18 +66,55 @@ class _VehiclePageState extends State with TickerProviderStateMixin return Scaffold( backgroundColor: backgroundColor, appBar: _buildAppBar(context), - body: _buildBody(context), + body: buildBody(context), ); } /// [Body] of the page. + Widget buildBody(BuildContext context) { + Widget progressEvent() { + return CircularProgressIndicator( + valueColor: AlwaysStoppedAnimation( + FlutterFlowTheme.of(context).primary, + ), + ); + } + + Widget errorEvent() { + WidgetsBinding.instance.addPostFrameCallback((_) async { + context.pop(); + await DialogUtil.errorDefault(navigatorKey.currentContext!); + }); + return progressEvent(); + } + + return FutureBuilder( + future: LicenseRepositoryImpl().getModule('FRE-HUB-VEHICLES-MANAGER'), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return progressEvent(); + } else if (snapshot.hasError) { + return errorEvent(); + } else if (snapshot.hasData && snapshot.data!.isNotEmpty) { + return _buildVehicleManager(context); + } else { + return _buildVehicleHistory(context); + } + }, + ); + } + void onEditingChanged(bool value) { setState(() { _model.handleEditingChanged(value); }); } - Widget _buildBody(BuildContext context) { + Widget _buildVehicleHistory(BuildContext context) { + return VehicleHistoryScreen(_model); + } + + Widget _buildVehicleManager(BuildContext context) { final vehicleHistoryScreenLabel = FFLocalizations.of(context).getVariableText(ptText: 'Consultar', enText: 'History'); final vehicleRegisterScreenLabel =