diff --git a/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart b/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart index 6dc7b85b..1bebbbef 100644 --- a/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart +++ b/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart @@ -138,6 +138,8 @@ class _BottomArrowLinkedLocalsComponentWidgetState return null; } + static Future _handleError( + BuildContext context, String errorMsg) async { static Future _handleError( BuildContext context, String errorMsg) async { await DialogUtil.error(context, errorMsg); diff --git a/lib/features/local/data/data_sources/locals_remote_data_source.dart b/lib/features/local/data/data_sources/locals_remote_data_source.dart index b39ff764..bf4b710b 100644 --- a/lib/features/local/data/data_sources/locals_remote_data_source.dart +++ b/lib/features/local/data/data_sources/locals_remote_data_source.dart @@ -20,7 +20,7 @@ abstract class LocalsRemoteDataSource { Future processLocals(BuildContext context); Future processData(BuildContext context); Future selectLocal(BuildContext context, ApiCallResponse? response); - Future detachLocal(BuildContext context); + Future detachLocal(BuildContext context); } class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { @@ -213,15 +213,15 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { } @override - Future detachLocal(BuildContext context) async { + Future detachLocal(BuildContext context) async { String content; try { content = FFLocalizations.of(context).getVariableText( enText: 'Device unlinked successfully', ptText: 'Dispositivo desvinculado com sucesso', ); - - await PhpGroup.resopndeVinculo.call(tarefa: 'I').then((value) async { + final bool status = + await PhpGroup.resopndeVinculo.call(tarefa: 'I').then((value) async { if (value.jsonBody['error'] == false) { await StorageHelper().set(ProfileStorageKey.clientName.key, ''); await StorageHelper().set(ProfileStorageKey.ownerName.key, ''); @@ -230,7 +230,9 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { context.go('/homePage', extra: {'update': LocalsRepositoryImpl().update}); SnackBarUtil.showSnackBar(context, content); + return true; } + return false; }).catchError((err, stack) { context.pop(); content = FFLocalizations.of(context).getVariableText( @@ -238,7 +240,9 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { ptText: 'Erro ao desvincular dispositivo', ); SnackBarUtil.showSnackBar(context, content, isError: true); + return false; }); + return status; } catch (err, stack) { context.pop(); log(err.toString(), stackTrace: stack); @@ -247,6 +251,7 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { ptText: 'Erro ao desvincular dispositivo', ); SnackBarUtil.showSnackBar(context, content, isError: true); + return false; } } } diff --git a/lib/features/local/data/repositories/locals_repository_impl.dart b/lib/features/local/data/repositories/locals_repository_impl.dart index e14e4227..2dd08bf2 100644 --- a/lib/features/local/data/repositories/locals_repository_impl.dart +++ b/lib/features/local/data/repositories/locals_repository_impl.dart @@ -7,6 +7,7 @@ import 'package:hub/features/menu/index.dart'; import 'package:hub/features/module/data/index.dart'; import 'package:hub/features/notification/index.dart'; import 'package:hub/features/storage/index.dart'; +import 'package:hub/flutter_flow/index.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:rxdart/rxdart.dart'; @@ -89,7 +90,11 @@ class LocalsRepositoryImpl implements LocalsRepository { @override Future unlinkLocal(BuildContext context) async { - await remoteDataSource.detachLocal(context); - await select(context); + final bool response = await remoteDataSource.detachLocal(context); + if (!response) return; + unselect(); + context.pop(); + context.go('/homePage', extra: {'update': update}); + await update(context); } } diff --git a/lib/features/menu/presentation/mappers/menu_entry.dart b/lib/features/menu/presentation/mappers/menu_entry.dart index 426da056..01ef1175 100644 --- a/lib/features/menu/presentation/mappers/menu_entry.dart +++ b/lib/features/menu/presentation/mappers/menu_entry.dart @@ -45,8 +45,8 @@ class MenuEntry implements BaseModule { key: 'FRE-HUB-FASTPASS', icon: Icons.attach_email_outlined, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Fast Pass', - enText: 'Fast Pass', + ptText: 'Convidar Visitante', + enText: 'Invite Visitor', ), route: '/fastPassPage', types: [MenuEntryType.Home, MenuEntryType.Drawer], @@ -213,8 +213,8 @@ class MenuEntry implements BaseModule { key: 'FRE-HUB-SETTINGS', icon: Icons.settings, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( - ptText: 'Configurações', - enText: 'Settings', + ptText: 'Opções do Sistema', + enText: 'System Settings', ), route: '/preferencesSettings', types: [MenuEntryType.Home, MenuEntryType.Drawer], diff --git a/lib/features/notification/notification_service.dart b/lib/features/notification/notification_service.dart index 9b1dcabb..8e1662d6 100644 --- a/lib/features/notification/notification_service.dart +++ b/lib/features/notification/notification_service.dart @@ -44,7 +44,7 @@ Future onMessageReceived( switch (handleClick) { case 'visit_request': showDialog( - context: StorageHelper().context!, + context: navigatorKey.currentContext!, barrierColor: Colors.transparent, barrierDismissible: true, builder: (BuildContext context) { @@ -167,7 +167,7 @@ Future onMessageReceived( break; case 'access': showDialog( - context: StorageHelper().context!, + context: navigatorKey.currentContext!, barrierColor: Colors.transparent, barrierDismissible: true, builder: (BuildContext context) { @@ -228,7 +228,7 @@ Future onMessageReceived( break; case 'mensagem': showDialog( - context: StorageHelper().context!, + context: navigatorKey.currentContext!, barrierColor: Colors.transparent, barrierDismissible: true, builder: (BuildContext context) { @@ -252,7 +252,7 @@ Future onMessageReceived( break; case 'enroll_cond': await StorageHelper().set(SecureStorageKey.haveLocal.value, true); - StorageHelper().context!.go('/homePage'); + navigatorKey.currentContext!.go('/homePage'); break; default: break; diff --git a/lib/pages/preferences_settings_page/preferences_settings_model.dart b/lib/pages/preferences_settings_page/preferences_settings_model.dart index 6e489b66..80925889 100644 --- a/lib/pages/preferences_settings_page/preferences_settings_model.dart +++ b/lib/pages/preferences_settings_page/preferences_settings_model.dart @@ -1,5 +1,3 @@ -import 'dart:developer'; - import 'package:flutter/material.dart'; import 'package:hub/components/templates_components/change_passs_qr_code_pass_key_template_component/change_pass_widget.dart'; import 'package:hub/features/auth/index.dart'; @@ -24,9 +22,6 @@ class PreferencesPageModel with ChangeNotifier { late bool isPanic = false; Future _initialize() async { - log( - 'TESTE:' + '${await StorageHelper().get(LocalsStorageKey.notify.key)}', - ); isFingerprint = await StorageHelper().get(LocalsStorageKey.fingerprint.key) == 'true'; isPerson = await StorageHelper().get(LocalsStorageKey.person.key) == 'true';