From b66b543a2828f428b835b61cbcd4e3974b84f8d9 Mon Sep 17 00:00:00 2001 From: "J. A. Messias" Date: Thu, 17 Oct 2024 16:04:51 -0300 Subject: [PATCH] WIP:some change --- .../localization/localization_service.dart | 70 +++++++++---------- lib/shared/utils/storage_util.dart | 2 + 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/lib/shared/services/localization/localization_service.dart b/lib/shared/services/localization/localization_service.dart index 4933b7af..85ec013d 100644 --- a/lib/shared/services/localization/localization_service.dart +++ b/lib/shared/services/localization/localization_service.dart @@ -12,6 +12,8 @@ import '../../utils/log_util.dart'; import '../../utils/snackbar_util.dart'; class LocalizationService { + + static Future checkLocals(BuildContext context) async { try { final GetLocalsCall callback = PhpGroup.getLocalsCall; @@ -40,7 +42,6 @@ class LocalizationService { log(e.toString(), stackTrace: s); } } - static Future processLocals(BuildContext context) async { try { final GetLocalsCall callback = PhpGroup.getLocalsCall; @@ -48,7 +49,8 @@ class LocalizationService { final bool isError = response.jsonBody['error']; if (isError) { - _handleError(context, response.jsonBody['error_msg']); + final String errorMsg = response.jsonBody['error_msg']; + _handleError(context, errorMsg); return false; } @@ -96,7 +98,6 @@ class LocalizationService { return await selectLocal(context); } } - static Future processData(BuildContext context) async { try { final GetDadosCall callback = PhpGroup.getDadosCall; @@ -118,7 +119,6 @@ class LocalizationService { return false; } } - static Future selectLocal(BuildContext context) async { return await showModalBottomSheet( isScrollControlled: true, @@ -137,7 +137,6 @@ class LocalizationService { ), ).then((_) async => await processData(context)); } - static Future unlinkLocal(BuildContext context) async { String content; try { @@ -187,38 +186,6 @@ class LocalizationService { context.go('/welcomePage'); DialogUtil.error(context, errorMsg); } - - static void _logLocalsStatus(List locals) { - for (var local in locals) { - final String status = local['CLU_STATUS']; - log('() => CLU_STATUS: $status'); - } - } - - static bool _isActive(List locals) { - return locals.where((local) => local['CLU_STATUS'] == 'A').isNotEmpty; - } - - static bool _isInactived(List locals) { - return locals.where((local) => local['CLI_ID'] != StorageUtil().cliUUID && local['CLU_STATUS'] == 'A').isNotEmpty; - } - - static bool _isPending(List locals) { - return locals.where((local) => local['CLU_STATUS'] != 'B' && local['CLU_STATUS'] != 'A').isNotEmpty; - } - - static bool _isUnselected() { - return StorageUtil().cliUUID.isEmpty && StorageUtil().cliName.isEmpty && StorageUtil().ownerUUID.isEmpty; - } - - static bool _isSelected(bool isInactived) { - return StorageUtil().cliUUID.isNotEmpty && StorageUtil().cliName.isNotEmpty && isInactived; - } - - static bool _isAvailable() { - return StorageUtil().cliUUID.isNotEmpty && StorageUtil().cliName.isNotEmpty; - } - static Future _handleUnavailable(BuildContext context, List locals) async { log('() => isUnavailable'); try { @@ -239,7 +206,6 @@ class LocalizationService { } return false; } - static Future _handleEnabled(BuildContext context, dynamic local) async { log('() => isEnabled'); StorageUtil().cliName = local['CLI_NOME']; @@ -249,6 +215,32 @@ class LocalizationService { return await processData(context); } + static void _logLocalsStatus(List locals) { + for (var local in locals) { + final String status = local['CLU_STATUS']; + log('() => CLU_STATUS: $status'); + } + } + + static bool _isActive(List locals) { + return locals.where((local) => local['CLU_STATUS'] == 'A').isNotEmpty; + } + static bool _isInactived(List locals) { + return locals.where((local) => local['CLI_ID'] != StorageUtil().cliUUID && local['CLU_STATUS'] == 'A').isNotEmpty; + } + static bool _isPending(List locals) { + return locals.where((local) => local['CLU_STATUS'] != 'B' && local['CLU_STATUS'] != 'A').isNotEmpty; + } + static bool _isUnselected() { + return StorageUtil().cliUUID.isEmpty && StorageUtil().cliName.isEmpty && StorageUtil().ownerUUID.isEmpty; + } + static bool _isSelected(bool isInactived) { + return StorageUtil().cliUUID.isNotEmpty && StorageUtil().cliName.isNotEmpty && isInactived; + } + static bool _isAvailable() { + return StorageUtil().cliUUID.isNotEmpty && StorageUtil().cliName.isNotEmpty; + } + static void _updateStorageUtil(Map jsonBody) { final bool whatsapp = jsonBody['whatsapp'] ?? false; final bool provisional = jsonBody['provisional'] ?? false; @@ -261,4 +253,6 @@ class LocalizationService { StorageUtil().petAmountRegister = petAmountRegister; StorageUtil().userName = name; } + + } \ No newline at end of file diff --git a/lib/shared/utils/storage_util.dart b/lib/shared/utils/storage_util.dart index 135fc7f4..9c1b5dcf 100644 --- a/lib/shared/utils/storage_util.dart +++ b/lib/shared/utils/storage_util.dart @@ -141,6 +141,8 @@ class StorageUtil { isFirstRun = false; await _sharedPreferences.prefs?.setBool('fre_isFirstRun', false); isLogged = false; + final String message = ''; + // _secureStorage.purge(); // _sqliteStorage.purge(); }