From ee4c257710d6ffc6c8dadead88fed5a00a3c3b85 Mon Sep 17 00:00:00 2001 From: "J. A. Messias" Date: Thu, 21 Nov 2024 16:55:22 -0300 Subject: [PATCH] WIP --- .../menu_component/menu_component_model.dart | 296 +----------------- .../menu_component/menu_component_widget.dart | 4 +- .../helpers/license/license_helper.dart | 130 ++++++++ .../services/license/license_service.dart | 13 +- .../localization/localization_service.dart | 139 +++++--- 5 files changed, 245 insertions(+), 337 deletions(-) diff --git a/lib/components/organism_components/menu_component/menu_component_model.dart b/lib/components/organism_components/menu_component/menu_component_model.dart index 213ad4cf..2f3f66c9 100644 --- a/lib/components/organism_components/menu_component/menu_component_model.dart +++ b/lib/components/organism_components/menu_component/menu_component_model.dart @@ -58,28 +58,25 @@ class MenuComponentModel extends FlutterFlowModel { BuildContext context, MenuItem item, List options) async { List entries = []; Future addMenuEntry( - IconData icon, String enText, String ptText, Function() action) async { + IconData icon, String text, Function() action) async { entries.add( item == MenuItem.button ? MenuButtonWidget( icon: icon, action: action, - title: FFLocalizations.of(context) - .getVariableText(enText: enText, ptText: ptText), + title: text, safeSetState: safeSetState) : item == MenuItem.card ? MenuCardItem( icon: icon, action: action, - title: FFLocalizations.of(context) - .getVariableText(enText: enText, ptText: ptText), + title: text, safeSetState: safeSetState) : item == MenuItem.tile ? MenuCardItem( icon: icon, action: action, - title: FFLocalizations.of(context) - .getVariableText(enText: enText, ptText: ptText), + title: text, safeSetState: safeSetState) : null, ); @@ -91,18 +88,19 @@ class MenuComponentModel extends FlutterFlowModel { log('Module: ${opt.value} - License: $v'); switch (v) { case 'VISIVEL': - addMenuEntry(Icons.engineering_outlined, 'Schedule Providers', - 'Agendar Prestadores', () async { - await open(context, '/provisionalSchedule'); + await addMenuEntry(opt.icon, opt.name, () async { + await open(context, opt.route); }); break; case 'BLOQUEADO': - DialogUnavailable.unavailableFeature(context); + await addMenuEntry(opt.icon, opt.name, () async { + await DialogUnavailable.unavailableFeature(context); + }); break; case 'INVISIVEL': break; default: - throw Exception('Invalid license value'); + break; } safeSetState(); } @@ -136,129 +134,6 @@ class MenuComponentModel extends FlutterFlowModel { () async => await AuthenticationService.signOut(context)); } - Future openDeliverySchedule(BuildContext context) async { - final bool isProvisional = - await StorageHelper().g(KeychainStorageKey.provisional.value) == 'true'; - if (isProvisional == true) { - context.push( - '/deliverySchedule', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } else { - DialogUnavailable.unavailableFeature(context); - } - } - - Future openProvisionalSchedule(BuildContext context) async { - final isProvisional = - await StorageHelper().g(KeychainStorageKey.provisional.value) == 'true'; - if (isProvisional == true) { - context.push( - '/provisionalSchedule', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } else { - DialogUnavailable.unavailableFeature(context); - } - } - - Future openFastPassSchedule(BuildContext context) async { - final isWpp = - await StorageHelper().g(KeychainStorageKey.whatsapp.value) == 'true'; - if (isWpp) { - context.push( - '/fastPassPage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } else { - DialogUnavailable.unavailableFeature(context); - } - } - - Future showSchedules(BuildContext context) async { - final routesListStr = [ - 'scheduleProvisionalVisitPage', - 'fastPassPage', - 'scheduleCompleteVisitPage', - ]; - final iconsListIcon = [ - Icons.date_range_rounded, - Icons.date_range_rounded, - Icons.date_range_rounded, - ]; - final nameListStr = [ - FFLocalizations.of(context).getVariableText( - ptText: 'Visita\nProvisória', - enText: 'Provisional\nSchedule', - ), - FFLocalizations.of(context).getVariableText( - ptText: 'Visita\nRápida', - enText: 'Fast\nSchedule', - ), - FFLocalizations.of(context).getVariableText( - ptText: 'Visita\nCompleta', - enText: 'Complete\nSchedule', - ), - ]; - await showAdaptiveDialog( - context: context, - builder: (context) { - return Padding( - padding: MediaQuery.viewInsetsOf(context), - child: OptionSelectionModalWidget( - routesListStr: routesListStr, - iconsListIcon: iconsListIcon, - nameListStr: nameListStr, - ), - ); - }, - ); - } - - Future openVisitorsRegister(BuildContext context) async { - context.push( - '/registerVisitorPage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } - - Future openPoepleOnTheProperty(BuildContext context) async { - context.push( - '/peopleOnThePropertyPage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } - Future Logout(BuildContext context) async { final String title = FFLocalizations.of(context).getVariableText( ptText: 'Sair', @@ -272,7 +147,7 @@ class MenuComponentModel extends FlutterFlowModel { () async => await AuthenticationService.signOut(context)); } - Future openPreferencesSettings(BuildContext context) async { + Future settings(BuildContext context) async { context.push( '/preferencesSettings', extra: { @@ -285,95 +160,9 @@ class MenuComponentModel extends FlutterFlowModel { ); } - Future openMyOrders(BuildContext context) async { - final isWpp = - await StorageHelper().g(KeychainStorageKey.whatsapp.value) == 'true'; - ; - if (isWpp) { - context.push( - '/packageOrder', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } else { - DialogUnavailable.unavailableFeature(context); - } - } - - Future openReservations(BuildContext context) async { - final isWpp = - await StorageHelper().g(KeychainStorageKey.whatsapp.value) == 'true'; - ; - if (isWpp) { - context.push( - '/reservation', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } else { - DialogUnavailable.unavailableFeature(context); - } - } - - Future showHistories(BuildContext context) async { - await showAdaptiveDialog( - // isScrollControlled: true, - // backgroundColor: Colors.transparent, - // enableDrag: false, - context: context, - builder: (context) { - return Padding( - padding: MediaQuery.viewInsetsOf(context), - child: OptionSelectionModalWidget( - routesListStr: const [ - 'liberationHistory', - 'acessHistoryPage', - 'scheduleCompleteVisitPage', - 'messageHistoryPage' - ], - iconsListIcon: const [ - Icons.history_rounded, - Icons.history_rounded, - Icons.history_rounded, - Icons.history_rounded, - ], - nameListStr: [ - FFLocalizations.of(context).getVariableText( - ptText: 'Histórico\nde Liberação', - enText: 'Liberation\nHistory', - ), - FFLocalizations.of(context).getVariableText( - ptText: 'Histórico\nde Acesso', - enText: 'Access\nHistory', - ), - FFLocalizations.of(context).getVariableText( - ptText: 'Histórico\nde Visita', - enText: 'Visit\nHistory', - ), - FFLocalizations.of(context).getVariableText( - ptText: 'Histórico\nde Mensagens', - enText: 'Message\nHistory', - ), - ], - ), - ); - }, - ); - } - - Future openLiberationsHistory(BuildContext context) async { + Future about(BuildContext context) async { context.push( - '/liberationHistory', + '/aboutProperty', extra: { kTransitionInfoKey: const TransitionInfo( hasTransition: false, @@ -383,63 +172,4 @@ class MenuComponentModel extends FlutterFlowModel { }, ); } - - Future openAccessHistory(BuildContext context) async { - context.push( - '/acessHistoryPage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } - - Future openVisitsHistory(BuildContext context) async { - context.push( - '/scheduleCompleteVisitPage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } - - Future openMessagesHistory(BuildContext context) async { - context.push( - '/messageHistoryPage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } - - Future openPetsRegister(BuildContext context) async { - bool isPet = - await StorageHelper().g(KeychainStorageKey.pets.value) == 'true'; - ; - if (isPet) { - context.push( - '/petsPage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: false, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } else { - DialogUnavailable.unavailableFeature(context); - } - } } diff --git a/lib/components/organism_components/menu_component/menu_component_widget.dart b/lib/components/organism_components/menu_component/menu_component_widget.dart index b6cb84ca..a687ba3f 100644 --- a/lib/components/organism_components/menu_component/menu_component_widget.dart +++ b/lib/components/organism_components/menu_component/menu_component_widget.dart @@ -32,8 +32,8 @@ class _MenuComponentWidgetState extends State { @override void didChangeDependencies() async { super.didChangeDependencies(); - widget.model.menuEntries = - await widget.model.generateMenuEntries(context, widget.model.item, widget.model.menuOptions); + widget.model.menuEntries = await widget.model.generateMenuEntries( + context, widget.model.item, widget.model.menuOptions); } @override diff --git a/lib/shared/helpers/license/license_helper.dart b/lib/shared/helpers/license/license_helper.dart index 7c55abcd..a0e6164a 100644 --- a/lib/shared/helpers/license/license_helper.dart +++ b/lib/shared/helpers/license/license_helper.dart @@ -1,5 +1,8 @@ import 'dart:developer'; +import 'package:flutter/material.dart'; +import 'package:hub/flutter_flow/internationalization.dart'; +import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/shared/helpers/database/database_helper.dart'; import 'package:sqflite/sqflite.dart'; @@ -19,6 +22,7 @@ enum ActiveModuleKey { providerSchedule, deliverySchedule, fastPass, + qrCode, } extension InactiveModuleKeyExtension on InactiveModuleKey { @@ -57,6 +61,8 @@ extension ActiveModuleKeyExtension on ActiveModuleKey { return 'FRE-HUB-AGE-PROV-DELIVERY'; case ActiveModuleKey.fastPass: return 'FRE-HUB-FASTPASS'; + case ActiveModuleKey.qrCode: + return 'FRE-HUB-QRCODE'; default: return ''; } @@ -111,11 +117,135 @@ extension LicenseKeyExtension on Module { return 'FRE-HUB-AGE-PROV-DELIVERY'; case Module.fastPass: return 'FRE-HUB-FASTPASS'; + case Module.qrCode: + return 'FRE-HUB-QRCODE'; default: return ''; } } + String get name { + switch (this) { + case Module.messages: + return FFLocalizations.of(key.currentContext!).getVariableText( + ptText: 'Mensagens', + enText: 'Messages', + ); + case Module.liberations: + return FFLocalizations.of(key.currentContext!).getVariableText( + ptText: 'Liberar', + enText: 'Liberations', + ); + case Module.reservations: + return FFLocalizations.of(key.currentContext!).getVariableText( + ptText: 'Reservas', + enText: 'Reservations', + ); + case Module.access: + return FFLocalizations.of(key.currentContext!).getVariableText( + ptText: 'Acessos', + enText: 'Access', + ); + case Module.openedVisits: + return FFLocalizations.of(key.currentContext!).getVariableText( + ptText: 'Visitas Abertas', + enText: 'Opened Visits', + ); + case Module.vehicles: + return FFLocalizations.of(key.currentContext!).getVariableText( + ptText: 'Veículos', + enText: 'Vehicles', + ); + case Module.residents: + return FFLocalizations.of(key.currentContext!).getVariableText( + ptText: 'Moradores', + enText: 'Residents', + ); + case Module.pets: + return FFLocalizations.of(key.currentContext!).getVariableText( + ptText: 'Pets', + enText: 'Pets', + ); + case Module.orders: + return FFLocalizations.of(key.currentContext!).getVariableText( + ptText: 'Encomendas', + enText: 'Orders', + ); + case Module.completeSchedule: + return FFLocalizations.of(key.currentContext!).getVariableText( + ptText: 'Agenda Completa', + enText: 'Complete Schedule', + ); + case Module.providerSchedule: + return FFLocalizations.of(key.currentContext!).getVariableText( + ptText: 'Agendar Prestadores', + enText: 'Schedule Providers', + ); + case Module.deliverySchedule: + return FFLocalizations.of(key.currentContext!).getVariableText( + ptText: 'Agendar Delivery', + enText: 'Schedule Delivery', + ); + case Module.fastPass: + return FFLocalizations.of(key.currentContext!).getVariableText( + ptText: 'Fast Pass', + enText: 'Fast Pass', + ); + case Module.qrCode: + return FFLocalizations.of(key.currentContext!).getVariableText( + ptText: 'QR Code', + enText: 'QR Code', + ); + case Module.settings: + return FFLocalizations.of(key.currentContext!).getVariableText( + ptText: 'Configurações', + enText: 'Settings', + ); + case Module.logout: + return FFLocalizations.of(key.currentContext!).getVariableText( + ptText: 'Sair', + enText: 'Logout', + ); + } + } + + IconData get icon { + switch (this) { + case Module.messages: + return Icons.message; + case Module.liberations: + return Icons.lock_open; + case Module.reservations: + return Icons.calendar_today; + case Module.access: + return Icons.access_time; + case Module.openedVisits: + return Icons.people; + case Module.vehicles: + return Icons.directions_car; + case Module.residents: + return Icons.person; + case Module.pets: + return Icons.pets; + case Module.orders: + return Icons.shopping_cart; + case Module.completeSchedule: + return Icons.schedule; + case Module.providerSchedule: + return Icons.engineering_outlined; + case Module.deliverySchedule: + return Icons.delivery_dining; + case Module.fastPass: + return Icons.fastfood; + case Module.qrCode: + return Icons.qr_code; + case Module.settings: + return Icons.settings; + case Module.logout: + return Icons.logout; + } + } + String get route { switch (this) { case Module.messages: diff --git a/lib/shared/services/license/license_service.dart b/lib/shared/services/license/license_service.dart index b2ea7651..9c5e8710 100644 --- a/lib/shared/services/license/license_service.dart +++ b/lib/shared/services/license/license_service.dart @@ -17,8 +17,10 @@ class LicenseService { LicenseService._internal(); static Future setupLicense(Database database) async { - await LicenseHelper.insertLicenseFoo(InactiveModuleKey.values.map((e) => e.value).toList(), 'INVISIVEL'); - await LicenseHelper.insertLicenseFoo(ActiveModuleKey.values.map((e) => e.value).toList(), 'VISIVEL'); + await LicenseHelper.insertLicenseFoo( + InactiveModuleKey.values.map((e) => e.value).toList(), 'INVISIVEL'); + await LicenseHelper.insertLicenseFoo( + ActiveModuleKey.values.map((e) => e.value).toList(), 'VISIVEL'); } static Future initLicenseService() async { @@ -68,6 +70,7 @@ class LicenseService { } return true; } catch (e) { + log('Erro ao obter licenças: $e'); await setupLicense(DatabaseStorage.database); return true; } @@ -78,9 +81,11 @@ class LicenseService { } static Future _saveModule(final dynamic body) async { - if (body is Map) log('Salvando módulo: ${body.toString()}'); + if (body is Map) + log('Salvando módulo: ${body.toString()}'); // if (body is Map) await StorageHelper().s(body['key'], ''); - if (body is Map) await StorageHelper().s(body['key'], body); + if (body is Map) + await StorageHelper().s(body['key'], body); // StorageHelper.getInstance(Storage.SQLiteStorage).set(key, value); } diff --git a/lib/shared/services/localization/localization_service.dart b/lib/shared/services/localization/localization_service.dart index 8a168906..019133fa 100644 --- a/lib/shared/services/localization/localization_service.dart +++ b/lib/shared/services/localization/localization_service.dart @@ -34,13 +34,15 @@ class LocalizationService { enText: 'Verify your connection', ptText: 'Verifique sua conexão', ); - await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response)); + await DialogUtil.error(context, errorMsg) + .whenComplete(() => selectLocal(context, response)); return; } final List locals = response.jsonBody['locais'] ?? []; final bool isEmpty = locals.isEmpty; - final bool isActive = locals.where((local) => local['CLU_STATUS'] != 'B').isNotEmpty; + final bool isActive = + locals.where((local) => local['CLU_STATUS'] != 'B').isNotEmpty; final bool isEnable = !isEmpty && isActive; if (isEnable) { @@ -72,7 +74,8 @@ class LocalizationService { enText: 'Verify your connection', ptText: 'Verifique sua conexão', ); - await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response)); + await DialogUtil.error(context, errorMsg) + .whenComplete(() => selectLocal(context, response)); return false; } @@ -83,7 +86,8 @@ class LocalizationService { final bool isInactived = await _isInactived(locals); final bool isPending = _isPending(locals); final bool isUnique = locals.length == 1; - final bool isBlocked = locals.where((local) => local['CLU_STATUS'] == 'B').isNotEmpty; + final bool isBlocked = + locals.where((local) => local['CLU_STATUS'] == 'B').isNotEmpty; final bool isEnabled = isUnique && isActive; final bool isDisabled = isUnique && isBlocked; final bool isUnselected = await _isUnselected(); @@ -123,7 +127,8 @@ class LocalizationService { enText: 'Error getting locals, verify your connection', ptText: 'Erro ao obter locais, verifique sua conexão', ); - await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, null)); + await DialogUtil.error(context, errorMsg) + .whenComplete(() => selectLocal(context, null)); return false; } } @@ -138,7 +143,8 @@ class LocalizationService { final GetLocalsCall callback = PhpGroup.getLocalsCall; response = await callback.call(); final String errorMsg = response.jsonBody['error_msg']; - await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response)); + await DialogUtil.error(context, errorMsg) + .whenComplete(() => selectLocal(context, response)); return false; } else if (response.jsonBody == null) { final GetLocalsCall callback = PhpGroup.getLocalsCall; @@ -147,15 +153,16 @@ class LocalizationService { enText: 'Verify your connection', ptText: 'Verifique sua conexão', ); - await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, response)); + await DialogUtil.error(context, errorMsg) + .whenComplete(() => selectLocal(context, response)); return false; } else { - final bool isNewVersion = await _updateStorageUtil(response.jsonBody); - if (!isNewVersion) { - await LicenseService.setupLicense(DatabaseStorage.database); - return false; - } - return await LicenseService.fetchLicenses(); + // final bool isNewVersion = await _updateStorageUtil(response.jsonBody); + // if (!isNewVersion) { + await LicenseService.setupLicense(DatabaseStorage.database); + return false; + // } + // return await LicenseService.fetchLicenses(); } } catch (e, s) { log('() => stack processData: $s'); @@ -164,12 +171,14 @@ class LocalizationService { enText: 'Error getting data, verify your connection', ptText: 'Erro ao obter dados, verifique sua conexão', ); - await DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context, null)); + await DialogUtil.error(context, errorMsg) + .whenComplete(() => selectLocal(context, null)); return false; } } - static Future selectLocal(BuildContext context, ApiCallResponse? response) async { + static Future selectLocal( + BuildContext context, ApiCallResponse? response) async { return await showModalBottomSheet( isScrollControlled: true, backgroundColor: Colors.transparent, @@ -233,10 +242,13 @@ class LocalizationService { } static void _handleError(BuildContext context, String errorMsg) async { - final String devUUID = await StorageHelper().g(KeychainStorageKey.devUUID.value) ?? ''; - final String userUUID = await StorageHelper().g(KeychainStorageKey.userUUID.value) ?? ''; + final String devUUID = + await StorageHelper().g(KeychainStorageKey.devUUID.value) ?? ''; + final String userUUID = + await StorageHelper().g(KeychainStorageKey.userUUID.value) ?? ''; final bool isAuthenticated = userUUID.isNotEmpty && devUUID.isNotEmpty; - final bool isDevLinked = !errorMsg.contains('Esse dispositivo nao pertence a esse usuario'); + final bool isDevLinked = + !errorMsg.contains('Esse dispositivo nao pertence a esse usuario'); log('() => isLinked: $errorMsg'); log('() => isLinked: $errorMsg'); if (!isAuthenticated) { @@ -256,15 +268,20 @@ class LocalizationService { await DialogUtil.warning(context, errorMsg); return; } - await DialogUtil.error(context, errorMsg).whenComplete(() async => await selectLocal(context, null)); + await DialogUtil.error(context, errorMsg) + .whenComplete(() async => await selectLocal(context, null)); } - static Future _handleUnavailable(BuildContext context, List locals) async { + static Future _handleUnavailable( + BuildContext context, List locals) async { log('() => isUnavailable'); try { - await StorageHelper().s(KeychainStorageKey.clientUUID.value, locals[0]['CLI_ID']); - await StorageHelper().s(KeychainStorageKey.ownerUUID.value, locals[0]['CLU_OWNER_ID']); - await StorageHelper().s(KeychainStorageKey.clientName.value, locals[0]['CLI_NOME']); + await StorageHelper() + .s(KeychainStorageKey.clientUUID.value, locals[0]['CLI_ID']); + await StorageHelper() + .s(KeychainStorageKey.ownerUUID.value, locals[0]['CLU_OWNER_ID']); + await StorageHelper() + .s(KeychainStorageKey.clientName.value, locals[0]['CLI_NOME']); var response = await PhpGroup.resopndeVinculo.call(tarefa: 'A'); if (response.jsonBody['error'] == true) { await StorageHelper().s(KeychainStorageKey.clientUUID.value, ''); @@ -272,21 +289,28 @@ class LocalizationService { await StorageHelper().s(KeychainStorageKey.clientName.value, ''); return false; } - if (response.jsonBody['error'] == false) return await processData(context).then((value) => value); + if (response.jsonBody['error'] == false) + return await processData(context).then((value) => value); } catch (e, s) { await DialogUtil.errorDefault(context); - LogUtil.requestAPIFailed('responderVinculo.php', '', 'Responder Vínculo', e, s); + LogUtil.requestAPIFailed( + 'responderVinculo.php', '', 'Responder Vínculo', e, s); return false; } return false; } - static Future _handleEnabled(BuildContext context, dynamic local) async { + static Future _handleEnabled( + BuildContext context, dynamic local) async { log('() => isEnabled'); - await StorageHelper().s(KeychainStorageKey.clientUUID.value, local['CLI_ID']); - await StorageHelper().s(KeychainStorageKey.ownerUUID.value, local['CLU_OWNER_ID']); - await StorageHelper().s(KeychainStorageKey.clientName.value, local['CLI_NOME']); - await StorageHelper().s(KeychainStorageKey.userName.value, local['USU_NOME']); + await StorageHelper() + .s(KeychainStorageKey.clientUUID.value, local['CLI_ID']); + await StorageHelper() + .s(KeychainStorageKey.ownerUUID.value, local['CLU_OWNER_ID']); + await StorageHelper() + .s(KeychainStorageKey.clientName.value, local['CLI_NOME']); + await StorageHelper() + .s(KeychainStorageKey.userName.value, local['USU_NOME']); return await processData(context); } @@ -298,19 +322,24 @@ class LocalizationService { } static Future _updateStorageUtil(Map jsonBody) async { - await StorageHelper().s(KeychainStorageKey.whatsapp.value, jsonBody['whatsapp'] != null && jsonBody['whatsapp']); - await StorageHelper() - .s(KeychainStorageKey.provisional.value, jsonBody['provisional'] != null && jsonBody['provisional']); - await StorageHelper().s(KeychainStorageKey.pets.value, jsonBody['pet'] != null && jsonBody['pet']); + await StorageHelper().s(KeychainStorageKey.whatsapp.value, + jsonBody['whatsapp'] != null && jsonBody['whatsapp']); + await StorageHelper().s(KeychainStorageKey.provisional.value, + jsonBody['provisional'] != null && jsonBody['provisional']); + await StorageHelper().s(KeychainStorageKey.pets.value, + jsonBody['pet'] != null && jsonBody['pet']); await StorageHelper().s( KeychainStorageKey.petAmount.value, - jsonBody['petAmountRegister'] != null && jsonBody['petAmountRegister'].toString().isEmpty + jsonBody['petAmountRegister'] != null && + jsonBody['petAmountRegister'].toString().isEmpty ? '0' : jsonBody['petAmountRegister'].toString()); - await StorageHelper().s(KeychainStorageKey.userName.value, jsonBody['visitado']['VDO_NOME']); await StorageHelper() - .s(KeychainStorageKey.isNewVersion.value, jsonBody['newVersion'] != null && jsonBody['newVersion']); - return jsonBody['newVersion'] != null && jsonBody['newVersion']; + .s(KeychainStorageKey.userName.value, jsonBody['visitado']['VDO_NOME']); + await StorageHelper().s(KeychainStorageKey.isNewVersion.value, + jsonBody['newVersion'] != null && jsonBody['newVersion']); + log('() => isNewVersion: ${jsonBody['newVersion']}'); + return jsonBody['newVersion'] == true; } static bool _isActive(List locals) { @@ -318,30 +347,44 @@ class LocalizationService { } static Future _isInactived(List locals) async { - String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; - return locals.where((local) => local['CLI_ID'] != cliUUID && local['CLU_STATUS'] == 'A').isNotEmpty; + String cliUUID = + (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + return locals + .where( + (local) => local['CLI_ID'] != cliUUID && local['CLU_STATUS'] == 'A') + .isNotEmpty; } static bool _isPending(List locals) { - return locals.where((local) => local['CLU_STATUS'] != 'B' && local['CLU_STATUS'] != 'A').isNotEmpty; + return locals + .where( + (local) => local['CLU_STATUS'] != 'B' && local['CLU_STATUS'] != 'A') + .isNotEmpty; } static Future _isUnselected() async { - String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; - String cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; - String ownerUUID = (await StorageHelper().g(KeychainStorageKey.ownerUUID.value)) ?? ''; + String cliUUID = + (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + String cliName = + (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; + String ownerUUID = + (await StorageHelper().g(KeychainStorageKey.ownerUUID.value)) ?? ''; return cliUUID.isEmpty && cliName.isEmpty && ownerUUID.isEmpty; } static Future _isSelected(bool isInactived) async { - String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; - String cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; + String cliUUID = + (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + String cliName = + (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; return cliUUID.isNotEmpty && cliName.isNotEmpty && isInactived; } static Future _isAvailable() async { - String cliUUID = (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; - String cliName = (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; + String cliUUID = + (await StorageHelper().g(KeychainStorageKey.clientUUID.value)) ?? ''; + String cliName = + (await StorageHelper().g(KeychainStorageKey.clientName.value)) ?? ''; return cliUUID.isNotEmpty && cliName.isNotEmpty; } }