This commit is contained in:
J. A. Messias 2024-10-23 12:42:58 -03:00
parent d6c5f50a78
commit 6c71fd8f93
3 changed files with 34 additions and 22 deletions

View File

@ -5,6 +5,7 @@ import 'package:hub/shared/extensions/dialog_extensions.dart';
import 'package:hub/shared/services/authentication/authentication_service.dart'; import 'package:hub/shared/services/authentication/authentication_service.dart';
import 'package:hub/shared/utils/storage_util.dart'; import 'package:hub/shared/utils/storage_util.dart';
import '../../../shared/services/localization/localization_service.dart';
import '/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart'; import '/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart';
import '/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart'; import '/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart';
import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_util.dart';
@ -42,7 +43,9 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
isGrid = !isGrid; isGrid = !isGrid;
} }
Future<bool> isChecked() async { Future<bool> isChecked(BuildContext context) async {
await StorageUtil().ensureInitialization();
await LocalizationService.processLocals(context);
return StorageUtil().cliUUID.isNotEmpty && return StorageUtil().cliUUID.isNotEmpty &&
StorageUtil().cliName.isNotEmpty && StorageUtil().cliName.isNotEmpty &&
StorageUtil().devUUID.isNotEmpty && StorageUtil().devUUID.isNotEmpty &&
@ -50,7 +53,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
} }
Future openQRCodeScanner(BuildContext context) async { Future openQRCodeScanner(BuildContext context) async {
isChecked().then((value) { isChecked(context).then((value) {
if (value) { if (value) {
context.push( context.push(
'/qrCodePage', '/qrCodePage',
@ -69,7 +72,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
} }
Future openCompleteSchedule(BuildContext context) async { Future openCompleteSchedule(BuildContext context) async {
isChecked().then((value) { isChecked(context).then((value) {
if (value) { if (value) {
context.push( context.push(
'/scheduleCompleteVisitPage', '/scheduleCompleteVisitPage',
@ -90,7 +93,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
Future openDeliverySchedule(BuildContext context) async { Future openDeliverySchedule(BuildContext context) async {
final bool isProvisional = StorageUtil().provisional; final bool isProvisional = StorageUtil().provisional;
isChecked().then((value) { isChecked(context).then((value) {
if (value) { if (value) {
if (isProvisional == true) { if (isProvisional == true) {
context.push( context.push(
@ -115,7 +118,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
Future openProvisionalSchedule(BuildContext context) async { Future openProvisionalSchedule(BuildContext context) async {
final isProvisional = StorageUtil().provisional; final isProvisional = StorageUtil().provisional;
isChecked().then((value) { isChecked(context).then((value) {
if (value) { if (value) {
if (isProvisional == true) { if (isProvisional == true) {
context.push( context.push(
@ -140,7 +143,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
Future openFastPassSchedule(BuildContext context) async { Future openFastPassSchedule(BuildContext context) async {
final isWpp = StorageUtil().whatsapp; final isWpp = StorageUtil().whatsapp;
isChecked().then((value) { isChecked(context).then((value) {
if (value) { if (value) {
if (isWpp) { if (isWpp) {
context.push( context.push(
@ -204,7 +207,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
} }
Future openVisitorsRegister(BuildContext context) async { Future openVisitorsRegister(BuildContext context) async {
isChecked().then((value) { isChecked(context).then((value) {
if (value) { if (value) {
context.push( context.push(
'/registerVisitorPage', '/registerVisitorPage',
@ -223,7 +226,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
} }
Future openPoepleOnTheProperty(BuildContext context) async { Future openPoepleOnTheProperty(BuildContext context) async {
isChecked().then((value) { isChecked(context).then((value) {
if (value) { if (value) {
context.push( context.push(
'/peopleOnThePropertyPage', '/peopleOnThePropertyPage',
@ -258,7 +261,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
} }
Future openPreferencesSettings(BuildContext context) async { Future openPreferencesSettings(BuildContext context) async {
isChecked().then((value) { isChecked(context).then((value) {
if (value) { if (value) {
context.push( context.push(
'/preferencesSettings', '/preferencesSettings',
@ -279,7 +282,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
Future openMyOrders(BuildContext context) async { Future openMyOrders(BuildContext context) async {
final isWpp = StorageUtil().whatsapp; final isWpp = StorageUtil().whatsapp;
isChecked().then((value) { isChecked(context).then((value) {
if (value) { if (value) {
if (isWpp) { if (isWpp) {
context.push( context.push(
@ -304,7 +307,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
Future openReservations(BuildContext context) async { Future openReservations(BuildContext context) async {
final isWpp = StorageUtil().whatsapp; final isWpp = StorageUtil().whatsapp;
isChecked().then((value) { isChecked(context).then((value) {
if (value) { if (value) {
if (isWpp) { if (isWpp) {
context.push( context.push(
@ -373,7 +376,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
} }
Future openLiberationsHistory(BuildContext context) async { Future openLiberationsHistory(BuildContext context) async {
isChecked().then((value) { isChecked(context).then((value) {
if (value) { if (value) {
context.push( context.push(
'/liberationHistory', '/liberationHistory',
@ -392,7 +395,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
} }
Future openAccessHistory(BuildContext context) async { Future openAccessHistory(BuildContext context) async {
isChecked().then((value) { isChecked(context).then((value) {
if (value) { if (value) {
context.push( context.push(
'/acessHistoryPage', '/acessHistoryPage',
@ -411,7 +414,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
} }
Future openVisitsHistory(BuildContext context) async { Future openVisitsHistory(BuildContext context) async {
isChecked().then((value) { isChecked(context).then((value) {
if (value) { if (value) {
context.push( context.push(
'/scheduleCompleteVisitPage', '/scheduleCompleteVisitPage',
@ -430,7 +433,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
} }
Future openMessagesHistory(BuildContext context) async { Future openMessagesHistory(BuildContext context) async {
isChecked().then((value) { isChecked(context).then((value) {
if (value) { if (value) {
context.push( context.push(
'/messageHistoryPage', '/messageHistoryPage',
@ -451,7 +454,7 @@ class MenuComponentModel extends FlutterFlowModel<MenuComponentWidget> {
Future openPetsRegister(BuildContext context) async { Future openPetsRegister(BuildContext context) async {
bool isPet = StorageUtil().pets; bool isPet = StorageUtil().pets;
isChecked().then((value) { isChecked(context).then((value) {
if (value) { if (value) {
if (isPet) { if (isPet) {
context.push( context.push(

View File

@ -287,8 +287,9 @@ class _AppState extends State<App> with WidgetsBindingObserver {
} }
@override void didChangeAppLifecycleState(AppLifecycleState state) async { @override void didChangeAppLifecycleState(AppLifecycleState state) async {
await StorageUtil().ensureInitialization(); if (state == AppLifecycleState.resumed) await StorageUtil().ensureInitialization();
LocalizationService.processLocals(context); if (state == AppLifecycleState.resumed) await LocalizationService.processLocals(context);
else LocalizationService.processData(context);
} }
@override Widget build(BuildContext context) { @override Widget build(BuildContext context) {

View File

@ -99,7 +99,13 @@ class LocalizationService {
} catch (e, s) { } catch (e, s) {
log('() => stack: $s'); log('() => stack: $s');
log('() => catch: $e', stackTrace: s); log('() => catch: $e', stackTrace: s);
return await selectLocal(context); // return await selectLocal(context);
final String errorMsg = FFLocalizations.of(context).getVariableText(
enText: 'Error getting locals, verify your connection',
ptText: 'Erro ao obter locais, verifique sua conexão',
);
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context));
return false;
} }
} }
static Future<bool> processData(BuildContext context) async { static Future<bool> processData(BuildContext context) async {
@ -119,7 +125,11 @@ class LocalizationService {
} catch (e, s) { } catch (e, s) {
log('() => stack processData: $s'); log('() => stack processData: $s');
log('() => error processData: $e', stackTrace: s); log('() => error processData: $e', stackTrace: s);
DialogUtil.warningDefault(context).whenComplete(() => selectLocal(context)); final String errorMsg = FFLocalizations.of(context).getVariableText(
enText: 'Error getting data, verify your connection',
ptText: 'Erro ao obter dados, verifique sua conexão',
);
DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context));
return false; return false;
} }
} }
@ -225,7 +235,6 @@ class LocalizationService {
log('() => CLU_STATUS: $status'); log('() => CLU_STATUS: $status');
} }
} }
static bool _isActive(List<dynamic> locals) { static bool _isActive(List<dynamic> locals) {
return locals.where((local) => local['CLU_STATUS'] == 'A').isNotEmpty; return locals.where((local) => local['CLU_STATUS'] == 'A').isNotEmpty;
} }
@ -244,7 +253,6 @@ class LocalizationService {
static bool _isAvailable() { static bool _isAvailable() {
return StorageUtil().cliUUID.isNotEmpty && StorageUtil().cliName.isNotEmpty; return StorageUtil().cliUUID.isNotEmpty && StorageUtil().cliName.isNotEmpty;
} }
static void _updateStorageUtil(Map<String, dynamic> jsonBody) { static void _updateStorageUtil(Map<String, dynamic> jsonBody) {
final bool whatsapp = jsonBody['whatsapp'] ?? false; final bool whatsapp = jsonBody['whatsapp'] ?? false;
final bool provisional = jsonBody['provisional'] ?? false; final bool provisional = jsonBody['provisional'] ?? false;