diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index f5a1de48..76beccc8 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -3,7 +3,8 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:hub/flutter_flow/random_data_util.dart'; import 'package:hub/main.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:integration_test/integration_test.dart'; late WidgetTester widget; @@ -13,8 +14,8 @@ void main() { group('Initialization', () { group('Navigation', () { - setUpAll(() async => - await initializeApp().then((_) => StorageUtil().isLogged = false)); + setUpAll(() async => await initializeApp().then( + (_) async => StorageHelper().set(SecureStorageKey.isLogged.value, 'false', Storage.SecureStorage))); testWidgets('Test Welcome', (WidgetTester tester) async { widget = tester; await _testWelcome(); @@ -25,16 +26,16 @@ void main() { }); group('Authentication', () { group('Sign in', () { - setUpAll(() async => - await initializeApp().then((_) => StorageUtil().isLogged = false)); + setUpAll(() async => await initializeApp().then( + (_) async => StorageHelper().set(SecureStorageKey.isLogged.value, 'false', Storage.SecureStorage))); testWidgets('Test Sign In', (WidgetTester tester) async { widget = tester; await _testSignIn(); }); }); group('Sign up', () { - setUpAll(() async => - await initializeApp().then((_) => StorageUtil().isLogged = false)); + setUpAll(() async => await initializeApp().then( + (_) async => StorageHelper().set(SecureStorageKey.isLogged.value, 'false', Storage.SecureStorage))); testWidgets('Test Sign Up', (WidgetTester tester) async { widget = tester; await _testSignUp(); @@ -96,14 +97,8 @@ Future _testWelcome() async { Future _testSignIn() async { await widget.pumpWidget(const App()); await _navigateToSignIn(); - await _auth({ - 'emailTextFormField': 'erro@exemplo.com', - 'passwordTextFormField': '12345678' - }); - await _auth({ - 'emailTextFormField': 'email_app@exemplo.com', - 'passwordTextFormField': '12345678' - }); + await _auth({'emailTextFormField': 'erro@exemplo.com', 'passwordTextFormField': '12345678'}); + await _auth({'emailTextFormField': 'email_app@exemplo.com', 'passwordTextFormField': '12345678'}); } Future _testSignUp() async { @@ -120,17 +115,10 @@ Future _testSignUp() async { var name = randomString(7, 7, true, true, true); var email = '$name@example.com'; var password = '12345678'; - credentials = { - 'nameTextFormField': name, - 'emailTextFormField': email, - 'passwordTextFormField': password - }; + credentials = {'nameTextFormField': name, 'emailTextFormField': email, 'passwordTextFormField': password}; await _navigateToSignUp(); await _auth(credentials); - credentials = { - 'emailTextFormField': email, - 'passwordTextFormField': password - }; + credentials = {'emailTextFormField': email, 'passwordTextFormField': password}; await _auth(credentials); } @@ -152,20 +140,17 @@ Future _testForgotPassword() async { Future _recoveryPassword() async { await widget.pumpAndSettle(); - final Finder forgotPassword = - find.byKey(const ValueKey('ForgotPassword')); + final Finder forgotPassword = find.byKey(const ValueKey('ForgotPassword')); if (forgotPassword.evaluate().isNotEmpty) await widget.tap(forgotPassword); await widget.ensureVisible(forgotPassword); await widget.pumpAndSettle(); } Future _navigateBackUsingSystemGesture() async => - IntegrationTestWidgetsFlutterBinding.instance.keyboard - .isLogicalKeyPressed(LogicalKeyboardKey.escape); + IntegrationTestWidgetsFlutterBinding.instance.keyboard.isLogicalKeyPressed(LogicalKeyboardKey.escape); Future _navigateToSignUp() async { await widget.pumpAndSettle(); - final Finder navToSignUp = - find.byKey(const ValueKey('toggleSignUpPage')); + final Finder navToSignUp = find.byKey(const ValueKey('toggleSignUpPage')); if (navToSignUp.evaluate().isNotEmpty) { await widget.tap(navToSignUp); await widget.pumpAndSettle(); @@ -174,8 +159,7 @@ Future _navigateToSignUp() async { Future _navigateToSignIn() async { await widget.pumpAndSettle(); - final Finder navToSignIn = - find.byKey(const ValueKey('toggleSignInPage')); + final Finder navToSignIn = find.byKey(const ValueKey('toggleSignInPage')); expect(navToSignIn, findsOneWidget); if (navToSignIn.evaluate().isNotEmpty) { await widget.tap(navToSignIn); @@ -214,8 +198,7 @@ Future _submit(String key) async { await widget.pumpAndSettle(); } - final Finder throwExceptionWidget = - find.byKey(const ValueKey('ThrowExceptionWidget')); + final Finder throwExceptionWidget = find.byKey(const ValueKey('ThrowExceptionWidget')); await widget.pumpAndSettle(); if (throwExceptionWidget.evaluate().isNotEmpty) { await widget.ensureVisible(throwExceptionWidget); diff --git a/lib/app_state.dart b/lib/app_state.dart deleted file mode 100644 index 8b137891..00000000 --- a/lib/app_state.dart +++ /dev/null @@ -1 +0,0 @@ - diff --git a/lib/backend/api_requests/api_calls.dart b/lib/backend/api_requests/api_calls.dart index 4665a13e..eb44686e 100644 --- a/lib/backend/api_requests/api_calls.dart +++ b/lib/backend/api_requests/api_calls.dart @@ -1,9 +1,13 @@ import 'dart:async'; import 'dart:convert'; +import 'dart:developer'; import 'package:flutter/foundation.dart'; import 'package:hub/backend/notifications/firebase_messaging_service.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; +import 'package:hub/shared/utils/dialog_util.dart'; +import 'package:hub/shared/utils/log_util.dart'; import 'package:hub/shared/utils/validator_util.dart'; import '/flutter_flow/flutter_flow_util.dart'; @@ -24,24 +28,22 @@ class PhpGroup { static ForgotPasswordCall forgotPasswordCall = ForgotPasswordCall(); static ChangePasswordCall changePasswordCall = ChangePasswordCall(); static GetLocalsCall getLocalsCall = GetLocalsCall(); - static PostScheduleVisitorCall postScheduleVisitorCall = - PostScheduleVisitorCall(); + static PostScheduleVisitorCall postScheduleVisitorCall = PostScheduleVisitorCall(); static PostScheduleVisitCall postScheduleVisitCall = PostScheduleVisitCall(); static GetScheduleVisitCall getScheduleVisitCall = GetScheduleVisitCall(); static GetDadosCall getDadosCall = GetDadosCall(); static GetVisitorByDocCall getVisitorByDocCall = GetVisitorByDocCall(); static GetFotoVisitanteCall getFotoVisitanteCall = GetFotoVisitanteCall(); - static PostProvVisitSchedulingCall postProvVisitSchedulingCall = - PostProvVisitSchedulingCall(); + static PostProvVisitSchedulingCall postProvVisitSchedulingCall = PostProvVisitSchedulingCall(); static GetVisitsCall getVisitsCall = GetVisitsCall(); static DeleteVisitCall deleteVisitCall = DeleteVisitCall(); static GetPessoasLocalCall getPessoasLocalCall = GetPessoasLocalCall(); - static RespondeSolicitacaoCall respondeSolicitacaoCall = - RespondeSolicitacaoCall(); + static RespondeSolicitacaoCall respondeSolicitacaoCall = RespondeSolicitacaoCall(); static GetAccessCall getAccessCall = GetAccessCall(); static GetLiberationsCall getLiberationsCall = GetLiberationsCall(); static GetMessagesCall getMessagesCall = GetMessagesCall(); static ChangeNotifica changeNotifica = ChangeNotifica(); + static UpdateIDE updateIDE = UpdateIDE(); static RespondeVinculo resopndeVinculo = RespondeVinculo(); static ChangePass changePass = ChangePass(); static ChangePanic changePanic = ChangePanic(); @@ -59,8 +61,10 @@ class PhpGroup { class UnregisterDevice { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; return ApiManager.instance.makeApiCall( callName: 'unregisterDevice', @@ -87,9 +91,12 @@ class UnregisterDevice { class DeletePet { Future call({final int? petID = 0}) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'excluirPet'; return ApiManager.instance.makeApiCall( @@ -132,9 +139,12 @@ class UpdatePet { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'atualizarPet'; return ApiManager.instance.makeApiCall( @@ -155,9 +165,7 @@ class UpdatePet { 'species': species, 'breed': breed, if (color != '') 'color': color, - if (birthdayDate != '') - 'birthdayDate': - ValidatorUtil.toISO8601USA('dd/MM/yyyy', birthdayDate!), + if (birthdayDate != '') 'birthdayDate': ValidatorUtil.toISO8601USA('dd/MM/yyyy', birthdayDate!), 'gender': gender, 'size': size, if (notes != '') 'notes': notes, @@ -174,12 +182,18 @@ class UpdatePet { } class GetPets { - Future call({final int? page, final int? pageSize,}) async { + Future call({ + final int? page, + final int? pageSize, + }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'consultaPets'; return ApiManager.instance.makeApiCall( @@ -211,9 +225,12 @@ class GetPetPhoto { Future call({final int? petId}) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'consultaFotoPet'; return ApiManager.instance.makeApiCall( @@ -254,9 +271,12 @@ class RegisterPet { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'cadastrarPet'; return ApiManager.instance.makeApiCall( @@ -276,9 +296,7 @@ class RegisterPet { 'species': species, 'breed': breed, if (color != '') 'color': color, - if (birthdayDate != '') - 'birthdayDate': - ValidatorUtil.toISO8601USA('dd/MM/yyyy', birthdayDate!), + if (birthdayDate != '') 'birthdayDate': ValidatorUtil.toISO8601USA('dd/MM/yyyy', birthdayDate!), 'gender': gender, 'size': size, if (notes != '') 'notes': notes, @@ -301,9 +319,12 @@ class BuscaEnconcomendas { final String? adresseeType, final String? status, }) async { - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'getEncomendas'; final String baseUrl = PhpGroup.getBaseUrl(); @@ -345,9 +366,12 @@ class CancelaVisita { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'cancelaVisita'; return ApiManager.instance.makeApiCall( @@ -379,8 +403,10 @@ class CancelaVisita { class DeleteAccount { Future call() async { - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; final String baseUrl = PhpGroup.getBaseUrl(); return ApiManager.instance.makeApiCall( @@ -411,9 +437,12 @@ class ChangePanic { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'updVisitado'; return ApiManager.instance.makeApiCall( @@ -447,9 +476,12 @@ class ChangePass { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'updVisitado'; return ApiManager.instance.makeApiCall( @@ -483,9 +515,12 @@ class RespondeVinculo { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; return ApiManager.instance.makeApiCall( callName: 'respondeVinculo', @@ -517,9 +552,12 @@ class ChangeNotifica { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'updVisitado'; return ApiManager.instance.makeApiCall( @@ -547,13 +585,54 @@ class ChangeNotifica { } } +class UpdateIDE { + Future call() async { + final String baseUrl = PhpGroup.getBaseUrl(); + + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliUUID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + final String newIde = + (await StorageHelper().get(SQLiteStorageKey.userDevUUID.value, Storage.SQLiteStorage)) ?? ''; + const String atividade = 'updVisitado'; + + return ApiManager.instance.makeApiCall( + callName: 'changeNotifica', + apiUrl: '$baseUrl/processRequest.php', + callType: ApiCallType.POST, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + params: { + 'devUUID': devUUID, + 'userUUID': userUUID, + 'cliID': cliUUID, + 'atividade': atividade, + 'newIde': newIde, + }, + bodyType: BodyType.X_WWW_FORM_URL_ENCODED, + returnBody: true, + encodeBodyUtf8: false, + decodeUtf8: false, + cache: false, + isStreamingApi: false, + alwaysAllowBody: false, + ); + } +} + class UpdToken { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String token = StorageUtil().token; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String token = (await StorageHelper().get(SecureStorageKey.token.value, Storage.SecureStorage)) ?? ''; return ApiManager.instance.makeApiCall( callName: 'updToken', @@ -580,12 +659,24 @@ class UpdToken { class LoginCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String email = StorageUtil().email; - final String password = StorageUtil().passwd; - final String type = StorageUtil().deviceType; - final String description = StorageUtil().deviceDescription; - final String token = await FirebaseMessagingService.getToken(); + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String email = (await StorageHelper().get(SecureStorageKey.email.value, Storage.SecureStorage)) ?? ''; + final String password = + (await StorageHelper().get(SecureStorageKey.password.value, Storage.SecureStorage)) ?? ''; + final String type = + (await StorageHelper().get(SecureStorageKey.deviceType.value, Storage.SecureStorage)) ?? ''; + final String description = + (await StorageHelper().get(SecureStorageKey.deviceDescription.value, Storage.SecureStorage)) ?? ''; + late final String token; + try { + token = await FirebaseMessagingService.getToken(); + if(token == null || token.isEmpty) throw Exception('Token is empty'); } + catch (e, s) { + token = ''; + log('Error getting token', error: e, stackTrace: s); + LogUtil.requestAPIFailed('login.php', email, "Login", e, s); + } return ApiManager.instance.makeApiCall( callName: 'login', @@ -652,7 +743,6 @@ class RegisterCall { } } - class ChangePasswordCall { Future call({ required final String email, @@ -660,9 +750,12 @@ class ChangePasswordCall { required final String psswd, }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; return ApiManager.instance.makeApiCall( callName: 'changePassword', @@ -696,7 +789,6 @@ class ForgotPasswordCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - return ApiManager.instance.makeApiCall( callName: 'forgotPassword', apiUrl: '$baseUrl/iforgot.php', @@ -722,8 +814,8 @@ class GetLocalsCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; + final String devUUID = await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage) ?? ''; + final String userUUID = await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage) ?? ''; return ApiManager.instance.makeApiCall( callName: 'getLocals', @@ -762,9 +854,12 @@ class PostScheduleVisitorCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'putVisitante'; return ApiManager.instance.makeApiCall( @@ -817,9 +912,12 @@ class PostScheduleVisitCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'putVisita'; return ApiManager.instance.makeApiCall( @@ -871,9 +969,12 @@ class GetScheduleVisitCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliUUID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliUUID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'getVisitas'; return ApiManager.instance.makeApiCall( @@ -1145,9 +1246,12 @@ class GetDadosCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliUUID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliUUID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'getDados'; return ApiManager.instance.makeApiCall( @@ -1181,8 +1285,7 @@ class GetDadosCall { response, r'''$.error_msg''', )); - String? visitedDesNomeStr(dynamic response) => - castToType(getJsonField( + String? visitedDesNomeStr(dynamic response) => castToType(getJsonField( response, r'''$.visitado.DES_NOME''', )); @@ -1190,33 +1293,27 @@ class GetDadosCall { response, r'''$.visitado.VDO_ID''', )); - String? visitedVDOTNomeStr(dynamic response) => - castToType(getJsonField( + String? visitedVDOTNomeStr(dynamic response) => castToType(getJsonField( response, r'''$.visitado.VDO_NOME''', )); - String? visitedVDOTipoStr(dynamic response) => - castToType(getJsonField( + String? visitedVDOTipoStr(dynamic response) => castToType(getJsonField( response, r'''$.visitado.VDO_TIPO''', )); - String? visitedVDOImeiStr(dynamic response) => - castToType(getJsonField( + String? visitedVDOImeiStr(dynamic response) => castToType(getJsonField( response, r'''$.visitado.VDO_IMEI''', )); - String? visitedVDODocumentoStr(dynamic response) => - castToType(getJsonField( + String? visitedVDODocumentoStr(dynamic response) => castToType(getJsonField( response, r'''$.visitado.VDO_DOCUMENTO''', )); - String? visitedVDOEmailStr(dynamic response) => - castToType(getJsonField( + String? visitedVDOEmailStr(dynamic response) => castToType(getJsonField( response, r'''$.visitado.VDO_EMAIL''', )); - String? visitedVDOStatusWebStr(dynamic response) => - castToType(getJsonField( + String? visitedVDOStatusWebStr(dynamic response) => castToType(getJsonField( response, r'''$.visitado.VDO_STATUSWEB''', )); @@ -1264,8 +1361,7 @@ class GetDadosCall { response, r'''$.visitado.DES_ID''', )); - String? visitedVDoNotTerceirosStr(dynamic response) => - castToType(getJsonField( + String? visitedVDoNotTerceirosStr(dynamic response) => castToType(getJsonField( response, r'''$.visitado.VDO_NOTTERCEIROS''', )); @@ -1334,8 +1430,7 @@ class GetDadosCall { .map((x) => castToType(x)) .withoutNulls .toList(); - List? levelNACIndPermiteReentradaStrList(dynamic response) => - (getJsonField( + List? levelNACIndPermiteReentradaStrList(dynamic response) => (getJsonField( response, r'''$.niveis[:].NAC_INDPERMITEREENTRADA''', true, @@ -1353,8 +1448,7 @@ class GetDadosCall { .map((x) => castToType(x)) .withoutNulls .toList(); - List? levelNACTempoAntiCaronaStrList(dynamic response) => - (getJsonField( + List? levelNACTempoAntiCaronaStrList(dynamic response) => (getJsonField( response, r'''$.niveis[:].NAC_TEMPOANTICARONA''', true, @@ -1388,9 +1482,12 @@ class GetVisitorByDocCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'getVisitante'; return ApiManager.instance.makeApiCall( @@ -1442,9 +1539,12 @@ class GetFotoVisitanteCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'getFotoVisitante'; return ApiManager.instance.makeApiCall( @@ -1481,9 +1581,12 @@ class PostProvVisitSchedulingCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'putAgendamentoProv'; return ApiManager.instance.makeApiCall( @@ -1530,9 +1633,12 @@ class GetVisitsCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'getVisitas'; return ApiManager.instance.makeApiCall( @@ -1793,9 +1899,12 @@ class DeleteVisitCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'cancelaVisita'; return ApiManager.instance.makeApiCall( @@ -1836,10 +1945,14 @@ class GetPessoasLocalCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String ownerUUID = StorageUtil().ownerUUID; - final String userUUID = StorageUtil().userUUID; - final String cliUUID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String ownerUUID = + (await StorageHelper().get(SQLiteStorageKey.ownerUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliUUID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; return ApiManager.instance.makeApiCall( callName: 'getPessoasLocal', @@ -1902,9 +2015,12 @@ class RespondeSolicitacaoCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliUUID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliUUID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'respondeSolicitacao'; return ApiManager.instance.makeApiCall( @@ -1944,7 +2060,6 @@ class RespondeSolicitacaoCall { )); } - class GetAccessCall { Future call({ final String? pageSize, @@ -1953,9 +2068,12 @@ class GetAccessCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliUUID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliUUID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'getAcessos'; return ApiManager.instance.makeApiCall( @@ -2195,15 +2313,19 @@ class GetAccessCall { .withoutNulls .toList(); } + class GetLiberationsCall { Stream call() { final String baseUrl = PhpGroup.getBaseUrl(); final StreamController controller = StreamController(); Future.microtask(() async { - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliUUID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliUUID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'getSolicitacoes'; try { @@ -2384,6 +2506,7 @@ class GetLiberationsCall { .withoutNulls .toList(); } + class GetMessagesCall { Future call({ final String? pageSize, @@ -2392,9 +2515,12 @@ class GetMessagesCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = StorageUtil().devUUID; - final String userUUID = StorageUtil().userUUID; - final String cliUUID = StorageUtil().cliUUID; + final String devUUID = + (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final String userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final String cliUUID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; const String atividade = 'getMensagens'; return ApiManager.instance.makeApiCall( diff --git a/lib/backend/api_requests/api_manager.dart b/lib/backend/api_requests/api_manager.dart index 72087153..5e8f68bb 100644 --- a/lib/backend/api_requests/api_manager.dart +++ b/lib/backend/api_requests/api_manager.dart @@ -107,9 +107,7 @@ class ApiCallResponse { final Object? exception; bool get succeeded => statusCode >= 200 && statusCode < 300; String getHeader(String headerName) => headers[headerName] ?? ''; - String get bodyText => - response?.body ?? - (jsonBody is String ? jsonBody as String : jsonEncode(jsonBody)); + String get bodyText => response?.body ?? (jsonBody is String ? jsonBody as String : jsonEncode(jsonBody)); String get exceptionMessage => exception.toString(); static ApiCallResponse fromHttpResponse( @@ -123,9 +121,7 @@ class ApiCallResponse { if (bodyType == BodyType.BLOB) { jsonBody = response.bodyBytes; } else { - final responseBody = decodeUtf8 && returnBody - ? const Utf8Decoder().convert(response.bodyBytes) - : response.body; + final responseBody = decodeUtf8 && returnBody ? const Utf8Decoder().convert(response.bodyBytes) : response.body; jsonBody = returnBody ? json.decode(responseBody) : null; } } catch (_) {} @@ -137,8 +133,7 @@ class ApiCallResponse { ); } - static ApiCallResponse fromCloudCallResponse(Map response) => - ApiCallResponse( + static ApiCallResponse fromCloudCallResponse(Map response) => ApiCallResponse( response['body'], ApiManager.toStringMap(response['headers'] ?? {}), response['statusCode'] ?? 400, @@ -155,17 +150,14 @@ class ApiManager { static String? _accessToken; - static void clearCache(String callName) => _apiCache.keys - .toSet() - .forEach((k) => k.callName == callName ? _apiCache.remove(k) : null); + static void clearCache(String callName) => + _apiCache.keys.toSet().forEach((k) => k.callName == callName ? _apiCache.remove(k) : null); static Map toStringMap(Map map) => map.map((key, value) => MapEntry(key.toString(), value.toString())); - static String asQueryParams(Map map) => map.entries - .map((e) => - "${Uri.encodeComponent(e.key)}=${Uri.encodeComponent(e.value.toString())}") - .join('&'); + static String asQueryParams(Map map) => + map.entries.map((e) => "${Uri.encodeComponent(e.key)}=${Uri.encodeComponent(e.value.toString())}").join('&'); static Future urlRequest( ApiCallType callType, @@ -179,15 +171,13 @@ class ApiManager { BodyType? bodyType, }) async { if (params.isNotEmpty) { - final specifier = - Uri.parse(apiUrl).queryParameters.isNotEmpty ? '&' : '?'; + final specifier = Uri.parse(apiUrl).queryParameters.isNotEmpty ? '&' : '?'; apiUrl = '$apiUrl$specifier${asQueryParams(params)}'; } if (isStreamingApi) { client ??= http.Client(); - final request = - http.Request(callType.toString().split('.').last, Uri.parse(apiUrl)) - ..headers.addAll(toStringMap(headers)); + final request = http.Request(callType.toString().split('.').last, Uri.parse(apiUrl)) + ..headers.addAll(toStringMap(headers)); final streamedResponse = await getStreamedResponse(request); return ApiCallResponse( null, @@ -199,10 +189,8 @@ class ApiManager { final makeRequest = callType == ApiCallType.GET ? (client != null ? client.get : http.get) : (client != null ? client.delete : http.delete); - final response = - await makeRequest(Uri.parse(apiUrl), headers: toStringMap(headers)); - return ApiCallResponse.fromHttpResponse( - response, returnBody, decodeUtf8, bodyType); + final response = await makeRequest(Uri.parse(apiUrl), headers: toStringMap(headers)); + return ApiCallResponse.fromHttpResponse(response, returnBody, decodeUtf8, bodyType); } static Future requestWithBody( @@ -224,13 +212,11 @@ class ApiManager { (alwaysAllowBody && type == ApiCallType.DELETE), 'Invalid ApiCallType $type for request with body', ); - final postBody = - createBody(headers, params, body, bodyType, encodeBodyUtf8); + final postBody = createBody(headers, params, body, bodyType, encodeBodyUtf8); if (isStreamingApi) { client ??= http.Client(); - final request = - http.Request(type.toString().split('.').last, Uri.parse(apiUrl)) - ..headers.addAll(toStringMap(headers)); + final request = http.Request(type.toString().split('.').last, Uri.parse(apiUrl)) + ..headers.addAll(toStringMap(headers)); request.body = postBody; final streamedResponse = await getStreamedResponse(request); return ApiCallResponse( @@ -242,8 +228,7 @@ class ApiManager { } if (bodyType == BodyType.MULTIPART) { - return multipartRequest(type, apiUrl, headers, params, returnBody, - decodeUtf8, alwaysAllowBody, bodyType); + return multipartRequest(type, apiUrl, headers, params, returnBody, decodeUtf8, alwaysAllowBody, bodyType); } final requestFn = { @@ -252,10 +237,8 @@ class ApiManager { ApiCallType.PATCH: client != null ? client.patch : http.patch, ApiCallType.DELETE: client != null ? client.delete : http.delete, }[type]!; - final response = await requestFn(Uri.parse(apiUrl), - headers: toStringMap(headers), body: postBody); - return ApiCallResponse.fromHttpResponse( - response, returnBody, decodeUtf8, bodyType); + final response = await requestFn(Uri.parse(apiUrl), headers: toStringMap(headers), body: postBody); + return ApiCallResponse.fromHttpResponse(response, returnBody, decodeUtf8, bodyType); } static Future multipartRequest( @@ -275,19 +258,14 @@ class ApiManager { ); bool isFile(dynamic e) => - e is FFUploadedFile || - e is List || - (e is List && e.firstOrNull is FFUploadedFile); + e is FFUploadedFile || e is List || (e is List && e.firstOrNull is FFUploadedFile); - final nonFileParams = toStringMap( - Map.fromEntries(params.entries.where((e) => !isFile(e.value)))); + final nonFileParams = toStringMap(Map.fromEntries(params.entries.where((e) => !isFile(e.value)))); List files = []; params.entries.where((e) => isFile(e.value)).forEach((e) { final param = e.value; - final uploadedFiles = param is List - ? param as List - : [param as FFUploadedFile]; + final uploadedFiles = param is List ? param as List : [param as FFUploadedFile]; for (var uploadedFile in uploadedFiles) { files.add( http.MultipartFile.fromBytes( @@ -300,15 +278,13 @@ class ApiManager { } }); - final request = http.MultipartRequest( - type.toString().split('.').last, Uri.parse(apiUrl)) + final request = http.MultipartRequest(type.toString().split('.').last, Uri.parse(apiUrl)) ..headers.addAll(toStringMap(headers)) ..files.addAll(files); nonFileParams.forEach((key, value) => request.fields[key] = value); final response = await http.Response.fromStream(await request.send()); - return ApiCallResponse.fromHttpResponse( - response, returnBody, decodeUtf8, bodyType); + return ApiCallResponse.fromHttpResponse(response, returnBody, decodeUtf8, bodyType); } static MediaType? _getMediaType(String? filename) { @@ -357,13 +333,10 @@ class ApiManager { case null: break; } - if (contentType != null && - !headers.keys.any((h) => h.toLowerCase() == 'content-type')) { + if (contentType != null && !headers.keys.any((h) => h.toLowerCase() == 'content-type')) { headers['Content-Type'] = contentType; } - return encodeBodyUtf8 && postBody is String - ? utf8.encode(postBody) - : postBody; + return encodeBodyUtf8 && postBody is String ? utf8.encode(postBody) : postBody; } Future call(ApiCallOptions options) => makeApiCall( diff --git a/lib/backend/api_requests/get_streamed_response.dart b/lib/backend/api_requests/get_streamed_response.dart index 303a19e5..73280a05 100644 --- a/lib/backend/api_requests/get_streamed_response.dart +++ b/lib/backend/api_requests/get_streamed_response.dart @@ -1,4 +1,3 @@ import 'package:http/http.dart'; -Future getStreamedResponse(Request request) => - Client().send(request); \ No newline at end of file +Future getStreamedResponse(Request request) => Client().send(request); diff --git a/lib/backend/notifications/firebase_messaging_service.dart b/lib/backend/notifications/firebase_messaging_service.dart index dfe76047..1fa9864e 100644 --- a/lib/backend/notifications/firebase_messaging_service.dart +++ b/lib/backend/notifications/firebase_messaging_service.dart @@ -2,8 +2,9 @@ import 'dart:developer'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:hub/backend/api_requests/api_calls.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/utils/log_util.dart'; -import 'package:hub/shared/utils/storage_util.dart'; import 'notification_service.dart'; @@ -16,8 +17,7 @@ Future handleMessage(RemoteMessage message) async { class FirebaseMessagingService { // Singleton instance - static final FirebaseMessagingService _instance = - FirebaseMessagingService._internal(); + static final FirebaseMessagingService _instance = FirebaseMessagingService._internal(); // Factory constructor factory FirebaseMessagingService() => _instance; @@ -36,15 +36,14 @@ class FirebaseMessagingService { _firebaseMessaging.pluginConstants; } - static Future getToken() async => - await FirebaseMessaging.instance.getToken() ?? ''; + static Future getToken() async => await FirebaseMessaging.instance.getToken() ?? ''; Future updateDeviceToken() async { try { final String? deviceToken = await _firebaseMessaging.getToken(); if (deviceToken != null) { - StorageUtil().token = deviceToken; + await StorageHelper().set(SecureStorageKey.token.value, deviceToken, Storage.SecureStorage); final ApiCallResponse? response; response = await PhpGroup.updToken.call(); diff --git a/lib/backend/notifications/notification_service.dart b/lib/backend/notifications/notification_service.dart index 15303b61..4254183d 100644 --- a/lib/backend/notifications/notification_service.dart +++ b/lib/backend/notifications/notification_service.dart @@ -8,14 +8,15 @@ 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/nav/nav.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/utils/dialog_util.dart'; -import 'package:hub/shared/utils/storage_util.dart'; -Future onMessageReceived( - Map payload, String? extra, String? handleClick) async { +Future onMessageReceived(Map payload, String? extra, String? handleClick) async { final localId = jsonDecode(payload['local']!)['CLI_ID']; - final cliUUID = StorageUtil().cliUUID; + final cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + answersRequest( {required BuildContext context, required String? ref, @@ -42,7 +43,7 @@ Future onMessageReceived( switch (handleClick) { case 'visit_request': showDialog( - context: StorageUtil().context!, + context: StorageHelper().context!, barrierColor: Colors.transparent, barrierDismissible: true, builder: (BuildContext context) { @@ -62,10 +63,8 @@ Future onMessageReceived( enText: 'Approve Visit', ), FFLocalizations.of(context).getVariableText( - ptText: - 'Você tem certeza que deseja aprovar essa visita?', - enText: - 'Are you sure you want to approve this visit?', + ptText: 'Você tem certeza que deseja aprovar essa visita?', + enText: 'Are you sure you want to approve this visit?', ), () async { await answersRequest( @@ -102,10 +101,8 @@ Future onMessageReceived( enText: 'Block Visit', ), FFLocalizations.of(context).getVariableText( - ptText: - 'Você tem certeza que deseja bloquear essa visita?', - enText: - 'Are you sure you want to block this visit?', + ptText: 'Você tem certeza que deseja bloquear essa visita?', + enText: 'Are you sure you want to block this visit?', ), () async { await answersRequest .call( @@ -165,7 +162,7 @@ Future onMessageReceived( break; case 'access': showDialog( - context: StorageUtil().context!, + context: StorageHelper().context!, barrierColor: Colors.transparent, barrierDismissible: true, builder: (BuildContext context) { @@ -186,13 +183,11 @@ Future onMessageReceived( FFLocalizations.of(context).getVariableText( enText: 'Name', ptText: 'Nome', - ): payload['PES_NOME'].toString(), + ): payload['PES_NOME'] != null ? payload['PES_NOME'].toString() : payload['USR_NOME'].toString(), FFLocalizations.of(context).getVariableText( enText: 'Type', ptText: 'Tipo', - ): payload['USR_TIPO'].toString() == 'O' - ? 'Morador' - : 'Visitante', + ): payload['USR_TIPO'].toString() == 'O' ? 'Morador' : 'Visitante', FFLocalizations.of(context).getVariableText( enText: 'Access Date', ptText: 'Data de Acesso', @@ -224,7 +219,7 @@ Future onMessageReceived( break; case 'mensagem': showDialog( - context: StorageUtil().context!, + context: StorageHelper().context!, barrierColor: Colors.transparent, barrierDismissible: true, builder: (BuildContext context) { @@ -235,11 +230,8 @@ Future onMessageReceived( child: MessageNotificationModalTemplateComponentWidget( id: localId, from: payload['remetente'].toString(), - to: payload['destinatario'].toString() == 'O' - ? 'Morador' - : 'Visitante', - message: - extra.toString().isEmpty ? 'Unknown' : extra.toString(), + to: payload['destinatario'].toString() == 'O' ? 'Morador' : 'Visitante', + message: extra.toString().isEmpty ? 'Unknown' : extra.toString(), ), ), ); @@ -247,8 +239,8 @@ Future onMessageReceived( break; case 'enroll_cond': - StorageUtil().haveLocal = true; - StorageUtil().context!.go('/homePage'); + await StorageHelper().set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage); + StorageHelper().context!.go('/homePage'); break; default: break; @@ -274,21 +266,17 @@ class NotificationService { ledColor: Colors.white, ) ], - channelGroups: [ - NotificationChannelGroup( - channelGroupKey: 'basic_channel_group', - channelGroupName: 'group_1') - ], + channelGroups: [NotificationChannelGroup(channelGroupKey: 'basic_channel_group', channelGroupName: 'group_1')], debug: kDebugMode); - await AwesomeNotifications() - .isNotificationAllowed() - .then((isAllowed) async { - final bool requestOSnotification = StorageUtil().requestOSnotification; + await AwesomeNotifications().isNotificationAllowed().then((isAllowed) async { + final bool requestOSnotification = + (await StorageHelper().get(SQLiteStorageKey.requestOSNotification.value, Storage.SQLiteStorage)) == + 'true'; if (requestOSnotification == false) { if (isAllowed == false) { - StorageUtil().requestOSnotification = true; + await StorageHelper().set(SQLiteStorageKey.requestOSNotification.value, 'true', Storage.SQLiteStorage); await AwesomeNotifications().requestPermissionToSendNotifications(); } } @@ -302,22 +290,18 @@ class NotificationService { onDismissActionReceivedMethod: onDismissActionReceivedMethod); } - static Future onActionReceivedMethod( - ReceivedAction receivedAction) async { + static Future onActionReceivedMethod(ReceivedAction receivedAction) async { final payload = receivedAction.payload ?? {}; final extra = receivedAction.body; final handleClick = payload['click_action']; onMessageReceived(payload, extra, handleClick); } - static Future onNotificationCreatedMethod( - ReceivedNotification receivedNotification) async {} + static Future onNotificationCreatedMethod(ReceivedNotification receivedNotification) async {} - static Future onNotificationDisplayedMethod( - ReceivedNotification receivedNotification) async {} + static Future onNotificationDisplayedMethod(ReceivedNotification receivedNotification) async {} - static Future onDismissActionReceivedMethod( - ReceivedAction receivedAction) async {} + static Future onDismissActionReceivedMethod(ReceivedAction receivedAction) async {} static Future show({ required final String title, @@ -351,8 +335,7 @@ class NotificationService { schedule: scheduled ? NotificationInterval( interval: Duration(seconds: interval!), - timeZone: - await AwesomeNotifications().getLocalTimeZoneIdentifier(), + timeZone: await AwesomeNotifications().getLocalTimeZoneIdentifier(), preciseAlarm: true) : null); } diff --git a/lib/backend/schema/enums/enums.dart b/lib/backend/schema/enums/enums.dart index 029e9293..3013905b 100644 --- a/lib/backend/schema/enums/enums.dart +++ b/lib/backend/schema/enums/enums.dart @@ -22,8 +22,7 @@ extension FFEnumExtensions on T { } extension FFEnumListExtensions on Iterable { - T? deserialize(String? value) => - firstWhereOrNull((e) => e.serialize() == value); + T? deserialize(String? value) => firstWhereOrNull((e) => e.serialize() == value); } T? deserializeEnum(String? value) { diff --git a/lib/backend/schema/structs/device_struct.dart b/lib/backend/schema/structs/device_struct.dart index 174afa98..620863c4 100644 --- a/lib/backend/schema/structs/device_struct.dart +++ b/lib/backend/schema/structs/device_struct.dart @@ -1,11 +1,9 @@ // ignore_for_file: unnecessary_getters_setters - import 'package:hub/flutter_flow/nav/nav.dart'; import 'index.dart'; - class DeviceStruct extends BaseStruct { DeviceStruct({ String? devUUID, @@ -67,8 +65,7 @@ class DeviceStruct extends BaseStruct { ), }.withoutNulls; - static DeviceStruct fromSerializableMap(Map data) => - DeviceStruct( + static DeviceStruct fromSerializableMap(Map data) => DeviceStruct( devUUID: deserializeParam( data['devUUID'], ParamType.String, @@ -98,8 +95,7 @@ class DeviceStruct extends BaseStruct { } @override - int get hashCode => - const ListEquality().hash([devUUID, version, description]); + int get hashCode => const ListEquality().hash([devUUID, version, description]); } DeviceStruct createDeviceStruct({ @@ -111,4 +107,4 @@ DeviceStruct createDeviceStruct({ devUUID: devUUID, version: version, description: description, - ); \ No newline at end of file + ); diff --git a/lib/backend/schema/util/schema_util.dart b/lib/backend/schema/util/schema_util.dart index 80a9f7a4..d6c251d9 100644 --- a/lib/backend/schema/util/schema_util.dart +++ b/lib/backend/schema/util/schema_util.dart @@ -6,13 +6,10 @@ import 'package:hub/backend/schema/enums/enums.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/nav/serialization_util.dart'; - - export 'package:collection/collection.dart' show ListEquality; export 'package:flutter/material.dart' show Color, Colors; export 'package:from_css_color/from_css_color.dart'; - typedef StructBuilder = T Function(Map data); abstract class BaseStruct { @@ -39,8 +36,7 @@ dynamic deserializeStructParam( return null; } return paramValues - .map((e) => deserializeStructParam(e, paramType, false, - structBuilder: structBuilder)) + .map((e) => deserializeStructParam(e, paramType, false, structBuilder: structBuilder)) .toList(); } else if (param is Map) { return structBuilder(param); @@ -58,16 +54,9 @@ List? getStructList( dynamic value, StructBuilder structBuilder, ) => - value is! List - ? null - : value - .whereType>() - .map((e) => structBuilder(e)) - .toList(); + value is! List ? null : value.whereType>().map((e) => structBuilder(e)).toList(); -List? getEnumList(dynamic value) => value is! List - ? null - : value.map((e) => deserializeEnum(e)).withoutNulls; +List? getEnumList(dynamic value) => value is! List ? null : value.map((e) => deserializeEnum(e)).withoutNulls; Color? getSchemaColor(dynamic value) => value is String ? fromCssColor(value) @@ -75,8 +64,6 @@ Color? getSchemaColor(dynamic value) => value is String ? value : null; -List? getColorsList(dynamic value) => - value is! List ? null : value.map(getSchemaColor).withoutNulls; +List? getColorsList(dynamic value) => value is! List ? null : value.map(getSchemaColor).withoutNulls; -List? getDataList(dynamic value) => - value is! List ? null : value.map((e) => castToType(e)!).toList(); \ No newline at end of file +List? getDataList(dynamic value) => value is! List ? null : value.map((e) => castToType(e)!).toList(); diff --git a/lib/components/atomic_components/menu_button_item/menu_button_item_widget.dart b/lib/components/atomic_components/menu_button_item/menu_button_item_widget.dart index 1c87f710..32471006 100644 --- a/lib/components/atomic_components/menu_button_item/menu_button_item_widget.dart +++ b/lib/components/atomic_components/menu_button_item/menu_button_item_widget.dart @@ -2,8 +2,6 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/components/molecular_components/menu_item/menu_item.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; -import 'package:hub/shared/utils/dialog_util.dart'; -import 'package:hub/shared/utils/storage_util.dart'; import '../../../shared/extensions/dialog_extensions.dart'; import '../../../shared/services/localization/localization_service.dart'; @@ -11,17 +9,17 @@ import '../../../shared/services/localization/localization_service.dart'; class MenuButtonWidget extends MenuEntry { const MenuButtonWidget({ super.key, - this.action, - this.title, - this.icon, - }); + required this.action, + required this.title, + required this.icon, + }) : super(action: action, title: title, icon: icon); @override - final Function()? action; + final Function() action; @override - final String? title; + final String title; @override - final IconData? icon; + final IconData icon; @override _MenuButtonWidgetState createState() => _MenuButtonWidgetState(); @@ -46,20 +44,9 @@ class _MenuButtonWidgetState extends State { onTap: _isProcessing ? null : () async { - setState(() { - _isProcessing = true; - }); - await LocalizationService.processLocals(context) - .then((value) async { - if (value) { - await widget.action?.call(); - } else { - DialogUnavailable.unavailableCredentials(context); - } - }); - setState(() { - _isProcessing = false; - }); + setState(() { _isProcessing = true; }); + await widget.action.call(); + setState(() { _isProcessing = false; }); }, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 0, vertical: 0), @@ -116,8 +103,7 @@ class _MenuButtonWidgetState extends State { fontSize: limitedFontSize, letterSpacing: 0.0, fontWeight: FontWeight.w500, - useGoogleFonts: - GoogleFonts.asMap().containsKey('Nunito'), + useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), ), ), ), diff --git a/lib/components/atomic_components/menu_card_item/menu_card_item.dart b/lib/components/atomic_components/menu_card_item/menu_card_item.dart index 3f69ba21..83afb4d6 100644 --- a/lib/components/atomic_components/menu_card_item/menu_card_item.dart +++ b/lib/components/atomic_components/menu_card_item/menu_card_item.dart @@ -9,17 +9,17 @@ import '../../../shared/services/localization/localization_service.dart'; class MenuCardItem extends MenuEntry { const MenuCardItem({ super.key, - this.action, - this.title, - this.icon, - }); + required this.action, + required this.title, + required this.icon, + }) : super(action: action, title: title, icon: icon); @override - final Function()? action; + final Function() action; @override - final String? title; + final String title; @override - final IconData? icon; + final IconData icon; @override _MenuCardItemState createState() => _MenuCardItemState(); @@ -39,20 +39,9 @@ class _MenuCardItemState extends State { onTap: _isProcessing ? null : () async { - setState(() { - _isProcessing = true; - }); - await LocalizationService.processLocals(context) - .then((value) async { - if (value) { - await widget.action?.call(); - } else { - DialogUnavailable.unavailableCredentials(context); - } - }); - setState(() { - _isProcessing = false; - }); + setState(() { _isProcessing = true; }); + await widget.action.call(); + setState(() { _isProcessing = false; }); }, child: Card( elevation: 0, @@ -64,8 +53,7 @@ class _MenuCardItemState extends State { Align( alignment: const AlignmentDirectional(-1.0, 0.0), child: Padding( - padding: - const EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 10.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 10.0, 0.0), child: Container( width: 30.0, height: 30.0, diff --git a/lib/components/atomic_components/shared_components_atoms/atom_image_svg_theme.dart b/lib/components/atomic_components/shared_components_atoms/atom_image_svg_theme.dart index 94484ab5..7f19801a 100644 --- a/lib/components/atomic_components/shared_components_atoms/atom_image_svg_theme.dart +++ b/lib/components/atomic_components/shared_components_atoms/atom_image_svg_theme.dart @@ -6,12 +6,7 @@ class AtomImageSvgTheme extends StatelessWidget { final double width; final double height; - const AtomImageSvgTheme({ - super.key, - required this.filename, - required this.width, - required this.height - }); + const AtomImageSvgTheme({super.key, required this.filename, required this.width, required this.height}); @override Widget build(BuildContext context) { @@ -21,5 +16,4 @@ class AtomImageSvgTheme extends StatelessWidget { return SvgPicture.asset(path, width: width, height: height); } - } diff --git a/lib/components/atomic_components/shared_components_atoms/custom_datepicker.dart b/lib/components/atomic_components/shared_components_atoms/custom_datepicker.dart index cffebe05..b615051b 100644 --- a/lib/components/atomic_components/shared_components_atoms/custom_datepicker.dart +++ b/lib/components/atomic_components/shared_components_atoms/custom_datepicker.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; @@ -66,8 +65,7 @@ class _CustomDatePickerState extends State { fontSize: 32.0, letterSpacing: 0.0, fontWeight: FontWeight.w600, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).headlineLargeFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).headlineLargeFamily), ), pickerBackgroundColor: FlutterFlowTheme.of(context).primaryBackground, pickerForegroundColor: FlutterFlowTheme.of(context).primaryText, @@ -90,27 +88,19 @@ class _CustomDatePickerState extends State { child!, headerBackgroundColor: FlutterFlowTheme.of(context).primary, headerForegroundColor: FlutterFlowTheme.of(context).info, - headerTextStyle: - FlutterFlowTheme.of(context).headlineLarge.override( - fontFamily: - FlutterFlowTheme.of(context).headlineLargeFamily, - fontSize: 32.0, - letterSpacing: 0.0, - fontWeight: FontWeight.w600, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).headlineLargeFamily), - ), - pickerBackgroundColor: - FlutterFlowTheme.of(context).primaryBackground, + headerTextStyle: FlutterFlowTheme.of(context).headlineLarge.override( + fontFamily: FlutterFlowTheme.of(context).headlineLargeFamily, + fontSize: 32.0, + letterSpacing: 0.0, + fontWeight: FontWeight.w600, + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).headlineLargeFamily), + ), + pickerBackgroundColor: FlutterFlowTheme.of(context).primaryBackground, pickerForegroundColor: FlutterFlowTheme.of(context).info, - selectedDateTimeBackgroundColor: - FlutterFlowTheme.of(context).primary, - selectedDateTimeForegroundColor: - FlutterFlowTheme.of(context).info, - pickerDialForegroundColor: - FlutterFlowTheme.of(context).primaryText, - actionButtonForegroundColor: - FlutterFlowTheme.of(context).primaryText, + selectedDateTimeBackgroundColor: FlutterFlowTheme.of(context).primary, + selectedDateTimeForegroundColor: FlutterFlowTheme.of(context).info, + pickerDialForegroundColor: FlutterFlowTheme.of(context).primaryText, + actionButtonForegroundColor: FlutterFlowTheme.of(context).primaryText, iconSize: 24.0, ); }, @@ -167,8 +157,7 @@ class _CustomDatePickerState extends State { child: Stack( children: [ Padding( - padding: - const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: TextFormField( controller: widget.controller, focusNode: widget.focusNode, @@ -178,26 +167,20 @@ class _CustomDatePickerState extends State { obscureText: false, decoration: InputDecoration( isDense: true, - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), hintText: widget.hintText, - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), lineHeight: 1.0, ), enabledBorder: OutlineInputBorder( @@ -234,11 +217,9 @@ class _CustomDatePickerState extends State { ), ), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), lineHeight: 1.8, ), textAlign: TextAlign.start, @@ -246,8 +227,7 @@ class _CustomDatePickerState extends State { ), ), Padding( - padding: - const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, diff --git a/lib/components/atomic_components/shared_components_atoms/custom_select.dart b/lib/components/atomic_components/shared_components_atoms/custom_select.dart index f25232fb..e21a0d80 100644 --- a/lib/components/atomic_components/shared_components_atoms/custom_select.dart +++ b/lib/components/atomic_components/shared_components_atoms/custom_select.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/flutter_flow/flutter_flow_drop_down.dart'; @@ -54,8 +53,7 @@ class _CustomSelectState extends State { children: [ Expanded( child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: Container( width: 100.0, height: 48.0, @@ -69,14 +67,11 @@ class _CustomSelectState extends State { isMultiSelect: false, width: double.infinity, height: double.infinity, - textStyle: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + textStyle: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), fontSize: limitedInputFontSize, ), hintText: widget.hintText, @@ -89,8 +84,7 @@ class _CustomSelectState extends State { borderColor: FlutterFlowTheme.of(context).customColor6, borderWidth: 0.5, borderRadius: 10.0, - margin: const EdgeInsetsDirectional.fromSTEB( - 12.0, 0.0, 16.0, 0.0), + margin: const EdgeInsetsDirectional.fromSTEB(12.0, 0.0, 16.0, 0.0), hidesUnderline: true, isOverButton: true, isSearchable: false, @@ -103,31 +97,24 @@ class _CustomSelectState extends State { if (widget.isRequired) if (widget.dropDownValue == null || widget.dropDownValue == '') Padding( - padding: - const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: Row( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ Padding( - padding: - const EdgeInsetsDirectional.only(top: 5, start: 15), + padding: const EdgeInsetsDirectional.only(top: 5, start: 15), child: Text( FFLocalizations.of(context).getVariableText( enText: 'This field is required', ptText: 'Este campo é obrigatório', ), - style: FlutterFlowTheme.of(context) - .bodySmall - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodySmallFamily, - color: - FlutterFlowTheme.of(context).customColor6, + style: FlutterFlowTheme.of(context).bodySmall.override( + fontFamily: FlutterFlowTheme.of(context).bodySmallFamily, + color: FlutterFlowTheme.of(context).customColor6, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .bodySmallFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodySmallFamily), fontSize: limitedInputFontSize )), ), diff --git a/lib/components/atomic_components/shared_components_atoms/submit_button.dart b/lib/components/atomic_components/shared_components_atoms/submit_button.dart index 4c1667fa..1a4cdd39 100644 --- a/lib/components/atomic_components/shared_components_atoms/submit_button.dart +++ b/lib/components/atomic_components/shared_components_atoms/submit_button.dart @@ -8,7 +8,8 @@ class SubmitButtonUtil extends StatelessWidget { final String labelText; Future Function()? onPressed; - SubmitButtonUtil({super.key, + SubmitButtonUtil({ + super.key, required this.labelText, required this.onPressed, }); @@ -29,8 +30,7 @@ class SubmitButtonUtil extends StatelessWidget { fontFamily: FlutterFlowTheme.of(context).titleSmallFamily, color: FlutterFlowTheme.of(context).info, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey(FlutterFlowTheme.of(context).titleSmallFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).titleSmallFamily), ), borderSide: const BorderSide( color: Colors.transparent, diff --git a/lib/components/atomic_components/shared_components_atoms/tabview.dart b/lib/components/atomic_components/shared_components_atoms/tabview.dart index 6c7a6493..3ae0d4dd 100644 --- a/lib/components/atomic_components/shared_components_atoms/tabview.dart +++ b/lib/components/atomic_components/shared_components_atoms/tabview.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; @@ -42,8 +41,7 @@ class TabViewUtil extends StatelessWidget { fontFamily: FlutterFlowTheme.of(context).titleMediumFamily, fontSize: LimitedFontSizeUtil.getBodyFontSize(context), letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).titleMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).titleMediumFamily), ), unselectedLabelStyle: const TextStyle(), indicatorColor: FlutterFlowTheme.of(context).primary, diff --git a/lib/components/atomic_components/text_field_component/text_field_component_model.dart b/lib/components/atomic_components/text_field_component/text_field_component_model.dart index a74572ce..ff40e7d4 100644 --- a/lib/components/atomic_components/text_field_component/text_field_component_model.dart +++ b/lib/components/atomic_components/text_field_component/text_field_component_model.dart @@ -2,9 +2,7 @@ import '/flutter_flow/flutter_flow_util.dart'; import 'text_field_component_widget.dart' show TextFieldComponentWidget; import 'package:flutter/material.dart'; - -class TextFieldComponentModel - extends FlutterFlowModel { +class TextFieldComponentModel extends FlutterFlowModel { /// State fields for stateful widgets in this component. // State field(s) for TextField widget. @@ -20,4 +18,4 @@ class TextFieldComponentModel textFieldFocusNode?.dispose(); textController?.dispose(); } -} \ No newline at end of file +} diff --git a/lib/components/atomic_components/text_field_component/text_field_component_widget.dart b/lib/components/atomic_components/text_field_component/text_field_component_widget.dart index 90a63614..2e98b097 100644 --- a/lib/components/atomic_components/text_field_component/text_field_component_widget.dart +++ b/lib/components/atomic_components/text_field_component/text_field_component_widget.dart @@ -7,7 +7,6 @@ export 'text_field_component_model.dart'; //// - class TextFieldComponentWidget extends StatefulWidget { const TextFieldComponentWidget({ super.key, @@ -21,8 +20,7 @@ class TextFieldComponentWidget extends StatefulWidget { final String? hintTextStrParam; @override - State createState() => - _TextFieldComponentWidgetState(); + State createState() => _TextFieldComponentWidgetState(); } class _TextFieldComponentWidgetState extends State { @@ -39,8 +37,7 @@ class _TextFieldComponentWidgetState extends State { super.initState(); _model = createModel(context, () => TextFieldComponentModel()); - _model.textController ??= - TextEditingController(text: widget.initialValueStrParam); + _model.textController ??= TextEditingController(text: widget.initialValueStrParam); _model.textFieldFocusNode ??= FocusNode(); } @@ -66,16 +63,14 @@ class _TextFieldComponentWidgetState extends State { fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), hintText: widget.hintTextStrParam, hintStyle: FlutterFlowTheme.of(context).labelMedium.override( fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( @@ -110,11 +105,10 @@ class _TextFieldComponentWidgetState extends State { fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).secondaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), validator: _model.textControllerValidator.asValidator(context), ), ); } -} \ No newline at end of file +} diff --git a/lib/components/molecular_components/menu_item/menu_item.dart b/lib/components/molecular_components/menu_item/menu_item.dart index ce3aac0a..790b3fb4 100644 --- a/lib/components/molecular_components/menu_item/menu_item.dart +++ b/lib/components/molecular_components/menu_item/menu_item.dart @@ -3,12 +3,12 @@ import 'package:flutter/material.dart'; abstract class MenuEntry extends StatefulWidget { const MenuEntry({ super.key, - this.action, - this.title, - this.icon, + required this.action, + required this.title, + required this.icon, }); - final Function()? action; - final String? title; - final IconData? icon; -} + final Function() action; + final String title; + final IconData icon; +} \ No newline at end of file diff --git a/lib/components/molecular_components/message_opt_modal/opt_modal_model.dart b/lib/components/molecular_components/message_opt_modal/opt_modal_model.dart index f7055ea5..e2b90125 100644 --- a/lib/components/molecular_components/message_opt_modal/opt_modal_model.dart +++ b/lib/components/molecular_components/message_opt_modal/opt_modal_model.dart @@ -18,8 +18,7 @@ class OptModalModel extends FlutterFlowModel { // State field(s) for CheckboxGroup widget. FormFieldController>? checkboxGroupValueController; List? get checkboxGroupValues => checkboxGroupValueController?.value; - set checkboxGroupValues(List? v) => - checkboxGroupValueController?.value = v; + set checkboxGroupValues(List? v) => checkboxGroupValueController?.value = v; @override void initState(BuildContext context) {} diff --git a/lib/components/molecular_components/message_opt_modal/opt_modal_widget.dart b/lib/components/molecular_components/message_opt_modal/opt_modal_widget.dart index 3c91574a..db8cd7e4 100644 --- a/lib/components/molecular_components/message_opt_modal/opt_modal_widget.dart +++ b/lib/components/molecular_components/message_opt_modal/opt_modal_widget.dart @@ -45,12 +45,8 @@ class _OptModalWidgetState extends State { _model.textFieldFocusNode ??= FocusNode(); selected = { - 'personType': widget.defaultPersonType == '.*' - ? ['E', 'O'] - : [widget.defaultPersonType], - 'accessType': widget.defaultAccessType == '.*' - ? ['0', '1'] - : [widget.defaultAccessType], + 'personType': widget.defaultPersonType == '.*' ? ['E', 'O'] : [widget.defaultPersonType], + 'accessType': widget.defaultAccessType == '.*' ? ['0', '1'] : [widget.defaultAccessType], 'search': '.*', }; } @@ -59,9 +55,7 @@ class _OptModalWidgetState extends State { Map filterResult = { 'personType': '', 'accessType': '', - 'search': _model.textController?.text == '' - ? '.*' - : _model.textController!.text.toLowerCase(), + 'search': _model.textController?.text == '' ? '.*' : _model.textController!.text.toLowerCase(), }; if (selected['personType']!.isEmpty) { @@ -102,8 +96,7 @@ class _OptModalWidgetState extends State { fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, fontSize: limitedInputFontSize, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), color: FlutterFlowTheme.of(context).primaryText, ), ), @@ -123,8 +116,7 @@ class _OptModalWidgetState extends State { fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, fontSize: limitedInputFontSize, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), color: FlutterFlowTheme.of(context).primaryText, ), ), @@ -151,8 +143,7 @@ class _OptModalWidgetState extends State { width: 5, color: FlutterFlowTheme.of(context).secondaryText, ), - controlAffinity: - ListTileControlAffinity.leading, // Adiciona esta linha + controlAffinity: ListTileControlAffinity.leading, // Adiciona esta linha ); }, ), @@ -196,24 +187,19 @@ class _OptModalWidgetState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 10.0, 10.0, 0.0, 10.0), + padding: const EdgeInsetsDirectional.fromSTEB(10.0, 10.0, 0.0, 10.0), child: Text( - FFLocalizations.of(context) - .getText('yfj9pd6k'), // Filtros - style: - FlutterFlowTheme.of(context).headlineMedium.override( - fontFamily: FlutterFlowTheme.of(context) - .headlineMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - fontSize: LimitedFontSizeUtil.getHeaderFontSize( + FFLocalizations.of(context).getText('yfj9pd6k'), // Filtros + style: FlutterFlowTheme.of(context).headlineMedium.override( + fontFamily: FlutterFlowTheme.of(context).headlineMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, + fontSize: LimitedFontSizeUtil.getHeaderFontSize( context), - letterSpacing: 0.0, - fontWeight: FontWeight.bold, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .headlineMediumFamily), - ), + letterSpacing: 0.0, + fontWeight: FontWeight.bold, + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).headlineMediumFamily), + ), ), ), ], @@ -225,8 +211,7 @@ class _OptModalWidgetState extends State { child: Column( mainAxisSize: MainAxisSize.min, children: [ - _buildCheckboxListTile( - 'personType', personTypeOptions, 14), + _buildCheckboxListTile('personType', personTypeOptions, 14), ], ), ), diff --git a/lib/components/molecular_components/opt_modal/opt_modal_model.dart b/lib/components/molecular_components/opt_modal/opt_modal_model.dart index 66133fb1..1f2e3693 100644 --- a/lib/components/molecular_components/opt_modal/opt_modal_model.dart +++ b/lib/components/molecular_components/opt_modal/opt_modal_model.dart @@ -3,8 +3,6 @@ import '/flutter_flow/form_field_controller.dart'; import 'opt_modal_widget.dart' show OptModalWidget; import 'package:flutter/material.dart'; - - class OptModalModel extends FlutterFlowModel { /// State fields for stateful widgets in this component. @@ -19,8 +17,7 @@ class OptModalModel extends FlutterFlowModel { // State field(s) for CheckboxGroup widget. FormFieldController>? checkboxGroupValueController; List? get checkboxGroupValues => checkboxGroupValueController?.value; - set checkboxGroupValues(List? v) => - checkboxGroupValueController?.value = v; + set checkboxGroupValues(List? v) => checkboxGroupValueController?.value = v; @override void initState(BuildContext context) {} @@ -30,4 +27,4 @@ class OptModalModel extends FlutterFlowModel { textFieldFocusNode?.dispose(); textController?.dispose(); } -} \ No newline at end of file +} diff --git a/lib/components/molecular_components/opt_modal/opt_modal_widget.dart b/lib/components/molecular_components/opt_modal/opt_modal_widget.dart index 2a5e9329..a4914b22 100644 --- a/lib/components/molecular_components/opt_modal/opt_modal_widget.dart +++ b/lib/components/molecular_components/opt_modal/opt_modal_widget.dart @@ -49,12 +49,8 @@ class _OptModalWidgetState extends State { _model.textFieldFocusNode ??= FocusNode(); selected = { - 'personType': widget.defaultPersonType == '.*' - ? ['E', 'O'] - : [widget.defaultPersonType], - 'accessType': widget.defaultAccessType == '.*' - ? ['0', '1'] - : [widget.defaultAccessType], + 'personType': widget.defaultPersonType == '.*' ? ['E', 'O'] : [widget.defaultPersonType], + 'accessType': widget.defaultAccessType == '.*' ? ['0', '1'] : [widget.defaultAccessType], 'search': '.*', }; } @@ -63,9 +59,7 @@ class _OptModalWidgetState extends State { Map filterResult = { 'personType': '', 'accessType': '', - 'search': _model.textController?.text == '' - ? '.*' - : _model.textController!.text.toLowerCase(), + 'search': _model.textController?.text == '' ? '.*' : _model.textController!.text.toLowerCase(), }; if (selected['personType']!.isEmpty) { @@ -96,17 +90,14 @@ class _OptModalWidgetState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Padding( - padding: - const EdgeInsetsDirectional.fromSTEB(0.0, 10.0, 0.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 10.0, 0.0, 0.0), child: Text( FFLocalizations.of(context).getText('l7tw8b92'), - textAlign: TextAlign - .left, // Adiciona esta linha para alinhar o texto à esquerda + textAlign: TextAlign.left, // Adiciona esta linha para alinhar o texto à esquerda style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), color: FlutterFlowTheme.of(context).primaryText, ), ), @@ -124,8 +115,7 @@ class _OptModalWidgetState extends State { style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), color: FlutterFlowTheme.of(context).primaryText, ), ), @@ -152,8 +142,7 @@ class _OptModalWidgetState extends State { width: 10, color: FlutterFlowTheme.of(context).secondaryText, ), - controlAffinity: - ListTileControlAffinity.leading, // Adiciona esta linha + controlAffinity: ListTileControlAffinity.leading, // Adiciona esta linha ); }, ), @@ -198,30 +187,23 @@ class _OptModalWidgetState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 10.0, 10.0, 0.0, 10.0), + padding: const EdgeInsetsDirectional.fromSTEB(10.0, 10.0, 0.0, 10.0), child: Text( - FFLocalizations.of(context) - .getText('yfj9pd6k'), // Filtros - style: FlutterFlowTheme.of(context) - .headlineMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .headlineMediumFamily, + FFLocalizations.of(context).getText('yfj9pd6k'), // Filtros + style: FlutterFlowTheme.of(context).headlineMedium.override( + fontFamily: FlutterFlowTheme.of(context).headlineMediumFamily, color: FlutterFlowTheme.of(context).primaryText, fontSize: 16.0, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .headlineMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).headlineMediumFamily), ), ), ), ], ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 8.0, 0.0, 8.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0), child: TextFormField( controller: _model.textController, focusNode: _model.textFieldFocusNode, @@ -232,27 +214,19 @@ class _OptModalWidgetState extends State { labelText: FFLocalizations.of(context).getText( '0enrtljz' /* Pesquise aqui..... */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( @@ -289,14 +263,12 @@ class _OptModalWidgetState extends State { ), ), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), - validator: - _model.textControllerValidator.asValidator(context), + validator: _model.textControllerValidator.asValidator(context), ), ), SingleChildScrollView( @@ -305,10 +277,8 @@ class _OptModalWidgetState extends State { child: Column( mainAxisSize: MainAxisSize.min, children: [ - _buildCheckboxListTile( - 'personType', personTypeOptions), - _buildCheckboxListTile( - 'accessType', accessTypeOptions), + _buildCheckboxListTile('personType', personTypeOptions), + _buildCheckboxListTile('accessType', accessTypeOptions), ], ), ), @@ -319,8 +289,7 @@ class _OptModalWidgetState extends State { foregroundColor: FlutterFlowTheme.of(context).info, backgroundColor: FlutterFlowTheme.of(context).primary, ), - child: - Text(FFLocalizations.of(context).getText('88kshkph')), + child: Text(FFLocalizations.of(context).getText('88kshkph')), ), ], ), diff --git a/lib/components/molecular_components/option_selection_modal/option_selection_modal_model.dart b/lib/components/molecular_components/option_selection_modal/option_selection_modal_model.dart index 38613124..e2e83af6 100644 --- a/lib/components/molecular_components/option_selection_modal/option_selection_modal_model.dart +++ b/lib/components/molecular_components/option_selection_modal/option_selection_modal_model.dart @@ -1,14 +1,12 @@ import 'package:hub/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; - import 'package:flutter/material.dart'; -class OptionSelectionModalModel - extends FlutterFlowModel { +class OptionSelectionModalModel extends FlutterFlowModel { @override void initState(BuildContext context) {} @override void dispose() {} -} \ No newline at end of file +} diff --git a/lib/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart b/lib/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart index a445cc81..ed4433d8 100644 --- a/lib/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart +++ b/lib/components/molecular_components/option_selection_modal/option_selection_modal_widget.dart @@ -21,12 +21,10 @@ class OptionSelectionModalWidget extends StatefulWidget { final List? nameListStr; @override - State createState() => - _OptionSelectionModalWidgetState(); + State createState() => _OptionSelectionModalWidgetState(); } -class _OptionSelectionModalWidgetState extends State - with TickerProviderStateMixin { +class _OptionSelectionModalWidgetState extends State with TickerProviderStateMixin { late OptionSelectionModalModel _model; final animationsMap = {}; @@ -92,17 +90,14 @@ class _OptionSelectionModalWidgetState extends State return GestureDetector( onTap: () async { context.pop(); - if (widget.routesListStr![optionsListIndex] == - 'scheduleCompleteVisitPage') { + if (widget.routesListStr![optionsListIndex] == 'scheduleCompleteVisitPage') { // Navegação para a página ScheduleCompleteVisitPage com queryParameters context.go( '/scheduleCompleteVisitPage', extra: { - 'visitStartDateStr': DateFormat('yyyy-MM-dd HH:mm:ss') - .format(DateTime.now()), - 'visitEndDateStr': DateFormat('yyyy-MM-dd HH:mm:ss') - .format( - DateTime.now().add(const Duration(days: 1))), + 'visitStartDateStr': DateFormat('yyyy-MM-dd HH:mm:ss').format(DateTime.now()), + 'visitEndDateStr': + DateFormat('yyyy-MM-dd HH:mm:ss').format(DateTime.now().add(const Duration(days: 1))), }, ); } else { @@ -149,27 +144,20 @@ class _OptionSelectionModalWidgetState extends State children: [ Expanded( child: Align( - alignment: - const AlignmentDirectional(-1.0, 0.0), + alignment: const AlignmentDirectional(-1.0, 0.0), child: Padding( - padding: - const EdgeInsetsDirectional.fromSTEB( - 8.0, 0.0, 0.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 0.0, 0.0), child: Container( width: 30.0, height: 30.0, decoration: BoxDecoration( - color: FlutterFlowTheme.of(context) - .primaryBackground, + color: FlutterFlowTheme.of(context).primaryBackground, shape: BoxShape.circle, ), - alignment: const AlignmentDirectional( - 0.0, 0.0), + alignment: const AlignmentDirectional(0.0, 0.0), child: Icon( - widget.iconsListIcon![ - optionsListIndex]!, - color: FlutterFlowTheme.of(context) - .accent1, + widget.iconsListIcon![optionsListIndex]!, + color: FlutterFlowTheme.of(context).accent1, size: 34.0, ), ), @@ -186,21 +174,16 @@ class _OptionSelectionModalWidgetState extends State mainAxisAlignment: MainAxisAlignment.center, children: [ Align( - alignment: - const AlignmentDirectional(0.0, 0.0), + alignment: const AlignmentDirectional(0.0, 0.0), child: Text( widget.nameListStr![optionsListIndex], - style: FlutterFlowTheme.of(context) - .titleLarge - .override( + style: FlutterFlowTheme.of(context).titleLarge.override( fontFamily: 'Nunito', - color: FlutterFlowTheme.of(context) - .primaryText, + color: FlutterFlowTheme.of(context).primaryText, fontSize: 14.0, letterSpacing: 0.0, fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts.asMap() - .containsKey('Nunito'), + useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), ), ), ), diff --git a/lib/components/molecular_components/order_filter_modal/order_filter_modal_model.dart b/lib/components/molecular_components/order_filter_modal/order_filter_modal_model.dart index e1f99286..79eefd3c 100644 --- a/lib/components/molecular_components/order_filter_modal/order_filter_modal_model.dart +++ b/lib/components/molecular_components/order_filter_modal/order_filter_modal_model.dart @@ -3,10 +3,7 @@ import '/flutter_flow/form_field_controller.dart'; import 'order_filter_modal_widget.dart' show OrderFilterModalWidget; import 'package:flutter/material.dart'; - - class OrderFilterModalModel extends FlutterFlowModel { - // State field(s) for TextField widget. FocusNode? textFieldFocusNode; TextEditingController? textController; @@ -18,8 +15,7 @@ class OrderFilterModalModel extends FlutterFlowModel { // State field(s) for CheckboxGroup widget. FormFieldController>? checkboxGroupValueController; List? get checkboxGroupValues => checkboxGroupValueController?.value; - set checkboxGroupValues(List? v) => - checkboxGroupValueController?.value = v; + set checkboxGroupValues(List? v) => checkboxGroupValueController?.value = v; @override void initState(BuildContext context) {} @@ -29,4 +25,4 @@ class OrderFilterModalModel extends FlutterFlowModel { textFieldFocusNode?.dispose(); textController?.dispose(); } -} \ No newline at end of file +} diff --git a/lib/components/molecular_components/order_filter_modal/order_filter_modal_widget.dart b/lib/components/molecular_components/order_filter_modal/order_filter_modal_widget.dart index b6289cca..de1a19dd 100644 --- a/lib/components/molecular_components/order_filter_modal/order_filter_modal_widget.dart +++ b/lib/components/molecular_components/order_filter_modal/order_filter_modal_widget.dart @@ -4,10 +4,10 @@ import 'package:hub/components/molecular_components/order_filter_modal/order_fil import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; // ignore: unused_import -import 'package:hub/shared/helpers/secure_storage_helper.dart'; + import 'package:hub/shared/utils/limited_text_size.dart'; -import 'package:hub/shared/utils/storage_util.dart'; class OrderFilterModalWidget extends StatefulWidget { final String defaultAdresseeType; @@ -29,26 +29,25 @@ class _OrderFilterModalWidgetState extends State { late Map selected; final List> adresseeTypeOptions = [ { - 'title': FFLocalizations.of(StorageUtil().context!) - .getVariableText(enText: 'Resident', ptText: 'Morador'), + 'title': + FFLocalizations.of(StorageHelper().context!).getVariableText(enText: 'Resident', ptText: 'Morador'), 'value': 'MOR' }, { - 'title': FFLocalizations.of(StorageUtil().context!) + 'title': FFLocalizations.of(StorageHelper().context!) .getVariableText(enText: 'Property', ptText: 'Propriedade'), 'value': 'PRO' }, ]; final List> statusOptions = [ { - 'title': FFLocalizations.of(StorageUtil().context!) - .getVariableText( - ptText: 'Aguardando Retirada', enText: 'Waiting for Pickup'), + 'title': FFLocalizations.of(StorageHelper().context!) + .getVariableText(ptText: 'Aguardando Retirada', enText: 'Waiting for Pickup'), 'value': 'notPickedUp' }, { - 'title': FFLocalizations.of(StorageUtil().context!) - .getVariableText(ptText: 'Retirado', enText: 'Picked Up'), + 'title': + FFLocalizations.of(StorageHelper().context!).getVariableText(ptText: 'Retirado', enText: 'Picked Up'), 'value': 'pickedUp' }, ]; @@ -66,12 +65,8 @@ class _OrderFilterModalWidgetState extends State { _model = createModel(context, () => OrderFilterModalModel()); selected = { - 'adresseeType': widget.defaultAdresseeType == '.*' - ? ['MOR', 'PRO'] - : [widget.defaultAdresseeType], - 'status': widget.defaultStatus == '.*' - ? ['notPickedUp', 'pickedUp'] - : [widget.defaultStatus], + 'adresseeType': widget.defaultAdresseeType == '.*' ? ['MOR', 'PRO'] : [widget.defaultAdresseeType], + 'status': widget.defaultStatus == '.*' ? ['notPickedUp', 'pickedUp'] : [widget.defaultStatus], }; } @@ -101,8 +96,7 @@ class _OrderFilterModalWidgetState extends State { context.pop(filterResult); } - Widget _buildCheckboxListTile( - String key, List> options, double fontsize) { + Widget _buildCheckboxListTile(String key, List> options, double fontsize) { return Column( children: [ Row( @@ -118,8 +112,7 @@ class _OrderFilterModalWidgetState extends State { fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, fontSize: fontsize, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), color: FlutterFlowTheme.of(context).primaryText, ), ), @@ -139,8 +132,7 @@ class _OrderFilterModalWidgetState extends State { fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, fontSize: fontsize, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), color: FlutterFlowTheme.of(context).primaryText, ), ), @@ -168,8 +160,7 @@ class _OrderFilterModalWidgetState extends State { width: 5, color: FlutterFlowTheme.of(context).secondaryText, ), - controlAffinity: - ListTileControlAffinity.leading, // Adiciona esta linha + controlAffinity: ListTileControlAffinity.leading, // Adiciona esta linha ); }, ), @@ -199,23 +190,18 @@ class _OrderFilterModalWidgetState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 10.0, 10.0, 0.0, 10.0), + padding: const EdgeInsetsDirectional.fromSTEB(10.0, 10.0, 0.0, 10.0), child: Text( - FFLocalizations.of(context) - .getText('yfj9pd6k'), // Filtros - style: - FlutterFlowTheme.of(context).headlineMedium.override( - fontFamily: FlutterFlowTheme.of(context) - .headlineMediumFamily, - color: FlutterFlowTheme.of(context).primaryText, - fontSize: 18.0, - letterSpacing: 0.0, - fontWeight: FontWeight.bold, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .headlineMediumFamily), - ), + FFLocalizations.of(context).getText('yfj9pd6k'), // Filtros + style: FlutterFlowTheme.of(context).headlineMedium.override( + fontFamily: FlutterFlowTheme.of(context).headlineMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, + fontSize: 18.0, + letterSpacing: 0.0, + fontWeight: FontWeight.bold, + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).headlineMediumFamily), + ), ), ), ], diff --git a/lib/components/molecular_components/throw_exception/throw_exception_model.dart b/lib/components/molecular_components/throw_exception/throw_exception_model.dart index 69ec5ec4..31b6cee7 100644 --- a/lib/components/molecular_components/throw_exception/throw_exception_model.dart +++ b/lib/components/molecular_components/throw_exception/throw_exception_model.dart @@ -2,12 +2,10 @@ import '/flutter_flow/flutter_flow_util.dart'; import 'throw_exception_widget.dart' show ThrowExceptionWidget; import 'package:flutter/material.dart'; - - class ThrowExceptionModel extends FlutterFlowModel { @override void initState(BuildContext context) {} @override void dispose() {} -} \ No newline at end of file +} diff --git a/lib/components/molecular_components/throw_exception/throw_exception_widget.dart b/lib/components/molecular_components/throw_exception/throw_exception_widget.dart index eab873ea..39cfea2b 100644 --- a/lib/components/molecular_components/throw_exception/throw_exception_widget.dart +++ b/lib/components/molecular_components/throw_exception/throw_exception_widget.dart @@ -14,8 +14,7 @@ export 'throw_exception_model.dart'; // ignore: must_be_immutable class ThrowExceptionWidget extends StatefulWidget { - ThrowExceptionWidget( - {super.key, required this.msg, this.type = EnumThrowException.error}); + ThrowExceptionWidget({super.key, required this.msg, this.type = EnumThrowException.error}); final String? msg; EnumThrowException type; @@ -24,8 +23,7 @@ class ThrowExceptionWidget extends StatefulWidget { State createState() => _ThrowExceptionWidgetState(); } -class _ThrowExceptionWidgetState extends State - with TickerProviderStateMixin { +class _ThrowExceptionWidgetState extends State with TickerProviderStateMixin { late ThrowExceptionModel _model; final animationsMap = {}; @@ -39,6 +37,7 @@ class _ThrowExceptionWidgetState extends State return FlutterFlowTheme.of(context).success; } } + IconData _getIconByType(BuildContext context) { switch (widget.type) { case EnumThrowException.error: @@ -49,26 +48,26 @@ class _ThrowExceptionWidgetState extends State return Icons.check_circle_outline; } } + String _getTitleByType(BuildContext context) { switch (widget.type) { case EnumThrowException.error: - return FFLocalizations.of(context) - .getVariableText(ptText: "Falha :(", enText: "Fail :("); + return FFLocalizations.of(context).getVariableText(ptText: "Falha :(", enText: "Fail :("); case EnumThrowException.warning: - return FFLocalizations.of(context) - .getVariableText(ptText: "Aviso :O", enText: "Warning :O"); + return FFLocalizations.of(context).getVariableText(ptText: "Aviso :O", enText: "Warning :O"); case EnumThrowException.success: - return FFLocalizations.of(context) - .getVariableText(ptText: "Sucesso ;)", enText: "Success ;)"); + return FFLocalizations.of(context).getVariableText(ptText: "Sucesso ;)", enText: "Success ;)"); } } - - @override void setState(VoidCallback callback) { + @override + void setState(VoidCallback callback) { super.setState(callback); _model.onUpdate(); } - @override void initState() { + + @override + void initState() { super.initState(); _model = createModel(context, () => ThrowExceptionModel()); animationsMap.addAll({ @@ -86,7 +85,9 @@ class _ThrowExceptionWidgetState extends State ), }); } - @override void dispose() { + + @override + void dispose() { _model.maybeDispose(); super.dispose(); diff --git a/lib/components/molecular_components/visitor_not_found_component/visitor_not_found_component_model.dart b/lib/components/molecular_components/visitor_not_found_component/visitor_not_found_component_model.dart index 6827c26d..98bb8579 100644 --- a/lib/components/molecular_components/visitor_not_found_component/visitor_not_found_component_model.dart +++ b/lib/components/molecular_components/visitor_not_found_component/visitor_not_found_component_model.dart @@ -1,14 +1,12 @@ import 'package:hub/components/molecular_components/visitor_not_found_component/visitor_not_found_component_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; - import 'package:flutter/material.dart'; -class VisitorNotFoundComponentModel - extends FlutterFlowModel { +class VisitorNotFoundComponentModel extends FlutterFlowModel { @override void initState(BuildContext context) {} @override void dispose() {} -} \ No newline at end of file +} diff --git a/lib/components/molecular_components/visitor_not_found_component/visitor_not_found_component_widget.dart b/lib/components/molecular_components/visitor_not_found_component/visitor_not_found_component_widget.dart index 00261f19..7fdc75c7 100644 --- a/lib/components/molecular_components/visitor_not_found_component/visitor_not_found_component_widget.dart +++ b/lib/components/molecular_components/visitor_not_found_component/visitor_not_found_component_widget.dart @@ -13,12 +13,10 @@ class VisitorNotFoundComponentWidget extends StatefulWidget { final String? doc; @override - State createState() => - _VisitorNotFoundComponentWidgetState(); + State createState() => _VisitorNotFoundComponentWidgetState(); } -class _VisitorNotFoundComponentWidgetState - extends State { +class _VisitorNotFoundComponentWidgetState extends State { late VisitorNotFoundComponentModel _model; @override @@ -61,8 +59,7 @@ class _VisitorNotFoundComponentWidgetState Align( alignment: const AlignmentDirectional(1.0, -1.0), child: Padding( - padding: - const EdgeInsetsDirectional.fromSTEB(0.0, 5.0, 5.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 5.0, 5.0, 0.0), child: FlutterFlowIconButton( borderRadius: 20.0, borderWidth: 1.0, @@ -84,19 +81,16 @@ class _VisitorNotFoundComponentWidgetState size: 72.0, ), Padding( - padding: - const EdgeInsetsDirectional.fromSTEB(5.0, 16.0, 5.0, 10.0), + padding: const EdgeInsetsDirectional.fromSTEB(5.0, 16.0, 5.0, 10.0), child: Text( FFLocalizations.of(context).getText( '1p9mykbj' /* Usuário não encontrado */, ), textAlign: TextAlign.center, style: FlutterFlowTheme.of(context).headlineSmall.override( - fontFamily: - FlutterFlowTheme.of(context).headlineSmallFamily, + fontFamily: FlutterFlowTheme.of(context).headlineSmallFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).headlineSmallFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).headlineSmallFamily), ), ), ), @@ -113,8 +107,7 @@ class _VisitorNotFoundComponentWidgetState fontSize: 14.0, letterSpacing: 0.0, fontStyle: FontStyle.italic, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelSmallFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelSmallFamily), ), ), ), @@ -147,22 +140,18 @@ class _VisitorNotFoundComponentWidgetState ).then((value) => context.pop(value)); // Navigator.pop(context, value) }, - text: FFLocalizations.of(context) - .getVariableText(enText: 'Add', ptText: 'Adicionar'), + text: FFLocalizations.of(context).getVariableText(enText: 'Add', ptText: 'Adicionar'), options: FFButtonOptions( height: 30.0, - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), - iconPadding: const EdgeInsetsDirectional.fromSTEB( - 0.0, 0.0, 0.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), + iconPadding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), color: FlutterFlowTheme.of(context).primary, textStyle: FlutterFlowTheme.of(context).labelSmall.override( - fontFamily: - FlutterFlowTheme.of(context).labelSmallFamily, + fontFamily: FlutterFlowTheme.of(context).labelSmallFamily, color: Colors.white, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelSmallFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelSmallFamily), ), elevation: 3.0, borderSide: const BorderSide( diff --git a/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_model.dart b/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_model.dart index 3ff8aba1..11d6aab5 100644 --- a/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_model.dart +++ b/lib/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_model.dart @@ -1,14 +1,12 @@ import 'package:hub/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; - import 'package:flutter/material.dart'; -class BottomArrowLinkedLocalsComponentModel - extends FlutterFlowModel { +class BottomArrowLinkedLocalsComponentModel extends FlutterFlowModel { @override void initState(BuildContext context) {} @override void dispose() {} -} \ No newline at end of file +} 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 0f242373..8712ddd3 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 @@ -3,9 +3,10 @@ import 'package:hub/components/organism_components/bottom_arrow_linked_locals_co import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/log_util.dart'; -import 'package:hub/shared/utils/storage_util.dart'; import '../../../shared/services/authentication/authentication_service.dart'; import '/backend/api_requests/api_calls.dart'; @@ -15,12 +16,10 @@ class BottomArrowLinkedLocalsComponentWidget extends StatefulWidget { const BottomArrowLinkedLocalsComponentWidget({super.key}); @override - State createState() => - _BottomArrowLinkedLocalsComponentWidgetState(); + State createState() => _BottomArrowLinkedLocalsComponentWidgetState(); } -class _BottomArrowLinkedLocalsComponentWidgetState - extends State { +class _BottomArrowLinkedLocalsComponentWidgetState extends State { late BottomArrowLinkedLocalsComponentModel _model; bool _loading = false; @@ -29,17 +28,21 @@ class _BottomArrowLinkedLocalsComponentWidgetState late Future _localsFuture; List _localsWrap = []; - @override void setState(VoidCallback callback) { + @override + void setState(VoidCallback callback) { super.setState(callback); _model.onUpdate(); } - @override void initState() { + + @override + void initState() { super.initState(); - _model = - createModel(context, () => BottomArrowLinkedLocalsComponentModel()); + _model = createModel(context, () => BottomArrowLinkedLocalsComponentModel()); _localsFuture = _fetchLocals(); } - @override void dispose() { + + @override + void dispose() { _model.maybeDispose(); super.dispose(); @@ -49,8 +52,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - FFLocalizations.of(context).getVariableText( - ptText: "Não há mais dados.", enText: "No more data."), + FFLocalizations.of(context).getVariableText(ptText: "Não há mais dados.", enText: "No more data."), ), duration: const Duration(seconds: 3), backgroundColor: FlutterFlowTheme.of(context).primary, @@ -64,7 +66,6 @@ class _BottomArrowLinkedLocalsComponentWidgetState var response = await PhpGroup.getLocalsCall.call(); final bool isError = response.jsonBody['error']; - if (isError) { final String errorMsg = response.jsonBody['error_msg']; _handleError(context, errorMsg); @@ -73,7 +74,6 @@ class _BottomArrowLinkedLocalsComponentWidgetState final List locals = response.jsonBody['locais'] ?? []; - final bool isEmpty = locals.isEmpty; final bool isUnique = locals.length == 1; final bool isActive = locals[0]['CLU_STATUS'] == 'A'; @@ -82,9 +82,6 @@ class _BottomArrowLinkedLocalsComponentWidgetState final bool isEnabled = isUnique && isActive; final bool isDisabled = isUnique && isBlocked; - - - if (!isEmpty) { setState(() { _localsWrap.addAll(locals); @@ -98,9 +95,11 @@ class _BottomArrowLinkedLocalsComponentWidgetState } if (isEnabled) { final local = locals[0]; - StorageUtil().cliName = local['CLI_NOME']; - StorageUtil().cliUUID = local['CLI_ID']; - StorageUtil().ownerUUID = local['CLU_OWNER_ID']; + + await StorageHelper().set(SQLiteStorageKey.clientName.value, local['CLI_NOME'], Storage.SQLiteStorage); + await StorageHelper().set(SQLiteStorageKey.clientUUID.value, local['CLI_ID'], Storage.SQLiteStorage); + await StorageHelper() + .set(SQLiteStorageKey.ownerUUID.value, local['CLU_OWNER_ID'], Storage.SQLiteStorage); context.pop(); return response; @@ -127,29 +126,26 @@ class _BottomArrowLinkedLocalsComponentWidgetState static void _handleError(BuildContext context, String errorMsg) { AuthenticationService.signOut(context); DialogUtil.error(context, errorMsg); - LogUtil.requestAPIFailed('getLocals.php', '{devUUID: ${StorageUtil().devUUID}, cliUUID: ${StorageUtil().userUUID}}', 'Get Locals', errorMsg, StackTrace.current); } Future _fetchResponseLink(String status, String cliID) async { try { - StorageUtil().cliUUID = cliID; + await StorageHelper().set(SQLiteStorageKey.clientUUID.value, cliID, Storage.SQLiteStorage); var response = await PhpGroup.resopndeVinculo.call(tarefa: status); if (response.jsonBody['error'] == false) { return { 'error': false, - 'error_msg': FFLocalizations.of(context).getVariableText( - ptText: "Vínculo Ativado com Sucesso", - enText: "Link Activated Successfully") + 'error_msg': FFLocalizations.of(context) + .getVariableText(ptText: "Vínculo Ativado com Sucesso", enText: "Link Activated Successfully") }; } else { - StorageUtil().cliUUID = ''; + await StorageHelper().set(SQLiteStorageKey.clientUUID.value, '', Storage.SQLiteStorage); return response.jsonBody; } } catch (e, s) { DialogUtil.errorDefault(context); - LogUtil.requestAPIFailed( - 'responderVinculo.php', '', 'Responder Vínculo', e, s); + LogUtil.requestAPIFailed('responderVinculo.php', '', 'Responder Vínculo', e, s); return { 'error': true, 'error_msg': FFLocalizations.of(context).getVariableText( @@ -174,17 +170,14 @@ class _BottomArrowLinkedLocalsComponentWidgetState Map _statusHashMap(dynamic local) { return Map.from({ if (local['CLU_STATUS'] == 'A') - FFLocalizations.of(context).getVariableText( - ptText: 'Ativo', - enText: 'Active'): FlutterFlowTheme.of(context).success + FFLocalizations.of(context).getVariableText(ptText: 'Ativo', enText: 'Active'): + FlutterFlowTheme.of(context).success else if (local['CLU_STATUS'] == 'B') - FFLocalizations.of(context).getVariableText( - ptText: 'Bloqueado', - enText: 'Blocked'): FlutterFlowTheme.of(context).error + FFLocalizations.of(context).getVariableText(ptText: 'Bloqueado', enText: 'Blocked'): + FlutterFlowTheme.of(context).error else - FFLocalizations.of(context).getVariableText( - ptText: 'Pendente', - enText: 'Pending'): FlutterFlowTheme.of(context).warning + FFLocalizations.of(context).getVariableText(ptText: 'Pendente', enText: 'Pending'): + FlutterFlowTheme.of(context).warning }); } @@ -195,15 +188,15 @@ class _BottomArrowLinkedLocalsComponentWidgetState statusHashMap: [_statusHashMap(local)], onTapCardItemAction: () async { if (local['CLU_STATUS'] == 'A') { - StorageUtil().cliUUID = local['CLI_ID']; - StorageUtil().cliName = local['CLI_NOME']; - StorageUtil().ownerUUID = local['CLU_OWNER_ID']; + await StorageHelper().set(SQLiteStorageKey.clientUUID.value, local['CLI_ID'], Storage.SQLiteStorage); + await StorageHelper().set(SQLiteStorageKey.clientName.value, local['CLI_NOME'], Storage.SQLiteStorage); + await StorageHelper() + .set(SQLiteStorageKey.ownerUUID.value, local['CLU_OWNER_ID'], Storage.SQLiteStorage); context.pop(); } else if (local['CLU_STATUS'] == 'B') { String message = FFLocalizations.of(context).getVariableText( - ptText: - 'Local Bloqueado para Acesso, Entre em Contato com Administração', + ptText: 'Local Bloqueado para Acesso, Entre em Contato com Administração', enText: 'Location Blocked for Access, Contact Administration', ); @@ -219,12 +212,10 @@ class _BottomArrowLinkedLocalsComponentWidgetState String localName = local['CLI_NOME']; showAlertDialog( context, - FFLocalizations.of(context).getVariableText( - ptText: 'Ativar Vínculo', enText: 'Activate Link'), + FFLocalizations.of(context).getVariableText(ptText: 'Ativar Vínculo', enText: 'Activate Link'), FFLocalizations.of(context).getVariableText( ptText: 'Deseja aceitar o vínculo a $localName?', - enText: 'Do you wish to accept the link to $localName?'), - () async { + enText: 'Do you wish to accept the link to $localName?'), () async { var response = await _fetchResponseLink('A', local['CLI_ID']); context.pop(); @@ -276,8 +267,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState height: height - (height * 0.5), decoration: BoxDecoration( color: FlutterFlowTheme.of(context).primaryBackground, - borderRadius: const BorderRadius.only( - topLeft: Radius.circular(25), topRight: Radius.circular(25))), + borderRadius: const BorderRadius.only(topLeft: Radius.circular(25), topRight: Radius.circular(25))), child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.start, @@ -289,16 +279,13 @@ class _BottomArrowLinkedLocalsComponentWidgetState mainAxisSize: MainAxisSize.max, children: [ Center( - child: Text(FFLocalizations.of(context).getVariableText( - ptText: "Nenhum Local Encontrado.", - enText: "No local found")), + child: Text(FFLocalizations.of(context) + .getVariableText(ptText: "Nenhum Local Encontrado.", enText: "No local found")), ) ], ), ) - else if (_hasData == true && - _loading == false && - _localsWrap.isNotEmpty) + else if (_hasData == true && _loading == false && _localsWrap.isNotEmpty) Expanded(child: _listItems(context)), if (_loading == true) Container( @@ -315,8 +302,7 @@ class _BottomArrowLinkedLocalsComponentWidgetState padding: const EdgeInsets.only(top: 10), child: Center( child: Text( - FFLocalizations.of(context).getVariableText( - ptText: 'Escolha um local', enText: 'Choose a location'), + FFLocalizations.of(context).getVariableText(ptText: 'Escolha um local', enText: 'Choose a location'), overflow: TextOverflow.ellipsis, style: const TextStyle(fontWeight: FontWeight.bold), )))), diff --git a/lib/components/organism_components/local_profile_component/local_profile_component_model.dart b/lib/components/organism_components/local_profile_component/local_profile_component_model.dart index a8b72c84..bf90645a 100644 --- a/lib/components/organism_components/local_profile_component/local_profile_component_model.dart +++ b/lib/components/organism_components/local_profile_component/local_profile_component_model.dart @@ -1,4 +1,5 @@ -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import '/flutter_flow/flutter_flow_util.dart'; import 'local_profile_component_widget.dart' show LocalProfileComponentWidget; @@ -6,8 +7,7 @@ import 'package:flutter/material.dart'; /// -class LocalProfileComponentModel - extends FlutterFlowModel { +class LocalProfileComponentModel extends FlutterFlowModel { String cliName = ''; String cliUUID = ''; VoidCallback? setStateCallback; @@ -18,8 +18,9 @@ class LocalProfileComponentModel } Future getData() async { - cliName = StorageUtil().cliName; - cliUUID = StorageUtil().cliUUID; + cliName = (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? ''; + cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + ; setStateCallback?.call(); } diff --git a/lib/components/organism_components/local_profile_component/local_profile_component_widget.dart b/lib/components/organism_components/local_profile_component/local_profile_component_widget.dart index f11ca000..2525ec30 100644 --- a/lib/components/organism_components/local_profile_component/local_profile_component_widget.dart +++ b/lib/components/organism_components/local_profile_component/local_profile_component_widget.dart @@ -16,12 +16,10 @@ class LocalProfileComponentWidget extends StatefulWidget { const LocalProfileComponentWidget({super.key}); @override - State createState() => - _LocalProfileComponentWidgetState(); + State createState() => _LocalProfileComponentWidgetState(); } -class _LocalProfileComponentWidgetState - extends State { +class _LocalProfileComponentWidgetState extends State { late LocalProfileComponentModel _model; @override @@ -114,12 +112,9 @@ class _LocalProfileComponentWidgetState height: 80.0, fit: BoxFit.cover, alignment: const Alignment(0.0, 0.0), - placeholder: (context, url) => - Image.asset('assets/images/home.png'), - errorListener: (_) => - Image.asset('assets/images/home.png'), - errorWidget: (_, __, ___) => - Image.asset('assets/images/home.png'), + placeholder: (context, url) => Image.asset('assets/images/home.png'), + errorListener: (_) => Image.asset('assets/images/home.png'), + errorWidget: (_, __, ___) => Image.asset('assets/images/home.png'), ), )), ), 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 7b4934f1..106dbf6c 100644 --- a/lib/components/organism_components/menu_component/menu_component_model.dart +++ b/lib/components/organism_components/menu_component/menu_component_model.dart @@ -2,29 +2,29 @@ import 'package:flutter/material.dart'; import 'package:hub/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_model.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/shared/extensions/dialog_extensions.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/services/authentication/authentication_service.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/organism_components/menu_list_view_component/menu_list_view_component_widget.dart'; import '/flutter_flow/flutter_flow_util.dart'; import 'menu_component_widget.dart' show MenuComponentWidget; class MenuComponentModel extends FlutterFlowModel { - bool isGrid = false; late MenuListViewComponentModel menuListViewComponentModel; late MenuStaggeredViewComponentModel menuStaggeredViewComponentModel; - @override void initState(BuildContext context) { - menuListViewComponentModel = - createModel(context, () => MenuListViewComponentModel()); - menuStaggeredViewComponentModel = - createModel(context, () => MenuStaggeredViewComponentModel()); + @override + void initState(BuildContext context) { + menuListViewComponentModel = createModel(context, () => MenuListViewComponentModel()); + menuStaggeredViewComponentModel = createModel(context, () => MenuStaggeredViewComponentModel()); } - @override void dispose() { + + @override + void dispose() { menuListViewComponentModel.dispose(); menuStaggeredViewComponentModel.dispose(); } @@ -32,81 +32,89 @@ class MenuComponentModel extends FlutterFlowModel { Future changeMenuStyle(BuildContext context) async { isGrid = !isGrid; } + Future openQRCodeScanner(BuildContext context) async { - context.push( - '/qrCodePage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } - Future openCompleteSchedule(BuildContext context) async { context.push( - '/scheduleCompleteVisitPage', + '/qrCodePage', extra: { kTransitionInfoKey: const TransitionInfo( - hasTransition: true, + hasTransition: false, transitionType: PageTransitionType.scale, alignment: Alignment.bottomCenter, ), }, ); } - Future openDeliverySchedule(BuildContext context) async { - final bool isProvisional = StorageUtil().provisional; - if (isProvisional == true) { - context.push( - '/deliverySchedule', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } else { - DialogUnavailable.unavailableFeature(context); - } - } - Future openProvisionalSchedule(BuildContext context) async { - final isProvisional = StorageUtil().provisional; - if (isProvisional == true) { - context.push( - '/provisionalSchedule', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } else { - DialogUnavailable.unavailableFeature(context); - } + + Future openCompleteSchedule(BuildContext context) async { + context.push( + '/scheduleCompleteVisitPage', + extra: { + kTransitionInfoKey: const TransitionInfo( + hasTransition: false, + transitionType: PageTransitionType.scale, + alignment: Alignment.bottomCenter, + ), + }, + ); } + + Future openDeliverySchedule(BuildContext context) async { + final bool isProvisional = + await StorageHelper().get(SQLiteStorageKey.provisional.value, Storage.SQLiteStorage) == '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().get(SQLiteStorageKey.provisional.value, Storage.SQLiteStorage) == '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 = StorageUtil().whatsapp; - if (isWpp) { - context.push( - '/fastPassPage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } else { - DialogUnavailable.unavailableFeature(context); - } - } + final isWpp = await StorageHelper().get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == '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', @@ -146,30 +154,33 @@ class MenuComponentModel extends FlutterFlowModel { }, ); } + Future openVisitorsRegister(BuildContext context) async { - context.push( - '/registerVisitorPage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } + 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: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } + 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', @@ -179,58 +190,60 @@ class MenuComponentModel extends FlutterFlowModel { ptText: 'Tem certeza que deseja sair?', enText: 'Are you sure you want to logout?', ); - showAlertDialog( - context, - title, - content, - () async => await AuthenticationService.signOut(context)); + showAlertDialog(context, title, content, () async => await AuthenticationService.signOut(context)); } + Future openPreferencesSettings(BuildContext context) async { - context.push( - '/preferencesSettings', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } + context.push( + '/preferencesSettings', + extra: { + kTransitionInfoKey: const TransitionInfo( + hasTransition: false, + transitionType: PageTransitionType.scale, + alignment: Alignment.bottomCenter, + ), + }, + ); + } + Future openMyOrders(BuildContext context) async { - final isWpp = StorageUtil().whatsapp; - if (isWpp) { - context.push( - '/packageOrder', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } else { - DialogUnavailable.unavailableFeature(context); - } - } + final isWpp = await StorageHelper().get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == '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 = StorageUtil().whatsapp; - if (isWpp) { - context.push( - '/reservation', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } else { - DialogUnavailable.unavailableFeature(context); - } - } + final isWpp = await StorageHelper().get(SQLiteStorageKey.whatsapp.value, Storage.SQLiteStorage) == '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, @@ -276,72 +289,75 @@ class MenuComponentModel extends FlutterFlowModel { }, ); } + Future openLiberationsHistory(BuildContext context) async { - context.push( - '/liberationHistory', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } + context.push( + '/liberationHistory', + extra: { + kTransitionInfoKey: const TransitionInfo( + hasTransition: false, + transitionType: PageTransitionType.scale, + alignment: Alignment.bottomCenter, + ), + }, + ); + } + Future openAccessHistory(BuildContext context) async { - context.push( - '/acessHistoryPage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } + 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: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } + 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: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } + context.push( + '/messageHistoryPage', + extra: { + kTransitionInfoKey: const TransitionInfo( + hasTransition: false, + transitionType: PageTransitionType.scale, + alignment: Alignment.bottomCenter, + ), + }, + ); + } + Future openPetsRegister(BuildContext context) async { - bool isPet = StorageUtil().pets; - if (isPet) { - context.push( - '/petsPage', - extra: { - kTransitionInfoKey: const TransitionInfo( - hasTransition: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }, - ); - } else { - DialogUnavailable.unavailableFeature(context); - } - } - - + bool isPet = await StorageHelper().get(SQLiteStorageKey.pets.value, Storage.SQLiteStorage) == '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 cd940d59..f9b12e64 100644 --- a/lib/components/organism_components/menu_component/menu_component_widget.dart +++ b/lib/components/organism_components/menu_component/menu_component_widget.dart @@ -562,15 +562,12 @@ class _MenuComponentWidgetState extends State { ptText: 'Sair da Conta', ), ), - MenuCardItem(icon: null, action: () {}, title: ''), ]; }(); return Builder( builder: (context) { - if (widget.style == MenuView.list_grid && - widget.expandable == true && - widget.item == MenuItem.button) { + if (widget.style == MenuView.list_grid && widget.expandable == true && widget.item == MenuItem.button) { if (_model.isGrid == true) { return wrapWithModel( model: _model.menuStaggeredViewComponentModel, @@ -605,9 +602,7 @@ class _MenuComponentWidgetState extends State { ); } } - if (widget.style == MenuView.list && - widget.expandable == false && - widget.item == MenuItem.tile) { + if (widget.style == MenuView.list && widget.expandable == false && widget.item == MenuItem.tile) { return wrapWithModel( model: _model.menuListViewComponentModel, updateCallback: () => setState(() {}), diff --git a/lib/components/organism_components/menu_list_view_component/menu_list_view_component_model.dart b/lib/components/organism_components/menu_list_view_component/menu_list_view_component_model.dart index 027278ab..d15273ee 100644 --- a/lib/components/organism_components/menu_list_view_component/menu_list_view_component_model.dart +++ b/lib/components/organism_components/menu_list_view_component/menu_list_view_component_model.dart @@ -2,13 +2,10 @@ import '/flutter_flow/flutter_flow_util.dart'; import 'menu_list_view_component_widget.dart' show MenuListViewComponentWidget; import 'package:flutter/material.dart'; - - -class MenuListViewComponentModel - extends FlutterFlowModel { +class MenuListViewComponentModel extends FlutterFlowModel { @override void initState(BuildContext context) {} @override void dispose() {} -} \ No newline at end of file +} diff --git a/lib/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart b/lib/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart index c16e3669..5a3b74df 100644 --- a/lib/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart +++ b/lib/components/organism_components/menu_list_view_component/menu_list_view_component_widget.dart @@ -27,12 +27,10 @@ class MenuListViewComponentWidget extends StatefulWidget { final Future Function()? changeMenuStyle; @override - State createState() => - _MenuListViewComponentWidgetState(); + State createState() => _MenuListViewComponentWidgetState(); } -class _MenuListViewComponentWidgetState - extends State { +class _MenuListViewComponentWidgetState extends State { late MenuListViewComponentModel _model; @override @@ -75,8 +73,7 @@ class _MenuListViewComponentWidgetState itemBuilder: (context, index) { return Padding( padding: const EdgeInsets.all(8.0), - child: SizedBox( - height: 115, width: 115, child: widget.options[index]), + child: SizedBox(height: 115, width: 115, child: widget.options[index]), ); }, ), @@ -95,8 +92,7 @@ class _MenuListViewComponentWidgetState itemBuilder: (context, index) { return Padding( padding: const EdgeInsets.all(8.0), - child: SizedBox( - height: 115, width: 115, child: widget.options[index]), + child: SizedBox(height: 115, width: 115, child: widget.options[index]), ); }, ), diff --git a/lib/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_model.dart b/lib/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_model.dart index 4ee29584..cb0efe51 100644 --- a/lib/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_model.dart +++ b/lib/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_model.dart @@ -4,12 +4,10 @@ import '/flutter_flow/flutter_flow_util.dart'; import 'package:flutter/material.dart'; - -class MenuStaggeredViewComponentModel - extends FlutterFlowModel { +class MenuStaggeredViewComponentModel extends FlutterFlowModel { @override void initState(BuildContext context) {} @override void dispose() {} -} \ No newline at end of file +} diff --git a/lib/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_widget.dart b/lib/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_widget.dart index bc872bab..1a0d6123 100644 --- a/lib/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_widget.dart +++ b/lib/components/organism_components/menu_staggered_view_component/menu_staggered_view_component_widget.dart @@ -23,12 +23,10 @@ class MenuStaggeredViewComponentWidget extends StatefulWidget { final Future Function()? changeMenuStyle; @override - State createState() => - _MenuStaggeredViewComponentWidgetState(); + State createState() => _MenuStaggeredViewComponentWidgetState(); } -class _MenuStaggeredViewComponentWidgetState - extends State { +class _MenuStaggeredViewComponentWidgetState extends State { late MenuStaggeredViewComponentModel _model; @override @@ -91,9 +89,7 @@ class _MenuStaggeredViewComponentWidgetState ); }, ), - ] - .addToStart(const SizedBox(height: 30)) - .addToEnd(const SizedBox(height: 30)), + ].addToStart(const SizedBox(height: 30)).addToEnd(const SizedBox(height: 30)), ); } diff --git a/lib/components/organism_components/message_well_component/message_well_component_model.dart b/lib/components/organism_components/message_well_component/message_well_component_model.dart index d3aad87c..d18746ee 100644 --- a/lib/components/organism_components/message_well_component/message_well_component_model.dart +++ b/lib/components/organism_components/message_well_component/message_well_component_model.dart @@ -1,4 +1,3 @@ - import 'package:hub/backend/api_requests/api_manager.dart'; import 'package:hub/flutter_flow/request_manager.dart'; @@ -6,10 +5,7 @@ import '/flutter_flow/flutter_flow_util.dart'; import 'message_well_component_widget.dart' show MessageWellComponentWidget; import 'package:flutter/material.dart'; - - -class MessageWellComponentModel - extends FlutterFlowModel { +class MessageWellComponentModel extends FlutterFlowModel { final unfocusNode = FocusNode(); // State field(s) for TextField widget. FocusNode? textFieldFocusNode; @@ -30,8 +26,7 @@ class MessageWellComponentModel requestFn: requestFn, ); void clearGetLiberationsCache() => _getLiberationsManager.clear(); - void clearGetLiberationsCacheKey(String? uniqueKey) => - _getLiberationsManager.clearRequest(uniqueKey); + void clearGetLiberationsCacheKey(String? uniqueKey) => _getLiberationsManager.clearRequest(uniqueKey); @override void initState(BuildContext context) {} @@ -46,4 +41,4 @@ class MessageWellComponentModel clearGetLiberationsCache(); } -} \ No newline at end of file +} diff --git a/lib/components/organism_components/message_well_component/message_well_component_widget.dart b/lib/components/organism_components/message_well_component/message_well_component_widget.dart index ad05326e..97b52e31 100644 --- a/lib/components/organism_components/message_well_component/message_well_component_widget.dart +++ b/lib/components/organism_components/message_well_component/message_well_component_widget.dart @@ -21,12 +21,10 @@ class MessageWellComponentWidget extends StatefulWidget { const MessageWellComponentWidget({super.key}); @override - State createState() => - _MessageWellComponentWidgetState(); + State createState() => _MessageWellComponentWidgetState(); } -class _MessageWellComponentWidgetState - extends State { +class _MessageWellComponentWidgetState extends State { StreamSubscription? _dropdownSubscription; @override @@ -143,8 +141,7 @@ class _MessageWellComponentWidgetState fillColor: theme.primary, ), onChanged: (String? newValue) { - safeSetState(() => dropdown.value = LinkedHashMap.from( - {newValue!: dropdownItems[newValue].toString()})); + safeSetState(() => dropdown.value = LinkedHashMap.from({newValue!: dropdownItems[newValue].toString()})); }, items: dropdownItems.entries .map((entry) => DropdownMenuItem( @@ -181,8 +178,7 @@ class _MessageWellComponentWidgetState final formattedWords = words.map((word) { if (word.isEmpty) return word; // Handle empty words final firstLetter = word.substring(0, 1).toUpperCase(); - final remainingLetters = - word.length > 1 ? word.substring(1).toLowerCase() : ''; + final remainingLetters = word.length > 1 ? word.substring(1).toLowerCase() : ''; return '$firstLetter$remainingLetters'; }); return formattedWords.join(' '); @@ -238,8 +234,7 @@ class _MessageWellComponentWidgetState padding: const EdgeInsets.only(left: 5), child: Icon( Icons.history, - color: - FlutterFlowTheme.of(context).customColor6, + color: FlutterFlowTheme.of(context).customColor6, size: 15, ), ), @@ -249,8 +244,7 @@ class _MessageWellComponentWidgetState style: TextStyle( fontWeight: FontWeight.bold, fontSize: 10, - color: - FlutterFlowTheme.of(context).customColor6, + color: FlutterFlowTheme.of(context).customColor6, ), overflow: TextOverflow.ellipsis, ), @@ -265,8 +259,7 @@ class _MessageWellComponentWidgetState padding: const EdgeInsets.only(left: 5), child: Icon( Icons.message, - color: - FlutterFlowTheme.of(context).customColor6, + color: FlutterFlowTheme.of(context).customColor6, size: 15, ), ), @@ -327,8 +320,7 @@ class MessageWellState { return MessageWellState( messages: messages ?? this.messages, pageNumber: pageNumber ?? this.pageNumber, - allowScrollInSingleChildScrollView: allowScrollInSingleChildScrollView ?? - this.allowScrollInSingleChildScrollView, + allowScrollInSingleChildScrollView: allowScrollInSingleChildScrollView ?? this.allowScrollInSingleChildScrollView, ); } } @@ -382,7 +374,6 @@ class MessageWellNotifier extends StateNotifier { } } -final messageWellProvider = - StateNotifierProvider((ref) { +final messageWellProvider = StateNotifierProvider((ref) { return MessageWellNotifier(); }); diff --git a/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_model.dart b/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_model.dart index 672f7c4d..f65158fa 100644 --- a/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_model.dart +++ b/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_model.dart @@ -1,15 +1,13 @@ - import 'package:flutter/material.dart'; import 'package:hub/backend/api_requests/api_manager.dart'; import 'package:hub/components/organism_components/schedule_visit_detail/schedule_visit_detail_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; // ignore: unused_import -import 'package:hub/shared/helpers/sqlite_storage_helper.dart'; -import 'package:hub/shared/utils/storage_util.dart'; import 'package:intl/intl.dart'; -class ScheduleVisitDetailModel - extends FlutterFlowModel { +class ScheduleVisitDetailModel extends FlutterFlowModel { late final String devUUID; late final String userUUID; late final String cliUUID; @@ -39,8 +37,7 @@ class ScheduleVisitDetailModel DateFormat originalFormat = DateFormat('d/M/y H:mm:ss'); DateFormat newFormat = DateFormat('y-M-d H:mm:ss'); - if (!RegExp(r'^\d{1,2}/\d{1,2}/\d{4} \d{1,2}:\d{2}:\d{2}$') - .hasMatch(dateStr)) { + if (!RegExp(r'^\d{1,2}/\d{1,2}/\d{4} \d{1,2}:\d{2}:\d{2}$').hasMatch(dateStr)) { return 'Invalid date format'; } @@ -59,9 +56,9 @@ class ScheduleVisitDetailModel } Future initDB() async { - devUUID = StorageUtil().devUUID; - userUUID = StorageUtil().userUUID; - cliUUID = StorageUtil().cliUUID; + devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; } @override diff --git a/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_widget.dart b/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_widget.dart index f64303fb..29f8f48d 100644 --- a/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_widget.dart +++ b/lib/components/organism_components/schedule_visit_detail/schedule_visit_detail_widget.dart @@ -35,8 +35,7 @@ class ScheduleVisitDetailWidget extends StatefulWidget { final String? visitObsStr; @override - State createState() => - _ScheduleVisitDetailWidgetState(); + State createState() => _ScheduleVisitDetailWidgetState(); } class _ScheduleVisitDetailWidgetState extends State { @@ -58,19 +57,16 @@ class _ScheduleVisitDetailWidgetState extends State { _model.textController1 ??= TextEditingController(text: widget.visitTempStr); _model.textFieldFocusNode1 ??= FocusNode(); - _model.textController2 ??= - TextEditingController(text: widget.visitStartDate); + _model.textController2 ??= TextEditingController(text: widget.visitStartDate); _model.textFieldFocusNode2 ??= FocusNode(); _model.textController3 ??= TextEditingController(text: widget.visitEndDate); _model.textFieldFocusNode3 ??= FocusNode(); - _model.textController4 ??= - TextEditingController(text: extractDescToStr(widget.visitResonStr!)); + _model.textController4 ??= TextEditingController(text: extractDescToStr(widget.visitResonStr!)); _model.textFieldFocusNode4 ??= FocusNode(); - _model.textController5 ??= - TextEditingController(text: extractDescToStr(widget.visitLevelStr!)); + _model.textController5 ??= TextEditingController(text: extractDescToStr(widget.visitLevelStr!)); _model.textFieldFocusNode5 ??= FocusNode(); _model.textController6 ??= TextEditingController(text: widget.visitObsStr); @@ -132,13 +128,11 @@ class _ScheduleVisitDetailWidgetState extends State { ), ), child: Visibility( - visible: widget.visitorStrList != null && - widget.visitorStrList != '', + visible: widget.visitorStrList != null && widget.visitorStrList != '', child: Align( alignment: const AlignmentDirectional(-1.0, 0.0), child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 15.0, 0.0, 0.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(15.0, 0.0, 0.0, 0.0), child: FlutterFlowIconButton( borderRadius: 20.0, borderWidth: 1.0, @@ -161,8 +155,7 @@ class _ScheduleVisitDetailWidgetState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 5.0, 0.0, 5.0, 20.0), + padding: const EdgeInsetsDirectional.fromSTEB(5.0, 0.0, 5.0, 20.0), child: SizedBox( width: 100.0, child: ClipRRect( @@ -190,8 +183,7 @@ class _ScheduleVisitDetailWidgetState extends State { Container( decoration: const BoxDecoration(), child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 8.0, 0.0, 8.0, 10.0), + padding: const EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 10.0), child: TextFormField( controller: _model.textController1, focusNode: _model.textFieldFocusNode1, @@ -203,31 +195,19 @@ class _ScheduleVisitDetailWidgetState extends State { labelText: FFLocalizations.of(context).getText( '7w4fohoa' /* Encerramento da Visita */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( @@ -258,32 +238,25 @@ class _ScheduleVisitDetailWidgetState extends State { borderRadius: BorderRadius.circular(8.0), ), ), - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodyMediumFamily, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey(FlutterFlowTheme.of(context) - .bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), - validator: _model.textController1Validator - .asValidator(context), + validator: _model.textController1Validator.asValidator(context), ), ), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 0.0, 0.0, 0.0, 10.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 10.0), child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded( child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 8.0, 0.0, 8.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0), child: TextFormField( controller: _model.textController2, focusNode: _model.textFieldFocusNode2, @@ -292,98 +265,71 @@ class _ScheduleVisitDetailWidgetState extends State { readOnly: true, decoration: InputDecoration( isDense: true, - labelText: FFLocalizations.of(context) - .getVariableText( + labelText: FFLocalizations.of(context).getVariableText( enText: 'Start', ptText: 'Início', ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), - hintText: - FFLocalizations.of(context).getText( + hintText: FFLocalizations.of(context).getText( '0cp1e31d' /* dd/mm/yyyy */, ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .accent1, + color: FlutterFlowTheme.of(context).accent1, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primary, + color: FlutterFlowTheme.of(context).primary, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), errorBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of(context).error, + color: FlutterFlowTheme.of(context).error, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), focusedErrorBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of(context).error, + color: FlutterFlowTheme.of(context).error, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), ), - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodyMediumFamily, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, fontSize: 12, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + .containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), textAlign: TextAlign.center, - validator: _model.textController2Validator - .asValidator(context), + validator: _model.textController2Validator.asValidator(context), ), ), ), Expanded( child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 8.0, 0.0, 8.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0), child: TextFormField( controller: _model.textController3, focusNode: _model.textFieldFocusNode3, @@ -392,90 +338,64 @@ class _ScheduleVisitDetailWidgetState extends State { readOnly: true, decoration: InputDecoration( isDense: true, - labelText: - FFLocalizations.of(context).getText( + labelText: FFLocalizations.of(context).getText( 'abppdgz3' /* Término */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), - hintText: - FFLocalizations.of(context).getText( + hintText: FFLocalizations.of(context).getText( 'kqralft4' /* dd/mm/yyyy */, ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .accent1, + color: FlutterFlowTheme.of(context).accent1, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primary, + color: FlutterFlowTheme.of(context).primary, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), errorBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of(context).error, + color: FlutterFlowTheme.of(context).error, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), focusedErrorBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of(context).error, + color: FlutterFlowTheme.of(context).error, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), ), - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodyMediumFamily, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, fontSize: 12, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + .containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), textAlign: TextAlign.center, - validator: _model.textController3Validator - .asValidator(context), + validator: _model.textController3Validator.asValidator(context), ), ), ), @@ -483,16 +403,14 @@ class _ScheduleVisitDetailWidgetState extends State { ), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 0.0, 0.0, 0.0, 10.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 10.0), child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded( child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 8.0, 0.0, 8.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0), child: TextFormField( controller: _model.textController4, focusNode: _model.textFieldFocusNode4, @@ -501,96 +419,69 @@ class _ScheduleVisitDetailWidgetState extends State { readOnly: true, decoration: InputDecoration( isDense: true, - labelText: - FFLocalizations.of(context).getText( + labelText: FFLocalizations.of(context).getText( 'xjxhzqqm' /* Motivo da Visita */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), - hintText: - FFLocalizations.of(context).getText( + hintText: FFLocalizations.of(context).getText( '47oezdm6' /* Motivo */, ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .accent1, + color: FlutterFlowTheme.of(context).accent1, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primary, + color: FlutterFlowTheme.of(context).primary, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), errorBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of(context).error, + color: FlutterFlowTheme.of(context).error, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), focusedErrorBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of(context).error, + color: FlutterFlowTheme.of(context).error, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), ), - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodyMediumFamily, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + .containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), textAlign: TextAlign.center, - validator: _model.textController4Validator - .asValidator(context), + validator: _model.textController4Validator.asValidator(context), ), ), ), Expanded( child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 8.0, 0.0, 8.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0), child: TextFormField( controller: _model.textController5, focusNode: _model.textFieldFocusNode5, @@ -599,89 +490,63 @@ class _ScheduleVisitDetailWidgetState extends State { readOnly: true, decoration: InputDecoration( isDense: true, - labelText: - FFLocalizations.of(context).getText( + labelText: FFLocalizations.of(context).getText( '2ujg7u18' /* Nível de Acesso */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), - hintText: - FFLocalizations.of(context).getText( + hintText: FFLocalizations.of(context).getText( '3emmbbfv' /* Nível de Acesso */, ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .accent1, + color: FlutterFlowTheme.of(context).accent1, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primary, + color: FlutterFlowTheme.of(context).primary, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), errorBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of(context).error, + color: FlutterFlowTheme.of(context).error, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), focusedErrorBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of(context).error, + color: FlutterFlowTheme.of(context).error, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), ), - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodyMediumFamily, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + .containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), textAlign: TextAlign.center, - validator: _model.textController5Validator - .asValidator(context), + validator: _model.textController5Validator.asValidator(context), ), ), ), @@ -691,8 +556,7 @@ class _ScheduleVisitDetailWidgetState extends State { Container( decoration: const BoxDecoration(), child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 8.0, 0.0, 8.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0), child: TextFormField( controller: _model.textController6, focusNode: _model.textFieldFocusNode6, @@ -704,31 +568,19 @@ class _ScheduleVisitDetailWidgetState extends State { labelText: FFLocalizations.of(context).getText( 'ritce5uw' /* Observações da Visita */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( @@ -759,18 +611,13 @@ class _ScheduleVisitDetailWidgetState extends State { borderRadius: BorderRadius.circular(8.0), ), ), - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodyMediumFamily, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey(FlutterFlowTheme.of(context) - .bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), - validator: _model.textController6Validator - .asValidator(context), + validator: _model.textController6Validator.asValidator(context), ), ), ), @@ -780,12 +627,10 @@ class _ScheduleVisitDetailWidgetState extends State { ), IconButton( onPressed: () async { - _model.postScheduleVisit = - await PhpGroup.postScheduleVisitCall.call( + _model.postScheduleVisit = await PhpGroup.postScheduleVisitCall.call( devDesc: widget.visitObsStr, idVisitante: widget.visitorStrList, - dtInicio: - _model.convertDateFormat(widget.visitStartDate ?? ''), + dtInicio: _model.convertDateFormat(widget.visitStartDate ?? ''), dtFim: _model.convertDateFormat(widget.visitEndDate ?? ''), unica: widget.visitTempStr, idMotivo: extractIdToStr(widget.visitResonStr!), @@ -799,12 +644,10 @@ class _ScheduleVisitDetailWidgetState extends State { false) { context.pop(); } else { - final String? msg = PhpGroup.postScheduleVisitCall.errorMsg( + final String? msg = PhpGroup.postScheduleVisitCall.errorMsg( (_model.postScheduleVisit?.jsonBody ?? ''), ); await DialogUtil.error(context, msg!).then((value) => safeSetState(() {})); - - } setState(() {}); diff --git a/lib/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_model.dart b/lib/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_model.dart index 58eb0783..b1733956 100644 --- a/lib/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_model.dart +++ b/lib/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_model.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; import 'package:hub/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; -class UpArrowLinkedLocalsComponentModel - extends FlutterFlowModel { +class UpArrowLinkedLocalsComponentModel extends FlutterFlowModel { late final String devUUID; late final String userUUID; late final String cliUUID; @@ -16,10 +16,10 @@ class UpArrowLinkedLocalsComponentModel } Future initDB() async { - devUUID = StorageUtil().devUUID; - userUUID = StorageUtil().userUUID; - cliUUID = StorageUtil().cliUUID; - cliName = StorageUtil().cliName; + devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + cliName = (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? ''; } @override diff --git a/lib/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_widget.dart b/lib/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_widget.dart index 9415e7fc..d371a85b 100644 --- a/lib/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_widget.dart +++ b/lib/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_widget.dart @@ -12,12 +12,10 @@ class UpArrowLinkedLocalsComponentWidget extends StatefulWidget { const UpArrowLinkedLocalsComponentWidget({super.key}); @override - State createState() => - _UpArrowLinkedLocalsComponentWidgetState(); + State createState() => _UpArrowLinkedLocalsComponentWidgetState(); } -class _UpArrowLinkedLocalsComponentWidgetState - extends State { +class _UpArrowLinkedLocalsComponentWidgetState extends State { late UpArrowLinkedLocalsComponentModel _model; @override @@ -107,8 +105,7 @@ class _UpArrowLinkedLocalsComponentWidgetState return GridView.builder( padding: EdgeInsets.zero, - gridDelegate: - const SliverGridDelegateWithFixedCrossAxisCount( + gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 1, crossAxisSpacing: 10.0, mainAxisSpacing: 0.0, @@ -117,8 +114,7 @@ class _UpArrowLinkedLocalsComponentWidgetState scrollDirection: Axis.horizontal, itemCount: eachLocals.length, itemBuilder: (context, eachLocalsIndex) { - final eachLocalsItem = - eachLocals[eachLocalsIndex]; + final eachLocalsItem = eachLocals[eachLocalsIndex]; return InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, @@ -141,40 +137,31 @@ class _UpArrowLinkedLocalsComponentWidgetState width: 50.0, height: double.infinity, decoration: const BoxDecoration(), - alignment: - const AlignmentDirectional(0.0, 0.0), + alignment: const AlignmentDirectional(0.0, 0.0), child: Column( mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, children: [ Container( width: 100.0, height: 100.0, decoration: BoxDecoration( - color: FlutterFlowTheme.of(context) - .primaryText, - borderRadius: - const BorderRadius.only( + color: FlutterFlowTheme.of(context).primaryText, + borderRadius: const BorderRadius.only( bottomLeft: Radius.circular(25.0), - bottomRight: - Radius.circular(25.0), + bottomRight: Radius.circular(25.0), topLeft: Radius.circular(25.0), topRight: Radius.circular(25.0), ), border: Border.all( - color: - FlutterFlowTheme.of(context) - .secondaryText, + color: FlutterFlowTheme.of(context).secondaryText, width: 3.0, ), ), child: ClipRRect( - borderRadius: - const BorderRadius.only( + borderRadius: const BorderRadius.only( bottomLeft: Radius.circular(25.0), - bottomRight: - Radius.circular(25.0), + bottomRight: Radius.circular(25.0), topLeft: Radius.circular(25.0), topRight: Radius.circular(25.0), ), @@ -187,36 +174,23 @@ class _UpArrowLinkedLocalsComponentWidgetState width: double.infinity, height: double.infinity, fit: BoxFit.fill, - alignment: - const Alignment(0.0, 0.0), + alignment: const Alignment(0.0, 0.0), ), ), ), Padding( - padding: const EdgeInsetsDirectional - .fromSTEB(0.0, 10.0, 0.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 10.0, 0.0, 0.0), child: Text( getJsonField( eachLocalsItem, r'''$.CLI_NOME''', ).toString(), - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of( - context) - .bodyMediumFamily, - color: FlutterFlowTheme.of( - context) - .primaryText, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of( - context) - .bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap() + .containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), ), ), diff --git a/lib/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_model.dart b/lib/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_model.dart index 3d747604..1de0af97 100644 --- a/lib/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_model.dart +++ b/lib/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_model.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import '/backend/api_requests/api_calls.dart'; import '/flutter_flow/flutter_flow_util.dart'; -import 'access_notification_modal_template_component_widget.dart' - show AccessNotificationModalTemplateComponentWidget; +import 'access_notification_modal_template_component_widget.dart' show AccessNotificationModalTemplateComponentWidget; class AccessNotificationModalTemplateComponentModel extends FlutterFlowModel { @@ -32,9 +32,9 @@ class AccessNotificationModalTemplateComponentModel } Future initDB() async { - devUUID = StorageUtil().devUUID; - userUUID = StorageUtil().userUUID; - cliUUID = StorageUtil().cliUUID; + devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; } @override diff --git a/lib/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_widget.dart b/lib/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_widget.dart index 652bdfe6..edb51dba 100644 --- a/lib/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_widget.dart +++ b/lib/components/templates_components/access_notification_modal_template_component/access_notification_modal_template_component_widget.dart @@ -41,8 +41,7 @@ class _AccessNotificationModalTemplateComponentWidgetState void initState() { super.initState(); - _model = createModel( - context, () => AccessNotificationModalTemplateComponentModel()); + _model = createModel(context, () => AccessNotificationModalTemplateComponentModel()); _model.textController1 ??= TextEditingController(text: widget.name); _model.textFieldFocusNode1 ??= FocusNode(); @@ -66,11 +65,9 @@ class _AccessNotificationModalTemplateComponentWidgetState @override Widget build(BuildContext context) { - String labelTypeResident = FFLocalizations.of(context) - .getVariableText(enText: 'Resident', ptText: 'Morador'); + String labelTypeResident = FFLocalizations.of(context).getVariableText(enText: 'Resident', ptText: 'Morador'); - String labelTypeVisitor = FFLocalizations.of(context) - .getVariableText(enText: 'Visitor', ptText: 'Visitante'); + String labelTypeVisitor = FFLocalizations.of(context).getVariableText(enText: 'Visitor', ptText: 'Visitante'); return Align( alignment: const AlignmentDirectional(0.0, 0.0), @@ -113,13 +110,10 @@ class _AccessNotificationModalTemplateComponentWidgetState fit: BoxFit.cover, ), ), - ] - .addToStart(const SizedBox(width: 10.0)) - .addToEnd(const SizedBox(width: 10.0)), + ].addToStart(const SizedBox(width: 10.0)).addToEnd(const SizedBox(width: 10.0)), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: TextFormField( controller: _model.textController1, focusNode: _model.textFieldFocusNode1, @@ -132,25 +126,19 @@ class _AccessNotificationModalTemplateComponentWidgetState labelText: FFLocalizations.of(context).getText( 'dvag09pq' /* Nome */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, @@ -162,18 +150,16 @@ class _AccessNotificationModalTemplateComponentWidgetState ), ), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), textAlign: TextAlign.start, maxLines: null, keyboardType: TextInputType.name, - validator: - _model.textController1Validator.asValidator(context), + validator: _model.textController1Validator.asValidator(context), ), ), Row( @@ -181,10 +167,8 @@ class _AccessNotificationModalTemplateComponentWidgetState children: [ Expanded( child: TextFormField( - controller: TextEditingController( - text: widget.type == 'O' - ? labelTypeResident - : labelTypeVisitor), + controller: + TextEditingController(text: widget.type == 'O' ? labelTypeResident : labelTypeVisitor), focusNode: _model.textFieldFocusNode2, autofocus: false, textInputAction: TextInputAction.next, @@ -195,27 +179,19 @@ class _AccessNotificationModalTemplateComponentWidgetState labelText: FFLocalizations.of(context).getText( 'h3s0r1he' /* Tipo */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, @@ -227,28 +203,22 @@ class _AccessNotificationModalTemplateComponentWidgetState ), ), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), textAlign: TextAlign.start, maxLines: null, keyboardType: TextInputType.name, - validator: _model.textController2Validator - .asValidator(context), + validator: _model.textController2Validator.asValidator(context), ), ), - ] - .addToStart(const SizedBox(width: 24.0)) - .addToEnd(const SizedBox(width: 24.0)), + ].addToStart(const SizedBox(width: 24.0)).addToEnd(const SizedBox(width: 24.0)), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: TextFormField( controller: _model.textController3, focusNode: _model.textFieldFocusNode3, @@ -261,25 +231,19 @@ class _AccessNotificationModalTemplateComponentWidgetState labelText: FFLocalizations.of(context).getText( 'jveeqpdz' /* Acesso */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, @@ -291,23 +255,20 @@ class _AccessNotificationModalTemplateComponentWidgetState ), ), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), textAlign: TextAlign.start, maxLines: null, keyboardType: TextInputType.name, - validator: - _model.textController3Validator.asValidator(context), + validator: _model.textController3Validator.asValidator(context), ), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: TextFormField( controller: _model.textController4, focusNode: _model.textFieldFocusNode4, @@ -322,24 +283,18 @@ class _AccessNotificationModalTemplateComponentWidgetState enText: 'Access Sector', ptText: 'Setor de Acesso', ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, @@ -351,16 +306,14 @@ class _AccessNotificationModalTemplateComponentWidgetState ), ), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), textAlign: TextAlign.start, - validator: - _model.textController4Validator.asValidator(context), + validator: _model.textController4Validator.asValidator(context), ), ), ] diff --git a/lib/components/templates_components/card_item_template_component/card_item_template_component_model.dart b/lib/components/templates_components/card_item_template_component/card_item_template_component_model.dart index 032a1f68..aed57244 100644 --- a/lib/components/templates_components/card_item_template_component/card_item_template_component_model.dart +++ b/lib/components/templates_components/card_item_template_component/card_item_template_component_model.dart @@ -1,14 +1,11 @@ import '/flutter_flow/flutter_flow_util.dart'; -import 'card_item_template_component_widget.dart' - show CardItemTemplateComponentWidget; +import 'card_item_template_component_widget.dart' show CardItemTemplateComponentWidget; import 'package:flutter/material.dart'; - -class CardItemTemplateComponentModel - extends FlutterFlowModel { +class CardItemTemplateComponentModel extends FlutterFlowModel { @override void initState(BuildContext context) {} @override void dispose() {} -} \ No newline at end of file +} diff --git a/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart b/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart index ad1e86d8..26b1d53d 100644 --- a/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart +++ b/lib/components/templates_components/card_item_template_component/card_item_template_component_widget.dart @@ -26,12 +26,10 @@ class CardItemTemplateComponentWidget extends StatefulWidget { final Future Function()? onTapCardItemAction; @override - State createState() => - _CardItemTemplateComponentWidgetState(); + State createState() => _CardItemTemplateComponentWidgetState(); } -class _CardItemTemplateComponentWidgetState - extends State { +class _CardItemTemplateComponentWidgetState extends State { late CardItemTemplateComponentModel _model; late LinkedHashMap labelsLinkedHashMap; late List> statusLinkedHashMap; @@ -41,9 +39,7 @@ class _CardItemTemplateComponentWidgetState super.initState(); _model = createModel(context, () => CardItemTemplateComponentModel()); labelsLinkedHashMap = LinkedHashMap.from(widget.labelsHashMap ?? {}); - statusLinkedHashMap = widget.statusHashMap - .map((map) => LinkedHashMap.from(map ?? {})) - .toList(); + statusLinkedHashMap = widget.statusHashMap.map((map) => LinkedHashMap.from(map ?? {})).toList(); } @override @@ -73,8 +69,7 @@ class _CardItemTemplateComponentWidgetState fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, fontWeight: FontWeight.bold, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), color: FlutterFlowTheme.of(context).primaryText, fontSize: limitedBodyTextSize, ), @@ -89,8 +84,7 @@ class _CardItemTemplateComponentWidgetState fontSize: limitedBodyTextSize, letterSpacing: 0.0, fontWeight: FontWeight.bold, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), ), ), @@ -182,9 +176,7 @@ class _CardItemTemplateComponentWidgetState ), ), _generateImage(), - ] - .addToEnd(const SizedBox(width: 10)) - .addToStart(const SizedBox(width: 10)), + ].addToEnd(const SizedBox(width: 10)).addToStart(const SizedBox(width: 10)), ); } else { return Column( diff --git a/lib/components/templates_components/change_passs_qr_code_pass_key_template_component/change_pass_model.dart b/lib/components/templates_components/change_passs_qr_code_pass_key_template_component/change_pass_model.dart index 716e98ef..ab9bda87 100644 --- a/lib/components/templates_components/change_passs_qr_code_pass_key_template_component/change_pass_model.dart +++ b/lib/components/templates_components/change_passs_qr_code_pass_key_template_component/change_pass_model.dart @@ -1,11 +1,8 @@ import '/flutter_flow/flutter_flow_util.dart'; -import 'change_pass_widget.dart' - show PassKeyTemplateWidget; +import 'change_pass_widget.dart' show PassKeyTemplateWidget; import 'package:flutter/material.dart'; - -class PassKeyTemplateComponentModel - extends FlutterFlowModel { +class PassKeyTemplateComponentModel extends FlutterFlowModel { /// State fields for stateful widgets in this component. final formKey = GlobalKey(); @@ -18,19 +15,18 @@ class PassKeyTemplateComponentModel late bool keyTextFieldVisibility2; String? Function(BuildContext, String?)? keyTextFieldTextControllerValidator1; String? Function(BuildContext, String?)? keyTextFieldTextControllerValidator2; - String? _keyTextFieldTextControllerValidator( - BuildContext context, String? val) { - if (val == null || val.isEmpty ) { + String? _keyTextFieldTextControllerValidator(BuildContext context, String? val) { + if (val == null || val.isEmpty) { return FFLocalizations.of(context).getVariableText( enText: 'This field is required', - ptText: 'Este campo é obrigatório', + ptText: 'Este campo é obrigatório', ); } - if ( val.length < 4 ) { + if (val.length < 4) { return FFLocalizations.of(context).getVariableText( - enText: 'This field must have at least 4 characters', - ptText: 'Este campo deve ter pelo menos 4 caracteres', - ); + enText: 'This field must have at least 4 characters', + ptText: 'Este campo deve ter pelo menos 4 caracteres', + ); } return null; } @@ -50,4 +46,4 @@ class PassKeyTemplateComponentModel keyTextFieldTextController1?.dispose(); keyTextFieldTextController2?.dispose(); } -} \ No newline at end of file +} diff --git a/lib/components/templates_components/change_passs_qr_code_pass_key_template_component/change_pass_widget.dart b/lib/components/templates_components/change_passs_qr_code_pass_key_template_component/change_pass_widget.dart index fb2c4b57..90395b06 100644 --- a/lib/components/templates_components/change_passs_qr_code_pass_key_template_component/change_pass_widget.dart +++ b/lib/components/templates_components/change_passs_qr_code_pass_key_template_component/change_pass_widget.dart @@ -3,7 +3,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; @@ -27,6 +28,8 @@ class PassKeyTemplateWidget extends StatefulWidget { class _PassKeyTemplateWidgetState extends State { late PassKeyTemplateComponentModel _model; + late String _accessPass = ''; + @override void setState(VoidCallback callback) { super.setState(callback); @@ -41,6 +44,12 @@ class _PassKeyTemplateWidgetState extends State { _model.keyTextFieldTextController1 ??= TextEditingController(); _model.keyTextFieldFocusNode1 ??= FocusNode(); _model.keyTextFieldFocusNode1!.addListener(() => setState(() {})); + + _initialize(); + } + + Future _initialize() async { + _accessPass = await StorageHelper().get(SecureStorageKey.accessPass.value, Storage.SecureStorage) ?? ''; } @override @@ -81,8 +90,7 @@ class _PassKeyTemplateWidgetState extends State { tablet: false, )) Padding( - padding: - const EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 16.0, 8.0), + padding: const EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 16.0, 8.0), child: InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, @@ -95,8 +103,7 @@ class _PassKeyTemplateWidgetState extends State { mainAxisSize: MainAxisSize.max, children: [ const Padding( - padding: EdgeInsetsDirectional.fromSTEB( - 0.0, 12.0, 0.0, 12.0), + padding: EdgeInsetsDirectional.fromSTEB(0.0, 12.0, 0.0, 12.0), child: Icon( Icons.arrow_back_rounded, color: Color(0xFF15161E), @@ -104,20 +111,17 @@ class _PassKeyTemplateWidgetState extends State { ), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 12.0, 0.0, 0.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(12.0, 0.0, 0.0, 0.0), child: Text( '', - style: - FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: 'Plus Jakarta Sans', - color: const Color(0xFF15161E), - fontSize: 14.0, - letterSpacing: 0.0, - fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts.asMap() - .containsKey('Plus Jakarta Sans'), - ), + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: 'Plus Jakarta Sans', + color: const Color(0xFF15161E), + fontSize: 14.0, + letterSpacing: 0.0, + fontWeight: FontWeight.w500, + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), + ), ), ), ], @@ -125,14 +129,11 @@ class _PassKeyTemplateWidgetState extends State { ), ), Padding( - padding: - const EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 0.0, 0.0), child: Text( FFLocalizations.of(context).getVariableText( enText: 'INSERT PASSWORD', - ptText: StorageUtil().accessPass != '' - ? 'ALTERAR SENHA' - : 'ADICIONAR SENHA', + ptText: _accessPass != '' ? 'ALTERAR SENHA' : 'ADICIONAR SENHA', ), style: FlutterFlowTheme.of(context).headlineMedium.override( fontFamily: 'Outfit', @@ -145,20 +146,17 @@ class _PassKeyTemplateWidgetState extends State { ), ), Padding( - padding: - const EdgeInsetsDirectional.fromSTEB(16.0, 4.0, 16.0, 4.0), + padding: const EdgeInsetsDirectional.fromSTEB(16.0, 4.0, 16.0, 4.0), child: Text( FFLocalizations.of(context).getVariableText( - enText: 'Enter your password to continue', - ptText: 'Digite sua senha para continuar'), + enText: 'Enter your password to continue', ptText: 'Digite sua senha para continuar'), style: FlutterFlowTheme.of(context).labelMedium.override( fontFamily: 'Plus Jakarta Sans', color: FlutterFlowTheme.of(context).primaryText, fontSize: 14.0, letterSpacing: 0.0, fontWeight: FontWeight.w500, - useGoogleFonts: - GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), ), ), @@ -168,8 +166,7 @@ class _PassKeyTemplateWidgetState extends State { child: Column( children: [ Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 16.0, 12.0, 16.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(16.0, 12.0, 16.0, 0.0), child: SizedBox( width: double.infinity, child: TextFormField( @@ -188,36 +185,29 @@ class _PassKeyTemplateWidgetState extends State { obscureText: !_model.keyTextFieldVisibility1, decoration: InputDecoration( isDense: true, - labelText: - FFLocalizations.of(context).getVariableText( + labelText: FFLocalizations.of(context).getVariableText( ptText: 'Senha', enText: 'Password', ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( fontFamily: 'Plus Jakarta Sans', color: FlutterFlowTheme.of(context).primaryText, fontSize: 14.0, letterSpacing: 0.0, fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts.asMap() - .containsKey('Plus Jakarta Sans'), + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), hintText: FFLocalizations.of(context).getVariableText( ptText: 'Digite a sua senha.....', enText: 'Enter your password.....', ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( fontFamily: 'Plus Jakarta Sans', color: FlutterFlowTheme.of(context).primaryText, fontSize: 14.0, letterSpacing: 0.0, fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts.asMap() - .containsKey('Plus Jakarta Sans'), + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( @@ -248,14 +238,11 @@ class _PassKeyTemplateWidgetState extends State { borderRadius: BorderRadius.circular(12.0), ), filled: true, - fillColor: - FlutterFlowTheme.of(context).primaryBackground, - contentPadding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 24.0, 20.0, 24.0), + fillColor: FlutterFlowTheme.of(context).primaryBackground, + contentPadding: const EdgeInsetsDirectional.fromSTEB(24.0, 24.0, 20.0, 24.0), suffixIcon: InkWell( onTap: () => setState( - () => _model.keyTextFieldVisibility1 = - !_model.keyTextFieldVisibility1, + () => _model.keyTextFieldVisibility1 = !_model.keyTextFieldVisibility1, ), focusNode: FocusNode(skipTraversal: true), child: Icon( @@ -273,20 +260,14 @@ class _PassKeyTemplateWidgetState extends State { fontSize: 14.0, letterSpacing: 0.0, fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts.asMap() - .containsKey('Plus Jakarta Sans'), + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), maxLength: 4, maxLengthEnforcement: MaxLengthEnforcement.enforced, - buildCounter: (context, - {required currentLength, - required isFocused, - maxLength}) => - null, + buildCounter: (context, {required currentLength, required isFocused, maxLength}) => null, keyboardType: TextInputType.number, cursorColor: FlutterFlowTheme.of(context).primary, - validator: _model.keyTextFieldTextControllerValidator1 - .asValidator(context), + validator: _model.keyTextFieldTextControllerValidator1.asValidator(context), inputFormatters: [ FilteringTextInputFormatter.allow(RegExp('[0-9]')), LengthLimitingTextInputFormatter(4), @@ -300,12 +281,10 @@ class _PassKeyTemplateWidgetState extends State { Align( alignment: const AlignmentDirectional(0.0, 0.0), child: Padding( - padding: - const EdgeInsetsDirectional.fromSTEB(0.0, 24.0, 0.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 24.0, 0.0, 0.0), child: FFButtonWidget( onPressed: () async { - if (_model.formKey.currentState == null || - !_model.formKey.currentState!.validate()) { + if (_model.formKey.currentState == null || !_model.formKey.currentState!.validate()) { return; } await widget.toggleActionStatus?.call( @@ -317,20 +296,14 @@ class _PassKeyTemplateWidgetState extends State { context.pop(true); }, text: FFLocalizations.of(context).getVariableText( - ptText: StorageUtil().accessPass != '' - ? 'Alterar' - : 'Adicionar', - enText: StorageUtil().accessPass != '' - ? 'Change' - : 'Add', + ptText: _accessPass != '' ? 'Alterar' : 'Adicionar', + enText: _accessPass != '' ? 'Change' : 'Add', ), options: FFButtonOptions( width: 270.0, height: 50.0, - padding: const EdgeInsetsDirectional.fromSTEB( - 0.0, 0.0, 0.0, 0.0), - iconPadding: const EdgeInsetsDirectional.fromSTEB( - 0.0, 0.0, 0.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), + iconPadding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), color: const Color(0xFF1AAB5F), textStyle: FlutterFlowTheme.of(context).titleSmall.override( fontFamily: 'Plus Jakarta Sans', @@ -338,8 +311,7 @@ class _PassKeyTemplateWidgetState extends State { fontSize: 16.0, letterSpacing: 0.0, fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts.asMap() - .containsKey('Plus Jakarta Sans'), + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), elevation: 3.0, borderSide: const BorderSide( diff --git a/lib/components/templates_components/details_component/details_component_widget.dart b/lib/components/templates_components/details_component/details_component_widget.dart index 3c84637e..39e73c6a 100644 --- a/lib/components/templates_components/details_component/details_component_widget.dart +++ b/lib/components/templates_components/details_component/details_component_widget.dart @@ -32,13 +32,10 @@ class DetailsComponentWidget extends StatefulWidget { class _DetailsComponentWidgetState extends State { late DetailsComponentModel _model; - LinkedHashMap get labelsLinkedHashMap => - LinkedHashMap.from(widget.labelsHashMap); + LinkedHashMap get labelsLinkedHashMap => LinkedHashMap.from(widget.labelsHashMap); List> get statusLinkedHashMap => - widget.statusHashMap - .map((map) => LinkedHashMap.from(map ?? {})) - .toList(); + widget.statusHashMap.map((map) => LinkedHashMap.from(map ?? {})).toList(); @override void setState(VoidCallback callback) { @@ -97,8 +94,7 @@ class _DetailsComponentWidgetState extends State { SizedBox(height: MediaQuery.of(context).size.height * 0.03), Row( children: statusLinkedHashMap.expand((linkedHashMap) { - return linkedHashMap.entries - .map((MapEntry item) { + return linkedHashMap.entries.map((MapEntry item) { return Expanded( child: Padding( padding: EdgeInsets.symmetric( @@ -122,31 +118,22 @@ class _DetailsComponentWidgetState extends State { filled: true, fillColor: item.value, labelText: item.key, - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, fontWeight: FontWeight.bold, color: FlutterFlowTheme.of(context).info, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily, - + FlutterFlowTheme.of(context).labelMediumFamily, ), fontSize: limitedBodyFontSize, ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).info, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily, + FlutterFlowTheme.of(context).labelMediumFamily, ), fontSize: limitedBodyFontSize, ), @@ -159,8 +146,7 @@ class _DetailsComponentWidgetState extends State { ), ), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).info, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap().containsKey( @@ -171,8 +157,7 @@ class _DetailsComponentWidgetState extends State { textAlign: TextAlign.start, maxLines: null, keyboardType: TextInputType.name, - validator: _model.textController1Validator - .asValidator(context), + validator: _model.textController1Validator.asValidator(context), ), ), ); @@ -193,8 +178,7 @@ class _DetailsComponentWidgetState extends State { initialValue: '$value', style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap().containsKey( @@ -211,15 +195,11 @@ class _DetailsComponentWidgetState extends State { border: OutlineInputBorder( borderRadius: BorderRadius.circular(10.0), borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primaryBackground, // Change border color here + color: FlutterFlowTheme.of(context).primaryBackground, // Change border color here ), ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap().containsKey( @@ -242,29 +222,25 @@ class _DetailsComponentWidgetState extends State { enabledBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10.0), borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primaryBackground, // Change border color here + color: FlutterFlowTheme.of(context).primaryBackground, // Change border color here ), ), focusedBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10.0), borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primaryBackground, // Change border color here + color: FlutterFlowTheme.of(context).primaryBackground, // Change border color here ), ), errorBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10.0), borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primaryBackground, // Change border color here + color: FlutterFlowTheme.of(context).primaryBackground, // Change border color here ), ), focusedErrorBorder: OutlineInputBorder( borderRadius: BorderRadius.circular(10.0), borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primaryBackground, // Change border color here + color: FlutterFlowTheme.of(context).primaryBackground, // Change border color here ), ), ), @@ -272,8 +248,7 @@ class _DetailsComponentWidgetState extends State { }, ), SizedBox(height: MediaQuery.of(context).size.height * 0.02), - if (widget.buttons - .isNotEmpty) // Adicione este SizedBox com a altura desejada + if (widget.buttons.isNotEmpty) // Adicione este SizedBox com a altura desejada OverflowBar( overflowAlignment: OverflowBarAlignment.center, overflowSpacing: 2, diff --git a/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_model.dart b/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_model.dart index e860162b..aff803ff 100644 --- a/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_model.dart +++ b/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_model.dart @@ -2,12 +2,10 @@ import 'package:hub/shared/utils/validator_util.dart'; import '/backend/api_requests/api_calls.dart'; import '/flutter_flow/flutter_flow_util.dart'; -import 'forgot_password_template_component_widget.dart' - show ForgotPasswordTemplateComponentWidget; +import 'forgot_password_template_component_widget.dart' show ForgotPasswordTemplateComponentWidget; import 'package:flutter/material.dart'; -class ForgotPasswordTemplateComponentModel - extends FlutterFlowModel { +class ForgotPasswordTemplateComponentModel extends FlutterFlowModel { /// State fields for stateful widgets in this component. final formKey = GlobalKey(); @@ -15,8 +13,7 @@ class ForgotPasswordTemplateComponentModel FocusNode? emailAddressFocusNode; TextEditingController? emailAddressTextController; String? Function(BuildContext, String?)? emailAddressTextControllerValidator; - String? _emailAddressTextControllerValidator( - BuildContext context, String? val) { + String? _emailAddressTextControllerValidator(BuildContext context, String? val) { if (val == null || val.isEmpty) { return FFLocalizations.of(context).getText( 'snnmkbyc' /* E-mail é Obrigatório */, @@ -44,4 +41,4 @@ class ForgotPasswordTemplateComponentModel emailAddressFocusNode?.dispose(); emailAddressTextController?.dispose(); } -} \ No newline at end of file +} diff --git a/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_widget.dart b/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_widget.dart index a63c7f37..33008753 100644 --- a/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_widget.dart +++ b/lib/components/templates_components/forgot_password_template_component/forgot_password_template_component_widget.dart @@ -19,12 +19,10 @@ class ForgotPasswordTemplateComponentWidget extends StatefulWidget { const ForgotPasswordTemplateComponentWidget({super.key}); @override - State createState() => - _ForgotPasswordTemplateComponentWidgetState(); + State createState() => _ForgotPasswordTemplateComponentWidgetState(); } -class _ForgotPasswordTemplateComponentWidgetState - extends State { +class _ForgotPasswordTemplateComponentWidgetState extends State { late ForgotPasswordTemplateComponentModel _model; @override diff --git a/lib/components/templates_components/liberation_history_item_details_template_component/liberation_history_item_details_template_component_model.dart b/lib/components/templates_components/liberation_history_item_details_template_component/liberation_history_item_details_template_component_model.dart index db1f6d26..26e45baa 100644 --- a/lib/components/templates_components/liberation_history_item_details_template_component/liberation_history_item_details_template_component_model.dart +++ b/lib/components/templates_components/liberation_history_item_details_template_component/liberation_history_item_details_template_component_model.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; import 'package:hub/components/templates_components/liberation_history_item_details_template_component/liberation_history_item_details_template_component_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; class LiberationHistoryItemDetailsTemplateComponentModel - extends FlutterFlowModel< - LiberationHistoryItemDetailsTemplateComponentWidget> { + extends FlutterFlowModel { late final String devUUID; late final String userUUID; late final String cliUUID; @@ -27,9 +27,10 @@ class LiberationHistoryItemDetailsTemplateComponentModel void initState(BuildContext context) {} Future initDatabase() async { - devUUID = StorageUtil().devUUID; - userUUID = StorageUtil().userUUID; - cliUUID = StorageUtil().cliUUID; + devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + ; } @override diff --git a/lib/components/templates_components/liberation_history_item_details_template_component/liberation_history_item_details_template_component_widget.dart b/lib/components/templates_components/liberation_history_item_details_template_component/liberation_history_item_details_template_component_widget.dart index 539f36eb..5ed0fd82 100644 --- a/lib/components/templates_components/liberation_history_item_details_template_component/liberation_history_item_details_template_component_widget.dart +++ b/lib/components/templates_components/liberation_history_item_details_template_component/liberation_history_item_details_template_component_widget.dart @@ -5,8 +5,7 @@ import 'package:hub/components/templates_components/liberation_history_item_deta import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; -class LiberationHistoryItemDetailsTemplateComponentWidget - extends StatefulWidget { +class LiberationHistoryItemDetailsTemplateComponentWidget extends StatefulWidget { const LiberationHistoryItemDetailsTemplateComponentWidget({ super.key, required this.name, @@ -40,8 +39,7 @@ class _LiberationHistoryItemDetailsTemplateComponentWidgetState @override void initState() { super.initState(); - _model = createModel( - context, () => LiberationHistoryItemDetailsTemplateComponentModel()); + _model = createModel(context, () => LiberationHistoryItemDetailsTemplateComponentModel()); _model.textController1 ??= TextEditingController(text: widget.name); _model.textFieldFocusNode1 ??= FocusNode(); @@ -106,13 +104,10 @@ class _LiberationHistoryItemDetailsTemplateComponentWidgetState fit: BoxFit.cover, ), ), - ] - .addToStart(const SizedBox(width: 10.0)) - .addToEnd(const SizedBox(width: 10.0)), + ].addToStart(const SizedBox(width: 10.0)).addToEnd(const SizedBox(width: 10.0)), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: TextFormField( controller: _model.textController1, focusNode: _model.textFieldFocusNode1, @@ -125,25 +120,19 @@ class _LiberationHistoryItemDetailsTemplateComponentWidgetState labelText: FFLocalizations.of(context).getText( 'dmazrriq' /* Nome */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, @@ -155,18 +144,16 @@ class _LiberationHistoryItemDetailsTemplateComponentWidgetState ), ), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), textAlign: TextAlign.start, maxLines: null, keyboardType: TextInputType.name, - validator: - _model.textController1Validator.asValidator(context), + validator: _model.textController1Validator.asValidator(context), ), ), Row( @@ -185,27 +172,19 @@ class _LiberationHistoryItemDetailsTemplateComponentWidgetState labelText: FFLocalizations.of(context).getText( 'xx3ivbr4' /* Tipo */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, @@ -217,28 +196,22 @@ class _LiberationHistoryItemDetailsTemplateComponentWidgetState ), ), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), textAlign: TextAlign.start, maxLines: null, keyboardType: TextInputType.name, - validator: _model.textController2Validator - .asValidator(context), + validator: _model.textController2Validator.asValidator(context), ), ), - ] - .addToStart(const SizedBox(width: 24.0)) - .addToEnd(const SizedBox(width: 24.0)), + ].addToStart(const SizedBox(width: 24.0)).addToEnd(const SizedBox(width: 24.0)), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: TextFormField( controller: _model.textController3, focusNode: _model.textFieldFocusNode3, @@ -251,25 +224,19 @@ class _LiberationHistoryItemDetailsTemplateComponentWidgetState labelText: FFLocalizations.of(context).getText( 'rhheok7k' /* Acesso */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, @@ -281,23 +248,20 @@ class _LiberationHistoryItemDetailsTemplateComponentWidgetState ), ), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), textAlign: TextAlign.start, maxLines: null, keyboardType: TextInputType.name, - validator: - _model.textController3Validator.asValidator(context), + validator: _model.textController3Validator.asValidator(context), ), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: TextFormField( controller: _model.textController4, focusNode: _model.textFieldFocusNode4, @@ -311,24 +275,18 @@ class _LiberationHistoryItemDetailsTemplateComponentWidgetState labelText: FFLocalizations.of(context).getText( 'w3tciqlv' /* Acionamento */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, @@ -340,16 +298,14 @@ class _LiberationHistoryItemDetailsTemplateComponentWidgetState ), ), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), textAlign: TextAlign.start, - validator: - _model.textController4Validator.asValidator(context), + validator: _model.textController4Validator.asValidator(context), ), ), ] diff --git a/lib/components/templates_components/message_notificaion_modal_template_component/message_notification_widget.dart b/lib/components/templates_components/message_notificaion_modal_template_component/message_notification_widget.dart index 84ed9118..2262612b 100644 --- a/lib/components/templates_components/message_notificaion_modal_template_component/message_notification_widget.dart +++ b/lib/components/templates_components/message_notificaion_modal_template_component/message_notification_widget.dart @@ -37,8 +37,7 @@ class _MessageNotificationModalTemplateComponentWidgetState @override void initState() { super.initState(); - _model = createModel( - context, () => MessageNotificationModalTemplateComponentModel()); + _model = createModel(context, () => MessageNotificationModalTemplateComponentModel()); _model.textController1 ??= TextEditingController(text: widget.message); _model.textFieldFocusNode1 ??= FocusNode(); @@ -80,8 +79,7 @@ class _MessageNotificationModalTemplateComponentWidgetState mainAxisAlignment: MainAxisAlignment.start, children: [ Padding( - padding: - const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: TextFormField( controller: _model.textController1, focusNode: _model.textFieldFocusNode1, @@ -96,21 +94,17 @@ class _MessageNotificationModalTemplateComponentWidgetState enText: 'Message', ), labelStyle: FlutterFlowTheme.of(context).labelMedium.override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), fontSize: limitedBodyFontSize, ), hintStyle: FlutterFlowTheme.of(context).labelMedium.override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), fontSize: limitedBodyFontSize, ), enabledBorder: InputBorder.none, @@ -126,8 +120,7 @@ class _MessageNotificationModalTemplateComponentWidgetState fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), fontSize: limitedBodyFontSize, ), textAlign: TextAlign.start, @@ -153,26 +146,20 @@ class _MessageNotificationModalTemplateComponentWidgetState ptText: 'De', enText: 'From', ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), fontSize: limitedBodyFontSize, ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), fontSize: limitedBodyFontSize, ), enabledBorder: InputBorder.none, @@ -185,27 +172,22 @@ class _MessageNotificationModalTemplateComponentWidgetState ), ), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), textAlign: TextAlign.start, maxLines: null, keyboardType: TextInputType.name, - validator: - _model.textController2Validator.asValidator(context), + validator: _model.textController2Validator.asValidator(context), ), ), - ] - .addToStart(const SizedBox(width: 24.0)) - .addToEnd(const SizedBox(width: 24.0)), + ].addToStart(const SizedBox(width: 24.0)).addToEnd(const SizedBox(width: 24.0)), ), Padding( - padding: - const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: TextFormField( controller: _model.textController3, focusNode: _model.textFieldFocusNode3, @@ -220,21 +202,17 @@ class _MessageNotificationModalTemplateComponentWidgetState enText: 'To', ), labelStyle: FlutterFlowTheme.of(context).labelMedium.override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), fontSize: limitedBodyFontSize, ), hintStyle: FlutterFlowTheme.of(context).labelMedium.override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), fontSize: limitedBodyFontSize, ), enabledBorder: InputBorder.none, @@ -250,8 +228,7 @@ class _MessageNotificationModalTemplateComponentWidgetState fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), fontSize: limitedBodyFontSize, ), textAlign: TextAlign.start, diff --git a/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart b/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart index e9a7606c..7c86e00d 100644 --- a/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart +++ b/lib/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart @@ -1,11 +1,13 @@ +import 'dart:developer'; + import 'package:flutter/material.dart'; import 'package:hub/backend/api_requests/api_manager.dart'; import 'package:hub/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; -class ScheduleProvisionalVisitPageModel - extends FlutterFlowModel { +class ScheduleProvisionalVisitPageModel extends FlutterFlowModel { String cliUUID = ''; String devUUID = ''; String userUUID = ''; @@ -19,35 +21,27 @@ class ScheduleProvisionalVisitPageModel void addToVisitors(dynamic item) => visitors.add(item); void removeFromVisitors(dynamic item) => visitors.remove(item); void removeAtIndexFromVisitors(int index) => visitors.removeAt(index); - void insertAtIndexInVisitors(int index, dynamic item) => - visitors.insert(index, item); - void updateVisitorsAtIndex(int index, Function(dynamic) updateFn) => - visitors[index] = updateFn(visitors[index]); + void insertAtIndexInVisitors(int index, dynamic item) => visitors.insert(index, item); + void updateVisitorsAtIndex(int index, Function(dynamic) updateFn) => visitors[index] = updateFn(visitors[index]); List docs = []; void addToDocs(String item) => docs.add(item); void removeFromDocs(String item) => docs.remove(item); void removeAtIndexFromDocs(int index) => docs.removeAt(index); void insertAtIndexInDocs(int index, String item) => docs.insert(index, item); - void updateDocsAtIndex(int index, Function(String) updateFn) => - docs[index] = updateFn(docs[index]); + void updateDocsAtIndex(int index, Function(String) updateFn) => docs[index] = updateFn(docs[index]); final formKey = GlobalKey(); FocusNode? personNameFocusNode; TextEditingController? personNameTextController; String? Function(BuildContext, String?)? personNameTextControllerValidator; - String? _personNameTextControllerValidator( - BuildContext context, String? val) { + String? _personNameTextControllerValidator(BuildContext context, String? val) { if (val == null || val.isEmpty) { - return FFLocalizations.of(context).getText( - '3hqg8buh', - ); + return FFLocalizations.of(context).getText('3hqg8buh'); } if (val.length > 80) { - return FFLocalizations.of(context).getText( - 'l0b0zr50', - ); + return FFLocalizations.of(context).getText('l0b0zr50'); } return null; @@ -58,31 +52,26 @@ class ScheduleProvisionalVisitPageModel String? Function(BuildContext, String?)? dateTimeTextControllerValidator; String? _dateTimeTextControllerValidator(BuildContext context, String? val) { if (val == null || val.isEmpty) { - return FFLocalizations.of(context).getText( - 'uzefkuf9', - ); + return FFLocalizations.of(context).getText('uzefkuf9'); } - DateTime selectedDateTime; - DateTime currentDateTime = DateTime.now(); - selectedDateTime = DateFormat('dd/MM/yyyy HH:mm:ss').parse(val); - + DateTime currentDateTime = DateTime.now().add(const Duration(minutes: 59)); + selectedDateTime = DateFormat('dd/MM/yyyy HH:mm:ss').parse(dateTimeTextController.text); try { - selectedDateTime = DateFormat('dd/MM/yyyy HH:mm:ss').parse(val); + log('dateTimeTextController.text: ${dateTimeTextController.text}'); + selectedDateTime = DateFormat('dd/MM/yyyy HH:mm:ss').parse(dateTimeTextController.text); } catch (e) { return FFLocalizations.of(context).getVariableText( - ptText: 'Formato de data/hora inválido', - enText: 'Invalid date/time format', + ptText: 'Formato de data inválido', + enText: 'Invalid date format', ); } - if (selectedDateTime.isBefore(currentDateTime)) { return FFLocalizations.of(context).getVariableText( - ptText: 'A data/hora selecionada é inválida', - enText: 'The selected date/time is invalid', + ptText: 'A data devem ser, no mínimo, uma (1) hora à frente.', + enText: 'The date must be at least one (1) hour ahead.', ); } - return null; } @@ -100,7 +89,8 @@ class ScheduleProvisionalVisitPageModel personNameTextController ??= TextEditingController(); personNameFocusNode ??= FocusNode(); - dateTimeTextController ??= TextEditingController(); + dateTimeTextController ??= TextEditingController( + text: DateFormat('dd/MM/yyyy HH:mm:ss').format(DateTime.now().add(const Duration(days: 1)))); dateTimeFocusNode ??= FocusNode(); notesTextController ??= TextEditingController(); @@ -109,44 +99,6 @@ class ScheduleProvisionalVisitPageModel init(); } - bool isFormValid() { - if (personNameTextController.text == '' || - personNameTextController.text.length > 80) { - return false; - } - - if (dateTimeTextController.text == '') { - return false; - } - - DateTime selectedDateTime; - DateTime currentDateTime = DateTime.now(); - selectedDateTime = - DateFormat('dd/MM/yyyy HH:mm:ss').parse(dateTimeTextController.text); - - try { - selectedDateTime = - DateFormat('dd/MM/yyyy HH:mm:ss').parse(dateTimeTextController.text); - } catch (e) { - return false; - } - - if (selectedDateTime.isBefore(currentDateTime)) { - return false; - } - - return true; - } - - Future init() async { - cliUUID = StorageUtil().cliUUID; - devUUID = StorageUtil().devUUID; - userUUID = StorageUtil().userUUID; - cliName = StorageUtil().cliName; - ownerUUID = StorageUtil().ownerUUID; - setState?.call(); - } - @override void dispose() { personNameFocusNode?.dispose(); @@ -158,4 +110,40 @@ class ScheduleProvisionalVisitPageModel notesFocusNode?.dispose(); notesTextController?.dispose(); } + + bool isFormValid() { + if (personNameTextController.text == '' || personNameTextController.text.length > 80) { + return false; + } + + if (dateTimeTextController.text == '') { + return false; + } + + DateTime selectedDateTime; + DateTime currentDateTime = DateTime.now().add(const Duration(minutes: 59)); + selectedDateTime = DateFormat('dd/MM/yyyy HH:mm:ss').parse(dateTimeTextController.text); + + try { + selectedDateTime = DateFormat('dd/MM/yyyy HH:mm:ss').parse(dateTimeTextController.text); + } catch (e) { + return false; + } + + if (selectedDateTime.isBefore(currentDateTime)) { + return false; + } + + return true; + } + + Future init() async { + devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + ; + cliName = (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? ''; + ownerUUID = (await StorageHelper().get(SQLiteStorageKey.ownerUUID.value, Storage.SQLiteStorage)) ?? ''; + setState?.call(); + } } diff --git a/lib/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart b/lib/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart index ab988446..c1ae573c 100644 --- a/lib/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart +++ b/lib/components/templates_components/provisional_schedule_template/provisional_shcedule_template_widget.dart @@ -17,12 +17,10 @@ class ScheduleProvisionalVisitPageWidget extends StatefulWidget { const ScheduleProvisionalVisitPageWidget({super.key}); @override - State createState() => - _ScheduleProvisionalVisitPageWidgetState(); + State createState() => _ScheduleProvisionalVisitPageWidgetState(); } -class _ScheduleProvisionalVisitPageWidgetState - extends State { +class _ScheduleProvisionalVisitPageWidgetState extends State { late ScheduleProvisionalVisitPageModel model; @override @@ -67,12 +65,9 @@ class _ScheduleProvisionalVisitPageWidgetState Align( alignment: const AlignmentDirectional(-1.0, 0.0), child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 24.0, 24.0, 24.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 24.0, 0.0, 24.0), child: Text( - FFLocalizations.of(context).getText( - 'uj8acuab' /* Preencha os Campos Abaixo: */, - ), + FFLocalizations.of(context).getText('uj8acuab'), textAlign: TextAlign.start, overflow: TextOverflow.clip, style: FlutterFlowTheme.of(context) @@ -83,10 +78,8 @@ class _ScheduleProvisionalVisitPageWidgetState fontSize: limitedHeaderFontSize, letterSpacing: 0.0, fontWeight: FontWeight.bold, - useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), ), ), @@ -94,29 +87,20 @@ class _ScheduleProvisionalVisitPageWidgetState Container( width: double.infinity, decoration: BoxDecoration( - color: - FlutterFlowTheme.of(context).primaryBackground, + color: FlutterFlowTheme.of(context).primaryBackground, ), child: Column( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.center, children: [ Align( - alignment: - const AlignmentDirectional(-1.0, 0.0), + alignment: const AlignmentDirectional(-1.0, 0.0), child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 0.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 0.0, 0.0), child: Text( - FFLocalizations.of(context).getText( - '8d3679lf' /* Propriedade */, - ), - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of(context) - .bodyMediumFamily, + FFLocalizations.of(context).getText('8d3679lf'), + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() .containsKey( @@ -128,8 +112,7 @@ class _ScheduleProvisionalVisitPageWidgetState ), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 10.0, 24.0, 10.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 10.0, 24.0, 10.0), child: Container( width: double.infinity, height: 50.0, @@ -141,16 +124,14 @@ class _ScheduleProvisionalVisitPageWidgetState topRight: Radius.circular(50.0), ), border: Border.all( - color: FlutterFlowTheme.of(context) - .customColor5, + color: FlutterFlowTheme.of(context).customColor5, ), ), child: Padding( padding: const EdgeInsets.all(5.0), child: Row( mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, children: [ ClipRRect( borderRadius: const BorderRadius.only( @@ -160,10 +141,8 @@ class _ScheduleProvisionalVisitPageWidgetState topRight: Radius.circular(50.0), ), child: CachedNetworkImage( - fadeInDuration: const Duration( - milliseconds: 200), - fadeOutDuration: const Duration( - milliseconds: 200), + fadeInDuration: const Duration(milliseconds: 200), + fadeOutDuration: const Duration(milliseconds: 200), imageUrl: 'https://freaccess.com.br/freaccess/Images/Clients/${model.cliUUID}.png', width: 35.0, @@ -217,22 +196,13 @@ class _ScheduleProvisionalVisitPageWidgetState mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Align( - alignment: - const AlignmentDirectional(-1.0, 0.0), + alignment: const AlignmentDirectional(-1.0, 0.0), child: Padding( - padding: - const EdgeInsetsDirectional.fromSTEB( - 24.0, 10.0, 0.0, 10.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 10.0, 0.0, 10.0), child: Text( - FFLocalizations.of(context).getText( - 'z6aawgqa' /* Dados da Visita */, - ), - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of(context) - .bodyMediumFamily, + FFLocalizations.of(context).getText('z6aawgqa'), + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() .containsKey( @@ -249,139 +219,76 @@ class _ScheduleProvisionalVisitPageWidgetState Container( height: 80.0, decoration: const BoxDecoration(), - alignment: - const AlignmentDirectional(0.0, 0.0), + alignment: const AlignmentDirectional(0.0, 0.0), child: Padding( - padding: const EdgeInsetsDirectional - .fromSTEB(24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: SizedBox( width: double.infinity, child: TextFormField( - controller: - model.personNameTextController, - focusNode: - model.personNameFocusNode, - cursorColor: - FlutterFlowTheme.of(context) - .primary, - onChanged: (_) => - EasyDebounce.debounce( - 'model.personNameTextController', - const Duration(milliseconds: 500), - () => setState(() {}), - ), + controller: model.personNameTextController, + focusNode: model.personNameFocusNode, + cursorColor: FlutterFlowTheme.of(context).primary, + onChanged: (_) => EasyDebounce.debounce('model.personNameTextController', + const Duration(milliseconds: 500), () => setState(() {})), autofocus: false, - textInputAction: - TextInputAction.next, + textInputAction: TextInputAction.next, obscureText: false, decoration: InputDecoration( isDense: true, - labelText: - FFLocalizations.of(context) - .getText( - 'wehvxbz4' /* Nome / Apelido do Visitante */, - ), - labelStyle: - FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of( - context) - .bodyMediumFamily, - color: - FlutterFlowTheme.of( - context) - .primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of( - context) - .bodyMediumFamily), + labelText: FFLocalizations.of(context).getText('wehvxbz4'), + labelStyle: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap() + .containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), fontSize: limitedInputFontSize, - ), - hintStyle: - FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of( - context) - .labelMediumFamily, - color: - FlutterFlowTheme.of( - context) - .primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of( - context) - .labelMediumFamily), + ), + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap() + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), fontSize: limitedInputFontSize, - ), + ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( - color: FlutterFlowTheme.of( - context) - .customColor5, + color: FlutterFlowTheme.of(context).customColor5, width: 0.5, ), - borderRadius: - BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(10.0), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide( - color: FlutterFlowTheme.of( - context) - .primary, + color: FlutterFlowTheme.of(context).primary, width: 0.5, ), - borderRadius: - BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(10.0), ), errorBorder: OutlineInputBorder( borderSide: BorderSide( - color: FlutterFlowTheme.of( - context) - .error, + color: FlutterFlowTheme.of(context).error, width: 0.5, ), - borderRadius: - BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(10.0), ), - focusedErrorBorder: - OutlineInputBorder( + focusedErrorBorder: OutlineInputBorder( borderSide: BorderSide( - color: FlutterFlowTheme.of( - context) - .error, + color: FlutterFlowTheme.of(context).error, width: 0.5, ), - borderRadius: - BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(10.0), ), suffixIcon: Icon( Icons.person, - color: - FlutterFlowTheme.of(context) - .accent1, + color: FlutterFlowTheme.of(context).accent1, ), ), - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of( - context) - .bodyMediumFamily, - color: FlutterFlowTheme.of( - context) - .primaryText, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts .asMap() @@ -394,9 +301,7 @@ class _ScheduleProvisionalVisitPageWidgetState ), textAlign: TextAlign.start, maxLines: null, - validator: model - .personNameTextControllerValidator - .asValidator(context), + validator: model.personNameTextControllerValidator.asValidator(context), ), ), ), @@ -410,203 +315,116 @@ class _ScheduleProvisionalVisitPageWidgetState SizedBox( height: 80.0, child: Stack( - alignment: const AlignmentDirectional( - 0.0, 0.0), + alignment: const AlignmentDirectional(0.0, 0.0), children: [ Padding( - padding: const EdgeInsetsDirectional - .fromSTEB(24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: TextFormField( - controller: - model.dateTimeTextController, - focusNode: - model.dateTimeFocusNode, - cursorColor: - FlutterFlowTheme.of(context) - .primary, - onChanged: (_) => - EasyDebounce.debounce( - 'model.dateTimeTextController', - const Duration( - milliseconds: 500), - () => setState(() {}), - ), + controller: model.dateTimeTextController, + focusNode: model.dateTimeFocusNode, + cursorColor: FlutterFlowTheme.of(context).primary, + onChanged: (_) => EasyDebounce.debounce('model.dateTimeTextController', + const Duration(milliseconds: 500), () => setState(() {})), readOnly: true, autofocus: false, obscureText: false, decoration: InputDecoration( isDense: true, - labelText: - FFLocalizations.of(context) - .getText( - '8zgsw5so' /* Data / Hora Limite da Visita */, + labelText: FFLocalizations.of(context).getVariableText( + ptText: "Data de Validade da Visita", + enText: "Visit Validity Date", ), - labelStyle: - FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of( - context) - .bodyMediumFamily, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of( - context) - .bodyMediumFamily), + labelStyle: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap() + .containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), fontSize: limitedInputFontSize, - ), - enabledBorder: - OutlineInputBorder( + ), + enabledBorder: OutlineInputBorder( borderSide: BorderSide( - color: FlutterFlowTheme.of( - context) - .customColor5, + color: FlutterFlowTheme.of(context).customColor5, width: 0.5, ), - borderRadius: - BorderRadius.circular( - 8.0), + borderRadius: BorderRadius.circular(8.0), ), - focusedBorder: - OutlineInputBorder( + focusedBorder: OutlineInputBorder( borderSide: BorderSide( - color: FlutterFlowTheme.of( - context) - .primary, + color: FlutterFlowTheme.of(context).primary, width: 0.5, ), - borderRadius: - BorderRadius.circular( - 8.0), + borderRadius: BorderRadius.circular(8.0), ), errorBorder: OutlineInputBorder( borderSide: BorderSide( - color: FlutterFlowTheme.of( - context) - .error, + color: FlutterFlowTheme.of(context).error, width: 0.5, ), - borderRadius: - BorderRadius.circular( - 8.0), + borderRadius: BorderRadius.circular(8.0), ), - focusedErrorBorder: - OutlineInputBorder( + focusedErrorBorder: OutlineInputBorder( borderSide: BorderSide( - color: FlutterFlowTheme.of( - context) - .error, + color: FlutterFlowTheme.of(context).error, width: 0.5, ), - borderRadius: - BorderRadius.circular( - 8.0), + borderRadius: BorderRadius.circular(8.0), ), suffixIcon: Icon( Icons.date_range, - color: FlutterFlowTheme.of( - context) - .accent1, + color: FlutterFlowTheme.of(context).accent1, ), ), - style: - FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of( - context) - .bodyMediumFamily, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of( - context) - .bodyMediumFamily), + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap() + .containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), fontSize: limitedInputFontSize, - ), + ), textAlign: TextAlign.start, - validator: model - .dateTimeTextControllerValidator - .asValidator(context), + validator: model.dateTimeTextControllerValidator.asValidator(context), ), ), Padding( - padding: const EdgeInsetsDirectional - .fromSTEB(24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, hoverColor: Colors.transparent, - highlightColor: - Colors.transparent, + highlightColor: Colors.transparent, onTap: () async { - final datePickedDate = - await showDatePicker( + final datePickedDate = await showDatePicker( context: context, - initialDate: - getCurrentTimestamp, - firstDate: - (getCurrentTimestamp), + initialDate: getCurrentTimestamp, + firstDate: (getCurrentTimestamp), lastDate: DateTime(2050), builder: (context, child) { return wrapInMaterialDatePickerTheme( context, child!, - headerBackgroundColor: - FlutterFlowTheme.of( - context) - .primary, - headerForegroundColor: - FlutterFlowTheme.of( - context) - .info, + headerBackgroundColor: FlutterFlowTheme.of(context).primary, + headerForegroundColor: FlutterFlowTheme.of(context).info, headerTextStyle: - FlutterFlowTheme.of( - context) - .headlineLarge - .override( - fontFamily: FlutterFlowTheme.of( - context) - .headlineLargeFamily, + FlutterFlowTheme.of(context).headlineLarge.override( + fontFamily: + FlutterFlowTheme.of(context).headlineLargeFamily, fontSize: 32.0, - letterSpacing: - 0.0, - fontWeight: - FontWeight - .w600, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of(context) - .headlineLargeFamily), + letterSpacing: 0.0, + fontWeight: FontWeight.w600, + useGoogleFonts: GoogleFonts.asMap().containsKey( + FlutterFlowTheme.of(context).headlineLargeFamily), ), pickerBackgroundColor: - FlutterFlowTheme.of( - context) - .secondaryBackground, - pickerForegroundColor: - FlutterFlowTheme.of( - context) - .primaryText, + FlutterFlowTheme.of(context).secondaryBackground, + pickerForegroundColor: FlutterFlowTheme.of(context).primaryText, selectedDateTimeBackgroundColor: - FlutterFlowTheme.of( - context) - .primary, + FlutterFlowTheme.of(context).primary, selectedDateTimeForegroundColor: - FlutterFlowTheme.of( - context) - .info, + FlutterFlowTheme.of(context).info, actionButtonForegroundColor: - FlutterFlowTheme.of( - context) - .primaryText, + FlutterFlowTheme.of(context).primaryText, iconSize: 24.0, ); }, @@ -614,77 +432,43 @@ class _ScheduleProvisionalVisitPageWidgetState TimeOfDay? datePickedTime; if (datePickedDate != null) { - datePickedTime = - await showTimePicker( + datePickedTime = await showTimePicker( context: context, - initialTime: - TimeOfDay.fromDateTime( - getCurrentTimestamp), + initialTime: TimeOfDay.fromDateTime(getCurrentTimestamp), builder: (context, child) { return wrapInMaterialTimePickerTheme( context, child!, - headerBackgroundColor: - FlutterFlowTheme.of( - context) - .primary, - headerForegroundColor: - FlutterFlowTheme.of( - context) - .info, + headerBackgroundColor: FlutterFlowTheme.of(context).primary, + headerForegroundColor: FlutterFlowTheme.of(context).info, headerTextStyle: - FlutterFlowTheme.of( - context) - .headlineLarge - .override( - fontFamily: FlutterFlowTheme.of( - context) - .headlineLargeFamily, - fontSize: - 32.0, - letterSpacing: - 0.0, - fontWeight: - FontWeight - .w600, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of(context) - .headlineLargeFamily), + FlutterFlowTheme.of(context).headlineLarge.override( + fontFamily: + FlutterFlowTheme.of(context).headlineLargeFamily, + fontSize: 32.0, + letterSpacing: 0.0, + fontWeight: FontWeight.w600, + useGoogleFonts: GoogleFonts.asMap().containsKey( + FlutterFlowTheme.of(context).headlineLargeFamily), ), pickerBackgroundColor: - FlutterFlowTheme.of( - context) - .secondaryBackground, - pickerForegroundColor: - FlutterFlowTheme.of( - context) - .info, + FlutterFlowTheme.of(context).secondaryBackground, + pickerForegroundColor: FlutterFlowTheme.of(context).info, selectedDateTimeBackgroundColor: - FlutterFlowTheme.of( - context) - .primary, + FlutterFlowTheme.of(context).primary, pickerDialForegroundColor: - FlutterFlowTheme.of( - context) - .primaryText, + FlutterFlowTheme.of(context).primaryText, selectedDateTimeForegroundColor: - FlutterFlowTheme.of( - context) - .info, + FlutterFlowTheme.of(context).info, actionButtonForegroundColor: - FlutterFlowTheme.of( - context) - .primaryText, + FlutterFlowTheme.of(context).primaryText, iconSize: 24.0, ); }, ); } - if (datePickedDate != null && - datePickedTime != null) { + if (datePickedDate != null && datePickedTime != null) { safeSetState(() { model.datePicked = DateTime( datePickedDate.year, @@ -696,35 +480,23 @@ class _ScheduleProvisionalVisitPageWidgetState }); } setState(() { - model.dateTimeTextController - ?.text = dateTimeFormat( + model.datePicked = model.datePicked; + model.dateTimeTextController?.text = dateTimeFormat( "dd/MM/yyyy HH:mm:ss", model.datePicked, - locale: FFLocalizations.of( - context) - .languageCode, + locale: FFLocalizations.of(context).languageCode, ); - - model.dateTimeTextController - ?.selection = - TextSelection.collapsed( - offset: model - .dateTimeTextController! - .text - .length); + model.dateTimeTextController?.selection = TextSelection.collapsed( + offset: model.dateTimeTextController!.text.length); }); }, child: Container( width: double.infinity, height: 50.0, decoration: BoxDecoration( - borderRadius: - BorderRadius.circular( - 8.0), + borderRadius: BorderRadius.circular(8.0), ), - alignment: - const AlignmentDirectional( - 0.0, 0.0), + alignment: const AlignmentDirectional(0.0, 0.0), ), ), ), @@ -734,43 +506,29 @@ class _ScheduleProvisionalVisitPageWidgetState ], ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 0.0, 10.0, 0.0, 10.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 10.0, 0.0, 10.0), child: Column( mainAxisSize: MainAxisSize.max, children: [ Align( - alignment: const AlignmentDirectional( - 0.0, 0.0), + alignment: const AlignmentDirectional(0.0, 0.0), child: Container( decoration: const BoxDecoration(), - alignment: const AlignmentDirectional( - 0.0, 0.0), + alignment: const AlignmentDirectional(0.0, 0.0), child: Align( - alignment: - const AlignmentDirectional( - 0.0, 0.0), + alignment: const AlignmentDirectional(0.0, 0.0), child: Padding( - padding: - const EdgeInsetsDirectional - .fromSTEB( - 24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: SizedBox( width: double.infinity, child: TextFormField( - controller: - model.notesTextController, - focusNode: - model.notesFocusNode, + controller: model.notesTextController, + focusNode: model.notesFocusNode, autofocus: false, showCursor: true, - cursorColor: - FlutterFlowTheme.of( - context) - .primary, - textInputAction: - TextInputAction.next, + cursorColor: FlutterFlowTheme.of(context).primary, + textInputAction: TextInputAction.next, obscureText: false, decoration: InputDecoration( isDense: true, @@ -813,117 +571,61 @@ class _ScheduleProvisionalVisitPageWidgetState .bodyMediumFamily), fontSize: limitedInputFontSize, ), - hintStyle: FlutterFlowTheme - .of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of( - context) - .labelMediumFamily, - color: FlutterFlowTheme - .of(context) - .primaryText, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of( - context) - .labelMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey( + FlutterFlowTheme.of(context).labelMediumFamily), fontSize: limitedInputFontSize, ), - enabledBorder: - OutlineInputBorder( + enabledBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of( - context) - .customColor5, + color: FlutterFlowTheme.of(context).customColor5, width: 0.5, ), - borderRadius: - BorderRadius.circular( - 10.0), + borderRadius: BorderRadius.circular(10.0), ), - focusedBorder: - OutlineInputBorder( + focusedBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of( - context) - .primary, + color: FlutterFlowTheme.of(context).primary, width: 0.5, ), - borderRadius: - BorderRadius.circular( - 10.0), + borderRadius: BorderRadius.circular(10.0), ), - errorBorder: - OutlineInputBorder( + errorBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of( - context) - .error, + color: FlutterFlowTheme.of(context).error, width: 0.5, ), - borderRadius: - BorderRadius.circular( - 10.0), + borderRadius: BorderRadius.circular(10.0), ), - focusedErrorBorder: - OutlineInputBorder( + focusedErrorBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of( - context) - .error, + color: FlutterFlowTheme.of(context).error, width: 0.5, ), - borderRadius: - BorderRadius.circular( - 10.0), + borderRadius: BorderRadius.circular(10.0), ), suffixIcon: Icon( Icons.text_fields, - color: - FlutterFlowTheme.of( - context) - .accent1, + color: FlutterFlowTheme.of(context).accent1, ), ), - style: FlutterFlowTheme.of( - context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of( - context) - .bodyMediumFamily, - color: - FlutterFlowTheme.of( - context) - .primaryText, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of( - context) - .bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap() + .containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), fontSize: limitedInputFontSize, ), textAlign: TextAlign.start, maxLines: 3, maxLength: 100, - maxLengthEnforcement: - MaxLengthEnforcement - .enforced, - validator: model - .notesTextControllerValidator - .asValidator(context), + maxLengthEnforcement: MaxLengthEnforcement.enforced, + validator: model.notesTextControllerValidator.asValidator(context), ), ), ), @@ -942,60 +644,46 @@ class _ScheduleProvisionalVisitPageWidgetState ? null : () async { try { - model.provVisitSchedule = await PhpGroup - .postProvVisitSchedulingCall - .call( - data: model.dateTimeTextController.text, + model.provVisitSchedule = await PhpGroup.postProvVisitSchedulingCall.call( + data: DateFormat('dd/MM/yyyy HH:mm:ss').format(DateFormat('dd/MM/yyyy HH:mm:ss') + .parse(model.dateTimeTextController.text) + .add(const Duration(hours: 3))), motivo: model.notesTextController.text, nome: model.personNameTextController.text, proID: model.ownerUUID, ); - if (PhpGroup.postProvVisitSchedulingCall - .error((model.provVisitSchedule - ?.jsonBody ?? - '')) == + .error((model.provVisitSchedule?.jsonBody ?? '')) == false) { DialogUtil.success( context, FFLocalizations.of(context).getVariableText( - ptText: - "Agendamento Provisório Realizado com Sucesso!", - enText: - "Provisional Scheduling Successfully Completed")); + ptText: "Agendamento Provisório Realizado com Sucesso!", + enText: "Provisional Scheduling Successfully Completed", + )); safeSetState(() { model.dateTimeTextController?.clear(); - model.personNameTextController?.clear(); model.notesTextController?.clear(); }); } else { - var message = PhpGroup - .postProvVisitSchedulingCall - .msg((model.provVisitSchedule - ?.jsonBody ?? - '')); + var message = PhpGroup.postProvVisitSchedulingCall + .msg((model.provVisitSchedule?.jsonBody ?? '')); if (message != null) { DialogUtil.error(context, message); } else { DialogUtil.errorDefault(context); } } - setState(() {}); } catch (e, s) { DialogUtil.errorDefault(context); LogUtil.requestAPIFailed( - "processRequest.php", - "", - "Cadastrar Visita Provisória", - e, - s); + "processRequest.php", "", "Cadastrar Visita Provisória", e, s); } }, showLoadingIndicator: true, - text: FFLocalizations.of(context) - .getText('bv5fg9sv' /* Enviar */), + text: FFLocalizations.of(context).getText('bv5fg9sv'), options: FFButtonOptions( height: 30.0 * MediaQuery.textScalerOf(context).scale(1), @@ -1004,27 +692,19 @@ class _ScheduleProvisionalVisitPageWidgetState iconPadding: const EdgeInsetsDirectional.fromSTEB( 0.0, 0.0, 0.0, 0.0), color: FlutterFlowTheme.of(context).primary, - textStyle: FlutterFlowTheme.of(context) - .titleSmall - .override( - fontFamily: FlutterFlowTheme.of(context) - .titleSmallFamily, + textStyle: FlutterFlowTheme.of(context).titleSmall.override( + fontFamily: FlutterFlowTheme.of(context).titleSmallFamily, color: Colors.white, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey(FlutterFlowTheme.of(context) - .titleSmallFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).titleSmallFamily), fontSize: limitedInputFontSize, ), elevation: 3.0, - borderSide: const BorderSide( - color: Colors.transparent, - width: 1.0, - ), + borderSide: const BorderSide(color: Colors.transparent, width: 1.0), borderRadius: BorderRadius.circular(8.0), - disabledColor: - FlutterFlowTheme.of(context).customColor5, + disabledColor: FlutterFlowTheme.of(context).customColor5, disabledTextColor: Colors.white, ), ), @@ -1034,9 +714,7 @@ class _ScheduleProvisionalVisitPageWidgetState ), ], ), - ] - .addToStart(const SizedBox(height: 4.0)) - .addToEnd(const SizedBox(height: 40.0)), + ].addToStart(const SizedBox(height: 4.0)).addToEnd(const SizedBox(height: 40.0)), ), ), ); diff --git a/lib/components/templates_components/qr_code_pass_key_template_component/qr_code_pass_key_template_component_model.dart b/lib/components/templates_components/qr_code_pass_key_template_component/qr_code_pass_key_template_component_model.dart index 7d6efd50..b9b9a341 100644 --- a/lib/components/templates_components/qr_code_pass_key_template_component/qr_code_pass_key_template_component_model.dart +++ b/lib/components/templates_components/qr_code_pass_key_template_component/qr_code_pass_key_template_component_model.dart @@ -1,10 +1,8 @@ import '/flutter_flow/flutter_flow_util.dart'; -import 'qr_code_pass_key_template_component_widget.dart' - show QrCodePassKeyTemplateComponentWidget; +import 'qr_code_pass_key_template_component_widget.dart' show QrCodePassKeyTemplateComponentWidget; import 'package:flutter/material.dart'; -class QrCodePassKeyTemplateComponentModel - extends FlutterFlowModel { +class QrCodePassKeyTemplateComponentModel extends FlutterFlowModel { /// State fields for stateful widgets in this component. final formKey = GlobalKey(); @@ -13,19 +11,18 @@ class QrCodePassKeyTemplateComponentModel TextEditingController? keyTextFieldTextController; late bool keyTextFieldVisibility; String? Function(BuildContext, String?)? keyTextFieldTextControllerValidator; - String? _keyTextFieldTextControllerValidator( - BuildContext context, String? val) { + String? _keyTextFieldTextControllerValidator(BuildContext context, String? val) { if (val == null || val.isEmpty) { return FFLocalizations.of(context).getVariableText( enText: 'This field is required', - ptText: 'Este campo é obrigatório', + ptText: 'Este campo é obrigatório', ); } if (val.length < 4) { return FFLocalizations.of(context).getVariableText( - enText: 'This field must be at least 4 characters', - ptText: 'Este campo deve ter pelo menos 4 caracteres', - ); + enText: 'This field must be at least 4 characters', + ptText: 'Este campo deve ter pelo menos 4 caracteres', + ); } return null; diff --git a/lib/components/templates_components/qr_code_pass_key_template_component/qr_code_pass_key_template_component_widget.dart b/lib/components/templates_components/qr_code_pass_key_template_component/qr_code_pass_key_template_component_widget.dart index 9a008778..c407fb42 100644 --- a/lib/components/templates_components/qr_code_pass_key_template_component/qr_code_pass_key_template_component_widget.dart +++ b/lib/components/templates_components/qr_code_pass_key_template_component/qr_code_pass_key_template_component_widget.dart @@ -20,12 +20,10 @@ class QrCodePassKeyTemplateComponentWidget extends StatefulWidget { final Future Function(String key)? toggleActionStatus; @override - State createState() => - _QrCodePassKeyTemplateComponentWidgetState(); + State createState() => _QrCodePassKeyTemplateComponentWidgetState(); } -class _QrCodePassKeyTemplateComponentWidgetState - extends State { +class _QrCodePassKeyTemplateComponentWidgetState extends State { late QrCodePassKeyTemplateComponentModel _model; @override @@ -242,18 +240,14 @@ class _QrCodePassKeyTemplateComponentWidgetState ), filled: true, fillColor: FlutterFlowTheme.of(context).primaryBackground, - contentPadding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 24.0, 20.0, 24.0), + contentPadding: const EdgeInsetsDirectional.fromSTEB(24.0, 24.0, 20.0, 24.0), suffixIcon: InkWell( onTap: () => safeSetState( - () => _model.keyTextFieldVisibility = - !_model.keyTextFieldVisibility, + () => _model.keyTextFieldVisibility = !_model.keyTextFieldVisibility, ), focusNode: FocusNode(skipTraversal: true), child: Icon( - _model.keyTextFieldVisibility - ? Icons.visibility_outlined - : Icons.visibility_off_outlined, + _model.keyTextFieldVisibility ? Icons.visibility_outlined : Icons.visibility_off_outlined, color: FlutterFlowTheme.of(context).accent1, size: 22.0, ), @@ -265,19 +259,13 @@ class _QrCodePassKeyTemplateComponentWidgetState fontSize: LimitedFontSizeUtil.getInputFontSize(context), letterSpacing: 0.0, fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts.asMap() - .containsKey('Plus Jakarta Sans'), + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), maxLength: 4, maxLengthEnforcement: MaxLengthEnforcement.enforced, - buildCounter: (context, - {required currentLength, - required isFocused, - maxLength}) => - null, + buildCounter: (context, {required currentLength, required isFocused, maxLength}) => null, keyboardType: TextInputType.number, - validator: _model.keyTextFieldTextControllerValidator - .asValidator(context), + validator: _model.keyTextFieldTextControllerValidator.asValidator(context), inputFormatters: [ FilteringTextInputFormatter.allow(RegExp('[0-9]')), LengthLimitingTextInputFormatter(4), diff --git a/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart b/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart index 02d829df..362efe87 100644 --- a/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart +++ b/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_model.dart @@ -1,7 +1,8 @@ import 'dart:async'; import 'package:flutter/material.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/utils/validator_util.dart'; import '/backend/api_requests/api_calls.dart'; @@ -9,8 +10,7 @@ import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/form_field_controller.dart'; import 'regisiter_vistor_template_component_widget.dart'; -class RegisiterVistorTemplateComponentModel - extends FlutterFlowModel { +class RegisiterVistorTemplateComponentModel extends FlutterFlowModel { Timer? _debounceTimer; late final String devUUID; late final String userUUID; @@ -18,8 +18,7 @@ class RegisiterVistorTemplateComponentModel final unfocusNode = FocusNode(); bool isDataUploading = false; - FFUploadedFile uploadedLocalFile = - FFUploadedFile(bytes: Uint8List.fromList([])); + FFUploadedFile uploadedLocalFile = FFUploadedFile(bytes: Uint8List.fromList([])); void debounce(Function() fn, Duration time) { if (_debounceTimer != null) { @@ -43,14 +42,12 @@ class RegisiterVistorTemplateComponentModel return null; } - Future getVisitanteByDocument( - String document, BuildContext context) async { + Future getVisitanteByDocument(String document, BuildContext context) async { final response = await PhpGroup.getVisitorByDocCall.call( documento: document, ); - if (response.jsonBody['visitante']['VTE_ID'] != '0' && - response.jsonBody['error'] != 'false') { + if (response.jsonBody['visitante']['VTE_ID'] != '0' && response.jsonBody['error'] != 'false') { return true; } return false; @@ -93,9 +90,7 @@ class RegisiterVistorTemplateComponentModel TextEditingController? textController4; String? Function(BuildContext, String?)? textController4Validator; String? _textController4Validator(BuildContext context, String? val) { - if (val != null && - val.isNotEmpty && - ValidatorUtil.isValidEmail(val) == false) { + if (val != null && val.isNotEmpty && ValidatorUtil.isValidEmail(val) == false) { return FFLocalizations.of(context).getVariableText( enText: 'Invalid email', ptText: 'Email inválido', @@ -134,9 +129,10 @@ class RegisiterVistorTemplateComponentModel } Future initializeDatabase() async { - devUUID = StorageUtil().devUUID; - userUUID = StorageUtil().userUUID; - cliUUID = StorageUtil().cliUUID; + devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + ; } @override diff --git a/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_widget.dart b/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_widget.dart index 3a3850fd..3300856b 100644 --- a/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_widget.dart +++ b/lib/components/templates_components/regisiter_vistor_template_component/regisiter_vistor_template_component_widget.dart @@ -24,16 +24,13 @@ class RegisiterVistorTemplateComponentWidget extends StatefulWidget { final String source; final String? doc; - const RegisiterVistorTemplateComponentWidget( - {super.key, required this.source, this.doc}); + const RegisiterVistorTemplateComponentWidget({super.key, required this.source, this.doc}); @override - State createState() => - _RegisiterVistorTemplateComponentWidgetState(); + State createState() => _RegisiterVistorTemplateComponentWidgetState(); } -class _RegisiterVistorTemplateComponentWidgetState - extends State { +class _RegisiterVistorTemplateComponentWidgetState extends State { late RegisiterVistorTemplateComponentModel _model; bool _isLoading = false; final scaffoldKey = GlobalKey(); @@ -53,8 +50,7 @@ class _RegisiterVistorTemplateComponentWidgetState visitorAlreadyRegistered = BehaviorSubject.seeded(false); - _model = - createModel(context, () => RegisiterVistorTemplateComponentModel()); + _model = createModel(context, () => RegisiterVistorTemplateComponentModel()); _model.textController1 ??= TextEditingController(); _model.textFieldFocusNode1 ??= FocusNode(); @@ -91,19 +87,15 @@ class _RegisiterVistorTemplateComponentWidgetState return false; } - if (_model.textController1.text.isEmpty || - _model.textController1.text == '') { + if (_model.textController1.text.isEmpty || _model.textController1.text == '') { return false; } - if (_model.dropDownValue == null || - _model.dropDownValue!.isEmpty || - _model.dropDownValue == '') { + if (_model.dropDownValue == null || _model.dropDownValue!.isEmpty || _model.dropDownValue == '') { return false; } - if (_model.textController2.text.isEmpty || - _model.textController2.text == '') { + if (_model.textController2.text.isEmpty || _model.textController2.text == '') { return false; } @@ -161,19 +153,17 @@ class _RegisiterVistorTemplateComponentWidgetState overflow: TextOverflow.clip, textAlign: TextAlign.start, style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), fontSize: limitedHeaderFontSize, ), ), ), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: Column(children: [ TextFormField( controller: _model.textController2, @@ -192,16 +182,12 @@ class _RegisiterVistorTemplateComponentWidgetState labelText: FFLocalizations.of(context).getText( 'rl8tvwnr' /* Documento */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), fontSize: limitedInputFontSize, ), hintStyle: @@ -252,8 +238,7 @@ class _RegisiterVistorTemplateComponentWidgetState ), ), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap().containsKey( @@ -262,15 +247,13 @@ class _RegisiterVistorTemplateComponentWidgetState ), onChanged: (value) { _model.debounce(() async { - var data = await _model.getVisitanteByDocument( - value, context); + var data = await _model.getVisitanteByDocument(value, context); setState(() { _isVisitorRegistered = data; }); }, const Duration(milliseconds: 500)); }, - validator: - _model.textController2Validator.asValidator(context), + validator: _model.textController2Validator.asValidator(context), inputFormatters: [ FilteringTextInputFormatter.allow(RegExp('[0-9]')), LengthLimitingTextInputFormatter(20) @@ -284,29 +267,17 @@ class _RegisiterVistorTemplateComponentWidgetState mainAxisAlignment: MainAxisAlignment.start, children: [ Padding( - padding: const EdgeInsetsDirectional.only( - top: 5, start: 12), + padding: const EdgeInsetsDirectional.only(top: 5, start: 12), child: Text( - FFLocalizations.of(context) - .getVariableText( + FFLocalizations.of(context).getVariableText( enText: 'Visitor already registered', ptText: 'Visitante já cadastrado', ), - style: FlutterFlowTheme.of(context) - .labelSmall - .override( + style: FlutterFlowTheme.of(context).labelSmall.override( fontFamily: 'Nunito', - color: Theme.of(context) - .brightness == - Brightness.dark - ? Color.alphaBlend( - Colors.white - .withOpacity(0.7), - Colors.red) - : Color.alphaBlend( - Colors.black - .withOpacity(0.25), - Colors.red), + color: Theme.of(context).brightness == Brightness.dark + ? Color.alphaBlend(Colors.white.withOpacity(0.7), Colors.red) + : Color.alphaBlend(Colors.black.withOpacity(0.25), Colors.red), fontSize: limitedInputFontSize, letterSpacing: 0.0, )), @@ -317,8 +288,7 @@ class _RegisiterVistorTemplateComponentWidgetState ]), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: TextFormField( controller: _model.textController1, autovalidateMode: AutovalidateMode.onUserInteraction, @@ -337,26 +307,20 @@ class _RegisiterVistorTemplateComponentWidgetState labelText: FFLocalizations.of(context).getText( 'v7g73yik' /* Nome */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), fontSize: limitedInputFontSize, ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), fontSize: limitedInputFontSize, ), enabledBorder: OutlineInputBorder( @@ -397,30 +361,26 @@ class _RegisiterVistorTemplateComponentWidgetState ), ), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), fontSize: limitedInputFontSize, ), maxLines: null, maxLength: 80, keyboardType: TextInputType.name, inputFormatters: [LengthLimitingTextInputFormatter(80)], - validator: - _model.textController1Validator.asValidator(context), + validator: _model.textController1Validator.asValidator(context), ), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 10.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 10.0), child: Column( children: [ FlutterFlowDropDown( - controller: _model.dropDownValueController ??= - FormFieldController(null), + controller: _model.dropDownValueController ??= FormFieldController(null), options: [ FFLocalizations.of(context).getText( 'n8vddmcq' /* Visitante */, @@ -429,20 +389,15 @@ class _RegisiterVistorTemplateComponentWidgetState '9luaa09e' /* Prestador de Serviço */, ) ], - onChanged: (val) => - setState(() => _model.dropDownValue = val), + onChanged: (val) => setState(() => _model.dropDownValue = val), width: MediaQuery.sizeOf(context).width * 0.9, // height: 44.0, - textStyle: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + textStyle: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), fontSize: limitedInputFontSize, ), hintText: FFLocalizations.of(context).getVariableText( @@ -458,39 +413,30 @@ class _RegisiterVistorTemplateComponentWidgetState borderColor: FlutterFlowTheme.of(context).customColor6, borderWidth: 0.5, borderRadius: 8.0, - margin: const EdgeInsetsDirectional.fromSTEB( - 16.0, 0.0, 16.0, 0.0), + margin: const EdgeInsetsDirectional.fromSTEB(16.0, 0.0, 16.0, 0.0), hidesUnderline: true, isOverButton: true, isSearchable: false, isMultiSelect: false, ), - if (_model.dropDownValue == null || - _model.dropDownValue == '') + if (_model.dropDownValue == null || _model.dropDownValue == '') Row( mainAxisAlignment: MainAxisAlignment.start, mainAxisSize: MainAxisSize.max, children: [ Padding( - padding: const EdgeInsetsDirectional.only( - top: 5, start: 15), + padding: const EdgeInsetsDirectional.only(top: 5, start: 15), child: Text( FFLocalizations.of(context).getVariableText( enText: 'Select the type of visitor', ptText: 'Selecione o tipo de visitante', ), - style: FlutterFlowTheme.of(context) - .bodySmall - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodySmallFamily, - color: FlutterFlowTheme.of(context) - .customColor6, + style: FlutterFlowTheme.of(context).bodySmall.override( + fontFamily: FlutterFlowTheme.of(context).bodySmallFamily, + color: FlutterFlowTheme.of(context).customColor6, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .bodySmallFamily), + .containsKey(FlutterFlowTheme.of(context).bodySmallFamily), fontSize: limitedInputFontSize, )), ), @@ -500,12 +446,10 @@ class _RegisiterVistorTemplateComponentWidgetState ), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: Builder( builder: (context) { - if ((_model.uploadedLocalFile.bytes?.isNotEmpty ?? - false)) { + if ((_model.uploadedLocalFile.bytes?.isNotEmpty ?? false)) { return InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, @@ -514,15 +458,13 @@ class _RegisiterVistorTemplateComponentWidgetState onTap: () async { setState(() { _model.isDataUploading = false; - _model.uploadedLocalFile = - FFUploadedFile(bytes: Uint8List.fromList([])); + _model.uploadedLocalFile = FFUploadedFile(bytes: Uint8List.fromList([])); }); }, child: ClipRRect( borderRadius: BorderRadius.circular(8.0), child: Image.memory( - _model.uploadedLocalFile.bytes ?? - Uint8List.fromList([]), + _model.uploadedLocalFile.bytes ?? Uint8List.fromList([]), width: 300.0, height: 200.0, fit: BoxFit.cover, @@ -553,27 +495,24 @@ class _RegisiterVistorTemplateComponentWidgetState Align( alignment: const AlignmentDirectional(-1.0, 0.0), child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 20.0, 10.0, 0.0, 15.0), + padding: const EdgeInsetsDirectional.fromSTEB(20.0, 10.0, 0.0, 15.0), child: Text( FFLocalizations.of(context).getText( 'bqpucwh0' /* Contatos */, ), textAlign: TextAlign.start, style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), fontSize: limitedSubHeaderFontSize, ), ), ), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: TextFormField( controller: _model.textController3, focusNode: _model.textFieldFocusNode3, @@ -585,8 +524,7 @@ class _RegisiterVistorTemplateComponentWidgetState maxLength: 25, keyboardType: TextInputType.phone, inputFormatters: [ - FilteringTextInputFormatter.allow( - RegExp('[0-9, +, -, (, )]')), + FilteringTextInputFormatter.allow(RegExp('[0-9, +, -, (, )]')), LengthLimitingTextInputFormatter(25) ], obscureText: false, @@ -596,26 +534,20 @@ class _RegisiterVistorTemplateComponentWidgetState labelText: FFLocalizations.of(context).getText( 'h84ls2r6' /* Telefone */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), fontSize: limitedInputFontSize, ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), fontSize: limitedInputFontSize, ), enabledBorder: OutlineInputBorder( @@ -652,12 +584,11 @@ class _RegisiterVistorTemplateComponentWidgetState ), ), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), fontSize: limitedInputFontSize, ), // validator: @@ -665,8 +596,7 @@ class _RegisiterVistorTemplateComponentWidgetState ), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), child: TextFormField( controller: _model.textController4, cursorColor: FlutterFlowTheme.of(context).primary, @@ -686,26 +616,20 @@ class _RegisiterVistorTemplateComponentWidgetState labelText: FFLocalizations.of(context).getText( 'fqp7qmka' /* Email */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), fontSize: limitedInputFontSize, ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), fontSize: limitedInputFontSize, ), enabledBorder: OutlineInputBorder( @@ -742,33 +666,28 @@ class _RegisiterVistorTemplateComponentWidgetState ), ), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), fontSize: limitedInputFontSize, ), keyboardType: TextInputType.emailAddress, inputFormatters: [LengthLimitingTextInputFormatter(80)], - validator: - _model.textController4Validator.asValidator(context), + validator: _model.textController4Validator.asValidator(context), ), ), Padding( - padding: - const EdgeInsetsDirectional.fromSTEB(0.0, 65.0, 0.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 65.0, 0.0, 0.0), child: FFButtonWidget( onPressed: _isFormValid(context) ? () async { - _model.imgBase64 = - await ImageUtils.convertImageFileToBase64( + _model.imgBase64 = await ImageUtils.convertImageFileToBase64( _model.uploadedLocalFile, ); - _model.scheduleVisitor = - await PhpGroup.postScheduleVisitorCall - .call( + _model.scheduleVisitor = await PhpGroup.postScheduleVisitorCall + .call( documento: _model.textController2.text, nome: _model.textController1.text, tipo: _model.dropDownValue == @@ -779,7 +698,7 @@ class _RegisiterVistorTemplateComponentWidgetState : 'P', foto: 'base64;jpeg,${_model.imgBase64}', ) - .onError((e, s) async { + .onError((e, s) async { return await DialogUtil.errorDefault(context); }); if (PhpGroup.postScheduleVisitorCall.error( @@ -792,24 +711,18 @@ class _RegisiterVistorTemplateComponentWidgetState _model.textController3?.clear(); _model.textController4?.clear(); _model.dropDownValueController?.reset(); - _model.uploadedLocalFile = FFUploadedFile( - bytes: Uint8List.fromList([])); + _model.uploadedLocalFile = FFUploadedFile(bytes: Uint8List.fromList([])); ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( FFLocalizations.of(context).getVariableText( - ptText: - 'Visitante cadastrado com sucesso.', - enText: - 'Visitor successfully registered.'), - style: TextStyle( - color: FlutterFlowTheme.of(context) - .info, + ptText: 'Visitante cadastrado com sucesso.', + enText: 'Visitor successfully registered.'), + style: TextStyle(color: FlutterFlowTheme.of(context).info, ) ), - backgroundColor: - FlutterFlowTheme.of(context).primary, + backgroundColor: FlutterFlowTheme.of(context).primary, duration: const Duration(seconds: 3), width: MediaQuery.of(context).size.width, behavior: SnackBarBehavior.floating, @@ -822,27 +735,20 @@ class _RegisiterVistorTemplateComponentWidgetState ), ); _formKey.currentState?.reset(); - if (widget.source == - 'VisitorNotFoundComponent') { + if (widget.source == 'VisitorNotFoundComponent') { Navigator.pop(context, true); } }); } else { return DialogUtil.error( context, - PhpGroup.postScheduleVisitorCall.errorMsg( - _model - .scheduleVisitor?.jsonBody) == - null - ? FFLocalizations.of(context) - .getVariableText( - ptText: - 'Erro ao se conectar com o servidor', + PhpGroup.postScheduleVisitorCall.errorMsg(_model.scheduleVisitor?.jsonBody) == null + ? FFLocalizations.of(context).getVariableText( + ptText: 'Erro ao se conectar com o servidor', enText: 'Error connecting to server', ) : PhpGroup.postScheduleVisitorCall - .errorMsg( - _model.scheduleVisitor?.jsonBody) + .errorMsg(_model.scheduleVisitor?.jsonBody) .toString()); } } @@ -853,20 +759,15 @@ class _RegisiterVistorTemplateComponentWidgetState options: FFButtonOptions( height: 30.0 * MediaQuery.textScalerOf(context).scale(1), disabledColor: FlutterFlowTheme.of(context).customColor5, - padding: const EdgeInsetsDirectional.fromSTEB( - 80.0, 0.0, 80.0, 0.0), - iconPadding: const EdgeInsetsDirectional.fromSTEB( - 0.0, 0.0, 0.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(80.0, 0.0, 80.0, 0.0), + iconPadding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), color: FlutterFlowTheme.of(context).primary, - textStyle: FlutterFlowTheme.of(context) - .titleSmall - .override( - fontFamily: - FlutterFlowTheme.of(context).titleSmallFamily, + textStyle: FlutterFlowTheme.of(context).titleSmall.override( + fontFamily: FlutterFlowTheme.of(context).titleSmallFamily, color: FlutterFlowTheme.of(context).info, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).titleSmallFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).titleSmallFamily), fontSize: limitedInputFontSize, ), borderSide: const BorderSide( diff --git a/lib/components/templates_components/sign_in_template_component/sign_in_template_component_model.dart b/lib/components/templates_components/sign_in_template_component/sign_in_template_component_model.dart index 21b10011..8614bf00 100644 --- a/lib/components/templates_components/sign_in_template_component/sign_in_template_component_model.dart +++ b/lib/components/templates_components/sign_in_template_component/sign_in_template_component_model.dart @@ -1,12 +1,9 @@ import 'package:flutter/material.dart'; import '/flutter_flow/flutter_flow_util.dart'; -import 'sign_in_template_component_widget.dart' - show SignInTemplateComponentWidget; - -class SignInTemplateComponentModel - extends FlutterFlowModel { +import 'sign_in_template_component_widget.dart' show SignInTemplateComponentWidget; +class SignInTemplateComponentModel extends FlutterFlowModel { final formKey = GlobalKey(); final unfocusNode = FocusNode(); FocusNode? emailAddressFocusNode; @@ -27,6 +24,7 @@ class SignInTemplateComponentModel } return null; } + FocusNode? passwordFocusNode; TextEditingController? passwordTextController; late bool passwordVisibility; @@ -41,11 +39,6 @@ class SignInTemplateComponentModel return null; } - - - - - @override void initState(BuildContext context) { emailAddressTextControllerValidator = _emailAddressTextControllerValidator; diff --git a/lib/components/templates_components/sign_in_template_component/sign_in_template_component_widget.dart b/lib/components/templates_components/sign_in_template_component/sign_in_template_component_widget.dart index 53d731eb..ea6993ef 100644 --- a/lib/components/templates_components/sign_in_template_component/sign_in_template_component_widget.dart +++ b/lib/components/templates_components/sign_in_template_component/sign_in_template_component_widget.dart @@ -28,12 +28,10 @@ class SignInTemplateComponentWidget extends StatefulWidget { final Future Function()? toggleSignUpPage; @override - State createState() => - _SignInTemplateComponentWidgetState(); + State createState() => _SignInTemplateComponentWidgetState(); } -class _SignInTemplateComponentWidgetState - extends State with TickerProviderStateMixin { +class _SignInTemplateComponentWidgetState extends State with TickerProviderStateMixin { late SignInTemplateComponentModel _model; final animationsMap = {}; diff --git a/lib/components/templates_components/sign_up_template_component/sign_up_template_component_model.dart b/lib/components/templates_components/sign_up_template_component/sign_up_template_component_model.dart index c07deb16..b6ed0b93 100644 --- a/lib/components/templates_components/sign_up_template_component/sign_up_template_component_model.dart +++ b/lib/components/templates_components/sign_up_template_component/sign_up_template_component_model.dart @@ -1,12 +1,9 @@ import 'package:flutter/material.dart'; import '/flutter_flow/flutter_flow_util.dart'; -import 'sign_up_template_component_widget.dart' - show SignUpTemplateComponentWidget; - -class SignUpTemplateComponentModel - extends FlutterFlowModel { +import 'sign_up_template_component_widget.dart' show SignUpTemplateComponentWidget; +class SignUpTemplateComponentModel extends FlutterFlowModel { final formKey = GlobalKey(); FocusNode? nameRegisterFormFocusNode; TextEditingController? nameRegisterFormTextController; @@ -80,7 +77,4 @@ class SignUpTemplateComponentModel passwordRegisterFormFocusNode?.dispose(); passwordRegisterFormTextController?.dispose(); } - - - } diff --git a/lib/components/templates_components/sign_up_template_component/sign_up_template_component_widget.dart b/lib/components/templates_components/sign_up_template_component/sign_up_template_component_widget.dart index 5b133d1e..7a25bb5f 100644 --- a/lib/components/templates_components/sign_up_template_component/sign_up_template_component_widget.dart +++ b/lib/components/templates_components/sign_up_template_component/sign_up_template_component_widget.dart @@ -5,7 +5,8 @@ import 'package:google_fonts/google_fonts.dart'; import 'package:hub/components/atomic_components/shared_components_atoms/atom_image_svg_theme.dart'; import 'package:hub/shared/components/atoms/atom_terms_of_use.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/utils/validator_util.dart'; import '/flutter_flow/flutter_flow_animations.dart'; @@ -22,14 +23,14 @@ class SignUpTemplateComponentWidget extends StatefulWidget { {super.key, required this.toggleSignInPage}); final Future Function()? toggleSignInPage; @override - State createState() => - _SignUpTemplateComponentWidgetState(); + State createState() => _SignUpTemplateComponentWidgetState(); } class _SignUpTemplateComponentWidgetState extends State with TickerProviderStateMixin { late SignUpTemplateComponentModel _model; final animationsMap = {}; + late String _deviceType; @override void setState(VoidCallback callback) { @@ -87,6 +88,12 @@ class _SignUpTemplateComponentWidgetState ], ), }); + + _initialize(); + } + + Future _initialize() async { + _deviceType = (await StorageHelper().get(SecureStorageKey.deviceType.value, Storage.SecureStorage)) ?? ''; } @override @@ -112,13 +119,11 @@ class _SignUpTemplateComponentWidgetState return true; } - if (!ValidatorUtil.isValidEmail( - _model.emailRegisterFormTextController.text)) { + if (!ValidatorUtil.isValidEmail(_model.emailRegisterFormTextController.text)) { return true; } - if (!ValidatorUtil.isValidPassword( - _model.passwordRegisterFormTextController.text)) { + if (!ValidatorUtil.isValidPassword(_model.passwordRegisterFormTextController.text)) { return true; } @@ -197,8 +202,7 @@ class _SignUpTemplateComponentWidgetState maxWidth: 570.0, ), decoration: BoxDecoration( - color: FlutterFlowTheme.of(context) - .primaryBackground, + color: FlutterFlowTheme.of(context).primaryBackground, borderRadius: BorderRadius.circular(12.0), ), child: Align( @@ -207,107 +211,64 @@ class _SignUpTemplateComponentWidgetState padding: const EdgeInsets.all(32.0), child: Column( mainAxisSize: MainAxisSize.max, - crossAxisAlignment: - CrossAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, children: [ Form( key: _model.formKey, - autovalidateMode: - AutovalidateMode.onUserInteraction, + autovalidateMode: AutovalidateMode.onUserInteraction, child: Column( mainAxisSize: MainAxisSize.max, children: [ Padding( - padding: - const EdgeInsetsDirectional - .fromSTEB( - 0.0, 0.0, 0.0, 16.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 16.0), child: SizedBox( width: double.infinity, child: TextFormField( - key: const ValueKey( - 'nameTextFormField'), - controller: _model - .nameRegisterFormTextController, - focusNode: _model - .nameRegisterFormFocusNode, - onChanged: (_) => - EasyDebounce.debounce( + key: const ValueKey('nameTextFormField'), + controller: _model.nameRegisterFormTextController, + focusNode: _model.nameRegisterFormFocusNode, + onChanged: (_) => EasyDebounce.debounce( '_model.nameRegisterFormTextController', - const Duration( - milliseconds: 500), + const Duration(milliseconds: 500), () => setState(() {}), ), autofocus: false, - autofillHints: const [ - AutofillHints.name - ], + autofillHints: const [AutofillHints.name], obscureText: false, decoration: InputDecoration( isDense: true, - labelText: - FFLocalizations.of( - context) - .getText( + labelText: FFLocalizations.of(context).getText( '3corpwhd' /* Nome */, ), - labelStyle: FlutterFlowTheme - .of(context) - .labelLarge - .override( - fontFamily: - 'Plus Jakarta Sans', - color: FlutterFlowTheme - .of(context) - .primaryText, + labelStyle: FlutterFlowTheme.of(context).labelLarge.override( + fontFamily: 'Plus Jakarta Sans', + color: FlutterFlowTheme.of(context).primaryText, fontSize: limitedInputFontSize, letterSpacing: 0.0, - fontWeight: - FontWeight.w500, + fontWeight: FontWeight.w500, useGoogleFonts: - GoogleFonts - .asMap() - .containsKey( - 'Plus Jakarta Sans'), + GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), - enabledBorder: - OutlineInputBorder( + enabledBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of( - context) - .customColor1, + color: FlutterFlowTheme.of(context).customColor1, width: 0.25, ), - borderRadius: - BorderRadius.circular( - 12.0), + borderRadius: BorderRadius.circular(12.0), ), - focusedBorder: - OutlineInputBorder( + focusedBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of( - context) - .success, + color: FlutterFlowTheme.of(context).success, width: 0.25, ), - borderRadius: - BorderRadius.circular( - 12.0), + borderRadius: BorderRadius.circular(12.0), ), - errorBorder: - OutlineInputBorder( + errorBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of( - context) - .error, + color: FlutterFlowTheme.of(context).error, width: 0.25, ), - borderRadius: - BorderRadius.circular( - 12.0), + borderRadius: BorderRadius.circular(12.0), ), errorStyle: TextStyle( fontFamily: @@ -323,146 +284,83 @@ class _SignUpTemplateComponentWidgetState focusedErrorBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of( - context) - .error, + color: FlutterFlowTheme.of(context).error, width: 0.25, ), - borderRadius: - BorderRadius.circular( - 12.0), + borderRadius: BorderRadius.circular(12.0), ), filled: true, - fillColor: - FlutterFlowTheme.of( - context) - .primaryBackground, + fillColor: FlutterFlowTheme.of(context).primaryBackground, suffixIcon: Icon( Icons.person, - color: - FlutterFlowTheme.of( - context) - .accent1, + color: FlutterFlowTheme.of(context).accent1, size: 22.0, ), ), - style: FlutterFlowTheme.of( - context) - .bodyLarge - .override( - fontFamily: - 'Plus Jakarta Sans', - color: - FlutterFlowTheme.of( - context) - .primaryText, + style: FlutterFlowTheme.of(context).bodyLarge.override( + fontFamily: 'Plus Jakarta Sans', + color: FlutterFlowTheme.of(context).primaryText, fontSize: limitedInputFontSize, letterSpacing: 0.0, - fontWeight: - FontWeight.w500, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - 'Plus Jakarta Sans'), + fontWeight: FontWeight.w500, + useGoogleFonts: + GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), - validator: _model - .nameRegisterFormTextControllerValidator + validator: _model.nameRegisterFormTextControllerValidator .asValidator(context), ), ), ), Padding( - padding: - const EdgeInsetsDirectional - .fromSTEB( - 0.0, 0.0, 0.0, 16.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 16.0), child: SizedBox( width: double.infinity, child: TextFormField( - key: const ValueKey( - 'emailTextFormField'), - controller: _model - .emailRegisterFormTextController, - focusNode: _model - .emailRegisterFormFocusNode, - onChanged: (_) => - EasyDebounce.debounce( + key: const ValueKey('emailTextFormField'), + controller: _model.emailRegisterFormTextController, + focusNode: _model.emailRegisterFormFocusNode, + onChanged: (_) => EasyDebounce.debounce( '_model.emailRegisterFormTextController', - const Duration( - milliseconds: 500), + const Duration(milliseconds: 500), () => setState(() {}), ), autofocus: false, - autofillHints: const [ - AutofillHints.email - ], + autofillHints: const [AutofillHints.email], obscureText: false, decoration: InputDecoration( isDense: true, - labelText: - FFLocalizations.of( - context) - .getText( + labelText: FFLocalizations.of(context).getText( '80wonb69' /* Email */, ), - labelStyle: FlutterFlowTheme - .of(context) - .labelLarge - .override( - fontFamily: - 'Plus Jakarta Sans', - color: FlutterFlowTheme - .of(context) - .primaryText, + labelStyle: FlutterFlowTheme.of(context).labelLarge.override( + fontFamily: 'Plus Jakarta Sans', + color: FlutterFlowTheme.of(context).primaryText, fontSize: limitedInputFontSize, letterSpacing: 0.0, - fontWeight: - FontWeight.w500, + fontWeight: FontWeight.w500, useGoogleFonts: - GoogleFonts - .asMap() - .containsKey( - 'Plus Jakarta Sans'), + GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), - enabledBorder: - OutlineInputBorder( + enabledBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of( - context) - .primaryText, + color: FlutterFlowTheme.of(context).primaryText, width: 0.25, ), - borderRadius: - BorderRadius.circular( - 12.0), + borderRadius: BorderRadius.circular(12.0), ), - focusedBorder: - OutlineInputBorder( + focusedBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of( - context) - .success, + color: FlutterFlowTheme.of(context).success, width: 0.25, ), - borderRadius: - BorderRadius.circular( - 12.0), + borderRadius: BorderRadius.circular(12.0), ), - errorBorder: - OutlineInputBorder( + errorBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of( - context) - .error, + color: FlutterFlowTheme.of(context).error, width: 0.25, ), - borderRadius: - BorderRadius.circular( - 12.0), + borderRadius: BorderRadius.circular(12.0), ), errorStyle: TextStyle( fontFamily: @@ -478,147 +376,84 @@ class _SignUpTemplateComponentWidgetState focusedErrorBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of( - context) - .error, + color: FlutterFlowTheme.of(context).error, width: 0.25, ), - borderRadius: - BorderRadius.circular( - 12.0), + borderRadius: BorderRadius.circular(12.0), ), filled: true, - fillColor: - FlutterFlowTheme.of( - context) - .primaryBackground, + fillColor: FlutterFlowTheme.of(context).primaryBackground, suffixIcon: Icon( Icons.email, - color: - FlutterFlowTheme.of( - context) - .accent1, + color: FlutterFlowTheme.of(context).accent1, size: 22.0, ), ), - style: FlutterFlowTheme.of( - context) - .bodyLarge - .override( - fontFamily: - 'Plus Jakarta Sans', - color: - FlutterFlowTheme.of( - context) - .customColor1, + style: FlutterFlowTheme.of(context).bodyLarge.override( + fontFamily: 'Plus Jakarta Sans', + color: FlutterFlowTheme.of(context).customColor1, fontSize: limitedInputFontSize, letterSpacing: 0.0, - fontWeight: - FontWeight.w500, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - 'Plus Jakarta Sans'), + fontWeight: FontWeight.w500, + useGoogleFonts: + GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), - keyboardType: TextInputType - .emailAddress, - validator: _model - .emailRegisterFormTextControllerValidator + keyboardType: TextInputType.emailAddress, + validator: _model.emailRegisterFormTextControllerValidator .asValidator(context), ), ), ), Padding( - padding: - const EdgeInsetsDirectional - .fromSTEB( - 0.0, 0.0, 0.0, 16.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 16.0), child: SizedBox( width: double.infinity, child: TextFormField( - key: const ValueKey( - 'passwordTextFormField'), - controller: _model - .passwordRegisterFormTextController, - focusNode: _model - .passwordRegisterFormFocusNode, - onChanged: (_) => - EasyDebounce.debounce( + key: const ValueKey('passwordTextFormField'), + controller: _model.passwordRegisterFormTextController, + focusNode: _model.passwordRegisterFormFocusNode, + onChanged: (_) => EasyDebounce.debounce( '_model.passwordRegisterFormTextController', - const Duration( - milliseconds: 500), + const Duration(milliseconds: 500), () => setState(() {}), ), autofocus: false, - autofillHints: const [ - AutofillHints.password - ], - obscureText: !_model - .passwordRegisterFormVisibility, + autofillHints: const [AutofillHints.password], + obscureText: !_model.passwordRegisterFormVisibility, decoration: InputDecoration( isDense: true, - labelText: - FFLocalizations.of( - context) - .getText( + labelText: FFLocalizations.of(context).getText( '0firji8l' /* Senha */, ), - labelStyle: FlutterFlowTheme - .of(context) - .labelLarge - .override( - fontFamily: - 'Plus Jakarta Sans', - color: FlutterFlowTheme - .of(context) - .primaryText, + labelStyle: FlutterFlowTheme.of(context).labelLarge.override( + fontFamily: 'Plus Jakarta Sans', + color: FlutterFlowTheme.of(context).primaryText, fontSize: limitedInputFontSize, letterSpacing: 0.0, - fontWeight: - FontWeight.w500, + fontWeight: FontWeight.w500, useGoogleFonts: - GoogleFonts - .asMap() - .containsKey( - 'Plus Jakarta Sans'), + GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), - enabledBorder: - OutlineInputBorder( + enabledBorder: OutlineInputBorder( borderSide: BorderSide( - color: - FlutterFlowTheme.of( - context) - .customColor1, + color: FlutterFlowTheme.of(context).customColor1, width: 0.25, ), - borderRadius: - BorderRadius.circular( - 12.0), + borderRadius: BorderRadius.circular(12.0), ), - focusedBorder: - OutlineInputBorder( - borderSide: - const BorderSide( - color: - Color(0xFF1AAB5F), + focusedBorder: OutlineInputBorder( + borderSide: const BorderSide( + color: Color(0xFF1AAB5F), width: 0.25, ), - borderRadius: - BorderRadius.circular( - 12.0), + borderRadius: BorderRadius.circular(12.0), ), - errorBorder: - OutlineInputBorder( - borderSide: - const BorderSide( - color: - Color(0xFFFF5963), + errorBorder: OutlineInputBorder( + borderSide: const BorderSide( + color: Color(0xFFFF5963), width: 0.25, ), - borderRadius: - BorderRadius.circular( - 12.0), + borderRadius: BorderRadius.circular(12.0), ), errorStyle: TextStyle( fontFamily: @@ -639,62 +474,38 @@ class _SignUpTemplateComponentWidgetState Color(0xFFFF5963), width: 0.25, ), - borderRadius: - BorderRadius.circular( - 12.0), + borderRadius: BorderRadius.circular(12.0), ), filled: true, - fillColor: - FlutterFlowTheme.of( - context) - .primaryBackground, + fillColor: FlutterFlowTheme.of(context).primaryBackground, suffixIcon: InkWell( key: const ValueKey< String>( 'passwordVisibilitySuffixIcon'), onTap: () => setState( - () => _model - .passwordRegisterFormVisibility = - !_model - .passwordRegisterFormVisibility, + () => _model.passwordRegisterFormVisibility = + !_model.passwordRegisterFormVisibility, ), - focusNode: FocusNode( - skipTraversal: true), + focusNode: FocusNode(skipTraversal: true), child: Icon( _model.passwordRegisterFormVisibility - ? Icons - .visibility_outlined - : Icons - .visibility_off_outlined, - color: - FlutterFlowTheme.of( - context) - .accent1, + ? Icons.visibility_outlined + : Icons.visibility_off_outlined, + color: FlutterFlowTheme.of(context).accent1, size: 24.0, ), ), ), - style: FlutterFlowTheme.of( - context) - .bodyLarge - .override( - fontFamily: - 'Plus Jakarta Sans', - color: - FlutterFlowTheme.of( - context) - .primaryText, + style: FlutterFlowTheme.of(context).bodyLarge.override( + fontFamily: 'Plus Jakarta Sans', + color: FlutterFlowTheme.of(context).primaryText, fontSize: limitedInputFontSize, letterSpacing: 0.0, - fontWeight: - FontWeight.w500, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - 'Plus Jakarta Sans'), + fontWeight: FontWeight.w500, + useGoogleFonts: + GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), - validator: _model - .passwordRegisterFormTextControllerValidator + validator: _model.passwordRegisterFormTextControllerValidator .asValidator(context), ), ), @@ -703,8 +514,7 @@ class _SignUpTemplateComponentWidgetState ), ), Padding( - padding: const EdgeInsetsDirectional - .fromSTEB(0.0, 0.0, 0.0, 16.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 16.0), child: FFButtonWidget( key: const ValueKey( 'SubmitButtonWidget'), @@ -712,24 +522,16 @@ class _SignUpTemplateComponentWidgetState ? null : () async { var shouldSetState = false; - _model.register = - await AuthenticationService - .signUp( + _model.register = await AuthenticationService.signUp( context, - email: _model - .emailRegisterFormTextController - .text, - name: _model - .nameRegisterFormTextController - .text, - passwd: _model - .passwordRegisterFormTextController - .text, - device: StorageUtil() - .deviceType, + email: _model.emailRegisterFormTextController.text, + name: _model.nameRegisterFormTextController.text, + passwd: _model.passwordRegisterFormTextController.text, + device: _deviceType, ); shouldSetState = true; if (_model.register == true) + await widget .toggleSignInPage ?.call(); @@ -741,48 +543,30 @@ class _SignUpTemplateComponentWidgetState if (shouldSetState) setState(() {}); }, - text: FFLocalizations.of(context) - .getText( + text: FFLocalizations.of(context).getText( 'rnvdwzei' /* Cadastrar-se */, ), options: FFButtonOptions( width: double.infinity, height: 44.0, - padding: const EdgeInsetsDirectional - .fromSTEB(0.0, 0.0, 0.0, 0.0), - iconPadding: - const EdgeInsetsDirectional - .fromSTEB( - 0.0, 0.0, 0.0, 0.0), - color: FlutterFlowTheme.of(context) - .accent1, - textStyle: FlutterFlowTheme.of( - context) - .titleSmall - .override( - fontFamily: - 'Plus Jakarta Sans', - color: FlutterFlowTheme.of( - context) - .secondaryText, + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), + iconPadding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), + color: FlutterFlowTheme.of(context).accent1, + textStyle: FlutterFlowTheme.of(context).titleSmall.override( + fontFamily: 'Plus Jakarta Sans', + color: FlutterFlowTheme.of(context).secondaryText, fontSize: limitedInputFontSize, letterSpacing: 0.0, fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - 'Plus Jakarta Sans'), + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), elevation: 3.0, borderSide: const BorderSide( color: Colors.transparent, width: 1.0, ), - borderRadius: - BorderRadius.circular(12.0), - disabledColor: - FlutterFlowTheme.of(context) - .customColor5, + borderRadius: BorderRadius.circular(12.0), + disabledColor: FlutterFlowTheme.of(context).customColor5, disabledTextColor: Colors.white, ), showLoadingIndicator: true, @@ -791,8 +575,7 @@ class _SignUpTemplateComponentWidgetState // You will have to add an action on this rich text to go to your login page. Padding( - padding: const EdgeInsetsDirectional - .fromSTEB(0.0, 12.0, 0.0, 12.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 12.0, 0.0, 12.0), child: InkWell( key: const ValueKey( 'toggleSignInPage'), @@ -804,66 +587,39 @@ class _SignUpTemplateComponentWidgetState .toggleSignInPage ?.call(), child: RichText( - textScaler: MediaQuery.of(context) - .textScaler, + textScaler: MediaQuery.of(context).textScaler, text: TextSpan( children: [ TextSpan( - text: FFLocalizations.of( - context) - .getText( + text: FFLocalizations.of(context).getText( 'a9smhn5b' /* Você já tem uma conta? */, ), style: TextStyle( - color: FlutterFlowTheme.of( - context) - .primaryText, + color: FlutterFlowTheme.of(context).primaryText, fontSize: limitedInputFontSize, ), ), TextSpan( - text: FFLocalizations.of( - context) - .getText( + text: FFLocalizations.of(context).getText( '09xv5ctc' /* Clique aqui */, ), - style: FlutterFlowTheme.of( - context) - .bodyMedium - .override( - fontFamily: - 'Plus Jakarta Sans', - color: - FlutterFlowTheme.of( - context) - .primary, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: 'Plus Jakarta Sans', + color: FlutterFlowTheme.of(context).primary, fontSize: limitedInputFontSize, letterSpacing: 0.0, - fontWeight: - FontWeight.w600, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - 'Plus Jakarta Sans'), + fontWeight: FontWeight.w600, + useGoogleFonts: + GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), ) ], - style: - FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of( - context) - .bodyMediumFamily, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of( - context) - .bodyMediumFamily), - ), + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap() + .containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), + ), ), ), ), @@ -873,8 +629,7 @@ class _SignUpTemplateComponentWidgetState ), ), ), - ).animateOnPageLoad( - animationsMap['containerOnPageLoadAnimation']!), + ).animateOnPageLoad(animationsMap['containerOnPageLoadAnimation']!), ), ), ], diff --git a/lib/components/templates_components/view_visit_detail/view_visit_detail_model.dart b/lib/components/templates_components/view_visit_detail/view_visit_detail_model.dart index 15e64040..5113e702 100644 --- a/lib/components/templates_components/view_visit_detail/view_visit_detail_model.dart +++ b/lib/components/templates_components/view_visit_detail/view_visit_detail_model.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import '/backend/api_requests/api_calls.dart'; import '/flutter_flow/flutter_flow_util.dart'; @@ -36,9 +37,10 @@ class ViewVisitDetailModel extends FlutterFlowModel { } Future initializeDatabase() async { - devUUID = StorageUtil().devUUID; - userUUID = StorageUtil().userUUID; - cliUUID = StorageUtil().cliUUID; + devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + ; } @override diff --git a/lib/components/templates_components/view_visit_detail/view_visit_detail_widget.dart b/lib/components/templates_components/view_visit_detail/view_visit_detail_widget.dart index fbbd960a..ead69613 100644 --- a/lib/components/templates_components/view_visit_detail/view_visit_detail_widget.dart +++ b/lib/components/templates_components/view_visit_detail/view_visit_detail_widget.dart @@ -85,23 +85,20 @@ class _ViewVisitDetailWidgetState extends State { // } // }); - _model.textController1 = TextEditingController( - text: widget.visitTempStr == 'null' ? '' : widget.visitTempStr ?? ''); + _model.textController1 = + TextEditingController(text: widget.visitTempStr == 'null' ? '' : widget.visitTempStr ?? ''); _model.textFieldFocusNode1 ??= FocusNode(); - _model.textController2 ??= - TextEditingController(text: widget.visitStartDate); + _model.textController2 ??= TextEditingController(text: widget.visitStartDate); _model.textFieldFocusNode2 ??= FocusNode(); _model.textController3 ??= TextEditingController(text: widget.visitEndDate); _model.textFieldFocusNode3 ??= FocusNode(); - _model.textController4 ??= - TextEditingController(text: widget.visitReasonStr); + _model.textController4 ??= TextEditingController(text: widget.visitReasonStr); _model.textFieldFocusNode4 ??= FocusNode(); - _model.textController5 ??= - TextEditingController(text: widget.visitLevelStr); + _model.textController5 ??= TextEditingController(text: widget.visitLevelStr); _model.textFieldFocusNode5 ??= FocusNode(); _model.textController6 ??= TextEditingController(text: widget.visitObsStr); @@ -117,8 +114,7 @@ class _ViewVisitDetailWidgetState extends State { @override Widget build(BuildContext context) { - var filteredVisitorJsonList = - findVisitorById(widget.visitorJsonList, widget.visitIdStr) ?? 'null'; + var filteredVisitorJsonList = findVisitorById(widget.visitorJsonList, widget.visitIdStr) ?? 'null'; return Padding( padding: const EdgeInsetsDirectional.fromSTEB(0.0, 200.0, 0.0, 0.0), @@ -154,8 +150,7 @@ class _ViewVisitDetailWidgetState extends State { child: Align( alignment: const AlignmentDirectional(1.0, 0.0), child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 15.0, 0.0, 15.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(15.0, 0.0, 15.0, 0.0), child: FlutterFlowIconButton( borderRadius: 20.0, borderWidth: 1.0, @@ -184,8 +179,7 @@ class _ViewVisitDetailWidgetState extends State { Align( alignment: const AlignmentDirectional(1.0, -1.0), child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 0.0, 0.0, 20.0, 20.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 20.0, 20.0), child: Container( width: 100.0, decoration: const BoxDecoration(), @@ -225,10 +219,8 @@ class _ViewVisitDetailWidgetState extends State { child: ClipRRect( borderRadius: BorderRadius.circular(100.0), child: CachedNetworkImage( - fadeInDuration: - const Duration(milliseconds: 500), - fadeOutDuration: - const Duration(milliseconds: 500), + fadeInDuration: const Duration(milliseconds: 500), + fadeOutDuration: const Duration(milliseconds: 500), imageUrl: valueOrDefault( widget.visitorImgPath, 'https://storage.googleapis.com/flutterflow-io-6f20.appspot.com/projects/flutter-freaccess-hub-0xgz9q/assets/7ftdetkzc3s0/360_F_64676383_LdbmhiNM6Ypzb3FM4PPuFP9rHe7ri8Ju.jpg', @@ -247,8 +239,7 @@ class _ViewVisitDetailWidgetState extends State { Container( decoration: const BoxDecoration(), child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 8.0, 0.0, 8.0, 10.0), + padding: const EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 10.0), child: TextFormField( controller: _model.textController1, focusNode: _model.textFieldFocusNode1, @@ -262,27 +253,19 @@ class _ViewVisitDetailWidgetState extends State { labelText: FFLocalizations.of(context).getText( '9yu35pzg' /* Encerramento da Visita */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( @@ -314,29 +297,24 @@ class _ViewVisitDetailWidgetState extends State { ), ), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), - validator: _model.textController1Validator - .asValidator(context), + validator: _model.textController1Validator.asValidator(context), ), ), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 0.0, 0.0, 0.0, 10.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 10.0), child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded( child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 8.0, 0.0, 8.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0), child: TextFormField( controller: _model.textController2, focusNode: _model.textFieldFocusNode2, @@ -350,34 +328,22 @@ class _ViewVisitDetailWidgetState extends State { labelText: FFLocalizations.of(context).getText( 'aj6scczp' /* Início */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), hintText: FFLocalizations.of(context).getText( 'ub084nhy' /* dd/mm/yyyy */, ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( @@ -408,27 +374,20 @@ class _ViewVisitDetailWidgetState extends State { borderRadius: BorderRadius.circular(8.0), ), ), - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodyMediumFamily, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), textAlign: TextAlign.center, - validator: _model.textController2Validator - .asValidator(context), + validator: _model.textController2Validator.asValidator(context), ), ), ), Expanded( child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 8.0, 0.0, 8.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0), child: TextFormField( controller: _model.textController3, focusNode: _model.textFieldFocusNode3, @@ -442,34 +401,22 @@ class _ViewVisitDetailWidgetState extends State { labelText: FFLocalizations.of(context).getText( 'rvi5z7wg' /* Término */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), hintText: FFLocalizations.of(context).getText( 'ixs67mrz' /* dd/mm/yyyy */, ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( @@ -500,20 +447,14 @@ class _ViewVisitDetailWidgetState extends State { borderRadius: BorderRadius.circular(8.0), ), ), - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodyMediumFamily, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), textAlign: TextAlign.center, - validator: _model.textController3Validator - .asValidator(context), + validator: _model.textController3Validator.asValidator(context), ), ), ), @@ -521,16 +462,14 @@ class _ViewVisitDetailWidgetState extends State { ), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 0.0, 0.0, 0.0, 10.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 10.0), child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded( child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 8.0, 0.0, 8.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0), child: TextFormField( controller: _model.textController4, focusNode: _model.textFieldFocusNode4, @@ -544,34 +483,22 @@ class _ViewVisitDetailWidgetState extends State { labelText: FFLocalizations.of(context).getText( 'yxilg7ek' /* Motivo da Visita */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), hintText: FFLocalizations.of(context).getText( 'ypeydbem' /* Motivo */, ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( @@ -602,27 +529,20 @@ class _ViewVisitDetailWidgetState extends State { borderRadius: BorderRadius.circular(8.0), ), ), - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodyMediumFamily, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), textAlign: TextAlign.center, - validator: _model.textController4Validator - .asValidator(context), + validator: _model.textController4Validator.asValidator(context), ), ), ), Expanded( child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 8.0, 0.0, 8.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0), child: TextFormField( controller: _model.textController5, focusNode: _model.textFieldFocusNode5, @@ -636,34 +556,22 @@ class _ViewVisitDetailWidgetState extends State { labelText: FFLocalizations.of(context).getText( 'dgr3pk3a' /* Nível de Acesso */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), hintText: FFLocalizations.of(context).getText( 'rs3d4gb8' /* Nível de Acesso */, ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( @@ -694,20 +602,14 @@ class _ViewVisitDetailWidgetState extends State { borderRadius: BorderRadius.circular(8.0), ), ), - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodyMediumFamily, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), textAlign: TextAlign.center, - validator: _model.textController5Validator - .asValidator(context), + validator: _model.textController5Validator.asValidator(context), ), ), ), @@ -717,8 +619,7 @@ class _ViewVisitDetailWidgetState extends State { Container( decoration: const BoxDecoration(), child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 8.0, 0.0, 8.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(8.0, 0.0, 8.0, 0.0), child: TextFormField( controller: _model.textController6, focusNode: _model.textFieldFocusNode6, @@ -732,27 +633,19 @@ class _ViewVisitDetailWidgetState extends State { labelText: FFLocalizations.of(context).getText( 'lppn9rxa' /* Observações da Visita */, ), - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( @@ -784,15 +677,12 @@ class _ViewVisitDetailWidgetState extends State { ), ), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), - validator: _model.textController6Validator - .asValidator(context), + validator: _model.textController6Validator.asValidator(context), ), ), ), @@ -817,8 +707,7 @@ class _ViewVisitDetailWidgetState extends State { size: 24.0, ), onPressed: () async { - _model.deleteVisit = - await PhpGroup.deleteVisitCall.call( + _model.deleteVisit = await PhpGroup.deleteVisitCall.call( idVisita: widget.visitIdStr, ); @@ -828,8 +717,7 @@ class _ViewVisitDetailWidgetState extends State { false) { context.pop(); } else { - final error = - await DialogUtil.errorDefault(context); + final error = await DialogUtil.errorDefault(context); await showModalBottomSheet( isScrollControlled: true, backgroundColor: Colors.transparent, diff --git a/lib/components/templates_components/visit_details_modal_template_component/visit_details_modal_template_component_model.dart b/lib/components/templates_components/visit_details_modal_template_component/visit_details_modal_template_component_model.dart index 9ec1e19d..c7143f06 100644 --- a/lib/components/templates_components/visit_details_modal_template_component/visit_details_modal_template_component_model.dart +++ b/lib/components/templates_components/visit_details_modal_template_component/visit_details_modal_template_component_model.dart @@ -1,5 +1,3 @@ - - import 'package:hub/components/organism_components/schedule_visit_detail/schedule_visit_detail_model.dart'; import 'package:hub/components/templates_components/view_visit_detail/view_visit_detail_model.dart'; import 'package:hub/components/templates_components/visit_details_modal_template_component/visit_details_modal_template_component_widget.dart'; @@ -7,8 +5,7 @@ import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:flutter/material.dart'; -class VisitDetailsModalTemplateComponentModel - extends FlutterFlowModel { +class VisitDetailsModalTemplateComponentModel extends FlutterFlowModel { /// Local state fields for this component. Color statusColor = const Color(0xff000000); @@ -23,8 +20,7 @@ class VisitDetailsModalTemplateComponentModel @override void initState(BuildContext context) { viewVisitDetailModel = createModel(context, () => ViewVisitDetailModel()); - scheduleVisitDetailModel = - createModel(context, () => ScheduleVisitDetailModel()); + scheduleVisitDetailModel = createModel(context, () => ScheduleVisitDetailModel()); } @override @@ -32,4 +28,4 @@ class VisitDetailsModalTemplateComponentModel viewVisitDetailModel.dispose(); scheduleVisitDetailModel.dispose(); } -} \ No newline at end of file +} diff --git a/lib/components/templates_components/visit_details_modal_template_component/visit_details_modal_template_component_widget.dart b/lib/components/templates_components/visit_details_modal_template_component/visit_details_modal_template_component_widget.dart index f4864b0b..b6e63072 100644 --- a/lib/components/templates_components/visit_details_modal_template_component/visit_details_modal_template_component_widget.dart +++ b/lib/components/templates_components/visit_details_modal_template_component/visit_details_modal_template_component_widget.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:hub/components/organism_components/schedule_visit_detail/schedule_visit_detail_widget.dart'; import 'package:hub/components/templates_components/view_visit_detail/view_visit_detail_widget.dart'; @@ -42,12 +41,10 @@ class VisitDetailsModalTemplateComponentWidget extends StatefulWidget { final Color? visitStatusColor; @override - State createState() => - _VisitDetailsModalTemplateComponentWidgetState(); + State createState() => _VisitDetailsModalTemplateComponentWidgetState(); } -class _VisitDetailsModalTemplateComponentWidgetState - extends State { +class _VisitDetailsModalTemplateComponentWidgetState extends State { late VisitDetailsModalTemplateComponentModel _model; @override @@ -59,8 +56,7 @@ class _VisitDetailsModalTemplateComponentWidgetState @override void initState() { super.initState(); - _model = - createModel(context, () => VisitDetailsModalTemplateComponentModel()); + _model = createModel(context, () => VisitDetailsModalTemplateComponentModel()); } @override diff --git a/lib/components/templates_components/visitor_details_modal_template_component/visitor_details_modal_template_component_model.dart b/lib/components/templates_components/visitor_details_modal_template_component/visitor_details_modal_template_component_model.dart index d0f79706..ee7ec7cf 100644 --- a/lib/components/templates_components/visitor_details_modal_template_component/visitor_details_modal_template_component_model.dart +++ b/lib/components/templates_components/visitor_details_modal_template_component/visitor_details_modal_template_component_model.dart @@ -1,10 +1,8 @@ import '/flutter_flow/flutter_flow_util.dart'; -import 'visitor_details_modal_template_component_widget.dart' - show VisitorDetailsModalTemplateComponentWidget; +import 'visitor_details_modal_template_component_widget.dart' show VisitorDetailsModalTemplateComponentWidget; import 'package:flutter/material.dart'; -class VisitorDetailsModalTemplateComponentModel - extends FlutterFlowModel { +class VisitorDetailsModalTemplateComponentModel extends FlutterFlowModel { @override void initState(BuildContext context) {} diff --git a/lib/components/templates_components/visitor_details_modal_template_component/visitor_details_modal_template_component_widget.dart b/lib/components/templates_components/visitor_details_modal_template_component/visitor_details_modal_template_component_widget.dart index 98309e51..fcd55d7b 100644 --- a/lib/components/templates_components/visitor_details_modal_template_component/visitor_details_modal_template_component_widget.dart +++ b/lib/components/templates_components/visitor_details_modal_template_component/visitor_details_modal_template_component_widget.dart @@ -25,12 +25,10 @@ class VisitorDetailsModalTemplateComponentWidget extends StatefulWidget { final String? visitorEmail; @override - State createState() => - _VisitorDetailsModalTemplateComponentWidgetState(); + State createState() => _VisitorDetailsModalTemplateComponentWidgetState(); } -class _VisitorDetailsModalTemplateComponentWidgetState - extends State { +class _VisitorDetailsModalTemplateComponentWidgetState extends State { late VisitorDetailsModalTemplateComponentModel _model; @override @@ -42,8 +40,7 @@ class _VisitorDetailsModalTemplateComponentWidgetState @override void initState() { super.initState(); - _model = - createModel(context, () => VisitorDetailsModalTemplateComponentModel()); + _model = createModel(context, () => VisitorDetailsModalTemplateComponentModel()); } @override @@ -85,8 +82,7 @@ class _VisitorDetailsModalTemplateComponentWidgetState child: Align( alignment: const AlignmentDirectional(1.0, -1.0), child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 10.0, 5.0, 15.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(10.0, 5.0, 15.0, 0.0), child: InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, @@ -107,21 +103,18 @@ class _VisitorDetailsModalTemplateComponentWidgetState Align( alignment: const AlignmentDirectional(0.0, -1.0), child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 20.0, 40.0, 20.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(20.0, 40.0, 20.0, 0.0), child: Container( decoration: const BoxDecoration( shape: BoxShape.rectangle, ), child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 0.0, 10.0, 0.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 10.0, 0.0, 0.0), child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.start, children: [ - if (widget.visitorImageURL != '' && - widget.visitorImageURL != null) + if (widget.visitorImageURL != '' && widget.visitorImageURL != null) Container( width: 100.0, height: 100.0, @@ -137,23 +130,17 @@ class _VisitorDetailsModalTemplateComponentWidgetState Align( alignment: const AlignmentDirectional(0.0, 0.0), child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 20.0, 0.0, 20.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(20.0, 0.0, 20.0, 0.0), child: Text( widget.visitorName ?? '', textAlign: TextAlign.start, - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodyMediumFamily, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, fontSize: 24.0, letterSpacing: 0.0, fontWeight: FontWeight.bold, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + .containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), ), ), @@ -161,24 +148,18 @@ class _VisitorDetailsModalTemplateComponentWidgetState Align( alignment: const AlignmentDirectional(0.0, 0.0), child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 20.0, 0.0, 20.0, 30.0), + padding: const EdgeInsetsDirectional.fromSTEB(20.0, 0.0, 20.0, 30.0), child: Text( FFLocalizations.of(context).getText( 'hz7ivuqn' /* Tipo de Visitante */, ), textAlign: TextAlign.start, - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodyMediumFamily, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, fontWeight: FontWeight.bold, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + .containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), ), ), @@ -192,28 +173,20 @@ class _VisitorDetailsModalTemplateComponentWidgetState size: 24.0, ), Align( - alignment: - const AlignmentDirectional(-1.0, 0.0), + alignment: const AlignmentDirectional(-1.0, 0.0), child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 20.0, 0.0, 20.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(20.0, 0.0, 20.0, 0.0), child: Text( FFLocalizations.of(context).getText( 'rwqn0det' /* (00) 0 0000-0000 */, ), textAlign: TextAlign.start, - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of(context) - .bodyMediumFamily, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, fontWeight: FontWeight.bold, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + .containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), ), ), @@ -229,28 +202,20 @@ class _VisitorDetailsModalTemplateComponentWidgetState size: 24.0, ), Align( - alignment: - const AlignmentDirectional(-1.0, 0.0), + alignment: const AlignmentDirectional(-1.0, 0.0), child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 20.0, 0.0, 20.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(20.0, 0.0, 20.0, 0.0), child: Text( FFLocalizations.of(context).getText( '0wqbiekp' /* email@provider.etc */, ), textAlign: TextAlign.start, - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of(context) - .bodyMediumFamily, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, fontWeight: FontWeight.bold, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + .containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), ), ), diff --git a/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_model.dart b/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_model.dart index a8efa6c4..f9f4e6f5 100644 --- a/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_model.dart +++ b/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_model.dart @@ -2,10 +2,10 @@ import 'package:flutter/material.dart'; import 'package:hub/backend/api_requests/api_manager.dart'; import 'package:hub/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; -class VisitorSearchModalTemplateComponentModel - extends FlutterFlowModel { +class VisitorSearchModalTemplateComponentModel extends FlutterFlowModel { late final String devUUID; late final String userUUID; late final String cliUUID; @@ -14,18 +14,15 @@ class VisitorSearchModalTemplateComponentModel void addToVisitors(dynamic item) => visitors.add(item); void removeFromVisitors(dynamic item) => visitors.remove(item); void removeAtIndexFromVisitors(int index) => visitors.removeAt(index); - void insertAtIndexInVisitors(int index, dynamic item) => - visitors.insert(index, item); - void updateVisitorsAtIndex(int index, Function(dynamic) updateFn) => - visitors[index] = updateFn(visitors[index]); + void insertAtIndexInVisitors(int index, dynamic item) => visitors.insert(index, item); + void updateVisitorsAtIndex(int index, Function(dynamic) updateFn) => visitors[index] = updateFn(visitors[index]); List docs = []; void addToDocs(String item) => docs.add(item); void removeFromDocs(String item) => docs.remove(item); void removeAtIndexFromDocs(int index) => docs.removeAt(index); void insertAtIndexInDocs(int index, String item) => docs.insert(index, item); - void updateDocsAtIndex(int index, Function(String) updateFn) => - docs[index] = updateFn(docs[index]); + void updateDocsAtIndex(int index, Function(String) updateFn) => docs[index] = updateFn(docs[index]); FocusNode? textFieldFocusNode; TextEditingController? textController; @@ -38,9 +35,10 @@ class VisitorSearchModalTemplateComponentModel } Future initDatabase() async { - devUUID = StorageUtil().devUUID; - userUUID = StorageUtil().userUUID; - cliUUID = StorageUtil().cliUUID; + devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + ; } @override @@ -48,4 +46,4 @@ class VisitorSearchModalTemplateComponentModel textFieldFocusNode?.dispose(); textController?.dispose(); } -} +} \ No newline at end of file diff --git a/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart b/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart index 9f84ff8e..93ace1e6 100644 --- a/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart +++ b/lib/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart @@ -27,12 +27,10 @@ class VisitorSearchModalTemplateComponentWidget extends StatefulWidget { final Future Function(List? docsParam)? getDocs; @override - State createState() => - _VisitorSearchModalTemplateComponentWidgetState(); + State createState() => _VisitorSearchModalTemplateComponentWidgetState(); } -class _VisitorSearchModalTemplateComponentWidgetState - extends State +class _VisitorSearchModalTemplateComponentWidgetState extends State with TickerProviderStateMixin { late VisitorSearchModalTemplateComponentModel _model; @@ -44,8 +42,7 @@ class _VisitorSearchModalTemplateComponentWidgetState @override void initState() { super.initState(); - _model = - createModel(context, () => VisitorSearchModalTemplateComponentModel()); + _model = createModel(context, () => VisitorSearchModalTemplateComponentModel()); _model.textController ??= TextEditingController(); _model.textFieldFocusNode ??= FocusNode(); @@ -90,8 +87,7 @@ class _VisitorSearchModalTemplateComponentWidgetState ), ), Padding( - padding: - const EdgeInsetsDirectional.fromSTEB(16.0, 25.0, 16.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(16.0, 25.0, 16.0, 0.0), child: TextFormField( controller: _model.textController, focusNode: _model.textFieldFocusNode, @@ -109,82 +105,57 @@ class _VisitorSearchModalTemplateComponentWidgetState ptText: 'Documento do Visitante', ), labelStyle: FlutterFlowTheme.of(context).labelMedium.override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), fontSize: limitedInputFontSize, ), enabledBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).accent1, - width: 0.5, - ), + borderSide: BorderSide(color: FlutterFlowTheme.of(context).accent1, width: 0.5), borderRadius: const BorderRadius.only( - bottomLeft: Radius.circular(15.0), - bottomRight: Radius.circular(15.0), - topLeft: Radius.circular(15.0), - topRight: Radius.circular(15.0), - ), + bottomLeft: Radius.circular(15.0), + bottomRight: Radius.circular(15.0), + topLeft: Radius.circular(15.0), + topRight: Radius.circular(15.0)), ), focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).primary, - width: 0.5, - ), + borderSide: BorderSide(color: FlutterFlowTheme.of(context).primary, width: 0.5), borderRadius: const BorderRadius.only( - bottomLeft: Radius.circular(15.0), - bottomRight: Radius.circular(15.0), - topLeft: Radius.circular(15.0), - topRight: Radius.circular(15.0), - ), + bottomLeft: Radius.circular(15.0), + bottomRight: Radius.circular(15.0), + topLeft: Radius.circular(15.0), + topRight: Radius.circular(15.0)), ), errorBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).error, - width: 0.5, - ), + borderSide: BorderSide(color: FlutterFlowTheme.of(context).error, width: 0.5), borderRadius: const BorderRadius.only( - bottomLeft: Radius.circular(15.0), - bottomRight: Radius.circular(15.0), - topLeft: Radius.circular(15.0), - topRight: Radius.circular(15.0), - ), + bottomLeft: Radius.circular(15.0), + bottomRight: Radius.circular(15.0), + topLeft: Radius.circular(15.0), + topRight: Radius.circular(15.0)), ), focusedErrorBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context).error, - width: 0.5, - ), + borderSide: BorderSide(color: FlutterFlowTheme.of(context).error, width: 0.5), borderRadius: const BorderRadius.only( - bottomLeft: Radius.circular(15.0), - bottomRight: Radius.circular(15.0), - topLeft: Radius.circular(15.0), - topRight: Radius.circular(15.0), - ), + bottomLeft: Radius.circular(15.0), + bottomRight: Radius.circular(15.0), + topLeft: Radius.circular(15.0), + topRight: Radius.circular(15.0)), ), filled: true, fillColor: FlutterFlowTheme.of(context).primaryBackground, - prefixIcon: Icon( - Icons.search_outlined, - color: FlutterFlowTheme.of(context).accent1, - ), + prefixIcon: Icon(Icons.search_outlined, color: FlutterFlowTheme.of(context).accent1), ), style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), fontSize: limitedInputFontSize, ), - keyboardType: - const TextInputType.numberWithOptions(signed: true), + keyboardType: const TextInputType.numberWithOptions(signed: true), validator: _model.textControllerValidator.asValidator(context), - inputFormatters: [ - FilteringTextInputFormatter.allow(RegExp('[0-9]')), - ], + inputFormatters: [FilteringTextInputFormatter.allow(RegExp('[0-9]'))], ), ), if (_model.visitors.isNotEmpty && _model.visitors.isNotEmpty) @@ -193,34 +164,28 @@ class _VisitorSearchModalTemplateComponentWidgetState mainAxisAlignment: MainAxisAlignment.start, children: [ Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 16.0, 12.0, 0.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(16.0, 12.0, 0.0, 0.0), child: Text( - FFLocalizations.of(context).getText( - '9coywebh' /* Visitantes encontrados */, - ), + FFLocalizations.of(context).getText('9coywebh'), style: FlutterFlowTheme.of(context).labelMedium.override( - fontFamily: - FlutterFlowTheme.of(context).labelMediumFamily, + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).labelMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).labelMediumFamily), fontSize: limitedHeaderFontSize, ), ), ), Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 4.0, 12.0, 16.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(4.0, 12.0, 16.0, 0.0), child: Text( _model.visitors.length.toString(), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), fontSize: limitedHeaderFontSize, ), ), @@ -232,12 +197,10 @@ class _VisitorSearchModalTemplateComponentWidgetState builder: (context) { if (_model.visitors.isNotEmpty) { return Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 8.0, 8.0, 8.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(8.0, 8.0, 8.0, 0.0), child: Builder( builder: (context) { - final visitor = - _model.visitors.map((e) => e).toList(); + final visitor = _model.visitors.map((e) => e).toList(); final doc = _model.docs.map((e) => e).toList(); return ListView.builder( padding: EdgeInsets.zero, @@ -247,8 +210,7 @@ class _VisitorSearchModalTemplateComponentWidgetState final visitorItem = visitor[visitorIndex]; final docItem = doc[visitorIndex]; return Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 0.0, 0.0, 0.0, 1.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 1.0), child: InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, @@ -257,24 +219,19 @@ class _VisitorSearchModalTemplateComponentWidgetState child: Container( width: 100.0, decoration: BoxDecoration( - color: FlutterFlowTheme.of(context) - .primaryBackground, + color: FlutterFlowTheme.of(context).primaryBackground, ), child: Padding( padding: const EdgeInsets.all(8.0), child: Row( mainAxisSize: MainAxisSize.min, - crossAxisAlignment: - CrossAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, children: [ ClipRRect( - borderRadius: - BorderRadius.circular(40.0), + borderRadius: BorderRadius.circular(40.0), child: CachedNetworkImage( - fadeInDuration: const Duration( - milliseconds: 500), - fadeOutDuration: const Duration( - milliseconds: 500), + fadeInDuration: const Duration(milliseconds: 500), + fadeOutDuration: const Duration(milliseconds: 500), imageUrl: "https://freaccess.com.br/freaccess/getImage.php?devUUID=${_model.devUUID}&userUUID=${_model.userUUID}&cliID=${_model.cliUUID}&atividade=getFoto&Documento=${getJsonField( visitorItem, @@ -288,39 +245,21 @@ class _VisitorSearchModalTemplateComponentWidgetState Expanded( child: Column( mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.center, - crossAxisAlignment: - CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: - const EdgeInsetsDirectional - .fromSTEB( - 12.0, 0.0, 0.0, 0.0), + padding: const EdgeInsetsDirectional.fromSTEB(12.0, 0.0, 0.0, 0.0), child: Text( valueOrDefault( - getJsonField( - visitorItem, - r'''$.VTE_NOME''', - )?.toString(), + getJsonField(visitorItem, r'''$.VTE_NOME''')?.toString(), 'NOT FOUND', ), - style: FlutterFlowTheme.of( - context) - .bodyLarge - .override( - fontFamily: - FlutterFlowTheme.of( - context) - .bodyLargeFamily, + style: FlutterFlowTheme.of(context).bodyLarge.override( + fontFamily: FlutterFlowTheme.of(context).bodyLargeFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of( - context) - .bodyLargeFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey( + FlutterFlowTheme.of(context).bodyLargeFamily), fontSize: limitedBodyFontSize, ), ), @@ -332,16 +271,10 @@ class _VisitorSearchModalTemplateComponentWidgetState borderRadius: 20.0, borderWidth: 1.0, buttonSize: 40.0, - icon: Icon( - Icons.close, - color: - FlutterFlowTheme.of(context) - .customColor6, - size: 20.0, - ), + icon: Icon(Icons.close, + color: FlutterFlowTheme.of(context).customColor6, size: 20.0), onPressed: () async { - _model.removeFromVisitors( - visitorItem); + _model.removeFromVisitors(visitorItem); _model.removeFromDocs(docItem); safeSetState(() {}); }, @@ -361,9 +294,7 @@ class _VisitorSearchModalTemplateComponentWidgetState return Container( width: 100.0, height: 100.0, - decoration: BoxDecoration( - color: FlutterFlowTheme.of(context).primaryBackground, - ), + decoration: BoxDecoration(color: FlutterFlowTheme.of(context).primaryBackground), ); } }, @@ -375,14 +306,8 @@ class _VisitorSearchModalTemplateComponentWidgetState children: [ FFButtonWidget( onPressed: MediaQuery.of(context).viewInsets.bottom > 0 - ? () async { - await addVisitor(context); - - safeSetState(() {}); - } - : () async { - await sendVisitors(context); - }, + ? () async => await addVisitor(context).whenComplete(safeSetState(() {})) + : () async => await sendVisitors(context), text: MediaQuery.of(context).viewInsets.bottom > 0 ? FFLocalizations.of(context).getVariableText( enText: 'Add', @@ -401,32 +326,25 @@ class _VisitorSearchModalTemplateComponentWidgetState 0.0, 0.0, 0.0, 0.0), color: FlutterFlowTheme.of(context).primary, textStyle: FlutterFlowTheme.of(context).titleSmall.override( - fontFamily: - FlutterFlowTheme.of(context).titleSmallFamily, + fontFamily: FlutterFlowTheme.of(context).titleSmallFamily, color: Colors.white, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).titleSmallFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).titleSmallFamily), fontSize: limitedInputFontSize, ), elevation: 3.0, - borderSide: const BorderSide( - color: Colors.transparent, - width: 1.0, - ), + borderSide: const BorderSide(color: Colors.transparent, width: 1.0), borderRadius: const BorderRadius.only( - bottomLeft: Radius.circular(15), - bottomRight: Radius.circular(15), - topLeft: Radius.circular(15), - topRight: Radius.circular(15), - ), + bottomLeft: Radius.circular(15), + bottomRight: Radius.circular(15), + topLeft: Radius.circular(15), + topRight: Radius.circular(15)), ), ), ], ), - const SizedBox( - height: 30.0, - ) + const SizedBox(height: 30.0) ], ), ), @@ -434,9 +352,7 @@ class _VisitorSearchModalTemplateComponentWidgetState } Future sendVisitors(BuildContext context) async { - await widget.getVisitors?.call( - _model.visitors, - ); + await widget.getVisitors?.call(_model.visitors); log('() => docs: ${_model.docs}'); await widget.getDocs?.call(_model.docs); context.pop(); @@ -445,37 +361,25 @@ class _VisitorSearchModalTemplateComponentWidgetState Future addVisitor(BuildContext context) async { safeSetState(() { _model.textController?.text = _model.textController.text; - _model.textController?.selection = - TextSelection.collapsed(offset: _model.textController!.text.length); + _model.textController?.selection = TextSelection.collapsed(offset: _model.textController!.text.length); }); - _model.getVisitorByDoc = await PhpGroup.getVisitorByDocCall.call( - documento: _model.textController.text, - ); + _model.getVisitorByDoc = + await PhpGroup.getVisitorByDocCall.call(documento: _model.textController.text.replaceFirst(RegExp(r'^0+'), '')); - if (PhpGroup.getVisitorByDocCall.vistanteId( - (_model.getVisitorByDoc?.jsonBody ?? ''), - ) != - '0' && - PhpGroup.getVisitorByDocCall - .error((_model.getVisitorByDoc?.jsonBody ?? '')) == - false && - PhpGroup.getVisitorByDocCall - .vistanteId((_model.getVisitorByDoc?.jsonBody ?? '')) != - null) { - String newDoc = _model.textController.text; + if (PhpGroup.getVisitorByDocCall.vistanteId((_model.getVisitorByDoc?.jsonBody ?? '')) != '0' && + PhpGroup.getVisitorByDocCall.error((_model.getVisitorByDoc?.jsonBody ?? '')) == false && + PhpGroup.getVisitorByDocCall.vistanteId((_model.getVisitorByDoc?.jsonBody ?? '')) != null) { + String newDoc = _model.textController.text.replaceFirst(RegExp(r'^0+'), ''); bool existDoc = _model.docs.contains(newDoc); if (existDoc == false) { - _model.addToVisitors(PhpGroup.getVisitorByDocCall.visitante( - (_model.getVisitorByDoc?.jsonBody ?? ''), - )); + _model.addToVisitors(PhpGroup.getVisitorByDocCall.visitante((_model.getVisitorByDoc?.jsonBody ?? ''))); safeSetState(() {}); - _model.addToDocs(_model.textController.text); + _model.addToDocs(_model.textController.text.replaceFirst(RegExp(r'^0+'), '')); safeSetState(() {}); } else if (existDoc == true) { ToastUtil.showToast( - message: FFLocalizations.of(context).getVariableText( - ptText: 'Visitante já adicionado!', - enText: 'Visitor already added!'), + message: FFLocalizations.of(context) + .getVariableText(ptText: 'Visitante já adicionado!', enText: 'Visitor already added!'), gravity: ToastGravity.TOP, backgroundColor: Colors.red); } @@ -485,9 +389,7 @@ class _VisitorSearchModalTemplateComponentWidgetState context: context, builder: (context) { return Dialog( - child: VisitorNotFoundComponentWidget( - doc: _model.textController.text, - ), + child: VisitorNotFoundComponentWidget(doc: _model.textController.text), ); }, ).then((value) => safeSetState(() { @@ -497,4 +399,4 @@ class _VisitorSearchModalTemplateComponentWidgetState })); } } -} +} \ No newline at end of file diff --git a/lib/components/templates_components/welcome_template_component/welcome_template_component_model.dart b/lib/components/templates_components/welcome_template_component/welcome_template_component_model.dart index 17ea3047..8a23ea35 100644 --- a/lib/components/templates_components/welcome_template_component/welcome_template_component_model.dart +++ b/lib/components/templates_components/welcome_template_component/welcome_template_component_model.dart @@ -1,10 +1,8 @@ import '/flutter_flow/flutter_flow_util.dart'; -import 'welcome_template_component_widget.dart' - show WelcomeTemplateComponentWidget; +import 'welcome_template_component_widget.dart' show WelcomeTemplateComponentWidget; import 'package:flutter/material.dart'; -class WelcomeTemplateComponentModel - extends FlutterFlowModel { +class WelcomeTemplateComponentModel extends FlutterFlowModel { @override void initState(BuildContext context) {} diff --git a/lib/components/templates_components/welcome_template_component/welcome_template_component_widget.dart b/lib/components/templates_components/welcome_template_component/welcome_template_component_widget.dart index b2fbb575..3d592075 100644 --- a/lib/components/templates_components/welcome_template_component/welcome_template_component_widget.dart +++ b/lib/components/templates_components/welcome_template_component/welcome_template_component_widget.dart @@ -23,8 +23,7 @@ class WelcomeTemplateComponentWidget extends StatefulWidget { final Future Function()? toggleSignInPage; @override - State createState() => - _WelcomeTemplateComponentWidgetState(); + State createState() => _WelcomeTemplateComponentWidgetState(); } class _WelcomeTemplateComponentWidgetState @@ -200,8 +199,7 @@ class _WelcomeTemplateComponentWidgetState onPressed: () async { await widget.toggleSignInPage?.call(); }, - text: FFLocalizations.of(context) - .getText('dynet730' /* Entrar */), + text: FFLocalizations.of(context).getText('dynet730' /* Entrar */), options: FFButtonOptions( width: double.infinity, height: 44.0, @@ -217,67 +215,45 @@ class _WelcomeTemplateComponentWidgetState .titleSmall .override( fontFamily: 'Plus Jakarta Sans', - color: - FlutterFlowTheme.of(context) - .info, + color: FlutterFlowTheme.of(context).info, fontSize: limitedInputFontSize, letterSpacing: 0.0, fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - 'Plus Jakarta Sans'), + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), elevation: 3.0, borderSide: const BorderSide( color: Colors.transparent, width: 1.0, ), - borderRadius: - BorderRadius.circular(12.0), + borderRadius: BorderRadius.circular(12.0), ), showLoadingIndicator: false, ), ), Padding( - padding: - const EdgeInsetsDirectional.fromSTEB( - 0.0, 0.0, 0.0, 16.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 16.0), child: FFButtonWidget( - key: const ValueKey( - 'toggleSignUpPage'), + key: const ValueKey('toggleSignUpPage'), onPressed: () async { await widget.toggleSignUpPage?.call(); }, - text: - FFLocalizations.of(context).getText( + text: FFLocalizations.of(context).getText( 'hha60cg7' /* Cadastrar */, ), options: FFButtonOptions( width: double.infinity, height: 44.0, - padding: const EdgeInsetsDirectional - .fromSTEB(0.0, 0.0, 0.0, 0.0), - iconPadding: - const EdgeInsetsDirectional - .fromSTEB(0.0, 0.0, 0.0, 0.0), - color: FlutterFlowTheme.of(context) - .customColor1, - textStyle: FlutterFlowTheme.of( - context) - .titleSmall - .override( + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), + iconPadding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), + color: FlutterFlowTheme.of(context).customColor1, + textStyle: FlutterFlowTheme.of(context).titleSmall.override( fontFamily: 'Plus Jakarta Sans', - color: - FlutterFlowTheme.of(context) - .primaryBackground, + color: FlutterFlowTheme.of(context).primaryBackground, fontSize: limitedInputFontSize, letterSpacing: 0.0, fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - 'Plus Jakarta Sans'), + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), elevation: 3.0, @@ -285,8 +261,7 @@ class _WelcomeTemplateComponentWidgetState color: Colors.transparent, width: 1.0, ), - borderRadius: - BorderRadius.circular(12.0), + borderRadius: BorderRadius.circular(12.0), ), showLoadingIndicator: false, ), @@ -296,13 +271,11 @@ class _WelcomeTemplateComponentWidgetState } else { return Row( mainAxisSize: MainAxisSize.max, - mainAxisAlignment: - MainAxisAlignment.spaceEvenly, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Expanded( child: Padding( - padding: const EdgeInsetsDirectional - .fromSTEB(0.0, 0.0, 0.0, 16.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 16.0), child: FFButtonWidget( key: const ValueKey( 'toggleSignInPage'), @@ -310,45 +283,29 @@ class _WelcomeTemplateComponentWidgetState await widget.toggleSignInPage ?.call(); }, - text: FFLocalizations.of(context) - .getText( + text: FFLocalizations.of(context).getText( 'zvtay8ee' /* Entrar */, ), options: FFButtonOptions( width: double.infinity, height: 44.0, - padding: const EdgeInsetsDirectional - .fromSTEB(0.0, 0.0, 0.0, 0.0), - iconPadding: - const EdgeInsetsDirectional - .fromSTEB( - 0.0, 0.0, 0.0, 0.0), - color: FlutterFlowTheme.of(context) - .primary, - textStyle: FlutterFlowTheme.of( - context) - .titleSmall - .override( - fontFamily: - 'Plus Jakarta Sans', - color: FlutterFlowTheme.of( - context) - .info, + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), + iconPadding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), + color: FlutterFlowTheme.of(context).primary, + textStyle: FlutterFlowTheme.of(context).titleSmall.override( + fontFamily: 'Plus Jakarta Sans', + color: FlutterFlowTheme.of(context).info, fontSize: 16.0, letterSpacing: 0.0, fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - 'Plus Jakarta Sans'), + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), elevation: 3.0, borderSide: const BorderSide( color: Colors.transparent, width: 1.0, ), - borderRadius: - BorderRadius.circular(12.0), + borderRadius: BorderRadius.circular(12.0), ), showLoadingIndicator: false, ), @@ -356,54 +313,36 @@ class _WelcomeTemplateComponentWidgetState ), Expanded( child: Padding( - padding: const EdgeInsetsDirectional - .fromSTEB(0.0, 0.0, 0.0, 16.0), + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 16.0), child: FFButtonWidget( key: const ValueKey( 'toggleSignUpPage'), onPressed: () async { - await widget.toggleSignUpPage - ?.call(); + await widget.toggleSignUpPage?.call(); }, - text: FFLocalizations.of(context) - .getText( + text: FFLocalizations.of(context).getText( 'o6zob50a' /* Cadastrar */, ), options: FFButtonOptions( width: double.infinity, height: 44.0, - padding: const EdgeInsetsDirectional - .fromSTEB(0.0, 0.0, 0.0, 0.0), - iconPadding: - const EdgeInsetsDirectional - .fromSTEB( - 0.0, 0.0, 0.0, 0.0), - color: FlutterFlowTheme.of(context) - .primary, - textStyle: FlutterFlowTheme.of( - context) - .titleSmall - .override( - fontFamily: - 'Plus Jakarta Sans', - color: FlutterFlowTheme.of( - context) - .info, + padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), + iconPadding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 0.0), + color: FlutterFlowTheme.of(context).primary, + textStyle: FlutterFlowTheme.of(context).titleSmall.override( + fontFamily: 'Plus Jakarta Sans', + color: FlutterFlowTheme.of(context).info, fontSize: 16.0, letterSpacing: 0.0, fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - 'Plus Jakarta Sans'), + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), elevation: 3.0, borderSide: const BorderSide( color: Colors.transparent, width: 1.0, ), - borderRadius: - BorderRadius.circular(12.0), + borderRadius: BorderRadius.circular(12.0), ), showLoadingIndicator: false, ), @@ -418,8 +357,7 @@ class _WelcomeTemplateComponentWidgetState ), ), ), - ).animateOnPageLoad( - animationsMap['containerOnPageLoadAnimation']!), + ).animateOnPageLoad(animationsMap['containerOnPageLoadAnimation']!), ), ), ], diff --git a/lib/firebase_options.dart b/lib/firebase_options.dart index ac64bcb6..df4c0669 100644 --- a/lib/firebase_options.dart +++ b/lib/firebase_options.dart @@ -1,8 +1,7 @@ // File generated by FlutterFire CLI. // ignore_for_file: type=lint import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; -import 'package:flutter/foundation.dart' - show defaultTargetPlatform, kIsWeb, TargetPlatform; +import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform; /// Default [FirebaseOptions] for use with your Firebase apps. /// @@ -73,10 +72,8 @@ class DefaultFirebaseOptions { projectId: 'accessmoblie-da839', databaseURL: 'https://accessmoblie-da839.firebaseio.com', storageBucket: 'accessmoblie-da839.appspot.com', - androidClientId: - '187064172787-7et0qu5p2qtmisvqgndn3kfi1b7u9ifl.apps.googleusercontent.com', - iosClientId: - '187064172787-c5gs7fvp78om9r7dofkjn2qmpumkuvig.apps.googleusercontent.com', + androidClientId: '187064172787-7et0qu5p2qtmisvqgndn3kfi1b7u9ifl.apps.googleusercontent.com', + iosClientId: '187064172787-c5gs7fvp78om9r7dofkjn2qmpumkuvig.apps.googleusercontent.com', iosBundleId: 'br.com.freaccess.hub', ); } diff --git a/lib/flutter_flow/custom_icons.dart b/lib/flutter_flow/custom_icons.dart index 07cebe2e..92ede9d6 100644 --- a/lib/flutter_flow/custom_icons.dart +++ b/lib/flutter_flow/custom_icons.dart @@ -14,8 +14,7 @@ class FFIcons { static const IconData kvector1 = IconData(0xe902, fontFamily: _iconsFamily); // menu - static const IconData kiconFastPass = - IconData(0xe900, fontFamily: _menuFamily); + static const IconData kiconFastPass = IconData(0xe900, fontFamily: _menuFamily); static const IconData kvector2 = IconData(0xe905, fontFamily: _menuFamily); static const IconData kvector3 = IconData(0xe906, fontFamily: _menuFamily); -} \ No newline at end of file +} diff --git a/lib/flutter_flow/flutter_flow_animations.dart b/lib/flutter_flow/flutter_flow_animations.dart index c101a376..6f897e25 100644 --- a/lib/flutter_flow/flutter_flow_animations.dart +++ b/lib/flutter_flow/flutter_flow_animations.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; - enum AnimationTrigger { onPageLoad, onActionTrigger, @@ -52,12 +51,8 @@ extension AnimatedWidgetExtension on Widget { return Animate( effects: animationInfo.effects, child: this, - onPlay: (controller) => animationInfo.loop - ? controller.repeat(reverse: animationInfo.reverse) - : null, - onComplete: (controller) => !animationInfo.loop && animationInfo.reverse - ? controller.reverse() - : null, + onPlay: (controller) => animationInfo.loop ? controller.repeat(reverse: animationInfo.reverse) : null, + onComplete: (controller) => !animationInfo.loop && animationInfo.reverse ? controller.reverse() : null, ); } @@ -68,11 +63,7 @@ extension AnimatedWidgetExtension on Widget { }) { animationInfo.maybeUpdateEffects(effects); return hasBeenTriggered || animationInfo.applyInitialState - ? Animate( - controller: animationInfo.controller, - autoPlay: false, - effects: animationInfo.effects, - child: this) + ? Animate(controller: animationInfo.controller, autoPlay: false, effects: animationInfo.effects, child: this) : this; } } @@ -109,4 +100,4 @@ class TiltEffect extends Effect { ), ); } -} \ No newline at end of file +} diff --git a/lib/flutter_flow/flutter_flow_button_tabbar.dart b/lib/flutter_flow/flutter_flow_button_tabbar.dart index 4ea6374d..45bee44f 100644 --- a/lib/flutter_flow/flutter_flow_button_tabbar.dart +++ b/lib/flutter_flow/flutter_flow_button_tabbar.dart @@ -6,12 +6,9 @@ import 'package:flutter/gestures.dart' show DragStartBehavior; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; - - const double _kTabHeight = 46.0; -typedef _LayoutCallback = void Function( - List xOffsets, TextDirection textDirection, double width); +typedef _LayoutCallback = void Function(List xOffsets, TextDirection textDirection, double width); class _TabLabelBarRenderer extends RenderFlex { _TabLabelBarRenderer({ @@ -36,8 +33,7 @@ class _TabLabelBarRenderer extends RenderFlex { RenderBox? child = firstChild; final List xOffsets = []; while (child != null) { - final FlexParentData childParentData = - child.parentData! as FlexParentData; + final FlexParentData childParentData = child.parentData! as FlexParentData; xOffsets.add(childParentData.offset.dx); assert(child.parentData == childParentData); child = childParentData.nextSibling; @@ -86,8 +82,7 @@ class _TabLabelBar extends Flex { } @override - void updateRenderObject( - BuildContext context, _TabLabelBarRenderer renderObject) { + void updateRenderObject(BuildContext context, _TabLabelBarRenderer renderObject) { super.updateRenderObject(context, renderObject); renderObject.onPerformLayout = onPerformLayout; } @@ -138,8 +133,7 @@ class _IndicatorPainter extends CustomPainter { assert(_currentTabOffsets!.isNotEmpty); assert(tabIndex >= 0); assert(tabIndex <= maxTabIndex); - return (_currentTabOffsets![tabIndex] + _currentTabOffsets![tabIndex + 1]) / - 2.0; + return (_currentTabOffsets![tabIndex] + _currentTabOffsets![tabIndex + 1]) / 2.0; } @override @@ -194,12 +188,10 @@ class _TabBarScrollPosition extends ScrollPositionWithSingleContext { // ballistic scroll activity. if (!_viewportDimensionWasNonZero || _needsPixelsCorrection) { _needsPixelsCorrection = false; - correctPixels(tabBar._initialScrollOffset( - viewportDimension, minScrollExtent, maxScrollExtent)); + correctPixels(tabBar._initialScrollOffset(viewportDimension, minScrollExtent, maxScrollExtent)); result = false; } - return super.applyContentDimensions(minScrollExtent, maxScrollExtent) && - result; + return super.applyContentDimensions(minScrollExtent, maxScrollExtent) && result; } void markNeedsPixelsCorrection() { @@ -215,8 +207,7 @@ class _TabBarScrollController extends ScrollController { final _FlutterFlowButtonTabBarState tabBar; @override - ScrollPosition createScrollPosition(ScrollPhysics physics, - ScrollContext context, ScrollPosition? oldPosition) { + ScrollPosition createScrollPosition(ScrollPhysics physics, ScrollContext context, ScrollPosition? oldPosition) { return _TabBarScrollPosition( physics: physics, context: context, @@ -227,8 +218,7 @@ class _TabBarScrollController extends ScrollController { } /// A Flutterflow Design widget that displays a horizontal row of tabs. -class FlutterFlowButtonTabBar extends StatefulWidget - implements PreferredSizeWidget { +class FlutterFlowButtonTabBar extends StatefulWidget implements PreferredSizeWidget { /// The [tabs] argument must not be null and its length must match the [controller]'s /// [TabController.length]. /// @@ -362,17 +352,14 @@ class FlutterFlowButtonTabBar extends StatefulWidget maxHeight = math.max(itemHeight, maxHeight); } } - return Size.fromHeight( - maxHeight + labelPadding.vertical + buttonMargin.vertical); + return Size.fromHeight(maxHeight + labelPadding.vertical + buttonMargin.vertical); } @override - State createState() => - _FlutterFlowButtonTabBarState(); + State createState() => _FlutterFlowButtonTabBarState(); } -class _FlutterFlowButtonTabBarState extends State - with TickerProviderStateMixin { +class _FlutterFlowButtonTabBarState extends State with TickerProviderStateMixin { ScrollController? _scrollController; TabController? _controller; _IndicatorPainter? _indicatorPainter; @@ -396,8 +383,7 @@ class _FlutterFlowButtonTabBarState extends State /// The animation duration is 2/3 of the tab scroll animation duration in /// Material design (kTabScrollDuration). - _animationController = AnimationController( - vsync: this, duration: const Duration(milliseconds: 200)); + _animationController = AnimationController(vsync: this, duration: const Duration(milliseconds: 200)); // so the buttons start in their "final" state (color) _animationController @@ -415,8 +401,7 @@ class _FlutterFlowButtonTabBarState extends State bool get _controllerIsValid => _controller?.animation != null; void _updateTabController() { - final TabController? newController = - widget.controller ?? DefaultTabController.maybeOf(context); + final TabController? newController = widget.controller ?? DefaultTabController.maybeOf(context); assert(() { if (newController == null) { throw FlutterError( @@ -501,8 +486,7 @@ class _FlutterFlowButtonTabBarState extends State int get maxTabIndex => _indicatorPainter!.maxTabIndex; - double _tabScrollOffset( - int index, double viewportWidth, double minExtent, double maxExtent) { + double _tabScrollOffset(int index, double viewportWidth, double minExtent, double maxExtent) { if (!widget.isScrollable) { return 0.0; } @@ -518,34 +502,27 @@ class _FlutterFlowButtonTabBarState extends State break; } - return clampDouble( - tabCenter + paddingStart - viewportWidth / 2.0, minExtent, maxExtent); + return clampDouble(tabCenter + paddingStart - viewportWidth / 2.0, minExtent, maxExtent); } double _tabCenteredScrollOffset(int index) { final ScrollPosition position = _scrollController!.position; - return _tabScrollOffset(index, position.viewportDimension, - position.minScrollExtent, position.maxScrollExtent); + return _tabScrollOffset(index, position.viewportDimension, position.minScrollExtent, position.maxScrollExtent); } - double _initialScrollOffset( - double viewportWidth, double minExtent, double maxExtent) { + double _initialScrollOffset(double viewportWidth, double minExtent, double maxExtent) { return _tabScrollOffset(_currentIndex, viewportWidth, minExtent, maxExtent); } void _scrollToCurrentIndex() { final double offset = _tabCenteredScrollOffset(_currentIndex); - _scrollController! - .animateTo(offset, duration: kTabScrollDuration, curve: Curves.ease); + _scrollController!.animateTo(offset, duration: kTabScrollDuration, curve: Curves.ease); } void _scrollToControllerValue() { - final double? leadingPosition = - _currentIndex > 0 ? _tabCenteredScrollOffset(_currentIndex - 1) : null; + final double? leadingPosition = _currentIndex > 0 ? _tabCenteredScrollOffset(_currentIndex - 1) : null; final double middlePosition = _tabCenteredScrollOffset(_currentIndex); - final double? trailingPosition = _currentIndex < maxTabIndex - ? _tabCenteredScrollOffset(_currentIndex + 1) - : null; + final double? trailingPosition = _currentIndex < maxTabIndex ? _tabCenteredScrollOffset(_currentIndex + 1) : null; final double index = _controller!.index.toDouble(); final double value = _controller!.animation!.value; @@ -557,13 +534,9 @@ class _FlutterFlowButtonTabBarState extends State } else if (value == index) { offset = middlePosition; } else if (value < index) { - offset = leadingPosition == null - ? middlePosition - : lerpDouble(middlePosition, leadingPosition, index - value)!; + offset = leadingPosition == null ? middlePosition : lerpDouble(middlePosition, leadingPosition, index - value)!; } else { - offset = trailingPosition == null - ? middlePosition - : lerpDouble(middlePosition, trailingPosition, value - index)!; + offset = trailingPosition == null ? middlePosition : lerpDouble(middlePosition, trailingPosition, value - index)!; } _scrollController!.jumpTo(offset); @@ -601,8 +574,7 @@ class _FlutterFlowButtonTabBarState extends State } // Called each time layout completes. - void _saveTabOffsets( - List tabOffsets, TextDirection textDirection, double width) { + void _saveTabOffsets(List tabOffsets, TextDirection textDirection, double width) { _tabStripWidth = width; _indicatorPainter?.saveTabOffsets(tabOffsets, textDirection); } @@ -626,52 +598,34 @@ class _FlutterFlowButtonTabBarState extends State } final TextStyle? textStyle = TextStyle.lerp( - (widget.unselectedLabelStyle ?? - tabBarTheme.labelStyle ?? - DefaultTextStyle.of(context).style) - .copyWith( + (widget.unselectedLabelStyle ?? tabBarTheme.labelStyle ?? DefaultTextStyle.of(context).style).copyWith( color: widget.unselectedLabelColor, ), - (widget.labelStyle ?? - tabBarTheme.labelStyle ?? - DefaultTextStyle.of(context).style) - .copyWith( + (widget.labelStyle ?? tabBarTheme.labelStyle ?? DefaultTextStyle.of(context).style).copyWith( color: widget.labelColor, ), animationValue); - final Color? textColor = Color.lerp( - widget.unselectedLabelColor, widget.labelColor, animationValue); + final Color? textColor = Color.lerp(widget.unselectedLabelColor, widget.labelColor, animationValue); - final Color? borderColor = Color.lerp( - widget.unselectedBorderColor, widget.borderColor, animationValue); + final Color? borderColor = Color.lerp(widget.unselectedBorderColor, widget.borderColor, animationValue); BoxDecoration? boxDecoration = BoxDecoration.lerp( BoxDecoration( - color: widget.unselectedDecoration?.color ?? - widget.unselectedBackgroundColor ?? - Colors.transparent, + color: widget.unselectedDecoration?.color ?? widget.unselectedBackgroundColor ?? Colors.transparent, boxShadow: widget.unselectedDecoration?.boxShadow, gradient: widget.unselectedDecoration?.gradient, - borderRadius: widget.useToggleButtonStyle - ? null - : BorderRadius.circular(widget.borderRadius), + borderRadius: widget.useToggleButtonStyle ? null : BorderRadius.circular(widget.borderRadius), ), BoxDecoration( - color: widget.decoration?.color ?? - widget.backgroundColor ?? - Colors.transparent, + color: widget.decoration?.color ?? widget.backgroundColor ?? Colors.transparent, boxShadow: widget.decoration?.boxShadow, gradient: widget.decoration?.gradient, - borderRadius: widget.useToggleButtonStyle - ? null - : BorderRadius.circular(widget.borderRadius), + borderRadius: widget.useToggleButtonStyle ? null : BorderRadius.circular(widget.borderRadius), ), animationValue); - if (widget.useToggleButtonStyle && - widget.borderWidth > 0 && - boxDecoration != null) { + if (widget.useToggleButtonStyle && widget.borderWidth > 0 && boxDecoration != null) { if (index == 0) { boxDecoration = boxDecoration.copyWith( border: Border( @@ -705,13 +659,11 @@ class _FlutterFlowButtonTabBarState extends State return Padding( key: _tabKeys[index], // padding for the buttons - padding: - widget.useToggleButtonStyle ? EdgeInsets.zero : widget.buttonMargin, + padding: widget.useToggleButtonStyle ? EdgeInsets.zero : widget.buttonMargin, child: TextButton( onPressed: () => _handleTap(index), style: ButtonStyle( - elevation: WidgetStateProperty.all( - widget.useToggleButtonStyle ? 0 : widget.elevation), + elevation: WidgetStateProperty.all(widget.useToggleButtonStyle ? 0 : widget.elevation), /// give a pretty small minimum size minimumSize: WidgetStateProperty.all(const Size(10, 10)), @@ -777,14 +729,11 @@ class _FlutterFlowButtonTabBarState extends State if (_controller!.length == 0) { return Container( - height: _kTabHeight + - widget.labelPadding.vertical + - widget.buttonMargin.vertical, + height: _kTabHeight + widget.labelPadding.vertical + widget.buttonMargin.vertical, ); } - final List wrappedTabs = - List.generate(widget.tabs.length, (int index) { + final List wrappedTabs = List.generate(widget.tabs.length, (int index) { return _buildStyledTab(widget.tabs[index], index); }); @@ -853,4 +802,4 @@ class _FlutterFlowButtonTabBarState extends State return tabBar; } -} \ No newline at end of file +} diff --git a/lib/flutter_flow/flutter_flow_checkbox_group.dart b/lib/flutter_flow/flutter_flow_checkbox_group.dart index fc089d10..8f367952 100644 --- a/lib/flutter_flow/flutter_flow_checkbox_group.dart +++ b/lib/flutter_flow/flutter_flow_checkbox_group.dart @@ -6,7 +6,6 @@ import 'package:flutter/scheduler.dart'; //// - class FlutterFlowCheckboxGroup extends StatefulWidget { const FlutterFlowCheckboxGroup({ super.key, @@ -38,8 +37,7 @@ class FlutterFlowCheckboxGroup extends StatefulWidget { final TextStyle? unselectedTextStyle; @override - State createState() => - _FlutterFlowCheckboxGroupState(); + State createState() => _FlutterFlowCheckboxGroupState(); } class _FlutterFlowCheckboxGroupState extends State { @@ -87,8 +85,7 @@ class _FlutterFlowCheckboxGroupState extends State { itemBuilder: (context, index) { final option = widget.options[index]; final selected = selectedValues.contains(option); - final unselectedTextStyle = - widget.unselectedTextStyle ?? widget.textStyle; + final unselectedTextStyle = widget.unselectedTextStyle ?? widget.textStyle; return Theme( data: ThemeData(unselectedWidgetColor: widget.checkboxBorderColor), child: Padding( @@ -102,9 +99,7 @@ class _FlutterFlowCheckboxGroupState extends State { if (isSelected == null) { return; } - isSelected - ? checkboxValues.add(option) - : checkboxValues.remove(option); + isSelected ? checkboxValues.add(option) : checkboxValues.remove(option); widget.controller.value = List.from(checkboxValues); setState(() {}); } @@ -112,8 +107,7 @@ class _FlutterFlowCheckboxGroupState extends State { activeColor: widget.activeColor, checkColor: widget.checkColor, shape: RoundedRectangleBorder( - borderRadius: - widget.checkboxBorderRadius ?? BorderRadius.zero, + borderRadius: widget.checkboxBorderRadius ?? BorderRadius.zero, ), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, visualDensity: VisualDensity.compact, @@ -123,8 +117,7 @@ class _FlutterFlowCheckboxGroupState extends State { padding: widget.labelPadding ?? EdgeInsets.zero, child: Text( widget.options[index], - style: - selected ? widget.textStyle : unselectedTextStyle, + style: selected ? widget.textStyle : unselectedTextStyle, ), ), ), @@ -134,4 +127,4 @@ class _FlutterFlowCheckboxGroupState extends State { ); }, ); -} \ No newline at end of file +} diff --git a/lib/flutter_flow/flutter_flow_drop_down.dart b/lib/flutter_flow/flutter_flow_drop_down.dart index 493a9e50..3988efa6 100644 --- a/lib/flutter_flow/flutter_flow_drop_down.dart +++ b/lib/flutter_flow/flutter_flow_drop_down.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'form_field_controller.dart'; - class FlutterFlowDropDown extends StatefulWidget { const FlutterFlowDropDown({ super.key, @@ -87,13 +86,10 @@ class FlutterFlowDropDown extends StatefulWidget { class _FlutterFlowDropDownState extends State> { bool get isMultiSelect => widget.isMultiSelect; FormFieldController get controller => widget.controller!; - FormFieldController?> get multiSelectController => - widget.multiSelectController!; + FormFieldController?> get multiSelectController => widget.multiSelectController!; T? get currentValue { - final value = isMultiSelect - ? multiSelectController.value?.firstOrNull - : controller.value; + final value = isMultiSelect ? multiSelectController.value?.firstOrNull : controller.value; return widget.options.contains(value) ? value : null; } @@ -101,17 +97,14 @@ class _FlutterFlowDropDownState extends State> { if (!isMultiSelect || multiSelectController.value == null) { return {}; } - return widget.options - .toSet() - .intersection(multiSelectController.value!.toSet()); + return widget.options.toSet().intersection(multiSelectController.value!.toSet()); } Map get optionLabels => Map.fromEntries( widget.options.asMap().entries.map( (option) => MapEntry( option.value, - widget.optionLabels == null || - widget.optionLabels!.length < option.key + 1 + widget.optionLabels == null || widget.optionLabels!.length < option.key + 1 ? option.value.toString() : widget.optionLabels![option.key], ), @@ -130,8 +123,7 @@ class _FlutterFlowDropDownState extends State> { void initState() { super.initState(); if (isMultiSelect) { - _listener = - () => widget.onMultiSelectChanged!(multiSelectController.value); + _listener = () => widget.onMultiSelectChanged!(multiSelectController.value); multiSelectController.addListener(_listener); } else { _listener = () => widget.onChanged!(controller.value); @@ -166,22 +158,16 @@ class _FlutterFlowDropDownState extends State> { ), child: Padding( padding: _useDropdown2() ? EdgeInsets.zero : widget.margin, - child: widget.hidesUnderline - ? DropdownButtonHideUnderline(child: dropdownWidget) - : dropdownWidget, + child: widget.hidesUnderline ? DropdownButtonHideUnderline(child: dropdownWidget) : dropdownWidget, ), ), ); } bool _useDropdown2() => - widget.isMultiSelect || - widget.isSearchable || - !widget.isOverButton || - widget.maxHeight != null; + widget.isMultiSelect || widget.isSearchable || !widget.isOverButton || widget.maxHeight != null; - Widget _buildDropdownWidget() => - _useDropdown2() ? _buildDropdown() : _buildLegacyDropdown(); + Widget _buildDropdownWidget() => _useDropdown2() ? _buildDropdown() : _buildLegacyDropdown(); Widget _buildLegacyDropdown() { return DropdownButtonFormField( @@ -195,20 +181,14 @@ class _FlutterFlowDropDownState extends State> { dropdownColor: widget.fillColor, focusColor: Colors.transparent, decoration: InputDecoration( - labelText: widget.labelText == null || widget.labelText!.isEmpty - ? null - : widget.labelText, + labelText: widget.labelText == null || widget.labelText!.isEmpty ? null : widget.labelText, labelStyle: widget.labelTextStyle, - border: widget.hidesUnderline - ? InputBorder.none - : const UnderlineInputBorder(), + border: widget.hidesUnderline ? InputBorder.none : const UnderlineInputBorder(), ), ); } - Text? _createHintText() => widget.hintText != null - ? Text(widget.hintText!, style: widget.textStyle) - : null; + Text? _createHintText() => widget.hintText != null ? Text(widget.hintText!, style: widget.textStyle) : null; List> _createMenuItems() => widget.options .map( @@ -229,14 +209,11 @@ class _FlutterFlowDropDownState extends State> { enabled: false, child: StatefulBuilder( builder: (context, menuSetState) { - final isSelected = - multiSelectController.value?.contains(item) ?? false; + final isSelected = multiSelectController.value?.contains(item) ?? false; return InkWell( onTap: () { multiSelectController.value ??= []; - isSelected - ? multiSelectController.value!.remove(item) - : multiSelectController.value!.add(item); + isSelected ? multiSelectController.value!.remove(item) : multiSelectController.value!.add(item); multiSelectController.update(); // This rebuilds the StatefulWidget to update the button's text. setState(() {}); @@ -269,11 +246,9 @@ class _FlutterFlowDropDownState extends State> { .toList(); Widget _buildDropdown() { - final overlayColor = WidgetStateProperty.resolveWith((states) => - states.contains(WidgetState.focused) ? Colors.transparent : null); - final iconStyleData = widget.icon != null - ? IconStyleData(icon: widget.icon!) - : const IconStyleData(); + final overlayColor = WidgetStateProperty.resolveWith( + (states) => states.contains(WidgetState.focused) ? Colors.transparent : null); + final iconStyleData = widget.icon != null ? IconStyleData(icon: widget.icon!) : const IconStyleData(); return DropdownButton2( value: currentValue, hint: _createHintText(), @@ -299,19 +274,14 @@ class _FlutterFlowDropDownState extends State> { maxHeight: widget.maxHeight, padding: EdgeInsets.zero, ), - onChanged: widget.disabled - ? null - : (isMultiSelect ? (_) {} : (val) => widget.controller!.value = val), + onChanged: widget.disabled ? null : (isMultiSelect ? (_) {} : (val) => widget.controller!.value = val), isExpanded: true, selectedItemBuilder: (context) => widget.options .map((item) => Align( alignment: AlignmentDirectional.centerStart, child: Text( isMultiSelect - ? currentValues - .where((v) => optionLabels.containsKey(v)) - .map((v) => optionLabels[v]) - .join(', ') + ? currentValues.where((v) => optionLabels.containsKey(v)).map((v) => optionLabels[v]).join(', ') : optionLabels[item]!, style: widget.textStyle, maxLines: 1, @@ -351,9 +321,7 @@ class _FlutterFlowDropDownState extends State> { ), ), searchMatchFn: (item, searchValue) { - return (optionLabels[item.value] ?? '') - .toLowerCase() - .contains(searchValue.toLowerCase()); + return (optionLabels[item.value] ?? '').toLowerCase().contains(searchValue.toLowerCase()); }, ) : null, diff --git a/lib/flutter_flow/flutter_flow_icon_button.dart b/lib/flutter_flow/flutter_flow_icon_button.dart index d41b72bb..69e35057 100644 --- a/lib/flutter_flow/flutter_flow_icon_button.dart +++ b/lib/flutter_flow/flutter_flow_icon_button.dart @@ -1,8 +1,6 @@ import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; - - class FlutterFlowIconButton extends StatefulWidget { const FlutterFlowIconButton({ super.key, @@ -92,12 +90,10 @@ class _FlutterFlowIconButtonState extends State { ), iconColor: WidgetStateProperty.resolveWith( (states) { - if (states.contains(WidgetState.disabled) && - widget.disabledIconColor != null) { + if (states.contains(WidgetState.disabled) && widget.disabledIconColor != null) { return widget.disabledIconColor; } - if (states.contains(WidgetState.hovered) && - widget.hoverIconColor != null) { + if (states.contains(WidgetState.hovered) && widget.hoverIconColor != null) { return widget.hoverIconColor; } return iconColor; @@ -105,12 +101,10 @@ class _FlutterFlowIconButtonState extends State { ), backgroundColor: WidgetStateProperty.resolveWith( (states) { - if (states.contains(WidgetState.disabled) && - widget.disabledColor != null) { + if (states.contains(WidgetState.disabled) && widget.disabledColor != null) { return widget.disabledColor; } - if (states.contains(WidgetState.hovered) && - widget.hoverColor != null) { + if (states.contains(WidgetState.hovered) && widget.hoverColor != null) { return widget.hoverColor; } @@ -169,4 +163,4 @@ class _FlutterFlowIconButtonState extends State { ), ); } -} \ No newline at end of file +} diff --git a/lib/flutter_flow/flutter_flow_model.dart b/lib/flutter_flow/flutter_flow_model.dart index 93752ff6..f5b7af2e 100644 --- a/lib/flutter_flow/flutter_flow_model.dart +++ b/lib/flutter_flow/flutter_flow_model.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:provider/provider.dart'; - Widget wrapWithModel({ required T model, required Widget child, @@ -112,8 +111,7 @@ class FlutterFlowDynamicModels { } S? getValueAtIndex(int index, S? Function(T) getValue) { - final uniqueKey = - _childrenIndexes.entries.firstWhereOrNull((e) => e.value == index)?.key; + final uniqueKey = _childrenIndexes.entries.firstWhereOrNull((e) => e.value == index)?.key; return getValueForKey(uniqueKey, getValue); } @@ -163,6 +161,5 @@ T? _getDefaultValue() { } extension TextValidationExtensions on String? Function(BuildContext, String?)? { - String? Function(String?)? asValidator(BuildContext context) => - this != null ? (val) => this!(context, val) : null; -} \ No newline at end of file + String? Function(String?)? asValidator(BuildContext context) => this != null ? (val) => this!(context, val) : null; +} diff --git a/lib/flutter_flow/flutter_flow_theme.dart b/lib/flutter_flow/flutter_flow_theme.dart index 0832ea68..fa892eb1 100644 --- a/lib/flutter_flow/flutter_flow_theme.dart +++ b/lib/flutter_flow/flutter_flow_theme.dart @@ -13,6 +13,7 @@ enum DeviceSize { tablet, desktop, } + DeviceSize getDeviceSize(BuildContext context) { final width = MediaQuery.sizeOf(context).width; if (width < 479) { @@ -27,8 +28,7 @@ DeviceSize getDeviceSize(BuildContext context) { abstract class FlutterFlowTheme { static DeviceSize deviceSize = DeviceSize.mobile; - static Future initialize() async => - _prefs = await SharedPreferences.getInstance(); + static Future initialize() async => _prefs = await SharedPreferences.getInstance(); static ThemeMode get themeMode { final darkMode = _prefs?.getBool(kThemeModeKey); return darkMode == null @@ -37,14 +37,12 @@ abstract class FlutterFlowTheme { ? ThemeMode.dark : ThemeMode.light; } - static void saveThemeMode(ThemeMode mode) => mode == ThemeMode.system - ? _prefs?.remove(kThemeModeKey) - : _prefs?.setBool(kThemeModeKey, mode == ThemeMode.dark); + + static void saveThemeMode(ThemeMode mode) => + mode == ThemeMode.system ? _prefs?.remove(kThemeModeKey) : _prefs?.setBool(kThemeModeKey, mode == ThemeMode.dark); static FlutterFlowTheme of(BuildContext context) { deviceSize = getDeviceSize(context); - return Theme.of(context).brightness == Brightness.dark - ? DarkModeTheme() - : LightModeTheme(); + return Theme.of(context).brightness == Brightness.dark ? DarkModeTheme() : LightModeTheme(); } @Deprecated('Use primary instead') @@ -145,6 +143,7 @@ abstract class FlutterFlowTheme { DeviceSize.desktop: DesktopTypography(this), }[deviceSize]!; } + class LightModeTheme extends FlutterFlowTheme { @Deprecated('Use primary instead') Color get primaryColor => primary; @@ -178,6 +177,7 @@ class LightModeTheme extends FlutterFlowTheme { late Color customColor5 = const Color(0xFF979595); late Color customColor6 = const Color(0xFF525252); } + class DarkModeTheme extends FlutterFlowTheme { @Deprecated('Use primary instead') Color get primaryColor => primary; @@ -244,6 +244,7 @@ abstract class Typography { String get bodySmallFamily; TextStyle get bodySmall; } + class MobileTypography extends Typography { MobileTypography(this.theme); @@ -352,8 +353,8 @@ class MobileTypography extends Typography { fontWeight: FontWeight.normal, fontSize: 12.0, ); - } + class TabletTypography extends Typography { TabletTypography(this.theme); final FlutterFlowTheme theme; @@ -462,8 +463,8 @@ class TabletTypography extends Typography { fontSize: 12.0, ); } -class DesktopTypography extends Typography { +class DesktopTypography extends Typography { DesktopTypography(this.theme); final FlutterFlowTheme theme; String get displayLargeFamily => 'Nunito Sans'; diff --git a/lib/flutter_flow/flutter_flow_util.dart b/lib/flutter_flow/flutter_flow_util.dart index dd9fb1f0..4369bd70 100644 --- a/lib/flutter_flow/flutter_flow_util.dart +++ b/lib/flutter_flow/flutter_flow_util.dart @@ -25,7 +25,6 @@ export 'dart:typed_data' show Uint8List; export 'package:intl/intl.dart'; export 'package:page_transition/page_transition.dart'; -export '/app_state.dart'; export 'custom_icons.dart' show FFIcons; export 'flutter_flow_model.dart'; export 'internationalization.dart' show FFLocalizations; @@ -69,8 +68,7 @@ Theme wrapInMaterialDatePickerTheme( required double iconSize, }) { final baseTheme = Theme.of(context); - final dateTimeMaterialStateForegroundColor = - WidgetStateProperty.resolveWith((states) { + final dateTimeMaterialStateForegroundColor = WidgetStateProperty.resolveWith((states) { if (states.contains(WidgetState.disabled)) { return pickerForegroundColor.withOpacity(0.60); } @@ -83,8 +81,7 @@ Theme wrapInMaterialDatePickerTheme( return null; }); - final dateTimeMaterialStateBackgroundColor = - WidgetStateProperty.resolveWith((states) { + final dateTimeMaterialStateBackgroundColor = WidgetStateProperty.resolveWith((states) { if (states.contains(WidgetState.selected)) { return selectedDateTimeBackgroundColor; } @@ -153,8 +150,7 @@ Theme wrapInMaterialDatePickerTheme( if (states.contains(WidgetState.hovered)) { return actionButtonForegroundColor.withOpacity(0.04); } - if (states.contains(WidgetState.focused) || - states.contains(WidgetState.pressed)) { + if (states.contains(WidgetState.focused) || states.contains(WidgetState.pressed)) { return actionButtonForegroundColor.withOpacity(0.12); } return null; @@ -259,8 +255,7 @@ Theme wrapInMaterialTimePickerTheme( if (states.contains(WidgetState.hovered)) { return actionButtonForegroundColor.withOpacity(0.04); } - if (states.contains(WidgetState.focused) || - states.contains(WidgetState.pressed)) { + if (states.contains(WidgetState.focused) || states.contains(WidgetState.pressed)) { return actionButtonForegroundColor.withOpacity(0.12); } return null; @@ -272,9 +267,7 @@ Theme wrapInMaterialTimePickerTheme( hourMinuteTextColor: pickerForegroundColor, dialHandColor: selectedDateTimeBackgroundColor, dialTextColor: WidgetStateColor.resolveWith((states) => - states.contains(WidgetState.selected) - ? selectedDateTimeForegroundColor - : pickerDialForegroundColor), + states.contains(WidgetState.selected) ? selectedDateTimeForegroundColor : pickerDialForegroundColor), dayPeriodBorderSide: BorderSide( color: pickerForegroundColor, ), @@ -283,13 +276,9 @@ Theme wrapInMaterialTimePickerTheme( fontSize: limitedFontSize, ), dayPeriodTextColor: WidgetStateColor.resolveWith((states) => - states.contains(WidgetState.selected) - ? selectedDateTimeForegroundColor - : pickerForegroundColor), - dayPeriodColor: WidgetStateColor.resolveWith((states) => - states.contains(WidgetState.selected) - ? selectedDateTimeBackgroundColor - : Colors.transparent), + states.contains(WidgetState.selected) ? selectedDateTimeForegroundColor : pickerForegroundColor), + dayPeriodColor: WidgetStateColor.resolveWith( + (states) => states.contains(WidgetState.selected) ? selectedDateTimeBackgroundColor : Colors.transparent), entryModeIconColor: pickerForegroundColor, ), ), @@ -372,8 +361,7 @@ String formatNumber( break; case FormatType.custom: final hasLocale = locale != null && locale.isNotEmpty; - formattedValue = - NumberFormat(format, hasLocale ? locale : null).format(value); + formattedValue = NumberFormat(format, hasLocale ? locale : null).format(value); } if (formattedValue.isEmpty) { @@ -381,9 +369,7 @@ String formatNumber( } if (currency != null) { - final currencySymbol = currency.isNotEmpty - ? currency - : NumberFormat.simpleCurrency().format(0.0).substring(0, 1); + final currencySymbol = currency.isNotEmpty ? currency : NumberFormat.simpleCurrency().format(0.0).substring(0, 1); formattedValue = '$currencySymbol$formattedValue'; } @@ -441,9 +427,7 @@ dynamic getJsonField( } final value = field.first.value; if (isForList) { - return value is! Iterable - ? [value] - : (value is List ? value : value.toList()); + return value is! Iterable ? [value] : (value is List ? value : value.toList()); } return value; } @@ -464,8 +448,7 @@ bool get isWeb => kIsWeb; const kBreakpointSmall = 479.0; const kBreakpointMedium = 767.0; const kBreakpointLarge = 991.0; -bool isMobileWidth(BuildContext context) => - MediaQuery.sizeOf(context).width < kBreakpointSmall; +bool isMobileWidth(BuildContext context) => MediaQuery.sizeOf(context).width < kBreakpointSmall; bool responsiveVisibility({ required BuildContext context, bool phone = true, @@ -498,28 +481,21 @@ extension FFTextEditingControllerExt on TextEditingController? { } extension IterableExt on Iterable { - List sortedList( - {S Function(T)? keyOf, bool desc = false}) { - final sortedAscending = toList() - ..sort(keyOf == null ? null : ((a, b) => keyOf(a).compareTo(keyOf(b)))); + List sortedList({S Function(T)? keyOf, bool desc = false}) { + final sortedAscending = toList()..sort(keyOf == null ? null : ((a, b) => keyOf(a).compareTo(keyOf(b)))); if (desc) { return sortedAscending.reversed.toList(); } return sortedAscending; } - List mapIndexed(S Function(int, T) func) => toList() - .asMap() - .map((index, value) => MapEntry(index, func(index, value))) - .values - .toList(); + List mapIndexed(S Function(int, T) func) => + toList().asMap().map((index, value) => MapEntry(index, func(index, value))).values.toList(); } -void setAppLanguage(BuildContext context, String language) => - App.of(context).setLocale(language); +void setAppLanguage(BuildContext context, String language) => App.of(context).setLocale(language); -void setDarkModeSetting(BuildContext context, ThemeMode themeMode) => - App.of(context).setThemeMode(themeMode); +void setDarkModeSetting(BuildContext context, ThemeMode themeMode) => App.of(context).setThemeMode(themeMode); void showSnackbar( BuildContext context, @@ -553,9 +529,7 @@ void showSnackbar( ], ), duration: Duration(seconds: duration), - backgroundColor: error - ? FlutterFlowTheme.of(context).error - : FlutterFlowTheme.of(context).success, + backgroundColor: error ? FlutterFlowTheme.of(context).error : FlutterFlowTheme.of(context).success, behavior: SnackBarBehavior.floating, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(30), @@ -642,9 +616,7 @@ void showAlertDialog(BuildContext context, String title, String content, extension FFStringExt on String { String maybeHandleOverflow({int? maxChars, String replacement = ''}) => - maxChars != null && length > maxChars - ? replaceRange(maxChars, null, replacement) - : this; + maxChars != null && length > maxChars ? replaceRange(maxChars, null, replacement) : this; } extension ListFilterExt on Iterable { @@ -653,16 +625,13 @@ extension ListFilterExt on Iterable { extension MapFilterExtensions on Map { Map get withoutNulls => Map.fromEntries( - entries - .where((e) => e.value != null) - .map((e) => MapEntry(e.key, e.value as T)), + entries.where((e) => e.value != null).map((e) => MapEntry(e.key, e.value as T)), ); } extension MapListContainsExt on List { - bool containsMap(dynamic map) => map is Map - ? any((e) => e is Map && const DeepCollectionEquality().equals(e, map)) - : contains(map); + bool containsMap(dynamic map) => + map is Map ? any((e) => e is Map && const DeepCollectionEquality().equals(e, map)) : contains(map); } extension ListDivideExt on Iterable { @@ -670,23 +639,17 @@ extension ListDivideExt on Iterable { List divide(Widget t, {bool Function(int)? filterFn}) => isEmpty ? [] - : (enumerate - .map((e) => [e.value, if (filterFn == null || filterFn(e.key)) t]) - .expand((i) => i) - .toList() + : (enumerate.map((e) => [e.value, if (filterFn == null || filterFn(e.key)) t]).expand((i) => i).toList() ..removeLast()); List around(Widget t) => addToStart(t).addToEnd(t); - List addToStart(Widget t) => - enumerate.map((e) => e.value).toList()..insert(0, t); + List addToStart(Widget t) => enumerate.map((e) => e.value).toList()..insert(0, t); - List addToEnd(Widget t) => - enumerate.map((e) => e.value).toList()..add(t); + List addToEnd(Widget t) => enumerate.map((e) => e.value).toList()..add(t); List paddingTopEach(double val) => - map((w) => Padding(padding: EdgeInsets.only(top: val), child: w)) - .toList(); + map((w) => Padding(padding: EdgeInsets.only(top: val), child: w)).toList(); } extension StatefulWidgetExtensions on State { diff --git a/lib/flutter_flow/flutter_flow_widgets.dart b/lib/flutter_flow/flutter_flow_widgets.dart index 7dc905a0..73bac9aa 100644 --- a/lib/flutter_flow/flutter_flow_widgets.dart +++ b/lib/flutter_flow/flutter_flow_widgets.dart @@ -2,7 +2,6 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:flutter/material.dart'; import 'package:auto_size_text/auto_size_text.dart'; - class FFButtonOptions { const FFButtonOptions({ this.textAlign, @@ -75,16 +74,13 @@ class _FFButtonWidgetState extends State { bool loading = false; int get maxLines => widget.options.maxLines ?? 1; - String? get text => - widget.options.textStyle?.fontSize == 0 ? null : widget.text; + String? get text => widget.options.textStyle?.fontSize == 0 ? null : widget.text; @override Widget build(BuildContext context) { Widget textWidget = loading ? SizedBox( - width: widget.options.width == null - ? _getTextWidth(text, widget.options.textStyle, maxLines) - : null, + width: widget.options.width == null ? _getTextWidth(text, widget.options.textStyle, maxLines) : null, child: Center( child: SizedBox( width: 23, @@ -99,8 +95,7 @@ class _FFButtonWidgetState extends State { ) : Text( text ?? '', - style: - text == null ? null : widget.options.textStyle?.withoutColor(), + style: text == null ? null : widget.options.textStyle?.withoutColor(), textAlign: widget.options.textAlign, maxLines: maxLines, overflow: TextOverflow.ellipsis, @@ -128,29 +123,24 @@ class _FFButtonWidgetState extends State { ButtonStyle style = ButtonStyle( shape: WidgetStateProperty.resolveWith( (states) { - if (states.contains(WidgetState.hovered) && - widget.options.hoverBorderSide != null) { + if (states.contains(WidgetState.hovered) && widget.options.hoverBorderSide != null) { return RoundedRectangleBorder( - borderRadius: - widget.options.borderRadius ?? BorderRadius.circular(8), + borderRadius: widget.options.borderRadius ?? BorderRadius.circular(8), side: widget.options.hoverBorderSide!, ); } return RoundedRectangleBorder( - borderRadius: - widget.options.borderRadius ?? BorderRadius.circular(8), + borderRadius: widget.options.borderRadius ?? BorderRadius.circular(8), side: widget.options.borderSide ?? BorderSide.none, ); }, ), foregroundColor: WidgetStateProperty.resolveWith( (states) { - if (states.contains(WidgetState.disabled) && - widget.options.disabledTextColor != null) { + if (states.contains(WidgetState.disabled) && widget.options.disabledTextColor != null) { return widget.options.disabledTextColor; } - if (states.contains(WidgetState.hovered) && - widget.options.hoverTextColor != null) { + if (states.contains(WidgetState.hovered) && widget.options.hoverTextColor != null) { return widget.options.hoverTextColor; } return widget.options.textStyle?.color ?? Colors.white; @@ -158,12 +148,10 @@ class _FFButtonWidgetState extends State { ), backgroundColor: WidgetStateProperty.resolveWith( (states) { - if (states.contains(WidgetState.disabled) && - widget.options.disabledColor != null) { + if (states.contains(WidgetState.disabled) && widget.options.disabledColor != null) { return widget.options.disabledColor; } - if (states.contains(WidgetState.hovered) && - widget.options.hoverColor != null) { + if (states.contains(WidgetState.hovered) && widget.options.hoverColor != null) { return widget.options.hoverColor; } return widget.options.color; @@ -175,12 +163,11 @@ class _FFButtonWidgetState extends State { } return widget.options.hoverColor == null ? null : Colors.transparent; }), - padding: WidgetStateProperty.all(widget.options.padding ?? - const EdgeInsets.symmetric(horizontal: 12.0, vertical: 4.0)), + padding: WidgetStateProperty.all( + widget.options.padding ?? const EdgeInsets.symmetric(horizontal: 12.0, vertical: 4.0)), elevation: WidgetStateProperty.resolveWith( (states) { - if (states.contains(WidgetState.hovered) && - widget.options.hoverElevation != null) { + if (states.contains(WidgetState.hovered) && widget.options.hoverElevation != null) { return widget.options.hoverElevation!; } return widget.options.elevation ?? 2.0; @@ -204,8 +191,7 @@ class _FFButtonWidgetState extends State { border: Border.fromBorderSide( widget.options.borderSide ?? BorderSide.none, ), - borderRadius: - widget.options.borderRadius ?? BorderRadius.circular(8), + borderRadius: widget.options.borderRadius ?? BorderRadius.circular(8), ), child: IconButton( splashRadius: 1.0, @@ -278,13 +264,12 @@ extension _WithoutColorExtension on TextStyle { } // Slightly hacky method of getting the layout width of the provided text. -double? _getTextWidth(String? text, TextStyle? style, int maxLines) => - text != null - ? (TextPainter( - text: TextSpan(text: text, style: style), - textDirection: TextDirection.ltr, - maxLines: maxLines, - )..layout()) - .size - .width - : null; \ No newline at end of file +double? _getTextWidth(String? text, TextStyle? style, int maxLines) => text != null + ? (TextPainter( + text: TextSpan(text: text, style: style), + textDirection: TextDirection.ltr, + maxLines: maxLines, + )..layout()) + .size + .width + : null; diff --git a/lib/flutter_flow/form_field_controller.dart b/lib/flutter_flow/form_field_controller.dart index 1d152bb9..b8d79ccb 100644 --- a/lib/flutter_flow/form_field_controller.dart +++ b/lib/flutter_flow/form_field_controller.dart @@ -1,6 +1,5 @@ import 'package:flutter/foundation.dart'; - class FormFieldController extends ValueNotifier { FormFieldController(this.initialValue) : super(initialValue); @@ -16,9 +15,8 @@ class FormFieldController extends ValueNotifier { class FormListFieldController extends FormFieldController> { final List? _initialListValue; - FormListFieldController(super.initialValue) - : _initialListValue = List.from(initialValue ?? []); + FormListFieldController(super.initialValue) : _initialListValue = List.from(initialValue ?? []); @override void reset() => value = List.from(_initialListValue ?? []); -} \ No newline at end of file +} diff --git a/lib/flutter_flow/internationalization.dart b/lib/flutter_flow/internationalization.dart index ffb64dcd..a7fd9712 100644 --- a/lib/flutter_flow/internationalization.dart +++ b/lib/flutter_flow/internationalization.dart @@ -9,16 +9,13 @@ class FFLocalizations { final Locale locale; - static FFLocalizations of(BuildContext context) => - Localizations.of(context, FFLocalizations)!; + static FFLocalizations of(BuildContext context) => Localizations.of(context, FFLocalizations)!; static List languages() => ['pt', 'en']; static late SharedPreferences _prefs; - static Future initialize() async => - _prefs = await SharedPreferences.getInstance(); - static Future storeLocale(String locale) => - _prefs.setString(_kLocaleStorageKey, locale); + static Future initialize() async => _prefs = await SharedPreferences.getInstance(); + static Future storeLocale(String locale) => _prefs.setString(_kLocaleStorageKey, locale); static Locale? getStoredLocale() { final locale = _prefs.getString(_kLocaleStorageKey); return locale != null && locale.isNotEmpty ? createLocale(locale) : null; @@ -26,15 +23,10 @@ class FFLocalizations { String get languageCode => locale.toString(); String? get languageShortCode => - _languagesWithShortCode.contains(locale.toString()) - ? '${locale.toString()}_short' - : null; - int get languageIndex => languages().contains(languageCode) - ? languages().indexOf(languageCode) - : 0; + _languagesWithShortCode.contains(locale.toString()) ? '${locale.toString()}_short' : null; + int get languageIndex => languages().contains(languageCode) ? languages().indexOf(languageCode) : 0; - String getText(String key) => - (kTranslationsMap[key] ?? {})[locale.toString()] ?? ''; + String getText(String key) => (kTranslationsMap[key] ?? {})[locale.toString()] ?? ''; String getVariableText({ String? ptText = '', @@ -83,15 +75,12 @@ class FFLocalizationsDelegate extends LocalizationsDelegate { bool isSupported(Locale locale) { final language = locale.toString(); return FFLocalizations.languages().contains( - language.endsWith('_') - ? language.substring(0, language.length - 1) - : language, + language.endsWith('_') ? language.substring(0, language.length - 1) : language, ); } @override - Future load(Locale locale) => - SynchronousFuture(FFLocalizations(locale)); + Future load(Locale locale) => SynchronousFuture(FFLocalizations(locale)); @override bool shouldReload(FFLocalizationsDelegate old) => false; @@ -1062,10 +1051,8 @@ final kTranslationsMap = >>[ 'en': 'FORGOT YOUR PASSWORD?', }, 'wu2f7yzo': { - 'pt': - 'Não se preucupe nós vamos te ajudar, digite o email cadastrado no aplicativo e clique em enviar.', - 'en': - 'Don\'t worry, we will help you, enter the email registered in the application and click send.', + 'pt': 'Não se preucupe nós vamos te ajudar, digite o email cadastrado no aplicativo e clique em enviar.', + 'en': 'Don\'t worry, we will help you, enter the email registered in the application and click send.', }, 'mtz8l7ft': { 'pt': 'E-mail', @@ -1180,10 +1167,8 @@ final kTranslationsMap = >>[ 'en': 'ENTER YOUR PASSWORD', }, 'ujodm2ci': { - 'pt': - 'Para gerar o QR Code digite a senha cadastrada no aplicativo e clique em enviar.', - 'en': - 'To generate the QR Code, enter the password registered in the application and click send.', + 'pt': 'Para gerar o QR Code digite a senha cadastrada no aplicativo e clique em enviar.', + 'en': 'To generate the QR Code, enter the password registered in the application and click send.', }, 'rfqrdet7': { 'pt': 'Senha', diff --git a/lib/flutter_flow/keep_alive_wrapper.dart b/lib/flutter_flow/keep_alive_wrapper.dart index fd9c5150..464ba0ca 100644 --- a/lib/flutter_flow/keep_alive_wrapper.dart +++ b/lib/flutter_flow/keep_alive_wrapper.dart @@ -12,8 +12,7 @@ class KeepAliveWidgetWrapper extends StatefulWidget { State createState() => _KeepAliveWidgetWrapperState(); } -class _KeepAliveWidgetWrapperState extends State - with AutomaticKeepAliveClientMixin { +class _KeepAliveWidgetWrapperState extends State with AutomaticKeepAliveClientMixin { @override bool get wantKeepAlive => true; @@ -22,4 +21,4 @@ class _KeepAliveWidgetWrapperState extends State super.build(context); return widget.builder(context); } -} \ No newline at end of file +} diff --git a/lib/flutter_flow/lat_lng.dart b/lib/flutter_flow/lat_lng.dart index 68758f91..88ef1eae 100644 --- a/lib/flutter_flow/lat_lng.dart +++ b/lib/flutter_flow/lat_lng.dart @@ -12,8 +12,5 @@ class LatLng { int get hashCode => latitude.hashCode + longitude.hashCode; @override - bool operator ==(other) => - other is LatLng && - latitude == other.latitude && - longitude == other.longitude; -} \ No newline at end of file + bool operator ==(other) => other is LatLng && latitude == other.latitude && longitude == other.longitude; +} diff --git a/lib/flutter_flow/nav/nav.dart b/lib/flutter_flow/nav/nav.dart index 3fcf2daf..09826746 100644 --- a/lib/flutter_flow/nav/nav.dart +++ b/lib/flutter_flow/nav/nav.dart @@ -12,8 +12,9 @@ import 'package:hub/pages/pets_page/pets_page_widget.dart'; import 'package:hub/pages/provisional_schedule_page/provisional_schedule_widget.dart'; import 'package:hub/pages/reception_page/reception_page_widget.dart'; import 'package:hub/pages/reservation_page/reservation_page_widget.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; -import 'package:hub/shared/utils/storage_util.dart'; import 'package:provider/provider.dart'; import '../../shared/utils/dialog_util.dart'; @@ -27,7 +28,6 @@ export 'serialization_util.dart'; const kTransitionInfoKey = '__transition_info__'; - class AppStateNotifier extends ChangeNotifier { AppStateNotifier._(); @@ -43,15 +43,6 @@ class AppStateNotifier extends ChangeNotifier { } GoRouter createRouter(AppStateNotifier appStateNotifier) { - final bool isLogged = StorageUtil().isLogged; - final bool? haveLocal = StorageUtil().haveLocal; - final bool haveUserUUID = StorageUtil().userUUID.isNotEmpty; - final bool haveDevUUID = StorageUtil().devUUID.isNotEmpty; - final bool isRecovered = StorageUtil().isRecovered; - - log('() => isLogged: $isLogged'); - log('() => haveLocal: $haveLocal'); - return GoRouter( initialLocation: '/', debugLogDiagnostics: true, @@ -87,41 +78,51 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) { name: '_initialize', path: '/', builder: (context, _) { - try { - return isLogged && haveDevUUID && haveUserUUID - ? haveLocal == true - ? const HomePageWidget() - : const ReceptionPageWidget() - : const WelcomePageWidget(); - } catch (e) { - DialogUtil.error(context, e.toString()); - return const WelcomePageWidget(); - } + return FutureBuilder( + future: () async { + final bool isLogged = await StorageHelper().get(SecureStorageKey.isLogged.value, Storage.SecureStorage) == 'true'; + final bool haveLocal = await StorageHelper().get(SecureStorageKey.haveLocal.value, Storage.SecureStorage) == 'true'; + final bool haveUserUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage))?.isNotEmpty ?? false; + final bool haveDevUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage))?.isNotEmpty ?? false; + + if (isLogged && haveDevUUID && haveUserUUID) { + return haveLocal ? const HomePageWidget() : const ReceptionPageWidget(); + } else { + return const WelcomePageWidget(); + } + }(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center(child: CircularProgressIndicator()); + } else if (snapshot.hasError) { + DialogUtil.error(context, snapshot.error.toString()); + return const WelcomePageWidget(); + } else { + return snapshot.data!; + } + }, + ); }, ), FFRoute( - name: 'forgotPassword', - path: '/forgotPassword', - builder: (context, params) { - late final String email = params.getParam('email', ParamType.String); - late final String token = params.getParam('token', ParamType.String); + name: 'forgotPassword', + path: '/forgotPassword', + builder: (context, params) { + late final String email = params.getParam('email', ParamType.String); + late final String token = params.getParam('token', ParamType.String); - return ForgotPasswordScreen( - key: UniqueKey(), - email: email, - token: token, - ); - } - ), + return ForgotPasswordScreen( + key: UniqueKey(), + email: email, + token: token, + ); + }), FFRoute( name: 'homePage', path: '/homePage', - builder: (context, params) => HomePageWidget(key: UniqueKey()), + builder: (context, params) => HomePageWidget(key: UniqueKey()), ), - FFRoute( - name: 'receptionPage', - path: '/receptionPage', - builder: (context, params) => const ReceptionPageWidget()), + FFRoute(name: 'receptionPage', path: '/receptionPage', builder: (context, params) => const ReceptionPageWidget()), FFRoute( name: 'messageHistoryPage', path: '/messageHistoryPage', @@ -236,11 +237,10 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) { extension NavParamExtensions on Map { Map get withoutNulls => Map.fromEntries( - entries - .where((e) => e.value != null) - .map((e) => MapEntry(e.key, e.value!)), + entries.where((e) => e.value != null).map((e) => MapEntry(e.key, e.value!)), ); } + extension NavigationExtensions on BuildContext { void safePop() { // If there is only one route on the stack, navigate to the initial @@ -252,9 +252,9 @@ extension NavigationExtensions on BuildContext { } } } + extension _GoRouterStateExtensions on GoRouterState { - Map get extraMap => - extra != null ? extra as Map : {}; + Map get extraMap => extra != null ? extra as Map : {}; Map get allParams => {} ..addAll(pathParameters) ..addAll(uri.queryParameters) @@ -263,12 +263,12 @@ extension _GoRouterStateExtensions on GoRouterState { ? extraMap[kTransitionInfoKey] as TransitionInfo : TransitionInfo.appDefault(); } + extension GoRouterLocationExtension on GoRouter { String getCurrentLocation() { final RouteMatch lastMatch = routerDelegate.currentConfiguration.last; - final RouteMatchList matchList = lastMatch is ImperativeRouteMatch - ? lastMatch.matches - : routerDelegate.currentConfiguration; + final RouteMatchList matchList = + lastMatch is ImperativeRouteMatch ? lastMatch.matches : routerDelegate.currentConfiguration; return matchList.uri.toString(); } } @@ -284,17 +284,13 @@ class FFParameters { // Parameters are empty if the params map is empty or if the only parameter // present is the special extra parameter reserved for the transition info. bool get isEmpty => - state.allParams.isEmpty || - (state.allParams.length == 1 && - state.extraMap.containsKey(kTransitionInfoKey)); - bool isAsyncParam(MapEntry param) => - asyncParams.containsKey(param.key) && param.value is String; + state.allParams.isEmpty || (state.allParams.length == 1 && state.extraMap.containsKey(kTransitionInfoKey)); + bool isAsyncParam(MapEntry param) => asyncParams.containsKey(param.key) && param.value is String; bool get hasFutures => state.allParams.entries.any(isAsyncParam); Future completeFutures() => Future.wait( state.allParams.entries.where(isAsyncParam).map( (param) async { - final doc = await asyncParams[param.key]!(param.value) - .onError((_, __) => null); + final doc = await asyncParams[param.key]!(param.value).onError((_, __) => null); if (doc != null) { futureParamValues[param.key] = doc; return true; @@ -330,6 +326,7 @@ class FFParameters { ); } } + class FFRoute { const FFRoute({ required this.name, @@ -367,9 +364,7 @@ class FFRoute { key: state.pageKey, child: child, transitionDuration: transitionInfo.duration, - transitionsBuilder: - (context, animation, secondaryAnimation, child) => - PageTransition( + transitionsBuilder: (context, animation, secondaryAnimation, child) => PageTransition( type: transitionInfo.transitionType, duration: transitionInfo.duration, reverseDuration: transitionInfo.duration, @@ -387,6 +382,7 @@ class FFRoute { routes: routes, ); } + class TransitionInfo { const TransitionInfo({ required this.hasTransition, @@ -400,9 +396,9 @@ class TransitionInfo { final Duration duration; final Alignment? alignment; - static TransitionInfo appDefault() => - const TransitionInfo(hasTransition: false); + static TransitionInfo appDefault() => const TransitionInfo(hasTransition: false); } + class RootPageContext { const RootPageContext(this.isRootPage, [this.errorRoute]); final bool isRootPage; @@ -412,13 +408,11 @@ class RootPageContext { final rootPageContext = context.read(); final isRootPage = rootPageContext?.isRootPage ?? false; final location = GoRouterState.of(context).uri.toString(); - return isRootPage && - location != '/' && - location != rootPageContext?.errorRoute; + return isRootPage && location != '/' && location != rootPageContext?.errorRoute; } + static Widget wrap(Widget child, {String? errorRoute}) => Provider.value( value: RootPageContext(true, errorRoute), child: child, ); } - diff --git a/lib/flutter_flow/nav/serialization_util.dart b/lib/flutter_flow/nav/serialization_util.dart index 9ee5ecdb..02f636c4 100644 --- a/lib/flutter_flow/nav/serialization_util.dart +++ b/lib/flutter_flow/nav/serialization_util.dart @@ -27,8 +27,7 @@ String placeToString(FFPlace place) => jsonEncode({ 'zipCode': place.zipCode, }); -String uploadedFileToString(FFUploadedFile uploadedFile) => - uploadedFile.serialize(); +String uploadedFileToString(FFUploadedFile uploadedFile) => uploadedFile.serialize(); String? serializeParam( dynamic param, @@ -137,8 +136,7 @@ FFPlace placeFromString(String placeStr) { ); } -FFUploadedFile uploadedFileFromString(String uploadedFileStr) => - FFUploadedFile.deserialize(uploadedFileStr); +FFUploadedFile uploadedFileFromString(String uploadedFileStr) => FFUploadedFile.deserialize(uploadedFileStr); enum ParamType { int, @@ -196,9 +194,7 @@ dynamic deserializeParam( return param == 'true'; case ParamType.DateTime: final milliseconds = int.tryParse(param); - return milliseconds != null - ? DateTime.fromMillisecondsSinceEpoch(milliseconds) - : null; + return milliseconds != null ? DateTime.fromMillisecondsSinceEpoch(milliseconds) : null; case ParamType.DateTimeRange: return dateTimeRangeFromString(param); case ParamType.LatLng: diff --git a/lib/flutter_flow/permissions_util.dart b/lib/flutter_flow/permissions_util.dart index 10768b17..31c0ad28 100644 --- a/lib/flutter_flow/permissions_util.dart +++ b/lib/flutter_flow/permissions_util.dart @@ -13,5 +13,4 @@ Future getPermissionStatus(Permission setting) async { return kPermissionStateToBool[status]!; } -Future requestPermission(Permission setting) async => - await setting.request(); \ No newline at end of file +Future requestPermission(Permission setting) async => await setting.request(); diff --git a/lib/flutter_flow/place.dart b/lib/flutter_flow/place.dart index 972fb8be..e3589b3b 100644 --- a/lib/flutter_flow/place.dart +++ b/lib/flutter_flow/place.dart @@ -43,4 +43,4 @@ class FFPlace { state == other.state && country == other.country && zipCode == other.zipCode; -} \ No newline at end of file +} diff --git a/lib/flutter_flow/random_data_util.dart b/lib/flutter_flow/random_data_util.dart index fd966a2c..c3e508f7 100644 --- a/lib/flutter_flow/random_data_util.dart +++ b/lib/flutter_flow/random_data_util.dart @@ -29,16 +29,14 @@ String randomString( if (digits) { chars += '0123456789'; } - return List.generate(randomInteger(minLength, maxLength), - (index) => chars[_random.nextInt(chars.length)]).join(); + return List.generate(randomInteger(minLength, maxLength), (index) => chars[_random.nextInt(chars.length)]).join(); } // Random date between 1970 and 2025. DateTime randomDate() { // Random max must be in range 0 < max <= 2^32. // So we have to generate the time in seconds and then convert to milliseconds. - return DateTime.fromMillisecondsSinceEpoch( - randomInteger(0, 1735689600) * 1000); + return DateTime.fromMillisecondsSinceEpoch(randomInteger(0, 1735689600) * 1000); } String randomImageUrl(int width, int height) { @@ -46,6 +44,5 @@ String randomImageUrl(int width, int height) { } Color randomColor() { - return Color.fromARGB( - 255, _random.nextInt(255), _random.nextInt(255), _random.nextInt(255)); -} \ No newline at end of file + return Color.fromARGB(255, _random.nextInt(255), _random.nextInt(255), _random.nextInt(255)); +} diff --git a/lib/flutter_flow/request_manager.dart b/lib/flutter_flow/request_manager.dart index c9b4dcc8..d130fb08 100644 --- a/lib/flutter_flow/request_manager.dart +++ b/lib/flutter_flow/request_manager.dart @@ -24,8 +24,7 @@ class FutureRequestManager { } // Remove the first cached result if we have reached the specified limit, // since we will be adding another. - if (!_requests.containsKey(uniqueQueryKey) && - _requests.length >= cacheLimit) { + if (!_requests.containsKey(uniqueQueryKey) && _requests.length >= cacheLimit) { _requests.remove(_requests.keys.first); } // Return the cached query result or set it to the new value. @@ -69,9 +68,8 @@ class StreamRequestManager { // Create a subscription that stores the latest result in the behavior subject. final streamSubject = BehaviorSubject(); - _requestSubscriptions[uniqueQueryKey] = requestFn() - .asBroadcastStream() - .listen((result) => streamSubject.add(result)); + _requestSubscriptions[uniqueQueryKey] = + requestFn().asBroadcastStream().listen((result) => streamSubject.add(result)); _streamSubjects[uniqueQueryKey] = streamSubject; return streamSubject.stream; @@ -89,5 +87,4 @@ class StreamRequestManager { }.forEach(clearRequest); } -String _requestKey(String? key) => - key == null || key.isEmpty ? '__DEFAULT_KEY__' : key; \ No newline at end of file +String _requestKey(String? key) => key == null || key.isEmpty ? '__DEFAULT_KEY__' : key; diff --git a/lib/flutter_flow/upload_data.dart b/lib/flutter_flow/upload_data.dart index 5673b06a..ae1b780d 100644 --- a/lib/flutter_flow/upload_data.dart +++ b/lib/flutter_flow/upload_data.dart @@ -65,9 +65,7 @@ Future?> selectMediaWithSourceBottomSheetandFaceDetection({ enableLandmarks: true, ), ); - createUploadMediaListTile( - String label, MediaSource mediaSource, IconData icon) => - ListTile( + createUploadMediaListTile(String label, MediaSource mediaSource, IconData icon) => ListTile( title: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -110,15 +108,12 @@ Future?> selectMediaWithSourceBottomSheetandFaceDetection({ padding: const EdgeInsets.fromLTRB(0, 8, 0, 0), child: ListTile( title: Text( - FFLocalizations.of(context).getVariableText( - ptText: "Escolha uma das opções", - enText: "Choose one of the options"), + FFLocalizations.of(context) + .getVariableText(ptText: "Escolha uma das opções", enText: "Choose one of the options"), textAlign: TextAlign.center, style: GoogleFonts.getFont( pickerFontFamily, - color: FlutterFlowTheme.of(context) - .primaryText - .withOpacity(0.65), + color: FlutterFlowTheme.of(context).primaryText.withOpacity(0.65), fontWeight: FontWeight.w500, fontSize: 14, ), @@ -134,40 +129,35 @@ Future?> selectMediaWithSourceBottomSheetandFaceDetection({ if (allowPhoto && allowVideo) ...[ Expanded( child: createUploadMediaListTile( - FFLocalizations.of(context).getVariableText( - ptText: "Galeria (Foto)", - enText: "Gallery (Photo)"), + FFLocalizations.of(context) + .getVariableText(ptText: "Galeria (Foto)", enText: "Gallery (Photo)"), MediaSource.photoGallery, Icons.camera), ), Expanded( child: createUploadMediaListTile( - FFLocalizations.of(context).getVariableText( - ptText: "Galeria (Video)", - enText: "Gallery (Video)"), + FFLocalizations.of(context) + .getVariableText(ptText: "Galeria (Video)", enText: "Gallery (Video)"), MediaSource.videoGallery, Icons.videocam), ) ] else if (allowPhoto) Expanded( child: createUploadMediaListTile( - FFLocalizations.of(context).getVariableText( - ptText: "Galeria", enText: "Gallery"), + FFLocalizations.of(context).getVariableText(ptText: "Galeria", enText: "Gallery"), MediaSource.photoGallery, Icons.photo)) else Expanded( child: createUploadMediaListTile( - FFLocalizations.of(context).getVariableText( - ptText: "Galeria", enText: "Gallery"), + FFLocalizations.of(context).getVariableText(ptText: "Galeria", enText: "Gallery"), MediaSource.videoGallery, Icons.videocam), ), if (!kIsWeb) ...[ Expanded( child: createUploadMediaListTile( - FFLocalizations.of(context).getVariableText( - ptText: "Camera", enText: "Camera"), + FFLocalizations.of(context).getVariableText(ptText: "Camera", enText: "Camera"), MediaSource.camera, Icons.camera_alt), ) @@ -186,8 +176,8 @@ Future?> selectMediaWithSourceBottomSheetandFaceDetection({ maxWidth: maxWidth, maxHeight: maxHeight, imageQuality: imageQuality, - isVideo: mediaSource == MediaSource.videoGallery || - (mediaSource == MediaSource.camera && allowVideo && !allowPhoto), + isVideo: + mediaSource == MediaSource.videoGallery || (mediaSource == MediaSource.camera && allowVideo && !allowPhoto), mediaSource: mediaSource, includeDimensions: includeDimensions, includeBlurHash: includeBlurHash, @@ -202,16 +192,14 @@ Future?> selectMediaWithSourceBottomSheetandFaceDetection({ final inputImage = InputImage.fromFilePath(media.filePath!); final faces = await faceDetector.processImage(inputImage); if (faces.isEmpty) { - final String message = FFLocalizations.of(context).getVariableText( - ptText: "Nenhuma face detectada na imagem", - enText: "No face detected in the image"); + final String message = FFLocalizations.of(context) + .getVariableText(ptText: "Nenhuma face detectada na imagem", enText: "No face detected in the image"); DialogUtil.error(context, message); return null; } if (faces.length > 1) { final String message = FFLocalizations.of(context).getVariableText( - ptText: "Mais de uma face detectada na imagem", - enText: "More than one face detected in the image"); + ptText: "Mais de uma face detectada na imagem", enText: "More than one face detected in the image"); DialogUtil.error(context, message); return null; } @@ -234,9 +222,7 @@ Future?> selectMediaWithSourceBottomSheet({ bool includeDimensions = false, bool includeBlurHash = false, }) async { - createUploadMediaListTile( - String label, MediaSource mediaSource, IconData icon) => - ListTile( + createUploadMediaListTile(String label, MediaSource mediaSource, IconData icon) => ListTile( title: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -280,15 +266,12 @@ Future?> selectMediaWithSourceBottomSheet({ padding: const EdgeInsets.fromLTRB(0, 8, 0, 0), child: ListTile( title: Text( - FFLocalizations.of(context).getVariableText( - ptText: "Escolha uma das opções", - enText: "Choose one of the options"), + FFLocalizations.of(context) + .getVariableText(ptText: "Escolha uma das opções", enText: "Choose one of the options"), textAlign: TextAlign.center, style: GoogleFonts.getFont( pickerFontFamily, - color: FlutterFlowTheme.of(context) - .primaryText - .withOpacity(0.65), + color: FlutterFlowTheme.of(context).primaryText.withOpacity(0.65), fontWeight: FontWeight.w500, fontSize: 14, ), @@ -304,40 +287,35 @@ Future?> selectMediaWithSourceBottomSheet({ if (allowPhoto && allowVideo) ...[ Expanded( child: createUploadMediaListTile( - FFLocalizations.of(context).getVariableText( - ptText: "Galeria (Foto)", - enText: "Gallery (Photo)"), + FFLocalizations.of(context) + .getVariableText(ptText: "Galeria (Foto)", enText: "Gallery (Photo)"), MediaSource.photoGallery, Icons.camera), ), Expanded( child: createUploadMediaListTile( - FFLocalizations.of(context).getVariableText( - ptText: "Galeria (Video)", - enText: "Gallery (Video)"), + FFLocalizations.of(context) + .getVariableText(ptText: "Galeria (Video)", enText: "Gallery (Video)"), MediaSource.videoGallery, Icons.videocam), ) ] else if (allowPhoto) Expanded( child: createUploadMediaListTile( - FFLocalizations.of(context).getVariableText( - ptText: "Galeria", enText: "Gallery"), + FFLocalizations.of(context).getVariableText(ptText: "Galeria", enText: "Gallery"), MediaSource.photoGallery, Icons.photo)) else Expanded( child: createUploadMediaListTile( - FFLocalizations.of(context).getVariableText( - ptText: "Galeria", enText: "Gallery"), + FFLocalizations.of(context).getVariableText(ptText: "Galeria", enText: "Gallery"), MediaSource.videoGallery, Icons.videocam), ), if (!kIsWeb) ...[ Expanded( child: createUploadMediaListTile( - FFLocalizations.of(context).getVariableText( - ptText: "Camera", enText: "Camera"), + FFLocalizations.of(context).getVariableText(ptText: "Camera", enText: "Camera"), MediaSource.camera, Icons.camera_alt), ) @@ -356,8 +334,8 @@ Future?> selectMediaWithSourceBottomSheet({ maxWidth: maxWidth, maxHeight: maxHeight, imageQuality: imageQuality, - isVideo: mediaSource == MediaSource.videoGallery || - (mediaSource == MediaSource.camera && allowVideo && !allowPhoto), + isVideo: + mediaSource == MediaSource.videoGallery || (mediaSource == MediaSource.camera && allowVideo && !allowPhoto), mediaSource: mediaSource, includeDimensions: includeDimensions, includeBlurHash: includeBlurHash, @@ -407,9 +385,7 @@ Future?> selectMedia({ })); } - final source = mediaSource == MediaSource.camera - ? ImageSource.camera - : ImageSource.gallery; + final source = mediaSource == MediaSource.camera ? ImageSource.camera : ImageSource.gallery; final pickedMediaFuture = isVideo ? picker.pickVideo(source: source) : picker.pickImage( @@ -480,8 +456,7 @@ Future?> selectFiles({ return Future.wait(pickedFiles.files.asMap().entries.map((e) async { final index = e.key; final file = e.value; - final storagePath = - _getStoragePath(storageFolderPath, file.name, false, index); + final storagePath = _getStoragePath(storageFolderPath, file.name, false, index); return SelectedFile( storagePath: storagePath, filePath: isWeb ? null : file.path, @@ -578,8 +553,7 @@ void showUploadMessage( padding: const EdgeInsetsDirectional.only(end: 10.0), child: CircularProgressIndicator( valueColor: Theme.of(context).brightness == Brightness.dark - ? AlwaysStoppedAnimation( - FlutterFlowTheme.of(context).info) + ? AlwaysStoppedAnimation(FlutterFlowTheme.of(context).info) : null, ), ), @@ -593,12 +567,10 @@ void showUploadMessage( topRight: Radius.circular(15), ), ), - duration: - showLoading ? const Duration(days: 1) : const Duration(seconds: 4), + duration: showLoading ? const Duration(days: 1) : const Duration(seconds: 4), ), ); } -String? _removeTrailingSlash(String? path) => path != null && path.endsWith('/') - ? path.substring(0, path.length - 1) - : path; +String? _removeTrailingSlash(String? path) => + path != null && path.endsWith('/') ? path.substring(0, path.length - 1) : path; diff --git a/lib/flutter_flow/uploaded_file.dart b/lib/flutter_flow/uploaded_file.dart index cbe68cad..2dfd2ff1 100644 --- a/lib/flutter_flow/uploaded_file.dart +++ b/lib/flutter_flow/uploaded_file.dart @@ -65,4 +65,4 @@ class FFUploadedFile { height == other.height && width == other.width && blurHash == other.blurHash; -} \ No newline at end of file +} diff --git a/lib/index.dart b/lib/index.dart index 3278d9b5..73ea1557 100644 --- a/lib/index.dart +++ b/lib/index.dart @@ -1,15 +1,10 @@ -export 'pages/acess_history_page/acess_history_page_widget.dart' - show AccessHistoryScreen; +export 'pages/acess_history_page/acess_history_page_widget.dart' show AccessHistoryScreen; export 'pages/home_page/home_page_widget.dart' show HomePageWidget; -export 'pages/liberation_history/liberation_history_widget.dart' - show LiberationHistoryWidget; -export 'pages/people_on_the_property_page/people_on_the_property_page_widget.dart' - show PeopleOnThePropertyPageWidget; -export 'pages/preferences_settings_page/preferences_settings_widget.dart' - show PreferencesPageWidget; +export 'pages/liberation_history/liberation_history_widget.dart' show LiberationHistoryWidget; +export 'pages/people_on_the_property_page/people_on_the_property_page_widget.dart' show PeopleOnThePropertyPageWidget; +export 'pages/preferences_settings_page/preferences_settings_widget.dart' show PreferencesPageWidget; export 'pages/qr_code_page/qr_code_page_widget.dart' show QrCodePageWidget; -export 'pages/register_visitor_page/register_visitor_page_widget.dart' - show RegisterVisitorPageWidget; +export 'pages/register_visitor_page/register_visitor_page_widget.dart' show RegisterVisitorPageWidget; export 'pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart' show ScheduleCompleteVisitPageWidget; export 'pages/sign_in_page/sign_in_page_widget.dart' show SignInPageWidget; diff --git a/lib/main.dart b/lib/main.dart index 3bcbff3a..ccda789a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -18,10 +18,10 @@ import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/pages/forgot_password_page/forgot_password_screen.dart'; -import 'package:hub/shared/helpers/shared_preferences_storage_helper.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/services/localization/localization_service.dart'; import 'package:hub/shared/utils/device_util.dart'; -import 'package:hub/shared/utils/storage_util.dart'; import 'package:responsive_framework/responsive_framework.dart'; final GlobalKey navigatorKey = GlobalKey(); @@ -35,7 +35,7 @@ void main() async { Future initializeApp() async { WidgetsFlutterBinding.ensureInitialized(); await _initializeTracking(); - await _initializeStorageHelpers(); + await StorageHelper().init(); await _initializeFirebase(); await _initializeNotificationService(); @@ -44,21 +44,12 @@ Future initializeApp() async { await _initializeFlutterFlow(); } -Future _initializeStorageHelpers() async { - log('Initializing SharedPreferencesStorageHelper'); - await SharedPreferencesStorageHelper().initialize(); - log('Initializing SharedPreferencesStorageHelper'); - await StorageUtil().ensureInitialization(); -} - Future _initializeTracking() async { await AppTrackingTransparency.requestTrackingAuthorization(); } - Future _initializeFirebase() async { await Firebase.initializeApp(); } - Future _initializeNotificationService() async { await NotificationService.initialize(); } @@ -66,7 +57,6 @@ Future _initializeNotificationService() async { void _initializeUrlStrategy() { setUrlStrategy(PathUrlStrategy()); } - void _initializeSystemSettings() { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); if (kDebugMode) { @@ -85,12 +75,12 @@ Future _initializeFlutterFlow() async { GoRouter.optionURLReflectsImperativeAPIs = true; usePathUrlStrategy(); } - Future _foregroundHandlerMessage(RemoteMessage message) async { if (message.data['click_action'] == 'enroll_cond') { - StorageUtil().haveLocal = true; - StorageUtil().context?.go('/homePage'); + await StorageHelper().set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage); + StorageHelper().context?.go('/homePage'); } + if (!Platform.isIOS) { NotificationService.show( title: message.notification!.title!, @@ -98,12 +88,10 @@ Future _foregroundHandlerMessage(RemoteMessage message) async { payload: Map.from(message.data)); } } - Future _backgroundHandlerMessage(RemoteMessage message) async { if (message.data['click_action'] == 'enroll_cond') { - log('backgroundHandlerMessage'); - StorageUtil().haveLocal = true; - StorageUtil().context?.go('/homePage'); + await StorageHelper().set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage); + StorageHelper().context?.go('/homePage'); } } @@ -113,10 +101,8 @@ class App extends StatefulWidget { @override State createState() => _AppState(); - static _AppState of(BuildContext context) => - context.findAncestorStateOfType<_AppState>()!; + static _AppState of(BuildContext context) => context.findAncestorStateOfType<_AppState>()!; } - class _AppState extends State with WidgetsBindingObserver { Locale? _locale = FFLocalizations.getStoredLocale(); ThemeMode _themeMode = FlutterFlowTheme.themeMode; @@ -158,8 +144,7 @@ class _AppState extends State with WidgetsBindingObserver { }), ), ); - final Iterable>? localizationsDelegates = - const [ + final Iterable>? localizationsDelegates = const [ FFLocalizationsDelegate(), GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, @@ -190,30 +175,27 @@ class _AppState extends State with WidgetsBindingObserver { Future initDeepLinks() async { _appLinks = AppLinks(); _linkSubscription = _appLinks.uriLinkStream.listen((uri) { - final bool isRecovered = StorageUtil().isRecovered; + final bool isRecovered = StorageHelper().isRecovered; if (!isRecovered) openAppLink(uri); }); } void openAppLink(Uri uri) { - final bool isRecovered = StorageUtil().isRecovered; + final bool isRecovered = StorageHelper().isRecovered; log('isRecovered: $isRecovered'); if (isRecovered) return; - StorageUtil().isRecovered = true; + StorageHelper().isRecovered = true; final String email = uri.queryParameters['email'] ?? ''; final String token = uri.queryParameters['token'] ?? ''; final bool isNotEmpty = email.isNotEmpty && token.isNotEmpty; if (isNotEmpty) { - final BuildContext context = StorageUtil().context!; - final MediaQueryData mediaQuery = MediaQuery.of(context); - final double height = mediaQuery.size.height * 0.6; + final BuildContext context = StorageHelper().context!; final FlutterFlowTheme theme = FlutterFlowTheme.of(context); final Widget screen = ForgotPasswordScreen(email: email, token: token); builder(context) => screen; showModalBottomSheet( context: context, - builder: (context) => Padding( - padding: MediaQuery.viewInsetsOf(context), child: builder(context)), + builder: (context) => Padding(padding: MediaQuery.viewInsetsOf(context), child: builder(context)), isScrollControlled: true, // barrierColor: theme.primaryBackground.withOpacity(0.2), backgroundColor: theme.primaryBackground, @@ -221,7 +203,7 @@ class _AppState extends State with WidgetsBindingObserver { useSafeArea: true, enableDrag: true, // isDismissible: true, - ).whenComplete(() => StorageUtil().isRecovered = false); + ).whenComplete(() => StorageHelper().isRecovered = false); } } @@ -234,19 +216,18 @@ class _AppState extends State with WidgetsBindingObserver { } FirebaseMessaging.onMessage.listen(_foregroundHandlerMessage); - FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) { + FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) async { if (message.data['click_action'] == 'enroll_cond') { - StorageUtil().haveLocal = true; + await StorageHelper().set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage); log('onMessageOpenedApp'); } else { - onMessageReceived(message.data, message.notification!.body, - message.data['click_action']); + onMessageReceived(message.data, message.notification!.body, message.data['click_action']); } }); - FirebaseMessaging.instance.getInitialMessage().then((message) { + FirebaseMessaging.instance.getInitialMessage().then((message) async { if (message != null) { if (message.data['click_action'] == 'enroll_cond') { - StorageUtil().haveLocal = true; + await StorageHelper().set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage); log('getInitialMessage'); } } @@ -275,8 +256,8 @@ class _AppState extends State with WidgetsBindingObserver { FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true); _appStateNotifier = AppStateNotifier.instance; _router = createRouter(_appStateNotifier); - Future.delayed(const Duration(milliseconds: 1000), - () => setState(() => _appStateNotifier.stopShowingSplashImage())); + Future.delayed( + const Duration(milliseconds: 1000), () => setState(() => _appStateNotifier.stopShowingSplashImage())); _setupFirebaseMessaging(); WidgetsBinding.instance.addPersistentFrameCallback((_) => initDeepLinks()); @@ -291,8 +272,7 @@ class _AppState extends State with WidgetsBindingObserver { @override void didChangeAppLifecycleState(AppLifecycleState state) async { - bool initialize = await StorageUtil().ensureInitialization(); - if (initialize) await LocalizationService.processLocals(context); + if(state == AppLifecycleState.resumed) await LocalizationService.processLocals(context); } @override @@ -311,3 +291,4 @@ class _AppState extends State with WidgetsBindingObserver { ); } } + diff --git a/lib/pages/acess_history_page/acess_history_page_model.dart b/lib/pages/acess_history_page/acess_history_page_model.dart index e32d744e..e42c0cf5 100644 --- a/lib/pages/acess_history_page/acess_history_page_model.dart +++ b/lib/pages/acess_history_page/acess_history_page_model.dart @@ -4,7 +4,8 @@ import 'package:hub/components/molecular_components/message_opt_modal/opt_modal_ import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/flutter_flow/request_manager.dart'; import 'package:hub/pages/acess_history_page/acess_history_page_widget.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; class AcessHistoryPageModel extends FlutterFlowModel { late final String devUUID; @@ -24,8 +25,7 @@ class AcessHistoryPageModel extends FlutterFlowModel { requestFn: requestFn, ); void clearAccessHistoryCache() => _accessHistoryManager.clear(); - void clearAccessHistoryCacheKey(String? uniqueKey) => - _accessHistoryManager.clearRequest(uniqueKey); + void clearAccessHistoryCacheKey(String? uniqueKey) => _accessHistoryManager.clearRequest(uniqueKey); @override void initState(BuildContext context) { @@ -33,9 +33,9 @@ class AcessHistoryPageModel extends FlutterFlowModel { } Future initDatabase() async { - devUUID = StorageUtil().devUUID; - userUUID = StorageUtil().userUUID; - cliUUID = StorageUtil().cliUUID; + devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; } @override diff --git a/lib/pages/acess_history_page/acess_history_page_widget.dart b/lib/pages/acess_history_page/acess_history_page_widget.dart index 9c612497..9f981850 100644 --- a/lib/pages/acess_history_page/acess_history_page_widget.dart +++ b/lib/pages/acess_history_page/acess_history_page_widget.dart @@ -44,8 +44,7 @@ class _AccessHistoryState extends State { late Future _accessFuture; List _accessWrap = []; - _AccessHistoryState(Map opt) - : selectedTypeSubject = BehaviorSubject.seeded(opt) { + _AccessHistoryState(Map opt) : selectedTypeSubject = BehaviorSubject.seeded(opt) { selectedTypeSubject.listen((value) {}); } @@ -57,8 +56,7 @@ class _AccessHistoryState extends State { _scrollController = ScrollController() ..addListener(() { - if (_scrollController.position.atEdge && - _scrollController.position.pixels != 0) { + if (_scrollController.position.atEdge && _scrollController.position.pixels != 0) { _loadMoreAccess(); } }); @@ -117,8 +115,7 @@ class _AccessHistoryState extends State { color: theme.primaryText, fontSize: 16.0, letterSpacing: 0.0, - useGoogleFonts: - GoogleFonts.asMap().containsKey(theme.headlineMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(theme.headlineMediumFamily), ), ); } @@ -132,27 +129,24 @@ class _AccessHistoryState extends State { child: IconButton( icon: const Icon(Icons.filter_list), onPressed: () async { - final Map? selectedFilter = - await showModalBottomSheet>( - isScrollControlled: true, - backgroundColor: Colors.transparent, - context: context, - builder: (context) { - return GestureDetector( - onTap: () => Navigator.of(context).pop(), - child: Container( - color: Colors.transparent, - child: GestureDetector( - onTap: () {}, - child: OptModalWidget( - defaultPersonType: - selectedTypeSubject.value['personType'] ?? - '.*', - ), - ), + final Map? selectedFilter = await showModalBottomSheet>( + isScrollControlled: true, + backgroundColor: Colors.transparent, + context: context, + builder: (context) { + return GestureDetector( + onTap: () => Navigator.of(context).pop(), + child: Container( + color: Colors.transparent, + child: GestureDetector( + onTap: () {}, + child: OptModalWidget( + defaultPersonType: selectedTypeSubject.value['personType'] ?? '.*', ), - ); - }); + ), + ), + ); + }); if (selectedFilter != null) { _updateAccessHistoryAction(selectedFilter); @@ -195,8 +189,7 @@ class _AccessHistoryState extends State { final List accessHistory = response.jsonBody['acessos'] ?? []; List filteredAccess = accessHistory.where((item) { - final personTypeMatches = - _personType == '.*' || item["PES_TIPO"].toString() == _personType; + final personTypeMatches = _personType == '.*' || item["PES_TIPO"].toString() == _personType; return personTypeMatches; }).toList(); @@ -229,8 +222,7 @@ class _AccessHistoryState extends State { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - FFLocalizations.of(context).getVariableText( - ptText: "Não há mais dados.", enText: "No more data."), + FFLocalizations.of(context).getVariableText(ptText: "Não há mais dados.", enText: "No more data."), ), duration: const Duration(seconds: 3), backgroundColor: FlutterFlowTheme.of(context).primary, @@ -250,9 +242,8 @@ class _AccessHistoryState extends State { children: [ Center( child: Text( - FFLocalizations.of(context).getVariableText( - ptText: "Nenhum histórico encontrado!", - enText: "No history found!"), + FFLocalizations.of(context) + .getVariableText(ptText: "Nenhum histórico encontrado!", enText: "No history found!"), )), ], ), @@ -292,8 +283,7 @@ class _AccessHistoryState extends State { return FutureBuilder( future: _accessFuture, builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.waiting && - _accessWrap.isEmpty) { + if (snapshot.connectionState == ConnectionState.waiting && _accessWrap.isEmpty) { return Center( child: SizedBox( width: 50.0, @@ -306,9 +296,8 @@ class _AccessHistoryState extends State { ); } else if (snapshot.hasError) { return Center( - child: Text(FFLocalizations.of(context).getVariableText( - ptText: "Falha ao efetuar operação!", - enText: "Failed to perform operation!")), + child: Text(FFLocalizations.of(context) + .getVariableText(ptText: "Falha ao efetuar operação!", enText: "Failed to perform operation!")), ); } @@ -326,8 +315,7 @@ class _AccessHistoryState extends State { ); } - Widget _accessHistoryCardMoleculeWidget( - BuildContext context, dynamic accessHistoryItem) { + Widget _accessHistoryCardMoleculeWidget(BuildContext context, dynamic accessHistoryItem) { return CardItemTemplateComponentWidget( imagePath: 'https://freaccess.com.br/freaccess/getImage.php?cliID=${_model.cliUUID}&atividade=getFoto&Documento=${accessHistoryItem['PES_ID'] ?? ''}&tipo=${accessHistoryItem['PES_TIPO'] ?? ''}', diff --git a/lib/pages/delivery_schedule_page/delivery_schedule_widget.dart b/lib/pages/delivery_schedule_page/delivery_schedule_widget.dart index 46d3c440..148a4220 100644 --- a/lib/pages/delivery_schedule_page/delivery_schedule_widget.dart +++ b/lib/pages/delivery_schedule_page/delivery_schedule_widget.dart @@ -50,10 +50,7 @@ class _DeliveryScheduleState extends State { }, ), title: Text( - FFLocalizations.of(context).getVariableText( - enText: 'Delivery Schedule', - ptText: 'Agendar Entregas', - ), + FFLocalizations.of(context).getVariableText(enText: 'Delivery Schedule', ptText: 'Agendar Entregas'), style: FlutterFlowTheme.of(context).headlineMedium.override( fontFamily: 'Nunito', color: FlutterFlowTheme.of(context).primaryText, @@ -67,7 +64,6 @@ class _DeliveryScheduleState extends State { centerTitle: true, elevation: 0.0, ), - body: const SafeArea( - top: true, child: ScheduleProvisionalVisitPageWidget())); + body: const SafeArea(top: true, child: ScheduleProvisionalVisitPageWidget())); } } diff --git a/lib/pages/fast_pass_page/fast_pass_page_widget.dart b/lib/pages/fast_pass_page/fast_pass_page_widget.dart index 3f2b66fb..58906122 100644 --- a/lib/pages/fast_pass_page/fast_pass_page_widget.dart +++ b/lib/pages/fast_pass_page/fast_pass_page_widget.dart @@ -5,7 +5,8 @@ import 'package:flutter/scheduler.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart' as hub; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/utils/webview_util.dart'; import 'package:url_launcher/url_launcher_string.dart'; import 'package:webview_flutter/webview_flutter.dart'; @@ -22,11 +23,15 @@ class _FastPassPageWidgetState extends State { late InAppWebViewController _controllerIOS; Future> initVariables() async { - final email = StorageUtil().email; - final name = StorageUtil().userName; - final userUUID = StorageUtil().userUUID; - final devUUID = StorageUtil().devUUID; - final cliUUID = StorageUtil().cliUUID; + final email = (await StorageHelper().get(hub.SecureStorageKey.email.value, hub.Storage.SecureStorage)) ?? ''; + final name = + (await StorageHelper().get(hub.SQLiteStorageKey.userName.value, hub.Storage.SQLiteStorage)) ?? ''; + final devUUID = + (await StorageHelper().get(hub.SQLiteStorageKey.devUUID.value, hub.Storage.SQLiteStorage)) ?? ''; + final userUUID = + (await StorageHelper().get(hub.SQLiteStorageKey.userUUID.value, hub.Storage.SQLiteStorage)) ?? ''; + final cliUUID = + (await StorageHelper().get(hub.SQLiteStorageKey.clientUUID.value, hub.Storage.SQLiteStorage)) ?? ''; const createdAt = '0000-00-00 00:00:00'; final url = 'https://hub.freaccess.com.br/hub/fast-pass/$cliUUID'; final freUserData = @@ -53,12 +58,10 @@ class _FastPassPageWidgetState extends State { builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return Center(child: CircularProgressIndicator()); - } else if (snapshot.hasError || - snapshot.hasData == false || - snapshot.data!.isEmpty) { + } else if (snapshot.hasError || snapshot.hasData == false || snapshot.data!.isEmpty) { return Center( - child: Text(FFLocalizations.of(context).getVariableText( - enText: 'Unexpected error', ptText: 'Erro inesperado'))); + child: Text(FFLocalizations.of(context) + .getVariableText(enText: 'Unexpected error', ptText: 'Erro inesperado'))); } else if (snapshot.hasData) { final data = snapshot.data!; final url = data['url']!; @@ -68,12 +71,18 @@ class _FastPassPageWidgetState extends State { return Platform.isIOS ? InAppWebView( initialUrlRequest: URLRequest(url: WebUri(url)), - initialSettings: InAppWebViewSettings(allowsBackForwardNavigationGestures: true, javaScriptEnabled: true,), + initialSettings: InAppWebViewSettings( + allowsBackForwardNavigationGestures: true, + javaScriptEnabled: true, + ), onWebViewCreated: (controller) async => _controllerIOS = controller, onLoadStop: (controller, url) async { - await controller.evaluateJavascript(source: "window.localStorage.setItem('fre-token', '\"$userUUID\"')"); - await controller.evaluateJavascript(source: "window.localStorage.setItem('fre-user-data', '$freUserData')"); - await controller.evaluateJavascript(source: "window.localStorage.setItem('enableBackButton', 'true')"); + await controller.evaluateJavascript( + source: "window.localStorage.setItem('fre-token', '\"$userUUID\"')"); + await controller.evaluateJavascript( + source: "window.localStorage.setItem('fre-user-data', '$freUserData')"); + await controller.evaluateJavascript( + source: "window.localStorage.setItem('enableBackButton', 'true')"); }, onUpdateVisitedHistory: (controller, uri, isVisited) { if (uri.toString().contains('/hub/home')) context.pop(); @@ -89,7 +98,7 @@ class _FastPassPageWidgetState extends State { NavigationDelegate( onProgress: (int progress) {}, onPageStarted: (String url) { - final String token = "localStorage.setItem('fre-token', '\"$userUUID\"');"; + final String token = "localStorage.setItem('fre-token', '\"$userUUID\"');"; final String data = "localStorage.setItem('fre-user-data', '$freUserData');"; const String backNavigation = "localStorage.setItem('enableBackButton', 'true');"; @@ -98,10 +107,8 @@ class _FastPassPageWidgetState extends State { _controllerAndroid.runJavaScript(backNavigation); }, onPageFinished: (String url) { - bool isDarkMode = SchedulerBinding - .instance - .platformDispatcher - .platformBrightness == Brightness.dark; + bool isDarkMode = + SchedulerBinding.instance.platformDispatcher.platformBrightness == Brightness.dark; if (isDarkMode) { _controllerAndroid.runJavaScript(WebviewUtil.jsEnableDarkMode); @@ -111,13 +118,13 @@ class _FastPassPageWidgetState extends State { if (request.url.startsWith('http') || request.url.startsWith('https://api.whatsapp.com/send') || request.url.startsWith('https://wa.me')) { - launchUrlString(request.url); - return NavigationDecision.prevent; - } + launchUrlString(request.url); + return NavigationDecision.prevent; + } return NavigationDecision.prevent; }, onUrlChange: (url) { - if (url.url.toString().contains('/hub/home')) context.pop(); + if (url.url.toString().contains('/hub/home')) context.pop(); }), ) ..loadRequest(Uri.parse(url)), diff --git a/lib/pages/forgot_password_page/forgot_password_model.dart b/lib/pages/forgot_password_page/forgot_password_model.dart index e3df2c9d..56580cac 100644 --- a/lib/pages/forgot_password_page/forgot_password_model.dart +++ b/lib/pages/forgot_password_page/forgot_password_model.dart @@ -53,28 +53,26 @@ class ForgotPasswordScreenModel extends FlutterFlowModel { bool? register; - - - bool isFormInvalid() { final password = passwordRegisterFormTextController?.text ?? ''; final confirmPassword = passwordConfirmFormTextController?.text ?? ''; - return password.isEmpty || confirmPassword.isEmpty || password != confirmPassword - || !ValidatorUtil.isValidPassword(password) || !ValidatorUtil.isValidPassword(confirmPassword); + return password.isEmpty || + confirmPassword.isEmpty || + password != confirmPassword || + !ValidatorUtil.isValidPassword(password) || + !ValidatorUtil.isValidPassword(confirmPassword); } - - - @override void initState(BuildContext context) { - - - + @override + void initState(BuildContext context) { passwordRegisterFormVisibility = false; passwordRegisterFormTextControllerValidator = _passwordRegisterFormTextControllerValidator; passwordConfirmFormVisibility = false; passwordConfirmFormTextControllerValidator = _passwordConfirmFormTextControllerValidator; } - @override void dispose() { + + @override + void dispose() { passwordRegisterFormFocusNode?.dispose(); passwordRegisterFormTextController?.dispose(); passwordConfirmFormFocusNode?.dispose(); diff --git a/lib/pages/forgot_password_page/forgot_password_screen.dart b/lib/pages/forgot_password_page/forgot_password_screen.dart index 7efbac3b..81aa567e 100644 --- a/lib/pages/forgot_password_page/forgot_password_screen.dart +++ b/lib/pages/forgot_password_page/forgot_password_screen.dart @@ -1,13 +1,10 @@ - - import 'package:easy_debounce/easy_debounce.dart'; import 'package:flutter/material.dart'; import 'package:flutter_animate/flutter_animate.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; -import '../../components/atomic_components/shared_components_atoms/atom_image_svg_theme.dart'; import '../../flutter_flow/flutter_flow_animations.dart'; import '../../flutter_flow/flutter_flow_icon_button.dart'; import '../../flutter_flow/flutter_flow_model.dart'; @@ -15,7 +12,6 @@ import '../../flutter_flow/flutter_flow_theme.dart'; import '../../flutter_flow/flutter_flow_widgets.dart'; import '../../flutter_flow/internationalization.dart'; import '../../shared/services/authentication/authentication_service.dart'; -import '../../shared/utils/validator_util.dart'; import 'forgot_password_model.dart'; class ForgotPasswordScreen extends StatefulWidget { @@ -23,18 +19,22 @@ class ForgotPasswordScreen extends StatefulWidget { final String email; final String token; - @override State createState() => _ForgotPasswordScreenState(); + @override + State createState() => _ForgotPasswordScreenState(); } class _ForgotPasswordScreenState extends State with TickerProviderStateMixin { late ForgotPasswordScreenModel _model; final animationsMap = {}; - @override void setState(VoidCallback callback) { + @override + void setState(VoidCallback callback) { super.setState(callback); _model.onUpdate(); } - @override void initState() { + + @override + void initState() { super.initState(); _model = createModel(context, () => ForgotPasswordScreenModel()); @@ -83,13 +83,16 @@ class _ForgotPasswordScreenState extends State with Ticker ), }); } - @override void dispose() { + + @override + void dispose() { _model.maybeDispose(); super.dispose(); } - @override Widget build(BuildContext context) => buildBody(context); + @override + Widget build(BuildContext context) => buildBody(context); AppBar buildAppBar(BuildContext context) { return AppBar( @@ -107,25 +110,29 @@ class _ForgotPasswordScreenState extends State with Ticker ), onPressed: () async { context.pop(); - StorageUtil().isRecovered = false; + StorageHelper().isRecovered = false; }, ), title: Text( - FFLocalizations.of(context).getVariableText(ptText: 'Recuperar Senha', enText: 'Recover Password',), - style: FlutterFlowTheme.of(context).headlineMedium.override( - fontFamily: 'Nunito', - color: FlutterFlowTheme.of(context).primaryText, - fontSize: 15.0, - fontWeight: FontWeight.bold, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), + FFLocalizations.of(context).getVariableText( + ptText: 'Recuperar Senha', + enText: 'Recover Password', ), + style: FlutterFlowTheme.of(context).headlineMedium.override( + fontFamily: 'Nunito', + color: FlutterFlowTheme.of(context).primaryText, + fontSize: 15.0, + fontWeight: FontWeight.bold, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), + ), ), actions: const [], centerTitle: true, elevation: 0.0, ); } + Widget buildBody(BuildContext context) { late final String title = FFLocalizations.of(context).getVariableText( ptText: 'Recuperar Senha', @@ -154,14 +161,18 @@ class _ForgotPasswordScreenState extends State with Ticker mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Center(child: Text(title, style: FlutterFlowTheme.of(context).title1.override( - fontFamily: 'Nunito', - color: FlutterFlowTheme.of(context).primaryText, - fontSize: 24.0, - fontWeight: FontWeight.bold, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), - ),)), + Center( + child: Text( + title, + style: FlutterFlowTheme.of(context).title1.override( + fontFamily: 'Nunito', + color: FlutterFlowTheme.of(context).primaryText, + fontSize: 24.0, + fontWeight: FontWeight.bold, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), + ), + )), Align( alignment: const AlignmentDirectional(-1.0, 0.0), child: Padding( @@ -170,11 +181,11 @@ class _ForgotPasswordScreenState extends State with Ticker message, textAlign: TextAlign.start, style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, - fontWeight: FontWeight.bold, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), - ), + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, + fontWeight: FontWeight.bold, + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), + ), ), ), ), @@ -189,9 +200,12 @@ class _ForgotPasswordScreenState extends State with Ticker controller: _model.passwordRegisterFormTextController, focusNode: _model.passwordRegisterFormFocusNode, visibility: _model.passwordRegisterFormVisibility, - onVisibilityToggle: () => setState(() => _model.passwordRegisterFormVisibility = !_model.passwordRegisterFormVisibility), - label: FFLocalizations.of(context).getVariableText(ptText: 'Nova Senha', enText: 'New Password'), - hint: FFLocalizations.of(context).getVariableText(ptText: 'Insira sua senha', enText: 'Enter your password'), + onVisibilityToggle: () => setState( + () => _model.passwordRegisterFormVisibility = !_model.passwordRegisterFormVisibility), + label: + FFLocalizations.of(context).getVariableText(ptText: 'Nova Senha', enText: 'New Password'), + hint: FFLocalizations.of(context) + .getVariableText(ptText: 'Insira sua senha', enText: 'Enter your password'), asValidator: _model.passwordRegisterFormTextControllerValidator.asValidator(context), ), _buildPasswordField( @@ -199,9 +213,12 @@ class _ForgotPasswordScreenState extends State with Ticker controller: _model.passwordConfirmFormTextController, focusNode: _model.passwordConfirmFormFocusNode, visibility: _model.passwordConfirmFormVisibility, - onVisibilityToggle: () => setState(() => _model.passwordConfirmFormVisibility = !_model.passwordConfirmFormVisibility), - label: FFLocalizations.of(context).getVariableText(ptText: 'Confirme a Senha', enText: 'Confirm Password'), - hint: FFLocalizations.of(context).getVariableText(ptText: 'Confirme sua senha', enText: 'Confirm your password'), + onVisibilityToggle: () => setState( + () => _model.passwordConfirmFormVisibility = !_model.passwordConfirmFormVisibility), + label: FFLocalizations.of(context) + .getVariableText(ptText: 'Confirme a Senha', enText: 'Confirm Password'), + hint: FFLocalizations.of(context) + .getVariableText(ptText: 'Confirme sua senha', enText: 'Confirm your password'), asValidator: _model.passwordConfirmFormTextControllerValidator.asValidator(context), ), ], @@ -211,10 +228,13 @@ class _ForgotPasswordScreenState extends State with Ticker padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 16.0), child: FFButtonWidget( key: const ValueKey('SubmitButtonWidget'), - onPressed: _model.isFormInvalid() ? null : () async { - await AuthenticationService.changePassword(context, widget.email, _model.passwordConfirmFormTextController!.text, widget.token); - setState(() {}); - }, + onPressed: _model.isFormInvalid() + ? null + : () async { + await AuthenticationService.changePassword( + context, widget.email, _model.passwordConfirmFormTextController!.text, widget.token); + setState(() {}); + }, text: FFLocalizations.of(context).getVariableText( ptText: 'Enviar', enText: 'Submit', @@ -246,7 +266,15 @@ class _ForgotPasswordScreenState extends State with Ticker ), ); } - Widget _buildPasswordField(BuildContext context, {required TextEditingController? controller, required FocusNode? focusNode, required bool visibility, required VoidCallback onVisibilityToggle, required String hint, required String label, required String? Function(String?)? asValidator}) { + + Widget _buildPasswordField(BuildContext context, + {required TextEditingController? controller, + required FocusNode? focusNode, + required bool visibility, + required VoidCallback onVisibilityToggle, + required String hint, + required String label, + required String? Function(String?)? asValidator}) { return Padding( padding: const EdgeInsetsDirectional.fromSTEB(0.0, 0.0, 0.0, 16.0), child: SizedBox( @@ -268,12 +296,12 @@ class _ForgotPasswordScreenState extends State with Ticker hintText: hint, labelText: label, labelStyle: FlutterFlowTheme.of(context).labelLarge.override( - fontFamily: 'Plus Jakarta Sans', - color: FlutterFlowTheme.of(context).primaryText, - fontSize: 16.0, - fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), - ), + fontFamily: 'Plus Jakarta Sans', + color: FlutterFlowTheme.of(context).primaryText, + fontSize: 16.0, + fontWeight: FontWeight.w500, + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), + ), enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: FlutterFlowTheme.of(context).customColor1, width: 0.25), borderRadius: BorderRadius.circular(12.0), @@ -304,17 +332,15 @@ class _ForgotPasswordScreenState extends State with Ticker ), ), style: FlutterFlowTheme.of(context).bodyLarge.override( - fontFamily: 'Plus Jakarta Sans', - color: FlutterFlowTheme.of(context).primaryText, - fontSize: 16.0, - fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), - ), + fontFamily: 'Plus Jakarta Sans', + color: FlutterFlowTheme.of(context).primaryText, + fontSize: 16.0, + fontWeight: FontWeight.w500, + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), + ), validator: asValidator, ), ), ); } - - -} \ No newline at end of file +} diff --git a/lib/pages/home_page/home_page_model.dart b/lib/pages/home_page/home_page_model.dart index a648e58b..dad2a7fe 100644 --- a/lib/pages/home_page/home_page_model.dart +++ b/lib/pages/home_page/home_page_model.dart @@ -4,7 +4,8 @@ import 'package:hub/components/organism_components/menu_component/menu_component import 'package:hub/components/organism_components/message_well_component/message_well_component_model.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/pages/home_page/home_page_widget.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; class HomePageModel extends FlutterFlowModel { bool isGrid = false; @@ -23,21 +24,19 @@ class HomePageModel extends FlutterFlowModel { late MessageWellComponentModel messageWellComponentModel; Future _initVariable() async { - devUUID = StorageUtil().devUUID; - cliUUID = StorageUtil().cliUUID; - userUUID = StorageUtil().userUUID; - userName = StorageUtil().userName; - userEmail = StorageUtil().email; + devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + userName = (await StorageHelper().get(SQLiteStorageKey.userName.value, Storage.SQLiteStorage)) ?? ''; + userEmail = (await StorageHelper().get(SecureStorageKey.email.value, Storage.SecureStorage)) ?? ''; } @override void initState(BuildContext context) { _initVariable(); - localComponentModel = - createModel(context, () => LocalProfileComponentModel()); + localComponentModel = createModel(context, () => LocalProfileComponentModel()); menuComponentModel = createModel(context, () => MenuComponentModel()); - messageWellComponentModel = - createModel(context, () => MessageWellComponentModel()); + messageWellComponentModel = createModel(context, () => MessageWellComponentModel()); } @override diff --git a/lib/pages/home_page/home_page_widget.dart b/lib/pages/home_page/home_page_widget.dart index 7b7ca0c3..7bcbd60d 100644 --- a/lib/pages/home_page/home_page_widget.dart +++ b/lib/pages/home_page/home_page_widget.dart @@ -9,7 +9,7 @@ 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/pages/home_page/home_page_model.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/widgets/drawer_widget/drawer_widget.dart'; class HomePageWidget extends StatefulWidget { @@ -35,6 +35,8 @@ class _HomePageWidgetState extends State { _model.dispose(); } + @override + void initState() { @override void initState() { super.initState(); @@ -50,7 +52,7 @@ class _HomePageWidgetState extends State { @override Widget build(BuildContext context) { - StorageUtil().context = context; + StorageHelper().context = context; return Scaffold( key: scaffoldKey, backgroundColor: FlutterFlowTheme.of(context).primaryBackground, @@ -94,8 +96,7 @@ class _HomePageWidgetState extends State { fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, color: FlutterFlowTheme.of(context).info, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), ), ].divide(const SizedBox(width: 8.0)), diff --git a/lib/pages/liberation_history/liberation_history_model.dart b/lib/pages/liberation_history/liberation_history_model.dart index cdc1f687..d0ff3638 100644 --- a/lib/pages/liberation_history/liberation_history_model.dart +++ b/lib/pages/liberation_history/liberation_history_model.dart @@ -3,7 +3,8 @@ import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/flutter_flow/request_manager.dart'; import 'package:hub/pages/liberation_history/liberation_history_widget.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; class LiberationHistoryModel extends FlutterFlowModel { late final String devUUID; @@ -27,8 +28,7 @@ class LiberationHistoryModel extends FlutterFlowModel { requestFn: requestFn, ); void clearGetLiberationsCache() => _getLiberationsManager.clear(); - void clearGetLiberationsCacheKey(String? uniqueKey) => - _getLiberationsManager.clearRequest(uniqueKey); + void clearGetLiberationsCacheKey(String? uniqueKey) => _getLiberationsManager.clearRequest(uniqueKey); @override void initState(BuildContext context) { @@ -36,9 +36,9 @@ class LiberationHistoryModel extends FlutterFlowModel { } Future init() async { - devUUID = StorageUtil().devUUID; - userUUID = StorageUtil().userUUID; - cliUUID = StorageUtil().cliUUID; + devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; } Future answersRequest( diff --git a/lib/pages/liberation_history/liberation_history_widget.dart b/lib/pages/liberation_history/liberation_history_widget.dart index 6b15532f..edaeae1b 100644 --- a/lib/pages/liberation_history/liberation_history_widget.dart +++ b/lib/pages/liberation_history/liberation_history_widget.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/backend/api_requests/api_calls.dart'; @@ -18,8 +17,7 @@ class LiberationHistoryWidget extends StatefulWidget { const LiberationHistoryWidget({super.key}); @override - State createState() => - _LiberationHistoryWidgetState(); + State createState() => _LiberationHistoryWidgetState(); } class _LiberationHistoryWidgetState extends State { @@ -54,15 +52,12 @@ class _LiberationHistoryWidgetState extends State { Map _labelsHashMap(dynamic request, bool details) { return Map.from({ - '${FFLocalizations.of(context).getVariableText(ptText: 'Nome', enText: 'Name')}:': - request['VTE_NOME'], + '${FFLocalizations.of(context).getVariableText(ptText: 'Nome', enText: 'Name')}:': request['VTE_NOME'], '${FFLocalizations.of(context).getVariableText(ptText: 'Dt. Envio', enText: 'Date Send')}:': request['NOT_DTENVIO'] != null - ? ValidatorUtil.toLocalDateTime( - 'yyyy-MM-dd HH:mm:ss', request['NOT_DTENVIO']) + ? ValidatorUtil.toLocalDateTime('yyyy-MM-dd HH:mm:ss', request['NOT_DTENVIO']) : '', - '${FFLocalizations.of(context).getVariableText(ptText: 'Motivo', enText: 'Reason')}:': - request['NOT_MOTIVO'], + '${FFLocalizations.of(context).getVariableText(ptText: 'Motivo', enText: 'Reason')}:': request['NOT_MOTIVO'], if (details == true) '${FFLocalizations.of(context).getVariableText(ptText: 'Mensagem', enText: 'Message')}:': request['NOT_MSGENVIO'], @@ -72,17 +67,14 @@ class _LiberationHistoryWidgetState extends State { Map _statusHashMap(dynamic request) { return Map.from({ if (request['NOT_STATUS'] == 'L') - FFLocalizations.of(context).getVariableText( - ptText: 'Finalizado', - enText: 'Finished'): FlutterFlowTheme.of(context).success + FFLocalizations.of(context).getVariableText(ptText: 'Finalizado', enText: 'Finished'): + FlutterFlowTheme.of(context).success else if (request['NOT_STATUS'] == 'B') - FFLocalizations.of(context).getVariableText( - ptText: 'Bloqueado', - enText: 'Blocked'): FlutterFlowTheme.of(context).error + FFLocalizations.of(context).getVariableText(ptText: 'Bloqueado', enText: 'Blocked'): + FlutterFlowTheme.of(context).error else - FFLocalizations.of(context).getVariableText( - ptText: 'Ativo', - enText: 'Active'): FlutterFlowTheme.of(context).warning + FFLocalizations.of(context).getVariableText(ptText: 'Ativo', enText: 'Active'): + FlutterFlowTheme.of(context).warning }); } @@ -148,16 +140,13 @@ class _LiberationHistoryWidgetState extends State { mainAxisSize: MainAxisSize.max, children: [ Center( - child: Text(FFLocalizations.of(context).getVariableText( - ptText: "Nenhuma solicitação encontrada!", - enText: "No requests found")), + child: Text(FFLocalizations.of(context) + .getVariableText(ptText: "Nenhuma solicitação encontrada!", enText: "No requests found")), ) ], ), ) - else if (_hasData == true && - _loading == false && - _requestWrap.isNotEmpty) + else if (_hasData == true && _loading == false && _requestWrap.isNotEmpty) Expanded(child: _listItems(context)), if (_loading == true) Container( @@ -214,8 +203,7 @@ class _LiberationHistoryWidgetState extends State { buttons: [ if (liberationHistoryItem['NOT_STATUS'] == 'S') FFButtonWidget( - text: FFLocalizations.of(context) - .getVariableText(ptText: "Aceitar", enText: "Accept"), + text: FFLocalizations.of(context).getVariableText(ptText: "Aceitar", enText: "Accept"), options: FFButtonOptions( width: 130, height: 40, @@ -243,15 +231,13 @@ class _LiberationHistoryWidgetState extends State { showSnackbar( context, FFLocalizations.of(context).getVariableText( - enText: 'Successfully resolved visit', - ptText: 'Visita resolvida com sucesso'), + enText: 'Successfully resolved visit', ptText: 'Visita resolvida com sucesso'), false); } else { showSnackbar( context, FFLocalizations.of(context).getVariableText( - enText: 'Error resolving visit', - ptText: 'Erro ao resolver visita'), + enText: 'Error resolving visit', ptText: 'Erro ao resolver visita'), true); } }).whenComplete(() { @@ -266,8 +252,7 @@ class _LiberationHistoryWidgetState extends State { ), if (liberationHistoryItem['NOT_STATUS'] == 'S') FFButtonWidget( - text: FFLocalizations.of(context) - .getVariableText(ptText: "Bloquear", enText: "Block"), + text: FFLocalizations.of(context).getVariableText(ptText: "Bloquear", enText: "Block"), options: FFButtonOptions( width: 130, height: 40, @@ -295,8 +280,7 @@ class _LiberationHistoryWidgetState extends State { showSnackbar( context, FFLocalizations.of(context).getVariableText( - enText: 'Successfully resolved visit', - ptText: 'Visita resolvida com sucesso'), + enText: 'Successfully resolved visit', ptText: 'Visita resolvida com sucesso'), false); } else { showSnackbar(context, message, true); @@ -349,8 +333,7 @@ class _LiberationHistoryWidgetState extends State { return null; } catch (e, s) { DialogUtil.errorDefault(context); - LogUtil.requestAPIFailed( - "proccessRequest.php", "", "Consulta de Solicitações", e, s); + LogUtil.requestAPIFailed("proccessRequest.php", "", "Consulta de Solicitações", e, s); setState(() { _hasData = false; _loading = false; @@ -363,8 +346,7 @@ class _LiberationHistoryWidgetState extends State { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - FFLocalizations.of(context).getVariableText( - ptText: "Não há mais dados.", enText: "No more data."), + FFLocalizations.of(context).getVariableText(ptText: "Não há mais dados.", enText: "No more data."), ), duration: const Duration(seconds: 3), backgroundColor: FlutterFlowTheme.of(context).primary, diff --git a/lib/pages/message_history_page/message_history_page_model.dart b/lib/pages/message_history_page/message_history_page_model.dart index 21471970..e8fdacbc 100644 --- a/lib/pages/message_history_page/message_history_page_model.dart +++ b/lib/pages/message_history_page/message_history_page_model.dart @@ -3,10 +3,10 @@ import 'package:hub/backend/api_requests/api_manager.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/flutter_flow/request_manager.dart'; import 'package:hub/pages/message_history_page/message_history_page_widget.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; -class MessageHistoryPageModel - extends FlutterFlowModel { +class MessageHistoryPageModel extends FlutterFlowModel { late final String devUUID; late final String userUUID; late final String cliUUID; @@ -17,8 +17,7 @@ class MessageHistoryPageModel String? Function(BuildContext, String?)? textControllerValidator; TabController? tabBarController; - int get tabBarCurrentIndex => - tabBarController != null ? tabBarController!.index : 0; + int get tabBarCurrentIndex => tabBarController != null ? tabBarController!.index : 0; final _getLiberationsManager = StreamRequestManager(); Stream getLiberations({ @@ -32,8 +31,7 @@ class MessageHistoryPageModel requestFn: requestFn, ); void clearGetLiberationsCache() => _getLiberationsManager.clear(); - void clearGetLiberationsCacheKey(String? uniqueKey) => - _getLiberationsManager.clearRequest(uniqueKey); + void clearGetLiberationsCacheKey(String? uniqueKey) => _getLiberationsManager.clearRequest(uniqueKey); @override void initState(BuildContext context) { @@ -41,9 +39,9 @@ class MessageHistoryPageModel } Future init() async { - devUUID = StorageUtil().devUUID; - userUUID = StorageUtil().userUUID; - cliUUID = StorageUtil().cliUUID; + devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; } @override diff --git a/lib/pages/message_history_page/message_history_page_widget.dart b/lib/pages/message_history_page/message_history_page_widget.dart index 79d40b78..2d5a19bc 100644 --- a/lib/pages/message_history_page/message_history_page_widget.dart +++ b/lib/pages/message_history_page/message_history_page_widget.dart @@ -14,12 +14,10 @@ class MessageHistoryPageWidget extends StatefulWidget { const MessageHistoryPageWidget({super.key}); @override - State createState() => - _MessageHistoryPageWidgetState(); + State createState() => _MessageHistoryPageWidgetState(); } -class _MessageHistoryPageWidgetState extends State - with TickerProviderStateMixin { +class _MessageHistoryPageWidgetState extends State with TickerProviderStateMixin { late MessageHistoryPageModel _model; final scaffoldKey = GlobalKey(); @@ -45,27 +43,25 @@ class _MessageHistoryPageWidgetState extends State _scrollController = ScrollController() ..addListener(() { - if (_scrollController.position.atEdge && - _scrollController.position.pixels != 0) { + if (_scrollController.position.atEdge && _scrollController.position.pixels != 0) { _loadMore(); } }); - _model.tabBarController = - TabController(vsync: this, length: 3, initialIndex: 0) - ..addListener(() { - if (_model.tabBarController?.index == 0) { - _destinyType = "P"; - } else if (_model.tabBarController?.index == 1) { - _destinyType = "A"; - } else { - _destinyType = "T"; - } + _model.tabBarController = TabController(vsync: this, length: 3, initialIndex: 0) + ..addListener(() { + if (_model.tabBarController?.index == 0) { + _destinyType = "P"; + } else if (_model.tabBarController?.index == 1) { + _destinyType = "A"; + } else { + _destinyType = "T"; + } - _pageNumber = 1; - _messageWrap = []; - _messageFuture = fetchMessage(); - }); + _pageNumber = 1; + _messageWrap = []; + _messageFuture = fetchMessage(); + }); _model.textController ??= TextEditingController(); _model.textFieldFocusNode ??= FocusNode(); @@ -124,8 +120,7 @@ class _MessageHistoryPageWidgetState extends State return null; } catch (e, s) { DialogUtil.errorDefault(context); - LogUtil.requestAPIFailed( - "proccessRequest.php", "", "Consulta de Mensagems", e, s); + LogUtil.requestAPIFailed("proccessRequest.php", "", "Consulta de Mensagems", e, s); setState(() { _hasData = false; _loading = false; @@ -196,8 +191,7 @@ class _MessageHistoryPageWidgetState extends State fontFamily: FlutterFlowTheme.of(context).titleMediumFamily, fontSize: limitedBodyFontSize, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).titleMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).titleMediumFamily), ), unselectedLabelStyle: const TextStyle(), indicatorColor: FlutterFlowTheme.of(context).primary, @@ -280,8 +274,7 @@ class _MessageHistoryPageWidgetState extends State ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - FFLocalizations.of(context).getVariableText( - ptText: "Não há mais dados.", enText: "No more data."), + FFLocalizations.of(context).getVariableText(ptText: "Não há mais dados.", enText: "No more data."), ), duration: const Duration(seconds: 3), backgroundColor: FlutterFlowTheme.of(context).primary, @@ -342,8 +335,7 @@ class _MessageHistoryPageWidgetState extends State padding: const EdgeInsets.only(left: 5), child: Icon( Icons.history, - color: - FlutterFlowTheme.of(context).customColor6, + color: FlutterFlowTheme.of(context).customColor6, size: 15, ), ), @@ -369,8 +361,7 @@ class _MessageHistoryPageWidgetState extends State padding: const EdgeInsets.only(left: 5), child: Icon( Icons.message, - color: - FlutterFlowTheme.of(context).customColor6, + color: FlutterFlowTheme.of(context).customColor6, size: 15, ), ), diff --git a/lib/pages/package_order_page/package_order_page.dart b/lib/pages/package_order_page/package_order_page.dart index 7deada31..7d457847 100644 --- a/lib/pages/package_order_page/package_order_page.dart +++ b/lib/pages/package_order_page/package_order_page.dart @@ -9,10 +9,11 @@ import 'package:hub/components/templates_components/details_component/details_co 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/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; import 'package:hub/shared/utils/log_util.dart'; -import 'package:hub/shared/utils/storage_util.dart'; import 'package:hub/shared/utils/validator_util.dart'; import 'package:rxdart/rxdart.dart'; @@ -55,8 +56,7 @@ class _PackageOrderPage extends State { _scrollController = ScrollController() ..addListener(() { - if (_scrollController.position.atEdge && - _scrollController.position.pixels != 0) { + if (_scrollController.position.atEdge && _scrollController.position.pixels != 0) { _loadMoreOrders(); } }); @@ -64,7 +64,7 @@ class _PackageOrderPage extends State { } Future initDatabase() async { - cliUUID = StorageUtil().cliUUID; + cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; } @override @@ -79,8 +79,7 @@ class _PackageOrderPage extends State { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - FFLocalizations.of(context).getVariableText( - ptText: "Não há mais dados.", enText: "No more data."), + FFLocalizations.of(context).getVariableText(ptText: "Não há mais dados.", enText: "No more data."), ), duration: const Duration(seconds: 3), backgroundColor: FlutterFlowTheme.of(context).primary, @@ -224,15 +223,10 @@ class _PackageOrderPage extends State { } PreferredSizeWidget _appBar(BuildContext context) { - double screenWidth = MediaQuery.of(context).size.width; - double screenHeight = MediaQuery.of(context).size.height; - return AppBar( backgroundColor: FlutterFlowTheme.of(context).primaryBackground, automaticallyImplyLeading: false, - title: Text( - FFLocalizations.of(context).getVariableText( - enText: 'My Orders', ptText: 'Minhas Encomendas'), + title: Text(FFLocalizations.of(context).getVariableText(enText: 'My Orders', ptText: 'Minhas Encomendas'), style: FlutterFlowTheme.of(context).headlineMedium.override( fontFamily: 'Nunito', color: FlutterFlowTheme.of(context).primaryText, @@ -321,12 +315,10 @@ class _PackageOrderPage extends State { '${FFLocalizations.of(context).getVariableText(ptText: 'Categoria', enText: 'Category')}:': order['customCategory'], '${FFLocalizations.of(context).getVariableText(ptText: 'Recebido em', enText: 'Received on')}:': - ValidatorUtil.toLocalDateTime( - 'yyyy-MM-dd HH:mm:ss', order['dtReceive']), + ValidatorUtil.toLocalDateTime('yyyy-MM-dd HH:mm:ss', order['dtReceive']), if (order['isPending'] == false) '${FFLocalizations.of(context).getVariableText(ptText: 'Retirado em', enText: 'Picked up on')}:': - ValidatorUtil.toLocalDateTime( - 'yyyy-MM-dd HH:mm:ss', order['dtPickUp']), + ValidatorUtil.toLocalDateTime('yyyy-MM-dd HH:mm:ss', order['dtPickUp']), }); } @@ -338,25 +330,21 @@ class _PackageOrderPage extends State { '${FFLocalizations.of(context).getVariableText(ptText: 'Categoria', enText: 'Category')}:': order['customCategory'], if (order['code'] != null) - '${FFLocalizations.of(context).getVariableText(ptText: 'Cód. Objeto', enText: 'Object Code')}:': - order['code'], + '${FFLocalizations.of(context).getVariableText(ptText: 'Cód. Objeto', enText: 'Object Code')}:': order['code'], '${FFLocalizations.of(context).getVariableText(ptText: 'Entregue por', enText: 'Delivered by')}:': order['sendedBy'], '${FFLocalizations.of(context).getVariableText(ptText: 'Recebido por', enText: 'Received by')}:': order['receivedBy'], '${FFLocalizations.of(context).getVariableText(ptText: 'Recebido em', enText: 'Received on')}:': - ValidatorUtil.toLocalDateTime( - 'yyyy-MM-dd HH:mm:ss', order['dtReceive']), + ValidatorUtil.toLocalDateTime('yyyy-MM-dd HH:mm:ss', order['dtReceive']), if (order['isPending'] == false) '${FFLocalizations.of(context).getVariableText(ptText: 'Retirado por', enText: 'Picked up by')}:': order['pickedUpBy'], if (order['isPending'] == false) '${FFLocalizations.of(context).getVariableText(ptText: 'Retirado em', enText: 'Picked up on')}:': - ValidatorUtil.toLocalDateTime( - 'yyyy-MM-dd HH:mm:ss', order['dtPickUp']), + ValidatorUtil.toLocalDateTime('yyyy-MM-dd HH:mm:ss', order['dtPickUp']), if (order['message'] != null) - '${FFLocalizations.of(context).getVariableText(ptText: 'Mensagem', enText: 'Message')}:': - order['message'] + '${FFLocalizations.of(context).getVariableText(ptText: 'Mensagem', enText: 'Message')}:': order['message'] }); } @@ -364,15 +352,13 @@ class _PackageOrderPage extends State { return [ if (order['isPending'] == true) Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Aguardando Retirada', - enText: 'Waiting Pick up'): FlutterFlowTheme.of(context).warning, + FFLocalizations.of(context).getVariableText(ptText: 'Aguardando Retirada', enText: 'Waiting Pick up'): + FlutterFlowTheme.of(context).warning, }) else Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Retirado', - enText: 'Picked up'): FlutterFlowTheme.of(context).primary, + FFLocalizations.of(context).getVariableText(ptText: 'Retirado', enText: 'Picked up'): + FlutterFlowTheme.of(context).primary, }), if (order['adresseeType'] == 'PRO') Map.from({ @@ -409,14 +395,12 @@ class _PackageOrderPage extends State { if (order['isPending'] == true) Map.from({ FFLocalizations.of(context).getVariableText( - ptText: 'Aguardando Retirada', - enText: 'Waiting Pick up'): - FlutterFlowTheme.of(context).warning, + ptText: 'Aguardando Retirada', + enText: 'Waiting Pick up'): FlutterFlowTheme.of(context).warning, }) else Map.from({ - FFLocalizations.of(context).getVariableText( - ptText: 'Retirado', enText: 'Picked up'): + FFLocalizations.of(context).getVariableText(ptText: 'Retirado', enText: 'Picked up'): FlutterFlowTheme.of(context).primary, }), ], diff --git a/lib/pages/people_on_the_property_page/people_on_the_property_page_model.dart b/lib/pages/people_on_the_property_page/people_on_the_property_page_model.dart index b33ee6b3..23a4779d 100644 --- a/lib/pages/people_on_the_property_page/people_on_the_property_page_model.dart +++ b/lib/pages/people_on_the_property_page/people_on_the_property_page_model.dart @@ -2,8 +2,7 @@ import 'package:flutter/material.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/pages/people_on_the_property_page/people_on_the_property_page_widget.dart'; -class PeopleOnThePropertyPageModel - extends FlutterFlowModel { +class PeopleOnThePropertyPageModel extends FlutterFlowModel { /// State fields for stateful widgets in this page. final unfocusNode = FocusNode(); diff --git a/lib/pages/people_on_the_property_page/people_on_the_property_page_widget.dart b/lib/pages/people_on_the_property_page/people_on_the_property_page_widget.dart index c6852f85..de433669 100644 --- a/lib/pages/people_on_the_property_page/people_on_the_property_page_widget.dart +++ b/lib/pages/people_on_the_property_page/people_on_the_property_page_widget.dart @@ -15,12 +15,10 @@ class PeopleOnThePropertyPageWidget extends StatefulWidget { const PeopleOnThePropertyPageWidget({super.key}); @override - State createState() => - _PeopleOnThePropertyPageWidgetState(); + State createState() => _PeopleOnThePropertyPageWidgetState(); } -class _PeopleOnThePropertyPageWidgetState - extends State { +class _PeopleOnThePropertyPageWidgetState extends State { late PeopleOnThePropertyPageModel _model; final scaffoldKey = GlobalKey(); @@ -100,11 +98,7 @@ class _PeopleOnThePropertyPageWidgetState if (snapshot.hasError || snapshot.data?.exception != null) { if (snapshot.error != null && snapshot.stackTrace != null) { LogUtil.requestAPIFailed( - 'getPessoasLocal.php', - "", - 'Busca Pessoas no Local', - snapshot.error, - snapshot.stackTrace!); + 'getPessoasLocal.php', "", 'Busca Pessoas no Local', snapshot.error, snapshot.stackTrace!); } return Center( @@ -112,9 +106,8 @@ class _PeopleOnThePropertyPageWidgetState width: double.infinity, height: 100, child: Text( - FFLocalizations.of(context).getVariableText( - ptText: "Pessoas não encontradas", - enText: "Persons not found"), + FFLocalizations.of(context) + .getVariableText(ptText: "Pessoas não encontradas", enText: "Persons not found"), textAlign: TextAlign.center, ), ), @@ -163,17 +156,14 @@ class _PeopleOnThePropertyPageWidgetState r'''$.USU_NOME''', ).toString(), style: FlutterFlowTheme.of(context).bodyMedium.override( - fontFamily: - FlutterFlowTheme.of(context).bodyMediumFamily, + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, fontSize: 14.0, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), ), - ] - .divide(const SizedBox(width: 20.0)) - .addToStart(const SizedBox(width: 40.0)), + ].divide(const SizedBox(width: 20.0)).addToStart(const SizedBox(width: 40.0)), ); }, ); diff --git a/lib/pages/pets_page/pets_history_screen.dart b/lib/pages/pets_page/pets_history_screen.dart index 3b39429b..4982a515 100644 --- a/lib/pages/pets_page/pets_history_screen.dart +++ b/lib/pages/pets_page/pets_history_screen.dart @@ -4,10 +4,11 @@ import 'package:hub/components/templates_components/card_item_template_component import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/pages/pets_page/pets_page_model.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; import 'package:hub/shared/utils/log_util.dart'; -import 'package:hub/shared/utils/storage_util.dart'; class PetsHistoryScreen extends StatefulWidget { const PetsHistoryScreen({super.key, required this.model}); @@ -18,8 +19,7 @@ class PetsHistoryScreen extends StatefulWidget { _PetsHistoryScreenState createState() => _PetsHistoryScreenState(); } -class _PetsHistoryScreenState extends State - with TickerProviderStateMixin { +class _PetsHistoryScreenState extends State with TickerProviderStateMixin { late ScrollController _scrollController; int _pageNumber = 1; @@ -39,8 +39,7 @@ class _PetsHistoryScreenState extends State _scrollController = ScrollController() ..addListener(() { - if (_scrollController.position.atEdge && - _scrollController.position.pixels != 0) { + if (_scrollController.position.atEdge && _scrollController.position.pixels != 0) { _loadMore(); } }); @@ -84,8 +83,7 @@ class _PetsHistoryScreenState extends State return null; } catch (e, s) { DialogUtil.errorDefault(context); - LogUtil.requestAPIFailed( - "proccessRequest.php", "", "Consulta de Pets", e, s); + LogUtil.requestAPIFailed("proccessRequest.php", "", "Consulta de Pets", e, s); setState(() { _hasData = false; _loading = false; @@ -106,8 +104,7 @@ class _PetsHistoryScreenState extends State ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - FFLocalizations.of(context).getVariableText( - ptText: "Não há mais dados.", enText: "No more data."), + FFLocalizations.of(context).getVariableText(ptText: "Não há mais dados.", enText: "No more data."), ), duration: const Duration(seconds: 3), backgroundColor: FlutterFlowTheme.of(context).primary, @@ -159,8 +156,7 @@ class _PetsHistoryScreenState extends State padding: const EdgeInsets.only(right: 30, top: 10), child: Text( widget.model.petAmountRegister == '0' - ? FFLocalizations.of(context).getVariableText( - ptText: "Ilimitado", enText: "Unlimited") + ? FFLocalizations.of(context).getVariableText(ptText: "Ilimitado", enText: "Unlimited") : "${FFLocalizations.of(context).getVariableText(ptText: "Quantidade de Pets: ", enText: "Amount of Pets: ")}$count/${widget.model.petAmountRegister}", textAlign: TextAlign.right, style: TextStyle( @@ -196,12 +192,9 @@ class _PetsHistoryScreenState extends State imagePath: 'https://freaccess.com.br/freaccess/getImage.php?devUUID=${widget.model.devUUID}&userUUID=${widget.model.userUUID}&cliID=${widget.model.cliUUID}&atividade=consultaFotoPet&petId=${uItem['id'] ?? ''}', labelsHashMap: { - '${FFLocalizations.of(context).getVariableText(ptText: "Nome", enText: "Name")}:': - uItem['name'] ?? '', - '${FFLocalizations.of(context).getVariableText(ptText: "Espécie", enText: "Species")}:': - uItem['species'] ?? '', - '${FFLocalizations.of(context).getVariableText(ptText: "Raça", enText: "Breed")}:': - uItem['breed'] ?? '', + '${FFLocalizations.of(context).getVariableText(ptText: "Nome", enText: "Name")}:': uItem['name'] ?? '', + '${FFLocalizations.of(context).getVariableText(ptText: "Espécie", enText: "Species")}:': uItem['species'] ?? '', + '${FFLocalizations.of(context).getVariableText(ptText: "Raça", enText: "Breed")}:': uItem['breed'] ?? '', }, statusHashMap: [ if (uItem['size'] == "MIN") @@ -241,8 +234,7 @@ class _PetsHistoryScreenState extends State }, if (uItem['gender'] == "MAC") { - FFLocalizations.of(context).getVariableText( - ptText: 'Macho', enText: 'Male'): const Color(0xFF094CB0), + FFLocalizations.of(context).getVariableText(ptText: 'Macho', enText: 'Male'): const Color(0xFF094CB0), }, if (uItem['gender'] == "FEM") { @@ -253,10 +245,13 @@ class _PetsHistoryScreenState extends State } ], onTapCardItemAction: () async { - final cliUUID = StorageUtil().cliUUID; - final cliName = StorageUtil().cliName; - final devUUID = StorageUtil().devUUID; - final userUUID = StorageUtil().userUUID; + final devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final cliUUID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + final cliName = + (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? ''; await showDialog( useSafeArea: true, context: context, @@ -278,13 +273,11 @@ class _PetsHistoryScreenState extends State safeSetState(() { _pageNumber = 1; _petsWrap = []; - _petsFuture = - _fetchVisits().then((value) => value!.jsonBody['pets'] ?? []); + _petsFuture = _fetchVisits().then((value) => value!.jsonBody['pets'] ?? []); }); }).catchError((e, s) { DialogUtil.errorDefault(context); - LogUtil.requestAPIFailed( - "proccessRequest.php", "", "Consulta de Pets", e, s); + LogUtil.requestAPIFailed("proccessRequest.php", "", "Consulta de Pets", e, s); safeSetState(() { _hasData = false; _loading = false; diff --git a/lib/pages/pets_page/pets_page_model.dart b/lib/pages/pets_page/pets_page_model.dart index e505c51f..0027a8ee 100644 --- a/lib/pages/pets_page/pets_page_model.dart +++ b/lib/pages/pets_page/pets_page_model.dart @@ -12,10 +12,11 @@ import 'package:hub/flutter_flow/flutter_flow_widgets.dart'; import 'package:hub/flutter_flow/form_field_controller.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/pages/pets_page/pets_page_widget.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/image_util.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; -import 'package:hub/shared/utils/storage_util.dart'; import 'package:hub/shared/utils/validator_util.dart'; class PetsPageModel extends FlutterFlowModel { @@ -102,10 +103,11 @@ class PetsPageModel extends FlutterFlowModel { String? Function(BuildContext, String?)? textControllerObservationValidator; Future initAsync() async { - devUUID = StorageUtil().devUUID; - userUUID = StorageUtil().userUUID; - cliUUID = StorageUtil().cliUUID; - petAmountRegister = StorageUtil().petAmountRegister.toString(); + devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + petAmountRegister = + (await StorageHelper().get(SQLiteStorageKey.petAmount.value, Storage.SQLiteStorage)) ?? ''; safeSetState?.call(); } @@ -135,11 +137,9 @@ class PetsPageModel extends FlutterFlowModel { textFieldFocusObservation = FocusNode(); textControllerObservation = TextEditingController(); - dropDownValueController1 = - FormFieldController(dropDownValue1 ??= 'Selecione uma opção'); + dropDownValueController1 = FormFieldController(dropDownValue1 ??= 'Selecione uma opção'); - dropDownValueController2 = - FormFieldController(dropDownValue2 ??= 'Selecione uma opção'); + dropDownValueController2 = FormFieldController(dropDownValue2 ??= 'Selecione uma opção'); initAsync(); } @@ -158,20 +158,16 @@ class PetsPageModel extends FlutterFlowModel { updateImage?.call(); })(); - textControllerName = - TextEditingController(text: item != null ? item['name'] ?? '' : ''); + textControllerName = TextEditingController(text: item != null ? item['name'] ?? '' : ''); textFieldFocusName = FocusNode(); - textControllerSpecies = - TextEditingController(text: item != null ? item['species'] ?? '' : ''); + textControllerSpecies = TextEditingController(text: item != null ? item['species'] ?? '' : ''); textFieldFocusSpecies = FocusNode(); - textControllerRace = - TextEditingController(text: item != null ? item['breed'] ?? '' : ''); + textControllerRace = TextEditingController(text: item != null ? item['breed'] ?? '' : ''); textFieldFocusRace = FocusNode(); - textControllerColor = - TextEditingController(text: item != null ? item['color'] ?? '' : ''); + textControllerColor = TextEditingController(text: item != null ? item['color'] ?? '' : ''); textFieldFocusColor = FocusNode(); textControllerData = TextEditingController( @@ -183,8 +179,7 @@ class PetsPageModel extends FlutterFlowModel { textFieldFocusData = FocusNode(); - textControllerObservation = - TextEditingController(text: item != null ? item['notes'] ?? '' : ''); + textControllerObservation = TextEditingController(text: item != null ? item['notes'] ?? '' : ''); textFieldFocusObservation = FocusNode(); item != null ? dropDownValue1 = item['gender'] ?? '' : dropDownValue1 = ''; @@ -226,27 +221,20 @@ class PetsPageModel extends FlutterFlowModel { if (uploadedLocalFile == null || uploadedLocalFile!.bytes!.isEmpty) { return false; } - if (textControllerName.text.isEmpty || - textControllerName.text.length > 80 || - textControllerName.text == '') { + if (textControllerName.text.isEmpty || textControllerName.text.length > 80 || textControllerName.text == '') { return false; } - if (textControllerSpecies.text.isEmpty || - textControllerSpecies.text == '') { + if (textControllerSpecies.text.isEmpty || textControllerSpecies.text == '') { return false; } if (textControllerRace.text.isEmpty || textControllerRace.text == '') { return false; } - if (dropDownValue1 == null || - dropDownValue1!.isEmpty || - dropDownValue1 == '') { + if (dropDownValue1 == null || dropDownValue1!.isEmpty || dropDownValue1 == '') { return false; } - if (dropDownValue2 == null || - dropDownValue2!.isEmpty || - dropDownValue2 == '') { + if (dropDownValue2 == null || dropDownValue2!.isEmpty || dropDownValue2 == '') { return false; } return true; @@ -285,8 +273,7 @@ class PetsPageModel extends FlutterFlowModel { } else { String errorMessage; try { - errorMessage = - jsonDecode(response.jsonBody['error_msg'])[0]['message'].toString(); + errorMessage = jsonDecode(response.jsonBody['error_msg'])[0]['message'].toString(); } catch (e) { errorMessage = FFLocalizations.of(buildContext!).getVariableText( enText: 'Failed to update pet', @@ -324,11 +311,9 @@ class PetsPageModel extends FlutterFlowModel { } else { String errorMessage; try { - errorMessage = - jsonDecode(response.jsonBody['error_msg'])[0]['message'].toString(); + errorMessage = jsonDecode(response.jsonBody['error_msg'])[0]['message'].toString(); } catch (e) { - if (response.jsonBody['error_msg'] == - "Limite de Cadastro de Pet Atingido.") { + if (response.jsonBody['error_msg'] == "Limite de Cadastro de Pet Atingido.") { errorMessage = FFLocalizations.of(buildContext!).getVariableText( enText: 'Pet registration limit reached', ptText: 'Limite de cadastro de pets atingido', @@ -519,33 +504,23 @@ class PetsPageModel extends FlutterFlowModel { '${FFLocalizations.of(context).getVariableText(ptText: "Data de Nascimento", enText: "Date of Birth")}:': ValidatorUtil.formatDateTimePicker(item['birthdayDate']), if (item['gender'] != null && item['gender'] != '') - '${FFLocalizations.of(context).getVariableText(ptText: "Gênero", enText: "Gender")}:': - item['gender'] == 'MAC' - ? FFLocalizations.of(context) - .getVariableText(ptText: 'MACHO', enText: 'MALE') - : FFLocalizations.of(context) - .getVariableText(enText: 'FEMALE', ptText: 'FÊMEA'), + '${FFLocalizations.of(context).getVariableText(ptText: "Gênero", enText: "Gender")}:': item['gender'] == 'MAC' + ? FFLocalizations.of(context).getVariableText(ptText: 'MACHO', enText: 'MALE') + : FFLocalizations.of(context).getVariableText(enText: 'FEMALE', ptText: 'FÊMEA'), if (item['size'] != null && item['size'] != '') - '${FFLocalizations.of(context).getVariableText(ptText: "Porte", enText: "Size")}:': - item['size'] == 'MIN' - ? FFLocalizations.of(context) - .getVariableText(ptText: 'MINI', enText: 'MINI') - : item['size'] == 'PEQ' - ? FFLocalizations.of(context) - .getVariableText(ptText: 'PEQUENO', enText: 'SMALL') - : item['size'] == 'MED' - ? FFLocalizations.of(context).getVariableText( - ptText: 'MÉDIO', enText: 'MEDIUM') - : item['size'] == 'GRD' - ? FFLocalizations.of(context).getVariableText( - ptText: 'GRANDE', enText: 'LARGE') - : item['size'] == 'GIG' - ? FFLocalizations.of(context).getVariableText( - ptText: 'GIGANTE', enText: 'GIANT') - : '', + '${FFLocalizations.of(context).getVariableText(ptText: "Porte", enText: "Size")}:': item['size'] == 'MIN' + ? FFLocalizations.of(context).getVariableText(ptText: 'MINI', enText: 'MINI') + : item['size'] == 'PEQ' + ? FFLocalizations.of(context).getVariableText(ptText: 'PEQUENO', enText: 'SMALL') + : item['size'] == 'MED' + ? FFLocalizations.of(context).getVariableText(ptText: 'MÉDIO', enText: 'MEDIUM') + : item['size'] == 'GRD' + ? FFLocalizations.of(context).getVariableText(ptText: 'GRANDE', enText: 'LARGE') + : item['size'] == 'GIG' + ? FFLocalizations.of(context).getVariableText(ptText: 'GIGANTE', enText: 'GIANT') + : '', if (item['notes'] != null && item['notes'] != '') - '${FFLocalizations.of(context).getVariableText(ptText: "Observação", enText: "Notes")}:': - item['notes'] ?? '', + '${FFLocalizations.of(context).getVariableText(ptText: "Observação", enText: "Notes")}:': item['notes'] ?? '', }), imagePath: 'https://freaccess.com.br/freaccess/getImage.php?devUUID=$devUUID&userUUID=$userUUID&cliID=$cliUUID&atividade=consultaFotoPet&petId=${item['id'] ?? ''}', diff --git a/lib/pages/pets_page/pets_page_widget.dart b/lib/pages/pets_page/pets_page_widget.dart index 8ff0f1ba..602bea91 100644 --- a/lib/pages/pets_page/pets_page_widget.dart +++ b/lib/pages/pets_page/pets_page_widget.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/components/atomic_components/shared_components_atoms/appbar.dart'; @@ -29,8 +28,7 @@ class PetsPageWidget extends StatefulWidget { State createState() => _PetsPageWidgetState(); } -class _PetsPageWidgetState extends State - with SingleTickerProviderStateMixin { +class _PetsPageWidgetState extends State with SingleTickerProviderStateMixin { late PetsPageModel _model; @override @@ -92,16 +90,11 @@ class _PetsPageWidgetState extends State context: context, model: _model, labelTab1: _model.isEditing - ? FFLocalizations.of(context) - .getVariableText(ptText: 'Editar', enText: 'Edit') - : FFLocalizations.of(context) - .getVariableText(ptText: 'Cadastrar', enText: 'Register'), - labelTab2: FFLocalizations.of(context) - .getVariableText(ptText: 'Consultar', enText: 'History'), + ? FFLocalizations.of(context).getVariableText(ptText: 'Editar', enText: 'Edit') + : FFLocalizations.of(context).getVariableText(ptText: 'Cadastrar', enText: 'Register'), + labelTab2: FFLocalizations.of(context).getVariableText(ptText: 'Consultar', enText: 'History'), controller: _model.tabBarController, - widget1: _model.isEditing - ? _buildEditForm(context) - : _buildRegisterForm(context), + widget1: _model.isEditing ? _buildEditForm(context) : _buildRegisterForm(context), widget2: PetsHistoryScreen(model: _model), onEditingChanged: onEditingChanged, ); @@ -129,8 +122,7 @@ class _PetsPageWidgetState extends State style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), fontSize: limitedHeaderFontSize, ), @@ -399,13 +391,13 @@ class _PetsPageWidgetState extends State }, ); - if (pickedDate != null) { - setState(() { - _model.selectedDate = DateTime( - pickedDate.year, - pickedDate.month, - pickedDate.day, - ); + if (pickedDate != null) { + setState(() { + _model.selectedDate = DateTime( + pickedDate.year, + pickedDate.month, + pickedDate.day, + ); _model.textControllerData = TextEditingController( @@ -594,8 +586,7 @@ class _PetsPageWidgetState extends State style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), ), ), @@ -603,442 +594,331 @@ class _PetsPageWidgetState extends State Form( key: _model.updateFormKey, autovalidateMode: AutovalidateMode.onUserInteraction, - child: Column( - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Padding( - padding: const EdgeInsets.fromLTRB(0, 10, 0, 20), - child: MediaUploadButtonUtil( - onUploadComplete: _model.handleUploadComplete, - isUploading: _model.isDataUploading, - uploadedFiles: _model.uploadedLocalFile, - labelText: FFLocalizations.of(context).getVariableText( - ptText: 'Clique para adicionar a foto de seu Pet', - enText: 'Click to add your Pet\'s photo'), - ), - ), - CustomInputUtil( - controller: _model.textControllerName, - validator: _model.textControllerNameValidator - .asValidator(context), - focusNode: _model.textFieldFocusName, - labelText: FFLocalizations.of(context) - .getVariableText(ptText: 'Nome', enText: 'Name'), - hintText: FFLocalizations.of(context) - .getVariableText(ptText: 'Nome', enText: 'Name'), - suffixIcon: Symbols.format_color_text, - haveMaxLength: true, - onChanged: (value) => setState(() {}), - maxLength: 80, - ), - Padding( - padding: const EdgeInsets.fromLTRB(0, 0, 0, 15), - child: CustomInputUtil( - controller: _model.textControllerSpecies, - validator: _model.textControllerSpeciesValidator - .asValidator(context), - focusNode: _model.textFieldFocusSpecies, - labelText: FFLocalizations.of(context).getVariableText( - ptText: 'Espécie', enText: 'Species'), - hintText: FFLocalizations.of(context).getVariableText( - ptText: 'Ex: Cachorro, Gato, Papagaio', - enText: 'e.g. Dog, Cat, Parrot'), - suffixIcon: Symbols.sound_detection_dog_barking, - haveMaxLength: true, - onChanged: (value) => setState(() {}), - maxLength: 80, - ), - ), - Padding( - padding: const EdgeInsets.fromLTRB(0, 0, 0, 15), - child: CustomInputUtil( - controller: _model.textControllerRace, - validator: _model.textControllerRaceValidator - .asValidator(context), - focusNode: _model.textFieldFocusRace, - labelText: FFLocalizations.of(context) - .getVariableText(ptText: 'Raça', enText: 'Race'), - hintText: FFLocalizations.of(context).getVariableText( - ptText: 'Ex: Labrador, Poodle, Siamês, Persa', - enText: 'e.g. Labrador, Poodle, Siamese, Persian'), - suffixIcon: Icons.pets_outlined, - haveMaxLength: true, - onChanged: (value) => setState(() {}), - maxLength: 80, - ), - ), - Padding( - padding: const EdgeInsets.fromLTRB(0, 0, 0, 15), - child: CustomInputUtil( - controller: _model.textControllerColor, - validator: _model.textControllerColorValidator - .asValidator(context), - focusNode: _model.textFieldFocusColor, - labelText: FFLocalizations.of(context) - .getVariableText(ptText: 'Cor', enText: 'Color'), - hintText: FFLocalizations.of(context).getVariableText( - ptText: 'Ex: Preto, Amarelo, Branco', - enText: 'e.g. Black, Yellow, White'), - suffixIcon: Symbols.palette, - haveMaxLength: true, - onChanged: (value) => setState(() {}), - maxLength: 80, - ), - ), - Padding( - padding: const EdgeInsets.fromLTRB(0, 0, 0, 15), - child: Row( - mainAxisSize: MainAxisSize.max, - children: [ - SizedBox( - width: MediaQuery.of(context).size.width, - height: 60.0, - child: Stack( - children: [ - Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), - child: TextFormField( - controller: _model.textControllerData, - focusNode: _model.textFieldFocusData, - cursorColor: - FlutterFlowTheme.of(context).primary, - readOnly: true, - autovalidateMode: - AutovalidateMode.onUserInteraction, - autofocus: false, - obscureText: false, - decoration: InputDecoration( - isDense: true, - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), - ), - hintText: FFLocalizations.of(context) - .getVariableText( - ptText: 'Data de Nascimento', - enText: 'Date of Birth', + child: + Column(mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ + Padding( + padding: const EdgeInsets.fromLTRB(0, 10, 0, 20), + child: MediaUploadButtonUtil( + onUploadComplete: _model.handleUploadComplete, + isUploading: _model.isDataUploading, + uploadedFiles: _model.uploadedLocalFile, + labelText: FFLocalizations.of(context).getVariableText( + ptText: 'Clique para adicionar a foto de seu Pet', enText: 'Click to add your Pet\'s photo'), + ), + ), + CustomInputUtil( + controller: _model.textControllerName, + validator: _model.textControllerNameValidator.asValidator(context), + focusNode: _model.textFieldFocusName, + labelText: FFLocalizations.of(context).getVariableText(ptText: 'Nome', enText: 'Name'), + hintText: FFLocalizations.of(context).getVariableText(ptText: 'Nome', enText: 'Name'), + suffixIcon: Symbols.format_color_text, + haveMaxLength: true, + onChanged: (value) => setState(() {}), + maxLength: 80, + ), + Padding( + padding: const EdgeInsets.fromLTRB(0, 0, 0, 15), + child: CustomInputUtil( + controller: _model.textControllerSpecies, + validator: _model.textControllerSpeciesValidator.asValidator(context), + focusNode: _model.textFieldFocusSpecies, + labelText: FFLocalizations.of(context).getVariableText(ptText: 'Espécie', enText: 'Species'), + hintText: FFLocalizations.of(context) + .getVariableText(ptText: 'Ex: Cachorro, Gato, Papagaio', enText: 'e.g. Dog, Cat, Parrot'), + suffixIcon: Symbols.sound_detection_dog_barking, + haveMaxLength: true, + onChanged: (value) => setState(() {}), + maxLength: 80, + ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(0, 0, 0, 15), + child: CustomInputUtil( + controller: _model.textControllerRace, + validator: _model.textControllerRaceValidator.asValidator(context), + focusNode: _model.textFieldFocusRace, + labelText: FFLocalizations.of(context).getVariableText(ptText: 'Raça', enText: 'Race'), + hintText: FFLocalizations.of(context).getVariableText( + ptText: 'Ex: Labrador, Poodle, Siamês, Persa', + enText: 'e.g. Labrador, Poodle, Siamese, Persian'), + suffixIcon: Icons.pets_outlined, + haveMaxLength: true, + onChanged: (value) => setState(() {}), + maxLength: 80, + ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(0, 0, 0, 15), + child: CustomInputUtil( + controller: _model.textControllerColor, + validator: _model.textControllerColorValidator.asValidator(context), + focusNode: _model.textFieldFocusColor, + labelText: FFLocalizations.of(context).getVariableText(ptText: 'Cor', enText: 'Color'), + hintText: FFLocalizations.of(context) + .getVariableText(ptText: 'Ex: Preto, Amarelo, Branco', enText: 'e.g. Black, Yellow, White'), + suffixIcon: Symbols.palette, + haveMaxLength: true, + onChanged: (value) => setState(() {}), + maxLength: 80, + ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(0, 0, 0, 15), + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + SizedBox( + width: MediaQuery.of(context).size.width, + height: 60.0, + child: Stack( + children: [ + Padding( + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), + child: TextFormField( + controller: _model.textControllerData, + focusNode: _model.textFieldFocusData, + cursorColor: FlutterFlowTheme.of(context).primary, + readOnly: true, + autovalidateMode: AutovalidateMode.onUserInteraction, + autofocus: false, + obscureText: false, + decoration: InputDecoration( + isDense: true, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap() + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: - FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), - lineHeight: 1.0, - ), - enabledBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .customColor6, - width: 0.5, - ), - borderRadius: - BorderRadius.circular(10.0), - ), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primary, - width: 0.5, - ), - borderRadius: - BorderRadius.circular(10.0), - ), - errorBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .error, - width: 0.5, - ), - borderRadius: - BorderRadius.circular(10.0), - ), - focusedErrorBorder: OutlineInputBorder( - borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .error, - width: 0.5, - ), - borderRadius: - BorderRadius.circular(10.0), - ), - suffixIcon: Icon( - Icons.date_range, - color: FlutterFlowTheme.of(context) - .accent1, + hintText: FFLocalizations.of(context).getVariableText( + ptText: 'Data de Nascimento', + enText: 'Date of Birth', + ), + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap() + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), + lineHeight: 1.0, ), + enabledBorder: OutlineInputBorder( + borderSide: BorderSide( + color: FlutterFlowTheme.of(context).customColor6, + width: 0.5, ), - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of(context) - .bodyMediumFamily, - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), - lineHeight: 1.8, - ), - textAlign: TextAlign.start, - validator: _model - .textControllerDataValidator - .asValidator(context), + borderRadius: BorderRadius.circular(10.0), + ), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: FlutterFlowTheme.of(context).primary, + width: 0.5, + ), + borderRadius: BorderRadius.circular(10.0), + ), + errorBorder: OutlineInputBorder( + borderSide: BorderSide( + color: FlutterFlowTheme.of(context).error, + width: 0.5, + ), + borderRadius: BorderRadius.circular(10.0), + ), + focusedErrorBorder: OutlineInputBorder( + borderSide: BorderSide( + color: FlutterFlowTheme.of(context).error, + width: 0.5, + ), + borderRadius: BorderRadius.circular(10.0), + ), + suffixIcon: Icon( + Icons.date_range, + color: FlutterFlowTheme.of(context).accent1, ), ), - Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0.0, 24.0, 0.0), - child: InkWell( - splashColor: Colors.transparent, - focusColor: Colors.transparent, - hoverColor: Colors.transparent, - highlightColor: Colors.transparent, - onTap: () async { - final pickedDate = await showDatePicker( - context: context, - initialDate: DateFormat('dd/MM/yyyy') - .tryParse( - _model.textControllerData.text), - firstDate: DateTime(1990), - lastDate: DateTime.now(), - builder: (context, child) { - return wrapInMaterialDatePickerTheme( - context, - child!, - headerBackgroundColor: - FlutterFlowTheme.of(context) - .primary, - headerForegroundColor: - FlutterFlowTheme.of(context) - .info, - headerTextStyle: - FlutterFlowTheme.of(context) - .headlineLarge - .override( - fontFamily: FlutterFlowTheme - .of(context) - .headlineLargeFamily, - fontSize: 32.0, - letterSpacing: 0.0, - fontWeight: - FontWeight.w600, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of( - context) - .headlineLargeFamily), - ), - pickerBackgroundColor: - FlutterFlowTheme.of(context) - .primaryBackground, - pickerForegroundColor: - FlutterFlowTheme.of(context) - .primaryText, - selectedDateTimeBackgroundColor: - FlutterFlowTheme.of(context) - .primary, - selectedDateTimeForegroundColor: - FlutterFlowTheme.of(context) - .info, - actionButtonForegroundColor: - FlutterFlowTheme.of(context) - .primaryText, - iconSize: 24.0, - ); - }, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap() + .containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), + lineHeight: 1.8, + ), + textAlign: TextAlign.start, + validator: _model.textControllerDataValidator.asValidator(context), + ), + ), + Padding( + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0.0, 24.0, 0.0), + child: InkWell( + splashColor: Colors.transparent, + focusColor: Colors.transparent, + hoverColor: Colors.transparent, + highlightColor: Colors.transparent, + onTap: () async { + final pickedDate = await showDatePicker( + context: context, + initialDate: DateFormat('dd/MM/yyyy').tryParse(_model.textControllerData.text), + firstDate: DateTime(1990), + lastDate: DateTime.now(), + builder: (context, child) { + return wrapInMaterialDatePickerTheme( + context, + child!, + headerBackgroundColor: FlutterFlowTheme.of(context).primary, + headerForegroundColor: FlutterFlowTheme.of(context).info, + headerTextStyle: FlutterFlowTheme.of(context).headlineLarge.override( + fontFamily: FlutterFlowTheme.of(context).headlineLargeFamily, + fontSize: 32.0, + letterSpacing: 0.0, + fontWeight: FontWeight.w600, + useGoogleFonts: GoogleFonts.asMap() + .containsKey(FlutterFlowTheme.of(context).headlineLargeFamily), + ), + pickerBackgroundColor: FlutterFlowTheme.of(context).primaryBackground, + pickerForegroundColor: FlutterFlowTheme.of(context).primaryText, + selectedDateTimeBackgroundColor: FlutterFlowTheme.of(context).primary, + selectedDateTimeForegroundColor: FlutterFlowTheme.of(context).info, + actionButtonForegroundColor: FlutterFlowTheme.of(context).primaryText, + iconSize: 24.0, + ); + }, + ); + + if (pickedDate != null) { + setState(() { + _model.selectedDate = DateTime( + pickedDate.year, + pickedDate.month, + pickedDate.day, ); - if (pickedDate != null) { - setState(() { - _model.selectedDate = DateTime( - pickedDate.year, - pickedDate.month, - pickedDate.day, - ); - - _model.textControllerData = - TextEditingController( - text: dateTimeFormat( - 'dd/MM/yyyy', - _model.selectedDate, - locale: FFLocalizations.of(context) - .languageCode, - )); - _model.textControllerData?.selection = - TextSelection.collapsed( - offset: _model.textControllerData! - .text.length, - ); - }); - } - }, - child: Container( - width: double.infinity, - height: 80.0, - decoration: BoxDecoration( - borderRadius: - BorderRadius.circular(10.0), - ), - ), + _model.textControllerData = TextEditingController( + text: dateTimeFormat( + 'dd/MM/yyyy', + _model.selectedDate, + locale: FFLocalizations.of(context).languageCode, + )); + _model.textControllerData?.selection = TextSelection.collapsed( + offset: _model.textControllerData!.text.length, + ); + }); + } + }, + child: Container( + width: double.infinity, + height: 80.0, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10.0), ), ), - ], + ), ), - ), - ], - ), - ), - Align( - alignment: const AlignmentDirectional(-1.0, 0.0), - child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0, 0.0, 15), - child: Text( - FFLocalizations.of(context).getVariableText( - ptText: 'Selecione as opções disponíveis', - enText: 'Select the available options', - ), - textAlign: TextAlign.start, - style: FlutterFlowTheme.of(context) - .bodySmall - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodySmallFamily, - letterSpacing: 0.0, - fontWeight: FontWeight.w600, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), - ), + ], ), ), - ), - Padding( - padding: const EdgeInsets.fromLTRB(0, 0, 0, 15), - child: CustomSelect( - options: const ['MAC', 'FEM'], - controller: _model.dropDownValueController1 ??= - FormFieldController( - _model.dropDownValue1 ??= ''), - isRequired: true, - changed: (val) => safeSetState(() { - _model.dropDownValue1 = val; - }), - dropDownValue: _model.dropDownValue1, - optionsLabel: [ - FFLocalizations.of(context).getVariableText( - ptText: 'Macho', enText: 'Male'), - FFLocalizations.of(context).getVariableText( - ptText: 'Fêmea', enText: 'Female') - ], - hintText: FFLocalizations.of(context).getVariableText( - ptText: 'Selecione o gênero do Pet', - enText: 'Select the gender of the Pet')), - ), - Padding( - padding: const EdgeInsets.fromLTRB(0, 0, 0, 15), - child: CustomSelect( - options: const ['MIN', 'PEQ', 'MED', 'GRA', 'GIG'], - controller: _model.dropDownValueController2 ??= - FormFieldController( - _model.dropDownValue2 ??= ''), - isRequired: true, - changed: (val) => safeSetState(() { - _model.dropDownValue2 = val; - }), - dropDownValue: _model.dropDownValue1, - optionsLabel: [ - FFLocalizations.of(context).getVariableText( - ptText: 'Mini', enText: 'Mini'), - FFLocalizations.of(context).getVariableText( - ptText: 'Pequeno', enText: 'Small'), - FFLocalizations.of(context).getVariableText( - ptText: 'Médio', enText: 'Medium'), - FFLocalizations.of(context).getVariableText( - ptText: 'Grande', enText: 'Big'), - FFLocalizations.of(context).getVariableText( - ptText: 'Gigante', enText: 'Giant'), - ], - hintText: FFLocalizations.of(context).getVariableText( - ptText: 'Selecione o porte do Pet', - enText: 'Select the size of the Pet')), - ), - Align( - alignment: const AlignmentDirectional(-1.0, 0.0), - child: Padding( - padding: const EdgeInsetsDirectional.fromSTEB( - 24.0, 0, 0.0, 15), - child: Text( - FFLocalizations.of(context).getVariableText( - ptText: - 'Você tem alguma observação sobre o seu Pet?', - enText: - 'Do you have any observations about your Pet?', - ), - textAlign: TextAlign.start, - style: FlutterFlowTheme.of(context) - .bodySmall - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodySmallFamily, - letterSpacing: 0.0, - fontWeight: FontWeight.w600, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), - ), - ), + ], + ), + ), + Align( + alignment: const AlignmentDirectional(-1.0, 0.0), + child: Padding( + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0, 0.0, 15), + child: Text( + FFLocalizations.of(context).getVariableText( + ptText: 'Selecione as opções disponíveis', + enText: 'Select the available options', ), + textAlign: TextAlign.start, + style: FlutterFlowTheme.of(context).bodySmall.override( + fontFamily: FlutterFlowTheme.of(context).bodySmallFamily, + letterSpacing: 0.0, + fontWeight: FontWeight.w600, + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), + ), ), - CustomInputUtil( - controller: _model.textControllerObservation, - validator: _model.textControllerObservationValidator - .asValidator(context), - focusNode: _model.textFieldFocusObservation, - labelText: FFLocalizations.of(context).getVariableText( - ptText: 'Escreva as suas observações aqui...', - enText: 'Write your observations here...'), + ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(0, 0, 0, 15), + child: CustomSelect( + options: const ['MAC', 'FEM'], + controller: _model.dropDownValueController1 ??= + FormFieldController(_model.dropDownValue1 ??= ''), + isRequired: true, + changed: (val) => safeSetState(() { + _model.dropDownValue1 = val; + }), + dropDownValue: _model.dropDownValue1, + optionsLabel: [ + FFLocalizations.of(context).getVariableText(ptText: 'Macho', enText: 'Male'), + FFLocalizations.of(context).getVariableText(ptText: 'Fêmea', enText: 'Female') + ], hintText: FFLocalizations.of(context).getVariableText( - ptText: 'Escreva as suas observações aqui...', - enText: 'Write your observations here...'), - suffixIcon: Icons.text_fields, - haveMaxLength: true, - maxLength: 250, - onChanged: (value) => setState(() {}), + ptText: 'Selecione o gênero do Pet', enText: 'Select the gender of the Pet')), + ), + Padding( + padding: const EdgeInsets.fromLTRB(0, 0, 0, 15), + child: CustomSelect( + options: const ['MIN', 'PEQ', 'MED', 'GRA', 'GIG'], + controller: _model.dropDownValueController2 ??= + FormFieldController(_model.dropDownValue2 ??= ''), + isRequired: true, + changed: (val) => safeSetState(() { + _model.dropDownValue2 = val; + }), + dropDownValue: _model.dropDownValue1, + optionsLabel: [ + FFLocalizations.of(context).getVariableText(ptText: 'Mini', enText: 'Mini'), + FFLocalizations.of(context).getVariableText(ptText: 'Pequeno', enText: 'Small'), + FFLocalizations.of(context).getVariableText(ptText: 'Médio', enText: 'Medium'), + FFLocalizations.of(context).getVariableText(ptText: 'Grande', enText: 'Big'), + FFLocalizations.of(context).getVariableText(ptText: 'Gigante', enText: 'Giant'), + ], + hintText: FFLocalizations.of(context) + .getVariableText(ptText: 'Selecione o porte do Pet', enText: 'Select the size of the Pet')), + ), + Align( + alignment: const AlignmentDirectional(-1.0, 0.0), + child: Padding( + padding: const EdgeInsetsDirectional.fromSTEB(24.0, 0, 0.0, 15), + child: Text( + FFLocalizations.of(context).getVariableText( + ptText: 'Você tem alguma observação sobre o seu Pet?', + enText: 'Do you have any observations about your Pet?', + ), + textAlign: TextAlign.start, + style: FlutterFlowTheme.of(context).bodySmall.override( + fontFamily: FlutterFlowTheme.of(context).bodySmallFamily, + letterSpacing: 0.0, + fontWeight: FontWeight.w600, + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), + ), ), - Padding( - padding: const EdgeInsets.fromLTRB(70, 20, 70, 30), - child: SubmitButtonUtil( - labelText: FFLocalizations.of(context) - .getVariableText( - ptText: 'Salvar', enText: 'Save'), - onPressed: _model.isFormValid(context) - ? _model.updatePet - : null), - ), - ])), + ), + ), + CustomInputUtil( + controller: _model.textControllerObservation, + validator: _model.textControllerObservationValidator.asValidator(context), + focusNode: _model.textFieldFocusObservation, + labelText: FFLocalizations.of(context).getVariableText( + ptText: 'Escreva as suas observações aqui...', enText: 'Write your observations here...'), + hintText: FFLocalizations.of(context).getVariableText( + ptText: 'Escreva as suas observações aqui...', enText: 'Write your observations here...'), + suffixIcon: Icons.text_fields, + haveMaxLength: true, + maxLength: 250, + onChanged: (value) => setState(() {}), + ), + Padding( + padding: const EdgeInsets.fromLTRB(70, 20, 70, 30), + child: SubmitButtonUtil( + labelText: FFLocalizations.of(context).getVariableText(ptText: 'Salvar', enText: 'Save'), + onPressed: _model.isFormValid(context) ? _model.updatePet : null), + ), + ])), ], ), ); diff --git a/lib/pages/preferences_settings_page/preferences_settings_model.dart b/lib/pages/preferences_settings_page/preferences_settings_model.dart index 09dfd292..ed89a882 100644 --- a/lib/pages/preferences_settings_page/preferences_settings_model.dart +++ b/lib/pages/preferences_settings_page/preferences_settings_model.dart @@ -1,13 +1,14 @@ +import 'dart:developer'; + import 'package:flutter/material.dart'; import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/components/templates_components/change_passs_qr_code_pass_key_template_component/change_pass_widget.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/helpers/secure_storage_helper.dart'; -import 'package:hub/shared/helpers/sqlite_storage_helper.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/services/authentication/authentication_service.dart'; import 'package:hub/shared/services/localization/localization_service.dart'; -import 'package:hub/shared/utils/storage_util.dart'; import 'package:share_plus/share_plus.dart'; import '../../shared/utils/snackbar_util.dart'; @@ -15,16 +16,29 @@ import '../../shared/utils/snackbar_util.dart'; class PreferencesPageModel with ChangeNotifier { final unfocusNode = FocusNode(); - PreferencesPageModel() { - initVariables(); - } + late bool isFingerprint = false; + late bool isPerson = false; + late bool isNotify = false; + late bool isAccess = false; + late bool isPanic = false; - Future initVariables() async { + Future _initialize() async { + isFingerprint = + await StorageHelper().get(SQLiteStorageKey.fingerprint.value, Storage.SQLiteStorage) == 'true'; + isPerson = await StorageHelper().get(SQLiteStorageKey.person.value, Storage.SQLiteStorage) == 'true'; + isNotify = await StorageHelper().get(SQLiteStorageKey.notify.value, Storage.SQLiteStorage) == 'true'; + isAccess = await StorageHelper().get(SQLiteStorageKey.access.value, Storage.SQLiteStorage) == 'true'; + isPanic = await StorageHelper().get(SQLiteStorageKey.panic.value, Storage.SQLiteStorage) == 'true'; notifyListeners(); } + PreferencesPageModel() { + _initialize(); + } + Future enablePerson(BuildContext context) async { - final String userDevUUID = StorageUtil().userDevUUID; + final String userDevUUID = + (await StorageHelper().get(SQLiteStorageKey.userDevUUID.value, Storage.SQLiteStorage)) ?? ''; notifyListeners(); Share.share( FFLocalizations.of(context).getVariableText( @@ -43,25 +57,81 @@ class PreferencesPageModel with ChangeNotifier { enText: 'Are you sure you want to change your notification?', ptText: 'Tem certeza que deseja alterar sua notificação?', ); + onConfirm() async { String content; - try { + String value = !isNotify ? 'N' : 'S'; + await PhpGroup.changeNotifica + .call(notifica: value) + .then((value) async { + if (value.jsonBody['error'] == false) { + await StorageHelper() + .set(SQLiteStorageKey.notify.value, isNotify ? 'false' : 'true', Storage.SQLiteStorage); + content = FFLocalizations.of(context).getVariableText( + enText: 'Notification changed successfully', + ptText: 'Notificação alterada com sucesso', + ); + notifyListeners(); + SnackBarUtil.showSnackBar(context, content); + } else { + content = FFLocalizations.of(context).getVariableText( + enText: 'Error changing notification', + ptText: 'Erro ao alterar notificação', + ); + SnackBarUtil.showSnackBar(context, content, isError: true); + } + }) + .catchError((e, s) { + log('toggleNotify', error: e, stackTrace: s); + content = FFLocalizations.of(context).getVariableText( + enText: 'Error changing notification', + ptText: 'Erro ao alterar notificação', + ); + SnackBarUtil.showSnackBar(context, content, isError: true); + }) + .then((_) async => isNotify = + await StorageHelper().get(SQLiteStorageKey.notify.value, Storage.SQLiteStorage) == 'true') + .whenComplete(() => notifyListeners()); + context.pop(); + } + + showAlertDialog(context, title, content, onConfirm); + } + + Future toggleIdentification(BuildContext context) async { + final String title = FFLocalizations.of(context).getVariableText( + ptText: 'Atualizar Identificador de Acesso', + enText: 'Update Access Identifier', + ); + final String content = FFLocalizations.of(context).getVariableText( + ptText: 'Tem certeza que deseja habilitar seu dispositivo para acesso?', + enText: 'Are you sure you want to enable your device for access?', + ); + onConfirm() async { + String content; + await PhpGroup.updateIDE.call().then((value) async { + if (value.jsonBody['error'] == false) { + notifyListeners(); + content = FFLocalizations.of(context).getVariableText( + ptText: 'Atualização do identificador de acesso realizada com sucesso', + enText: 'Access identifier updated successfully', + ); + SnackBarUtil.showSnackBar(context, content); + } else { + content = FFLocalizations.of(context).getVariableText( + ptText: 'Erro ao atualizar identificador de acesso', + enText: 'Error updating access identifier', + ); + SnackBarUtil.showSnackBar(context, content, isError: true); + } + }).catchError((e, s) { content = FFLocalizations.of(context).getVariableText( - enText: 'Notification changed successfully', - ptText: 'Notificação alterada com sucesso', + ptText: 'Erro ao atualizar identificador de acesso', + enText: 'Error updating access identifier', ); - context.pop(); - SnackBarUtil.showSnackBar(context, content); - StorageUtil().notify = !StorageUtil().notify; - notifyListeners(); - } catch (err) { - content = FFLocalizations.of(context).getVariableText( - enText: 'Error changing notification', - ptText: 'Erro ao alterar notificação', - ); - context.pop(); SnackBarUtil.showSnackBar(context, content, isError: true); - } + }).whenComplete(() => notifyListeners()); + context.pop(); } showAlertDialog(context, title, content, onConfirm); @@ -69,35 +139,38 @@ class PreferencesPageModel with ChangeNotifier { Future toggleAccess(BuildContext context) async { onChange(String key) async { - StorageUtil().accessPass = key; + await StorageHelper().set(SecureStorageKey.accessPass.value, key, Storage.SecureStorage); await PhpGroup.changePass - .call( - newSenha: key, - ) + .call(newSenha: key) .then((value) async { - final String content; - if (jsonDecode(value.jsonBody['error'].toString()) == false) { - if (!StorageUtil().access) StorageUtil().access = !StorageUtil().access; - notifyListeners(); - content = FFLocalizations.of(context).getVariableText( - enText: 'Access pass changed successfully', - ptText: 'Senha de acesso alterada com sucesso', - ); - SnackBarUtil.showSnackBar(context, content); - } else { - content = FFLocalizations.of(context).getVariableText( - ptText: 'Erro ao alterar senha de acesso', - enText: 'Error changing access pass', - ); - SnackBarUtil.showSnackBar(context, content, isError: true); - } - }).catchError((e, s) { - final String content = FFLocalizations.of(context).getVariableText( - ptText: 'Erro ao alterar senha de acesso', - enText: 'Error changing access pass', - ); - SnackBarUtil.showSnackBar(context, content, isError: true); - }).whenComplete(() => notifyListeners()); + final String content; + if (jsonDecode(value.jsonBody['error'].toString()) == false) { + await StorageHelper() + .set(SQLiteStorageKey.access.value, isAccess ? 'false' : 'true', Storage.SQLiteStorage); + notifyListeners(); + content = FFLocalizations.of(context).getVariableText( + enText: 'Access pass changed successfully', + ptText: 'Senha de acesso alterada com sucesso', + ); + SnackBarUtil.showSnackBar(context, content); + } else { + content = FFLocalizations.of(context).getVariableText( + ptText: 'Erro ao alterar senha de acesso', + enText: 'Error changing access pass', + ); + SnackBarUtil.showSnackBar(context, content, isError: true); + } + }) + .catchError((e, s) { + final String content = FFLocalizations.of(context).getVariableText( + ptText: 'Erro ao alterar senha de acesso', + enText: 'Error changing access pass', + ); + SnackBarUtil.showSnackBar(context, content, isError: true); + }) + .then((_) async => isAccess = + await StorageHelper().get(SQLiteStorageKey.access.value, Storage.SQLiteStorage) == 'true') + .whenComplete(() => notifyListeners()); } _showPassKey(context, onChange); @@ -105,35 +178,38 @@ class PreferencesPageModel with ChangeNotifier { Future togglePanic(BuildContext context) async { onChange(String key) async { - StorageUtil().panicPass = key; + await StorageHelper().set(SecureStorageKey.panicPass.value, key, Storage.SecureStorage); await PhpGroup.changePanic - .call( - newSenhaPanico: StorageUtil().panicPass, - ) + .call(newSenhaPanico: key) .then((value) async { - final String content; - if (jsonDecode(value.jsonBody['error'].toString()) == false) { - if (!StorageUtil().panic) StorageUtil().panic = !StorageUtil().panic; - notifyListeners(); - content = FFLocalizations.of(context).getVariableText( - enText: 'Panic password changed successfully', - ptText: 'Senha de pânico alterada com sucesso', - ); - SnackBarUtil.showSnackBar(context, content); - } else { - content = FFLocalizations.of(context).getVariableText( - ptText: 'Erro ao alterar senha de pânico', - enText: 'Error changing panic password', - ); - SnackBarUtil.showSnackBar(context, content, isError: true); - } - }).catchError((e, s) { - final String content = FFLocalizations.of(context).getVariableText( - ptText: 'Erro ao alterar senha de pânico', - enText: 'Error changing panic password', - ); - SnackBarUtil.showSnackBar(context, content, isError: true); - }).whenComplete(() => notifyListeners()); + final String content; + if (jsonDecode(value.jsonBody['error'].toString()) == false) { + await StorageHelper() + .set(SQLiteStorageKey.panic.value, isPanic ? 'false' : 'true', Storage.SQLiteStorage); + notifyListeners(); + content = FFLocalizations.of(context).getVariableText( + enText: 'Panic password changed successfully', + ptText: 'Senha de pânico alterada com sucesso', + ); + SnackBarUtil.showSnackBar(context, content); + } else { + content = FFLocalizations.of(context).getVariableText( + ptText: 'Erro ao alterar senha de pânico', + enText: 'Error changing panic password', + ); + SnackBarUtil.showSnackBar(context, content, isError: true); + } + }) + .catchError((e, s) { + final String content = FFLocalizations.of(context).getVariableText( + ptText: 'Erro ao alterar senha de pânico', + enText: 'Error changing panic password', + ); + SnackBarUtil.showSnackBar(context, content, isError: true); + }) + .then((_) async => + isPanic = await StorageHelper().get(SQLiteStorageKey.panic.value, Storage.SQLiteStorage) == 'true') + .whenComplete(() => notifyListeners()); } _showPassKey(context, onChange); @@ -146,16 +222,17 @@ class PreferencesPageModel with ChangeNotifier { ); onChange(String? key) async { - StorageUtil().fingerprint = !StorageUtil().fingerprint; - if (!StorageUtil().fingerprint) StorageUtil().fingerprintPass = key ?? ''; - if (StorageUtil().fingerprint) StorageUtil().fingerprintPass = ''; - + isFingerprint = !isFingerprint; + await StorageHelper().set(SecureStorageKey.fingerprintPass.value, key ?? '', Storage.SecureStorage); + await StorageHelper() + .set(SQLiteStorageKey.fingerprint.value, isFingerprint ? 'true' : 'false', Storage.SQLiteStorage); notifyListeners(); - SnackBarUtil.showSnackBar(context, content); + isFingerprint = + await StorageHelper().get(SQLiteStorageKey.fingerprint.value, Storage.SQLiteStorage) == 'true'; } - StorageUtil().fingerprint ? onChange(null) : _showPassKey(context, onChange); + isFingerprint ? onChange(null) : _showPassKey(context, onChange); } Future deleteAccount(BuildContext context) async { @@ -200,13 +277,6 @@ class PreferencesPageModel with ChangeNotifier { showAlertDialog(context, title, content, onConfirm); } - - - - - - - void _showPassKey(BuildContext context, void Function(String) onChange) async { await showModalBottomSheet( isScrollControlled: true, @@ -231,5 +301,4 @@ class PreferencesPageModel with ChangeNotifier { SnackBarUtil.showSnackBar(context, content, isError: true); }).whenComplete(() => notifyListeners()); } - } diff --git a/lib/pages/preferences_settings_page/preferences_settings_widget.dart b/lib/pages/preferences_settings_page/preferences_settings_widget.dart index 2093c715..38877076 100644 --- a/lib/pages/preferences_settings_page/preferences_settings_widget.dart +++ b/lib/pages/preferences_settings_page/preferences_settings_widget.dart @@ -6,7 +6,7 @@ import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/pages/preferences_settings_page/preferences_settings_model.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; -import 'package:hub/shared/utils/storage_util.dart'; + import 'package:provider/provider.dart'; class PreferencesPageWidget extends StatefulWidget { @@ -21,7 +21,7 @@ class _PreferencesPageWidgetState extends State { void initState() { super.initState(); } - + @override Widget build(BuildContext context) { @@ -77,7 +77,7 @@ class _PreferencesPageWidgetState extends State { Expanded( flex: 2, child: ListView.builder( - itemCount: 7, // Assuming 7 items for simplicity + itemCount: 8, padding: const EdgeInsets.symmetric(horizontal: 20.0), physics: const AlwaysScrollableScrollPhysics(), itemBuilder: (BuildContext context, int index) { @@ -93,8 +93,7 @@ class _PreferencesPageWidgetState extends State { ); } - Widget _buildIconButton( - BuildContext context, int index, PreferencesPageModel model) { + Widget _buildIconButton(BuildContext context, int index, PreferencesPageModel model) { IconData icon; Function() onPressed = () => {}; bool isEnabled; @@ -104,50 +103,58 @@ class _PreferencesPageWidgetState extends State { case 0: icon = Icons.fingerprint; onPressed = () => model.toggleFingerprint(context); - isEnabled = StorageUtil().fingerprint; + isEnabled = model.isFingerprint; content = FFLocalizations.of(context).getVariableText( - ptText: - 'Ative a autenticação por impressão digital para login seguro.', + ptText: 'Ative a autenticação por impressão digital para login seguro.', enText: 'Enable fingerprint authentication for secure login.', ); break; case 1: icon = Icons.person; onPressed = () => model.enablePerson(context); - isEnabled = StorageUtil().person; + isEnabled = model.isPerson; content = FFLocalizations.of(context).getVariableText( ptText: 'Compartilhe o código de identificação remota', enText: 'Share the remote identification code', ); break; case 2: + icon = Icons.info; + onPressed = () => model.toggleIdentification(context); + isEnabled = false; + content = FFLocalizations.of(context).getVariableText( + ptText: 'Atualize suas informações de identificação de acesso.', + enText: 'Update your access identification information.', + ); + break; + case 3: icon = Icons.notifications; onPressed = () => model.toggleNotify(context); - isEnabled = StorageUtil().notify; + isEnabled = model.isNotify; content = FFLocalizations.of(context).getVariableText( ptText: 'Ative para receber sua notificação de acesso', enText: 'Enable to receive your access notification', ); break; - case 3: + case 4: icon = Icons.lock; onPressed = () => model.toggleAccess(context); - isEnabled = StorageUtil().access; + isEnabled = model.isAccess; content = FFLocalizations.of(context).getVariableText( ptText: 'Ative para inserir uma credencial de acesso para o QRCode', enText: 'Enable to enter an access credential for the QRCode', ); break; - case 4: + case 5: icon = Icons.lock_clock_sharp; onPressed = () => model.togglePanic(context); - isEnabled = StorageUtil().panic; + isEnabled = model.isPanic; content = FFLocalizations.of(context).getVariableText( ptText: 'Ative para inserir uma credencial de pânico para o QRCode', enText: 'Enable to enter a panic credential for the QRCode', ); break; - case 5: + case 6: icon = Icons.landscape; onPressed = () { model.localUnlink(context); @@ -158,24 +165,22 @@ class _PreferencesPageWidgetState extends State { enText: 'Enable to unlink from the selected location', ); break; - case 6: + case 7: icon = Icons.delete; onPressed = () => model.deleteAccount(context); isEnabled = false; content = FFLocalizations.of(context).getVariableText( - ptText: - 'Delete sua conta e todos os dados associados permanentemente.', + ptText: 'Delete sua conta e todos os dados associados permanentemente.', enText: 'Delete your account and all associated data permanently.', ); break; - case 7: + case 8: icon = Icons.logout; onPressed = () => model.logout(context); isEnabled = false; content = FFLocalizations.of(context).getVariableText( ptText: 'Sair da conta atual e voltar para a tela de login.', - enText: - 'Log out of the current account and return to the login screen.', + enText: 'Log out of the current account and return to the login screen.', ); break; default: @@ -187,10 +192,10 @@ class _PreferencesPageWidgetState extends State { child: GestureDetector( onTap: () { switch (index) { - case 3: + case 4: model.toggleAccess(context); break; - case 4: + case 5: model.togglePanic(context); break; default: @@ -200,14 +205,12 @@ class _PreferencesPageWidgetState extends State { child: Row( children: [ CircleAvatar( - backgroundColor: isEnabled - ? FlutterFlowTheme.of(context).primary - : FlutterFlowTheme.of(context).alternate, + backgroundColor: + isEnabled ? FlutterFlowTheme.of(context).primary : FlutterFlowTheme.of(context).alternate, child: Icon( icon, - color: isEnabled - ? FlutterFlowTheme.of(context).primaryBackground - : FlutterFlowTheme.of(context).primary, + color: + isEnabled ? FlutterFlowTheme.of(context).primaryBackground : FlutterFlowTheme.of(context).primary, ), ), const SizedBox(width: 8.0), @@ -230,6 +233,4 @@ class _PreferencesPageWidgetState extends State { ), ); } - - } diff --git a/lib/pages/provisional_schedule_page/provisional_schedule_widget.dart b/lib/pages/provisional_schedule_page/provisional_schedule_widget.dart index 022822ed..96d35366 100644 --- a/lib/pages/provisional_schedule_page/provisional_schedule_widget.dart +++ b/lib/pages/provisional_schedule_page/provisional_schedule_widget.dart @@ -67,7 +67,6 @@ class _ProvisionalScheduleState extends State { centerTitle: true, elevation: 0.0, ), - body: const SafeArea( - top: true, child: ScheduleProvisionalVisitPageWidget())); + body: const SafeArea(top: true, child: ScheduleProvisionalVisitPageWidget())); } } diff --git a/lib/pages/qr_code_page/qr_code_page_model.dart b/lib/pages/qr_code_page/qr_code_page_model.dart index a69c39eb..a35c02ef 100644 --- a/lib/pages/qr_code_page/qr_code_page_model.dart +++ b/lib/pages/qr_code_page/qr_code_page_model.dart @@ -4,19 +4,20 @@ import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/pages/qr_code_page/qr_code_page_widget.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:qr_flutter/qr_flutter.dart'; class QrCodePageModel extends FlutterFlowModel { /// Local state fields for this page. - bool isAccess = false; - String? key; DateTime? time; + bool isAccess = false; late final bool isFingerprint; late final String userDevUUID; + late final VoidCallback? safeSetState; /// State fields for stateful widgets in this page. @@ -28,8 +29,10 @@ class QrCodePageModel extends FlutterFlowModel { } Future initVariable() async { - isFingerprint = StorageUtil().fingerprint; - userDevUUID = StorageUtil().userDevUUID; + isFingerprint = + await StorageHelper().get(SQLiteStorageKey.fingerprint.value, Storage.SQLiteStorage) == 'true'; + userDevUUID = await StorageHelper().get(SQLiteStorageKey.userDevUUID.value, Storage.SQLiteStorage) ?? ''; + safeSetState?.call(); } @override @@ -37,8 +40,7 @@ class QrCodePageModel extends FlutterFlowModel { unfocusNode.dispose(); } - Uint8List assembleQRPacket( - int direction, String identifier, String password) { + Uint8List assembleQRPacket(int direction, String identifier, String password) { List packet = [direction]; String paddedBadge = identifier.padLeft(30, '0'); @@ -56,8 +58,7 @@ class QrCodePageModel extends FlutterFlowModel { int sum = year + month + day + hour + minute; - if (sum == int.parse('0D', radix: 16) || - sum == int.parse('0A', radix: 16)) { + if (sum == int.parse('0D', radix: 16) || sum == int.parse('0A', radix: 16)) { packet.add(int.parse('FF', radix: 16)); } else { packet.add(sum); @@ -75,17 +76,12 @@ class QrCodePageModel extends FlutterFlowModel { check ^= b; } - if (check == int.parse('0D', radix: 16) || - check == int.parse('0A', radix: 16)) { + if (check == int.parse('0D', radix: 16) || check == int.parse('0A', radix: 16)) { packet.add(int.parse('FF', radix: 16)); } else { packet.add(check); } - var bytes = packet - .map((byte) => byte.toRadixString(16).padLeft(2, '0')) - .join((' ')); - return Uint8List.fromList(packet); } @@ -93,16 +89,13 @@ class QrCodePageModel extends FlutterFlowModel { int len = s.length; Uint8List data = Uint8List(len ~/ 2); for (int i = 0; i < len; i += 2) { - data[i ~/ 2] = - ((int.parse(s[i], radix: 16) << 4) + int.parse(s[i + 1], radix: 16)); + data[i ~/ 2] = ((int.parse(s[i], radix: 16) << 4) + int.parse(s[i + 1], radix: 16)); } return data; } String byteToHexa(Uint8List pDados) { - return pDados - .map((byte) => byte.toRadixString(16).padLeft(2, '0').toUpperCase()) - .join(); + return pDados.map((byte) => byte.toRadixString(16).padLeft(2, '0').toUpperCase()).join(); } Future byteToString(Uint8List bytes) async { @@ -120,8 +113,7 @@ class QrCodePageModel extends FlutterFlowModel { const Color foregroundColor = Colors.black; return QrImageView.withQr( qr: QrCode.fromUint8List( - data: assembleQRPacket(direction, identifier, pass), - errorCorrectLevel: errorCorrectLevel), + data: assembleQRPacket(direction, identifier, pass), errorCorrectLevel: errorCorrectLevel), size: dimension, padding: const EdgeInsets.all(10), backgroundColor: backgroundColor, diff --git a/lib/pages/qr_code_page/qr_code_page_widget.dart b/lib/pages/qr_code_page/qr_code_page_widget.dart index dfc801bb..4b56e466 100644 --- a/lib/pages/qr_code_page/qr_code_page_widget.dart +++ b/lib/pages/qr_code_page/qr_code_page_widget.dart @@ -1,4 +1,7 @@ +// ignore_for_file: use_build_context_synchronously + import 'dart:async'; +import 'dart:developer'; import 'package:barcode_widget/barcode_widget.dart'; import 'package:flutter/material.dart'; @@ -14,10 +17,11 @@ import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/flutter_flow_widgets.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/pages/qr_code_page/qr_code_page_model.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/utils/biometric_util.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; -import 'package:hub/shared/utils/storage_util.dart'; import 'package:percent_indicator/circular_percent_indicator.dart'; import 'package:qr_flutter/qr_flutter.dart'; @@ -29,8 +33,7 @@ class QrCodePageWidget extends StatefulWidget { State createState() => _QrCodePageWidgetState(); } -class _QrCodePageWidgetState extends State - with TickerProviderStateMixin { +class _QrCodePageWidgetState extends State with TickerProviderStateMixin { late QrCodePageModel _model; final scaffoldKey = GlobalKey(); @@ -41,8 +44,8 @@ class _QrCodePageWidgetState extends State void initState() { super.initState(); _model = createModel(context, () => QrCodePageModel()); + _model.safeSetState = () => safeSetState(() {}); - // On page load action. SchedulerBinding.instance.addPostFrameCallback((_) async { if (animationsMap['barcodeOnActionTriggerAnimation'] != null) { animationsMap['barcodeOnActionTriggerAnimation']!.controller.fling(); @@ -66,28 +69,16 @@ class _QrCodePageWidgetState extends State ), }); setupAnimations( - animationsMap.values.where((anim) => - anim.trigger == AnimationTrigger.onActionTrigger || - !anim.applyInitialState), + animationsMap.values.where((anim) => anim.trigger == AnimationTrigger.onActionTrigger || !anim.applyInitialState), this, ); - - // // Adicionando um ouvinte de status à animação para reiniciá-la após a conclusão - // animationsMap['barcodeOnActionTriggerAnimation']?.controller.addStatusListener((status) { - // if (status == AnimationStatus.completed) { - // animationsMap['barcodeOnActionTriggerAnimation']!.controller.reset(); - // animationsMap['barcodeOnActionTriggerAnimation']!.controller.forward(); - // } - // }); } @override void dispose() { // Removendo o ouvinte antes de chamar super.dispose para evitar vazamentos de memória if (animationsMap['barcodeOnActionTriggerAnimation'] != null) { - animationsMap['barcodeOnActionTriggerAnimation']! - .controller - .removeStatusListener((status) {}); + animationsMap['barcodeOnActionTriggerAnimation']!.controller.removeStatusListener((status) {}); } super.dispose(); @@ -106,8 +97,7 @@ class _QrCodePageWidgetState extends State Widget buildBody(BuildContext context) { double screenWidth = MediaQuery.of(context).size.width; double screenHeight = MediaQuery.of(context).size.height; - double smallerDimension = - screenWidth < screenHeight ? screenWidth : screenHeight; + double smallerDimension = screenWidth < screenHeight ? screenWidth : screenHeight; double dimension = smallerDimension * 0.75; double totalTimeInSeconds = 100.0; double limitedHeaderTextSize = LimitedFontSizeUtil.getCalculateFontSize(context, 18, 18, 16); @@ -381,23 +371,23 @@ class _QrCodePageWidgetState extends State } Future _showBiometricsAuth(BuildContext context) async { - BiometricHelper.checkBiometrics() - .then((value) => BiometricHelper.authenticateBiometric().then((value) { + await BiometricHelper.checkBiometrics() + .then((value) async => await BiometricHelper.authenticateBiometric().then((value) async { + if (value == false) throw Exception('Biometric authentication failed'); + final key = await StorageHelper().get(SecureStorageKey.fingerprintPass.value, Storage.SecureStorage); + if (key == null || key.isEmpty) throw Exception('No key found'); safeSetState(() { if (animationsMap['barcodeOnActionTriggerAnimation'] != null) { - animationsMap['barcodeOnActionTriggerAnimation']! - .controller - .stop(); - animationsMap['barcodeOnActionTriggerAnimation']! - .controller - .reverse(); + animationsMap['barcodeOnActionTriggerAnimation']!.controller.stop(); + animationsMap['barcodeOnActionTriggerAnimation']!.controller.reverse(); } _model.isAccess = !_model.isAccess; - _model.key = StorageUtil().fingerprintPass; + _model.key = key; }); })) - .onError((error, StackTrace) { - _showQrCodeBottomSheet(context); + .onError((error, stackTrace) { + log('Error', error: error, stackTrace: stackTrace); + if (mounted) _showQrCodeBottomSheet(context); }); } @@ -417,14 +407,9 @@ class _QrCodePageWidgetState extends State child: QrCodePassKeyTemplateComponentWidget( toggleActionStatus: (key) async { safeSetState(() { - if (animationsMap['barcodeOnActionTriggerAnimation'] != - null) { - animationsMap['barcodeOnActionTriggerAnimation']! - .controller - .stop(); - animationsMap['barcodeOnActionTriggerAnimation']! - .controller - .reverse(); + if (animationsMap['barcodeOnActionTriggerAnimation'] != null) { + animationsMap['barcodeOnActionTriggerAnimation']!.controller.stop(); + animationsMap['barcodeOnActionTriggerAnimation']!.controller.reverse(); } _model.isAccess = !_model.isAccess; _model.key = key; @@ -434,26 +419,19 @@ class _QrCodePageWidgetState extends State ), ); }, - ).catchError((error) => safeSetState(() { - _resetAnimationAndToggleAccess(); - })); + ).catchError((error) => safeSetState(() => _resetAnimationAndToggleAccess())); unawaited( () async { - await _model.qrCodeEncoder( - context, - key: _model.key, - ); - setState(() {}); + await _model.qrCodeEncoder(context, key: _model.key); + safeSetState(() {}); }(), ); } void _resetAnimationAndToggleAccess() { safeSetState(() { - // Reinicia a animação animationsMap['barcodeOnActionTriggerAnimation']!.controller.reset(); animationsMap['barcodeOnActionTriggerAnimation']!.controller.forward(); - // Alterna o estado de acesso _model.isAccess = !_model.isAccess; _model.key = null; }); @@ -478,17 +456,14 @@ class _QrCodePageWidgetState extends State }, ), title: Text( - FFLocalizations.of(context).getText( - 'ku7jqe53' /* QR Code de Acesso */, - ), + FFLocalizations.of(context).getText('ku7jqe53'), style: FlutterFlowTheme.of(context).headlineMedium.override( fontFamily: FlutterFlowTheme.of(context).headlineMediumFamily, color: FlutterFlowTheme.of(context).primaryText, fontSize: 15.0, fontWeight: FontWeight.bold, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).headlineMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).headlineMediumFamily), ), ), actions: const [], diff --git a/lib/pages/reception_page/reception_page_model.dart b/lib/pages/reception_page/reception_page_model.dart index 0c99841c..ad6c4b2e 100644 --- a/lib/pages/reception_page/reception_page_model.dart +++ b/lib/pages/reception_page/reception_page_model.dart @@ -1,11 +1,13 @@ import 'package:flutter/material.dart'; import 'package:hub/flutter_flow/internationalization.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:share_plus/share_plus.dart'; class ReceptionPageModel with ChangeNotifier { Future getIdenfifier(BuildContext context) async { - final String userDevUUID = StorageUtil().userDevUUID; + final String userDevUUID = + (await StorageHelper().get(SQLiteStorageKey.userDevUUID.value, Storage.SQLiteStorage)) ?? ''; notifyListeners(); Share.share( diff --git a/lib/pages/reception_page/reception_page_widget.dart b/lib/pages/reception_page/reception_page_widget.dart index 8ff4618e..2221ee17 100644 --- a/lib/pages/reception_page/reception_page_widget.dart +++ b/lib/pages/reception_page/reception_page_widget.dart @@ -11,9 +11,10 @@ import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/flutter_flow_widgets.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/pages/reception_page/reception_page_model.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/services/localization/localization_service.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; -import 'package:hub/shared/utils/storage_util.dart'; import 'package:provider/provider.dart'; class ReceptionPageWidget extends StatefulWidget { @@ -24,7 +25,8 @@ class ReceptionPageWidget extends StatefulWidget { } class _ReceptionPageWidgetState extends State with WidgetsBindingObserver { - @override void initState() { + @override + void initState() { super.initState(); WidgetsBinding.instance.addObserver(this); () async { @@ -36,13 +38,14 @@ class _ReceptionPageWidgetState extends State with WidgetsB LocalizationService.checkLocals(context); } - @override void dispose() { + @override + void dispose() { WidgetsBinding.instance.removeObserver(this); super.dispose(); } - - @override void didChangeAppLifecycleState(AppLifecycleState state) { + @override + void didChangeAppLifecycleState(AppLifecycleState state) { log('() => state: $state'); if (state == AppLifecycleState.resumed) { setState(() { @@ -74,45 +77,35 @@ class _ReceptionPageWidgetState extends State with WidgetsB padding: const EdgeInsets.fromLTRB(45, 20, 45, 15.0), child: Text( FFLocalizations.of(context).getVariableText( - ptText: - 'Falta pouco para você utilizar o FRE Access Hub...', - enText: - 'You are close to using the FRE Access Hub...'), + ptText: 'Falta pouco para você utilizar o FRE Access Hub...', + enText: 'You are close to using the FRE Access Hub...'), textAlign: TextAlign.center, - style: FlutterFlowTheme.of(context) - .displayLarge - .override( + style: FlutterFlowTheme.of(context).displayLarge.override( fontFamily: 'Plus Jakarta Sans', color: FlutterFlowTheme.of(context).accent1, fontSize: limitedHeaderFontSize, letterSpacing: 0.0, fontWeight: FontWeight.w700, - useGoogleFonts: GoogleFonts.asMap() - .containsKey('Plus Jakarta Sans'), + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), ), ), - const AtomImageSvgTheme( - filename: 'reception', width: 180, height: 180), + const AtomImageSvgTheme(filename: 'reception', width: 180, height: 180), Padding( padding: const EdgeInsets.fromLTRB(70, 30, 70.0, 40), child: Text( FFLocalizations.of(context).getVariableText( ptText: 'Envie seu identificador para seu condomínio para vincularem sua conta aos nossos sistemas.', - enText: - 'Send your identifier to your condominium to link your account to our systems.'), + enText: 'Send your identifier to your condominium to link your account to our systems.'), textAlign: TextAlign.center, - style: FlutterFlowTheme.of(context) - .displaySmall - .override( + style: FlutterFlowTheme.of(context).displaySmall.override( fontFamily: 'Nunito Sans', color: FlutterFlowTheme.of(context).primaryText, fontSize: limitedBodyFontSize, letterSpacing: 0.0, fontWeight: FontWeight.w600, - useGoogleFonts: GoogleFonts.asMap() - .containsKey('Plus Jakarta Sans'), + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), ), ), @@ -127,24 +120,19 @@ class _ReceptionPageWidgetState extends State with WidgetsB ptText: 'Seu identificador é utilizado para efetuar\no vínculo do seu APP com o condominio.', enText: 'My Identifier'), - textStyle: FlutterFlowTheme.of(context) - .labelSmall - .override( + textStyle: FlutterFlowTheme.of(context).labelSmall.override( fontFamily: 'Nunito Sans', color: FlutterFlowTheme.of(context) .secondaryText, fontSize: limitedInputFontSize, letterSpacing: 0.0, fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts.asMap() - .containsKey('Plus Jakarta Sans'), + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), child: FFButtonWidget( onPressed: () => model.getIdenfifier(context), text: FFLocalizations.of(context) - .getVariableText( - ptText: 'Meu Identificador', - enText: 'My Identifier'), + .getVariableText(ptText: 'Meu Identificador', enText: 'My Identifier'), options: FFButtonOptions( width: double.infinity, height:30, @@ -154,17 +142,13 @@ class _ReceptionPageWidgetState extends State with WidgetsB const EdgeInsetsDirectional.fromSTEB( 0.0, 0.0, 0.0, 0.0), color: FlutterFlowTheme.of(context).primary, - textStyle: FlutterFlowTheme.of(context) - .titleSmall - .override( + textStyle: FlutterFlowTheme.of(context).titleSmall.override( fontFamily: 'Nunito Sans', - color: - FlutterFlowTheme.of(context).info, + color: FlutterFlowTheme.of(context).info, fontSize: limitedInputFontSize, letterSpacing: 0.0, fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts.asMap() - .containsKey('Plus Jakarta Sans'), + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), elevation: 3.0, borderSide: const BorderSide( @@ -183,7 +167,8 @@ class _ReceptionPageWidgetState extends State with WidgetsB onPressed: () async { PhpGroup.unregisterDevice(); - StorageUtil.purge(); + StorageHelper().clearAll(Storage.SecureStorage); + setState(() {}); context.go( @@ -197,8 +182,8 @@ class _ReceptionPageWidgetState extends State with WidgetsB }, ); }, - text: FFLocalizations.of(context).getVariableText( - ptText: 'Sair da Conta', enText: 'Logout'), + text: FFLocalizations.of(context) + .getVariableText(ptText: 'Sair da Conta', enText: 'Logout'), options: FFButtonOptions( width: double.infinity, height: 30, @@ -213,13 +198,11 @@ class _ReceptionPageWidgetState extends State with WidgetsB .titleSmall .override( fontFamily: 'Nunito Sans', - color: FlutterFlowTheme.of(context) - .primaryBackground, + color: FlutterFlowTheme.of(context).primaryBackground, fontSize: limitedInputFontSize, letterSpacing: 0.0, fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts.asMap() - .containsKey('Plus Jakarta Sans'), + useGoogleFonts: GoogleFonts.asMap().containsKey('Plus Jakarta Sans'), ), elevation: 3.0, borderSide: const BorderSide( diff --git a/lib/pages/register_visitor_page/register_visitor_page_model.dart b/lib/pages/register_visitor_page/register_visitor_page_model.dart index 9c813fc5..e6db1afb 100644 --- a/lib/pages/register_visitor_page/register_visitor_page_model.dart +++ b/lib/pages/register_visitor_page/register_visitor_page_model.dart @@ -4,12 +4,10 @@ import '/flutter_flow/flutter_flow_util.dart'; import 'register_visitor_page_widget.dart' show RegisterVisitorPageWidget; import 'package:flutter/material.dart'; -class RegisterVisitorPageModel - extends FlutterFlowModel { +class RegisterVisitorPageModel extends FlutterFlowModel { /// State fields for stateful widgets in this page. - late RegisiterVistorTemplateComponentModel - regisiterVistorTemplateComponentModel; + late RegisiterVistorTemplateComponentModel regisiterVistorTemplateComponentModel; @override void initState(BuildContext context) {} diff --git a/lib/pages/register_visitor_page/register_visitor_page_widget.dart b/lib/pages/register_visitor_page/register_visitor_page_widget.dart index 483364bf..50e11f96 100644 --- a/lib/pages/register_visitor_page/register_visitor_page_widget.dart +++ b/lib/pages/register_visitor_page/register_visitor_page_widget.dart @@ -14,8 +14,7 @@ class RegisterVisitorPageWidget extends StatefulWidget { const RegisterVisitorPageWidget({super.key}); @override - State createState() => - _RegisterVisitorPageWidgetState(); + State createState() => _RegisterVisitorPageWidgetState(); } class _RegisterVisitorPageWidgetState extends State { @@ -66,8 +65,7 @@ class _RegisterVisitorPageWidgetState extends State { fontSize: 15.0, fontWeight: FontWeight.bold, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap().containsKey( - FlutterFlowTheme.of(context).headlineMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).headlineMediumFamily), ), ), actions: const [], diff --git a/lib/pages/reservation_page/reservation_page_widget.dart b/lib/pages/reservation_page/reservation_page_widget.dart index 5c430325..246b8b48 100644 --- a/lib/pages/reservation_page/reservation_page_widget.dart +++ b/lib/pages/reservation_page/reservation_page_widget.dart @@ -5,7 +5,8 @@ import 'package:flutter/scheduler.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart' as hub; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/utils/webview_util.dart'; import 'package:url_launcher/url_launcher_string.dart'; import 'package:webview_flutter/webview_flutter.dart'; @@ -21,12 +22,16 @@ class _ReservationPageWidgetState extends State { late WebViewController _controllerAll; Future> initVariables() async { - final email = StorageUtil().email; - final name = StorageUtil().cliName; - final userUUID = StorageUtil().userUUID; - final devUUID = StorageUtil().devUUID; - final createdAt = StorageUtil().createdAt; - final clientId = StorageUtil().cliUUID; + final email = (await StorageHelper().get(hub.SecureStorageKey.email.value, hub.Storage.SecureStorage)) ?? ''; + final name = + (await StorageHelper().get(hub.SQLiteStorageKey.userName.value, hub.Storage.SQLiteStorage)) ?? ''; + final devUUID = + (await StorageHelper().get(hub.SQLiteStorageKey.devUUID.value, hub.Storage.SQLiteStorage)) ?? ''; + final userUUID = + (await StorageHelper().get(hub.SQLiteStorageKey.userUUID.value, hub.Storage.SQLiteStorage)) ?? ''; + final clientId = + (await StorageHelper().get(hub.SQLiteStorageKey.clientUUID.value, hub.Storage.SQLiteStorage)) ?? ''; + const createdAt = '0000-00-00 00:00:00'; final url = 'https://hub.freaccess.com.br/hub/reservation/$clientId'; @@ -54,12 +59,10 @@ class _ReservationPageWidgetState extends State { builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return const Center(child: CircularProgressIndicator()); - } else if (snapshot.hasError || - snapshot.hasData == false || - snapshot.data!.isEmpty) { + } else if (snapshot.hasError || snapshot.hasData == false || snapshot.data!.isEmpty) { return Center( - child: Text(FFLocalizations.of(context).getVariableText( - enText: 'Unexpected error', ptText: 'Erro inesperado'))); + child: Text(FFLocalizations.of(context) + .getVariableText(enText: 'Unexpected error', ptText: 'Erro inesperado'))); } else if (snapshot.hasData) { final data = snapshot.data!; final url = data['url']!; @@ -73,18 +76,14 @@ class _ReservationPageWidgetState extends State { allowsBackForwardNavigationGestures: true, javaScriptEnabled: true, ), - onWebViewCreated: (controller) async { - }, + onWebViewCreated: (controller) async {}, onLoadStop: (controller, url) async { await controller.evaluateJavascript( - source: - "window.localStorage.setItem('fre-token', '\"$userUUID\"')"); + source: "window.localStorage.setItem('fre-token', '\"$userUUID\"')"); await controller.evaluateJavascript( - source: - "window.localStorage.setItem('fre-user-data', '$freUserData')"); + source: "window.localStorage.setItem('fre-user-data', '$freUserData')"); await controller.evaluateJavascript( - source: - "window.localStorage.setItem('enableBackButton', 'true')"); + source: "window.localStorage.setItem('enableBackButton', 'true')"); }, onUpdateVisitedHistory: (controller, uri, isVisited) { if (uri.toString().contains('/hub/home')) { @@ -102,33 +101,25 @@ class _ReservationPageWidgetState extends State { NavigationDelegate( onProgress: (int progress) {}, onPageStarted: (String url) { - final String token = - "localStorage.setItem('fre-token', '\"$userUUID\"');"; - final String data = - "localStorage.setItem('fre-user-data', '$freUserData');"; - const String backNavigation = - "localStorage.setItem('enableBackButton', 'true');"; + final String token = "localStorage.setItem('fre-token', '\"$userUUID\"');"; + final String data = "localStorage.setItem('fre-user-data', '$freUserData');"; + const String backNavigation = "localStorage.setItem('enableBackButton', 'true');"; _controllerAll.runJavaScript(token); _controllerAll.runJavaScript(data); _controllerAll.runJavaScript(backNavigation); }, onPageFinished: (String url) { - bool isDarkMode = SchedulerBinding - .instance - .platformDispatcher - .platformBrightness == - Brightness.dark; + bool isDarkMode = + SchedulerBinding.instance.platformDispatcher.platformBrightness == Brightness.dark; if (isDarkMode) { - _controllerAll.runJavaScript( - WebviewUtil.jsEnableDarkMode); + _controllerAll.runJavaScript(WebviewUtil.jsEnableDarkMode); } }, onNavigationRequest: (NavigationRequest request) { if (request.url.startsWith('http') || - request.url.startsWith( - 'https://api.whatsapp.com/send') || + request.url.startsWith('https://api.whatsapp.com/send') || request.url.startsWith('https://wa.me')) { launchUrlString(request.url); return NavigationDecision.prevent; diff --git a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart index 42c75e7e..4b2d819a 100644 --- a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart +++ b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart @@ -8,15 +8,15 @@ import 'package:hub/flutter_flow/form_field_controller.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/flutter_flow/request_manager.dart'; import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/mixins/status_mixin.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; -import 'package:hub/shared/utils/storage_util.dart'; import 'package:share_plus/share_plus.dart'; import '../../shared/utils/validator_util.dart'; -class ScheduleCompleteVisitPageModel - extends FlutterFlowModel { +class ScheduleCompleteVisitPageModel extends FlutterFlowModel { late VoidCallback safeSetState; late Function(Function) updateState; final _visitHistoryManager = FutureRequestManager(); @@ -42,16 +42,14 @@ class ScheduleCompleteVisitPageModel requestFn: requestFn, ); void clearVisitHistoryCache() => _visitHistoryManager.clear(); - void clearVisitHistoryCacheKey(String? uniqueKey) => - _visitHistoryManager.clearRequest(uniqueKey); + void clearVisitHistoryCacheKey(String? uniqueKey) => _visitHistoryManager.clearRequest(uniqueKey); String convertDateFormat(String dateStr) { try { DateFormat originalFormat = DateFormat('dd/MM/yyyy HH:mm:ss'); DateFormat newFormat = DateFormat('y-M-d H:mm:ss'); - if (!RegExp(r'^\d{1,2}/\d{1,2}/\d{4} \d{1,2}:\d{2}:\d{2}$') - .hasMatch(dateStr)) { + if (!RegExp(r'^\d{1,2}/\d{1,2}/\d{4} \d{1,2}:\d{2}:\d{2}$').hasMatch(dateStr)) { return 'Invalid date format'; } @@ -66,10 +64,8 @@ class ScheduleCompleteVisitPageModel void addToVisitorJsonList(dynamic item) => visitorJsonList.add(item); void removeFromVisitorJsonList(dynamic item) => visitorJsonList.remove(item); - void removeAtIndexFromVisitorJsonList(int index) => - visitorJsonList.removeAt(index); - void insertAtIndexInVisitorJsonList(int index, dynamic item) => - visitorJsonList.insert(index, item); + void removeAtIndexFromVisitorJsonList(int index) => visitorJsonList.removeAt(index); + void insertAtIndexInVisitorJsonList(int index, dynamic item) => visitorJsonList.insert(index, item); void updateVisitorJsonListAtIndex(int index, Function(dynamic) updateFn) => visitorJsonList[index] = updateFn(visitorJsonList[index]); @@ -92,14 +88,11 @@ class ScheduleCompleteVisitPageModel DateTime selectedDateTime1; DateTime selectedDateTime2; - DateTime currentDateTime = - DateTime.now().subtract(const Duration(minutes: 10)); + DateTime currentDateTime = DateTime.now().subtract(const Duration(minutes: 10)); try { - selectedDateTime1 = - DateFormat('dd/MM/yyyy HH:mm:ss').parse(textController1.text); - selectedDateTime2 = - DateFormat('dd/MM/yyyy HH:mm:ss').parse(textController2.text); + selectedDateTime1 = DateFormat('dd/MM/yyyy HH:mm:ss').parse(textController1.text); + selectedDateTime2 = DateFormat('dd/MM/yyyy HH:mm:ss').parse(textController2.text); } catch (e) { return false; } @@ -121,8 +114,7 @@ class ScheduleCompleteVisitPageModel final unfocusNode = FocusNode(); TabController? tabBarController; - int get tabBarCurrentIndex => - tabBarController != null ? tabBarController!.index : 0; + int get tabBarCurrentIndex => tabBarController != null ? tabBarController!.index : 0; FocusNode? textFieldFocusNode1; TextEditingController? textController1; @@ -137,16 +129,14 @@ class ScheduleCompleteVisitPageModel if (val != '0') { try { DateTime startDate = DateFormat('dd/MM/yyyy HH:mm:ss').parse(val); - DateTime endDate = - DateFormat('dd/MM/yyyy HH:mm:ss').parse(textController2!.text); + DateTime endDate = DateFormat('dd/MM/yyyy HH:mm:ss').parse(textController2!.text); if (startDate.isAfter(endDate)) { return FFLocalizations.of(context).getVariableText( ptText: 'A data de início deve ser anterior à data de término.', enText: 'Start date must be before end date.', ); } - if (startDate - .isBefore(DateTime.now().subtract(const Duration(minutes: 10)))) { + if (startDate.isBefore(DateTime.now().subtract(const Duration(minutes: 10)))) { return FFLocalizations.of(context).getVariableText( enText: 'Start date must be after current date.', ptText: 'A data de início deve ser posterior à data atual.', @@ -181,8 +171,7 @@ class ScheduleCompleteVisitPageModel if (val != '0') { try { DateTime endDate = DateFormat('dd/MM/yyyy HH:mm:ss').parse(val); - DateTime startDate = - DateFormat('dd/MM/yyyy HH:mm:ss').parse(textController1!.text); + DateTime startDate = DateFormat('dd/MM/yyyy HH:mm:ss').parse(textController1!.text); if (endDate.isBefore(startDate)) { return FFLocalizations.of(context).getVariableText( @@ -190,8 +179,7 @@ class ScheduleCompleteVisitPageModel ptText: 'A data de término deve ser posterior à data de início.', ); } - if (startDate - .isBefore(DateTime.now().subtract(const Duration(minutes: 10)))) { + if (startDate.isBefore(DateTime.now().subtract(const Duration(minutes: 10)))) { return FFLocalizations.of(context).getVariableText( enText: 'End date must be after current date.', ptText: 'A data de término deve ser posterior à data atual.', @@ -227,9 +215,9 @@ class ScheduleCompleteVisitPageModel } Future _initVariables() async { - devUUID = StorageUtil().devUUID; - cliUUID = StorageUtil().cliUUID; - userUUID = StorageUtil().userUUID; + devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; } @override @@ -260,10 +248,8 @@ class ScheduleCompleteVisitPageModel textController3 = TextEditingController(); textController3Validator = _textController3Validator; - dropDownValueController1 ??= - FormFieldController(dropDownValue1 ??= ''); - dropDownValueController2 ??= - FormFieldController(dropDownValue2 ??= ''); + dropDownValueController1 ??= FormFieldController(dropDownValue1 ??= ''); + dropDownValueController2 ??= FormFieldController(dropDownValue2 ??= ''); } // Updated variables for dropdowns @@ -279,11 +265,8 @@ class ScheduleCompleteVisitPageModel void processDropDown1(List reasonsJsonList) { if (dropDownValue1 != null && dropDownValue1!.isNotEmpty) { String value = dropDownValue1!; - if (!(value.contains('{') && - value.contains('}') && - value.contains(':'))) { - var item = reasonsJsonList.where((reason) => - reason['MOT_DESCRICAO'].toString().contains(dropDownValue1!)); + if (!(value.contains('{') && value.contains('}') && value.contains(':'))) { + var item = reasonsJsonList.where((reason) => reason['MOT_DESCRICAO'].toString().contains(dropDownValue1!)); dropDownValue1 = item.firstOrNull?.toString() ?? ''; dropDownValueController1?.value = dropDownValue1!; } @@ -295,11 +278,8 @@ class ScheduleCompleteVisitPageModel void processDropDown2(List lavelList) { if (dropDownValue2 != null && dropDownValue2!.isNotEmpty) { String value = dropDownValue2!; - if (!(value.contains('{') && - value.contains('}') && - value.contains(':'))) { - var item = lavelList.where((level) => - level['NAC_DESCRICAO'].toString().contains(dropDownValue2!)); + if (!(value.contains('{') && value.contains('}') && value.contains(':'))) { + var item = lavelList.where((level) => level['NAC_DESCRICAO'].toString().contains(dropDownValue2!)); dropDownValue2 = item.firstOrNull?.toString() ?? ''; dropDownValueController2?.value = dropDownValue2!; } @@ -351,10 +331,7 @@ class ScheduleCompleteVisitPageModel } Future visitCancelAction(BuildContext context, - {required int? idDestino, - required int? idVisita, - required String? accessKey, - required String? email}) async { + {required int? idDestino, required int? idVisita, required String? accessKey, required String? email}) async { final ApiCallResponse? response; final CancelaVisita callback = PhpGroup.cancelaVisita; @@ -426,8 +403,7 @@ class ScheduleCompleteVisitPageModel Widget buildVisitDetails({ required dynamic item, required BuildContext context, - required Future Function(BuildContext, int, int, String, String) - changeStatusAction, + required Future Function(BuildContext, int, int, String, String) changeStatusAction, required String devUUID, required String userUUID, required String cliUUID, @@ -435,8 +411,7 @@ class ScheduleCompleteVisitPageModel }) { return DetailsComponentWidget( buttons: [ - if (Status.getStatus(item['VAW_STATUS']) == - StatusEnum.active) // REJECT ACTION + if (Status.getStatus(item['VAW_STATUS']) == StatusEnum.active) // REJECT ACTION FFButtonWidget( text: FFLocalizations.of(context).getVariableText( ptText: 'Cancelar', @@ -516,8 +491,7 @@ class ScheduleCompleteVisitPageModel // borderRadius: 12, ), ), - if (Status.getStatus(item['VAW_STATUS']) != - StatusEnum.active) // RECALL ACTION + if (Status.getStatus(item['VAW_STATUS']) != StatusEnum.active) // RECALL ACTION FFButtonWidget( text: FFLocalizations.of(context).getVariableText( ptText: 'Reagendar', @@ -552,8 +526,7 @@ class ScheduleCompleteVisitPageModel // borderRadius: 12, ), ), - if (Status.getStatus(item['VAW_STATUS']) == - StatusEnum.active) // SHARE ACTION + if (Status.getStatus(item['VAW_STATUS']) == StatusEnum.active) // SHARE ACTION FFButtonWidget( text: FFLocalizations.of(context).getVariableText( ptText: 'Compartilhar', @@ -590,17 +563,14 @@ URL do Convite: https://visita.freaccess.com.br/${item['VAW_ID']}/$cliUUID/${ite ), ], labelsHashMap: Map.from({ - '${FFLocalizations.of(context).getVariableText(ptText: "Nome", enText: "Name")}:': - item['VTE_NOME'] ?? '', + '${FFLocalizations.of(context).getVariableText(ptText: "Nome", enText: "Name")}:': item['VTE_NOME'] ?? '', '${FFLocalizations.of(context).getVariableText(ptText: "Inicio", enText: "Start")}:': item['VAW_DTINICIO'] != '' && item['VAW_DTINICIO'] != null - ? ValidatorUtil.toLocalDateTime( - 'yyyy-MM-dd HH:mm:ss', item['VAW_DTINICIO']) + ? ValidatorUtil.toLocalDateTime('yyyy-MM-dd HH:mm:ss', item['VAW_DTINICIO']) : '', '${FFLocalizations.of(context).getVariableText(ptText: "Fim", enText: "End")}:': item['VAW_DTFIM'] != '' && item['VAW_DTFIM'] != null - ? ValidatorUtil.toLocalDateTime( - 'yyyy-MM-dd HH:mm:ss', item['VAW_DTFIM']) + ? ValidatorUtil.toLocalDateTime('yyyy-MM-dd HH:mm:ss', item['VAW_DTFIM']) : '', }), imagePath: diff --git a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart index e3c786cd..678724cc 100644 --- a/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart +++ b/lib/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart @@ -35,12 +35,10 @@ class ScheduleCompleteVisitPageWidget extends ScheduleComplete { const ScheduleCompleteVisitPageWidget({super.key}); @override - State createState() => - _ScheduleCompleteVisitPageWidgetState(); + State createState() => _ScheduleCompleteVisitPageWidgetState(); } -class _ScheduleCompleteVisitPageWidgetState - extends State +class _ScheduleCompleteVisitPageWidgetState extends State with TickerProviderStateMixin { bool _isLoading = false; late ScheduleCompleteVisitPageModel _model; @@ -81,8 +79,7 @@ class _ScheduleCompleteVisitPageWidgetState } final int start = _visitHistoryLoadingIdx * _visitHistoryLoadingCount; - final List newItems = - await fetchVisitHistory(start, _visitHistoryLoadingCount); + final List newItems = await fetchVisitHistory(start, _visitHistoryLoadingCount); if (newItems.isNotEmpty) { _visitHistoryList.addAll(newItems); @@ -92,8 +89,7 @@ class _ScheduleCompleteVisitPageWidgetState } void _scrollListener() { - if (_visitHistoryController.position.pixels == - _visitHistoryController.position.maxScrollExtent) { + if (_visitHistoryController.position.pixels == _visitHistoryController.position.maxScrollExtent) { _loadMoreVisitHistory(); } } @@ -275,8 +271,7 @@ class _ScheduleCompleteVisitPageWidgetState controller: model.textController1, readOnly: true, focusNode: model.textFieldFocusNode1, - autovalidateMode: - AutovalidateMode.onUserInteraction, + autovalidateMode: AutovalidateMode.onUserInteraction, autofocus: false, obscureText: false, decoration: InputDecoration( @@ -310,24 +305,20 @@ class _ScheduleCompleteVisitPageWidgetState .primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), lineHeight: 1.0, fontSize: limitedInputFontSize, ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .customColor6, + color: FlutterFlowTheme.of(context).accent4, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), ), focusedBorder: OutlineInputBorder( borderSide: BorderSide( - color: FlutterFlowTheme.of(context) - .primary, + color: FlutterFlowTheme.of(context).primary, width: 0.5, ), borderRadius: BorderRadius.circular(8.0), @@ -360,16 +351,11 @@ class _ScheduleCompleteVisitPageWidgetState FlutterFlowTheme.of(context).accent1, ), ), - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodyMediumFamily, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + .containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), lineHeight: 1.8, fontSize: limitedInputFontSize, ), @@ -541,41 +527,28 @@ class _ScheduleCompleteVisitPageWidgetState readOnly: true, controller: model.textController2, focusNode: model.textFieldFocusNode2, - autovalidateMode: - AutovalidateMode.onUserInteraction, + autovalidateMode: AutovalidateMode.onUserInteraction, autofocus: false, obscureText: false, decoration: InputDecoration( isDense: true, - labelStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + labelStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), fontSize: limitedInputFontSize, ), hintText: FFLocalizations.of(context).getText( 'xpgc5e8d', ), - hintStyle: FlutterFlowTheme.of(context) - .labelMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .labelMediumFamily, - color: FlutterFlowTheme.of(context) - .primaryText, + hintStyle: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: FlutterFlowTheme.of(context).labelMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .labelMediumFamily), + .containsKey(FlutterFlowTheme.of(context).labelMediumFamily), lineHeight: 1.0, fontSize: limitedInputFontSize, ), @@ -620,16 +593,11 @@ class _ScheduleCompleteVisitPageWidgetState color: FlutterFlowTheme.of(context).accent1, ), ), - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodyMediumFamily, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey( - FlutterFlowTheme.of(context) - .bodyMediumFamily), + useGoogleFonts: + GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), lineHeight: 1.8, fontSize: limitedInputFontSize, ), @@ -945,10 +913,12 @@ class _ScheduleCompleteVisitPageWidgetState padding: MediaQuery.viewInsetsOf(context), child: VisitorSearchModalTemplateComponentWidget( getVisitors: (visitorsParam) async { + model.visitorJsonList = visitorsParam!.toList().cast(); model.visitorJsonList = visitorsParam!.toList().cast(); safeSetState(() {}); }, getDocs: (docsParam) async { + model.visitorStrList = strListToStr(docsParam!.toList()); model.visitorStrList = strListToStr(docsParam!.toList()); safeSetState(() {}); }, @@ -1087,13 +1057,10 @@ class _ScheduleCompleteVisitPageWidgetState ); } - final reasonsJsonList = - PhpGroup.getDadosCall.reasonsJsonList( - snapshot.data!.jsonBody); - final reasonsOptionLabels = PhpGroup - .getDadosCall - .reasonsMotDescStrList( - snapshot.data!.jsonBody); + final reasonsJsonList = + PhpGroup.getDadosCall.reasonsJsonList(snapshot.data!.jsonBody); + final reasonsOptionLabels = + PhpGroup.getDadosCall.reasonsMotDescStrList(snapshot.data!.jsonBody); model.processDropDown1(reasonsJsonList!); @@ -1210,14 +1177,10 @@ class _ScheduleCompleteVisitPageWidgetState ); } - final lavelsJsonList = - PhpGroup.getDadosCall.levelJsonList( - snapshot.data!.jsonBody); - final lavelsOptionLabels = PhpGroup - .getDadosCall - .levelNACDescricaoStrList( - snapshot.data!.jsonBody); - model.processDropDown2(lavelsJsonList!); + final lavelsJsonList = PhpGroup.getDadosCall.levelJsonList(snapshot.data!.jsonBody); + final lavelsOptionLabels = + PhpGroup.getDadosCall.levelNACDescricaoStrList(snapshot.data!.jsonBody); + model.processDropDown2(lavelsJsonList!); return FlutterFlowDropDown( controller: @@ -1346,11 +1309,8 @@ class _ScheduleCompleteVisitPageWidgetState 'lgv0q5ht', ), textAlign: TextAlign.start, - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: FlutterFlowTheme.of(context) - .bodyMediumFamily, + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, useGoogleFonts: GoogleFonts.asMap() .containsKey( @@ -1575,14 +1535,12 @@ class _ScheduleCompleteVisitPageWidgetState false) { context.pop(); - model.dropDownValue1 = null; - model.dropDownValue2 = null; - model.dropDownValueController1 = - FormFieldController(''); - model.dropDownValueController2 = - FormFieldController(''); - model.visitorStrList = ''; - model.visitorJsonList = []; + model.dropDownValue1 = null; + model.dropDownValue2 = null; + model.dropDownValueController1 = FormFieldController(''); + model.dropDownValueController2 = FormFieldController(''); + model.visitorStrList = ''; + model.visitorJsonList = []; ToastUtil.showToast( message: FFLocalizations.of(context) diff --git a/lib/pages/schedule_complete_visit_page/visit_history_page_widget.dart b/lib/pages/schedule_complete_visit_page/visit_history_page_widget.dart index a1038248..464c38a8 100644 --- a/lib/pages/schedule_complete_visit_page/visit_history_page_widget.dart +++ b/lib/pages/schedule_complete_visit_page/visit_history_page_widget.dart @@ -5,11 +5,12 @@ import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_model.dart'; import 'package:hub/pages/schedule_complete_visit_page/schedule_complete_visit_page_widget.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/mixins/status_mixin.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; import 'package:hub/shared/utils/log_util.dart'; -import 'package:hub/shared/utils/storage_util.dart'; import 'package:hub/shared/utils/validator_util.dart'; class VisitHistoryWidget extends ScheduleComplete { @@ -19,8 +20,7 @@ class VisitHistoryWidget extends ScheduleComplete { _VisitHistoryWidgetState createState() => _VisitHistoryWidgetState(); } -class _VisitHistoryWidgetState extends State - with TickerProviderStateMixin, Status { +class _VisitHistoryWidgetState extends State with TickerProviderStateMixin, Status { late final String devUUID; late final String userUUID; late final String cliUUID; @@ -35,9 +35,9 @@ class _VisitHistoryWidgetState extends State List _visitWrap = []; Future _initVariables() async { - devUUID = StorageUtil().devUUID; - userUUID = StorageUtil().userUUID; - cliUUID = StorageUtil().cliUUID; + devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + userUUID = (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; } @override @@ -50,8 +50,7 @@ class _VisitHistoryWidgetState extends State _scrollController = ScrollController() ..addListener(() { - if (_scrollController.position.atEdge && - _scrollController.position.pixels != 0) { + if (_scrollController.position.atEdge && _scrollController.position.pixels != 0) { _loadMore(); } }); @@ -96,8 +95,7 @@ class _VisitHistoryWidgetState extends State return null; } catch (e, s) { DialogUtil.errorDefault(context); - LogUtil.requestAPIFailed( - "proccessRequest.php", "", "Consulta de Visitas", e, s); + LogUtil.requestAPIFailed("proccessRequest.php", "", "Consulta de Visitas", e, s); setState(() { _hasData = false; _loading = false; @@ -117,8 +115,7 @@ class _VisitHistoryWidgetState extends State ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text( - FFLocalizations.of(context).getVariableText( - ptText: "Não há mais dados.", enText: "No more data."), + FFLocalizations.of(context).getVariableText(ptText: "Não há mais dados.", enText: "No more data."), ), duration: const Duration(seconds: 3), backgroundColor: FlutterFlowTheme.of(context).primary, @@ -142,9 +139,8 @@ class _VisitHistoryWidgetState extends State mainAxisSize: MainAxisSize.max, children: [ Center( - child: Text(FFLocalizations.of(context).getVariableText( - ptText: "Nenhuma visita encontrada!", - enText: "No visit found"), + child: Text(FFLocalizations.of(context) + .getVariableText(ptText: "Nenhuma visita encontrada!", enText: "No visit found"), style: TextStyle( color: FlutterFlowTheme.of(context).primaryText, fontSize: limitedHeaderFontSize, @@ -194,16 +190,12 @@ class _VisitHistoryWidgetState extends State '${FFLocalizations.of(context).getVariableText(ptText: "Nome", enText: "Name")}:': visitaWrapItem['VTE_NOME'] ?? '', '${FFLocalizations.of(context).getVariableText(ptText: "Inicio", enText: "Start")}:': - visitaWrapItem['VAW_DTINICIO'] != '' && - visitaWrapItem['VAW_DTINICIO'] != null - ? ValidatorUtil.toLocalDateTime( - 'yyyy-MM-dd HH:mm:ss', visitaWrapItem['VAW_DTINICIO']) + visitaWrapItem['VAW_DTINICIO'] != '' && visitaWrapItem['VAW_DTINICIO'] != null + ? ValidatorUtil.toLocalDateTime('yyyy-MM-dd HH:mm:ss', visitaWrapItem['VAW_DTINICIO']) : '', '${FFLocalizations.of(context).getVariableText(ptText: "Fim", enText: "End")}:': - visitaWrapItem['VAW_DTFIM'] != '' && - visitaWrapItem['VAW_DTFIM'] != null - ? ValidatorUtil.toLocalDateTime( - 'yyyy-MM-dd HH:mm:ss', visitaWrapItem['VAW_DTFIM']) + visitaWrapItem['VAW_DTFIM'] != '' && visitaWrapItem['VAW_DTFIM'] != null + ? ValidatorUtil.toLocalDateTime('yyyy-MM-dd HH:mm:ss', visitaWrapItem['VAW_DTFIM']) : '', }, statusHashMap: [ @@ -214,40 +206,35 @@ class _VisitHistoryWidgetState extends State enText: 'Active', ): FlutterFlowTheme.of(context).warning, }, - if (Status.getStatus(visitaWrapItem['VAW_STATUS']) == - StatusEnum.finished) + if (Status.getStatus(visitaWrapItem['VAW_STATUS']) == StatusEnum.finished) { FFLocalizations.of(context).getVariableText( ptText: 'Finalizado', enText: 'Finished', ): FlutterFlowTheme.of(context).success, }, - if (Status.getStatus(visitaWrapItem['VAW_STATUS']) == - StatusEnum.unknown) + if (Status.getStatus(visitaWrapItem['VAW_STATUS']) == StatusEnum.unknown) { FFLocalizations.of(context).getVariableText( ptText: 'Desconhecido', enText: 'Unknown', ): FlutterFlowTheme.of(context).alternate, }, - if (Status.getStatus(visitaWrapItem['VAW_STATUS']) == - StatusEnum.canceled) + if (Status.getStatus(visitaWrapItem['VAW_STATUS']) == StatusEnum.canceled) { FFLocalizations.of(context).getVariableText( ptText: 'Cancelado', enText: 'Canceled', ): FlutterFlowTheme.of(context).error, }, - if (Status.getStatus(visitaWrapItem['VAW_STATUS']) == - StatusEnum.blocked) + if (Status.getStatus(visitaWrapItem['VAW_STATUS']) == StatusEnum.blocked) { FFLocalizations.of(context).getVariableText( ptText: 'Bloqueado', enText: 'Blocked', ): FlutterFlowTheme.of(context).error, }, - if (Status.getStatus(visitaWrapItem['VAW_STATUS']) == - StatusEnum.inactive) + if (Status.getStatus(visitaWrapItem['VAW_STATUS']) == StatusEnum.inactive) { FFLocalizations.of(context).getVariableText( ptText: 'Inativo', @@ -256,10 +243,13 @@ class _VisitHistoryWidgetState extends State }, ], onTapCardItemAction: () async { - final cliUUID = StorageUtil().cliUUID; - final cliName = StorageUtil().cliName; - final devUUID = StorageUtil().devUUID; - final userUUID = StorageUtil().userUUID; + final devUUID = (await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage)) ?? ''; + final userUUID = + (await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage)) ?? ''; + final cliUUID = + (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + final cliName = + (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? ''; await showDialog( useSafeArea: true, @@ -286,8 +276,7 @@ class _VisitHistoryWidgetState extends State }); }).catchError((e, s) { DialogUtil.errorDefault(context); - LogUtil.requestAPIFailed( - "proccessRequest.php", "", "Consulta de Visitas", e, s); + LogUtil.requestAPIFailed("proccessRequest.php", "", "Consulta de Visitas", e, s); safeSetState(() { _hasData = false; _loading = false; diff --git a/lib/pages/sign_in_page/sign_in_page_model.dart b/lib/pages/sign_in_page/sign_in_page_model.dart index 6cea2517..8642b98d 100644 --- a/lib/pages/sign_in_page/sign_in_page_model.dart +++ b/lib/pages/sign_in_page/sign_in_page_model.dart @@ -12,8 +12,7 @@ class SignInPageModel extends FlutterFlowModel { @override void initState(BuildContext context) { - signInTemplateComponentModel = - createModel(context, () => SignInTemplateComponentModel()); + signInTemplateComponentModel = createModel(context, () => SignInTemplateComponentModel()); } @override @@ -21,4 +20,4 @@ class SignInPageModel extends FlutterFlowModel { unfocusNode.dispose(); signInTemplateComponentModel.dispose(); } -} \ No newline at end of file +} diff --git a/lib/pages/sign_in_page/sign_in_page_widget.dart b/lib/pages/sign_in_page/sign_in_page_widget.dart index a826572e..471bbee2 100644 --- a/lib/pages/sign_in_page/sign_in_page_widget.dart +++ b/lib/pages/sign_in_page/sign_in_page_widget.dart @@ -1,6 +1,6 @@ +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/mixins/switcher_mixin.dart'; -import '../../shared/utils/storage_util.dart'; import '/components/templates_components/sign_in_template_component/sign_in_template_component_widget.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; @@ -35,7 +35,7 @@ class _SignInPageWidgetState extends State { @override Widget build(BuildContext context) { - StorageUtil().context = context; + StorageHelper().context = context; return GestureDetector( onTap: () => _model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(_model.unfocusNode) diff --git a/lib/pages/sign_up_page/sign_up_page_model.dart b/lib/pages/sign_up_page/sign_up_page_model.dart index 349ee990..ff69d9b5 100644 --- a/lib/pages/sign_up_page/sign_up_page_model.dart +++ b/lib/pages/sign_up_page/sign_up_page_model.dart @@ -12,8 +12,7 @@ class SignUpPageModel extends FlutterFlowModel { @override void initState(BuildContext context) { - signUpTemplateComponentModel = - createModel(context, () => SignUpTemplateComponentModel()); + signUpTemplateComponentModel = createModel(context, () => SignUpTemplateComponentModel()); } @override @@ -21,4 +20,4 @@ class SignUpPageModel extends FlutterFlowModel { unfocusNode.dispose(); signUpTemplateComponentModel.dispose(); } -} \ No newline at end of file +} diff --git a/lib/pages/sign_up_page/sign_up_page_widget.dart b/lib/pages/sign_up_page/sign_up_page_widget.dart index bb786c31..00d95f56 100644 --- a/lib/pages/sign_up_page/sign_up_page_widget.dart +++ b/lib/pages/sign_up_page/sign_up_page_widget.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/mixins/switcher_mixin.dart'; -import '../../shared/utils/storage_util.dart'; import '/components/templates_components/sign_up_template_component/sign_up_template_component_widget.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; @@ -36,7 +36,7 @@ class _SignUpPageWidgetState extends State { @override Widget build(BuildContext context) { - StorageUtil().context = context; + StorageHelper().context = context; return GestureDetector( onTap: () => _model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(_model.unfocusNode) diff --git a/lib/pages/welcome_page/welcome_page_model.dart b/lib/pages/welcome_page/welcome_page_model.dart index 4c08929e..7823f2b2 100644 --- a/lib/pages/welcome_page/welcome_page_model.dart +++ b/lib/pages/welcome_page/welcome_page_model.dart @@ -16,8 +16,7 @@ class WelcomePageModel extends FlutterFlowModel { @override void initState(BuildContext context) { - welcomeTemplateComponentModel = - createModel(context, () => WelcomeTemplateComponentModel()); + welcomeTemplateComponentModel = createModel(context, () => WelcomeTemplateComponentModel()); } @override @@ -25,4 +24,4 @@ class WelcomePageModel extends FlutterFlowModel { unfocusNode.dispose(); welcomeTemplateComponentModel.dispose(); } -} \ No newline at end of file +} diff --git a/lib/pages/welcome_page/welcome_page_widget.dart b/lib/pages/welcome_page/welcome_page_widget.dart index 544ef3a7..cb24d5e1 100644 --- a/lib/pages/welcome_page/welcome_page_widget.dart +++ b/lib/pages/welcome_page/welcome_page_widget.dart @@ -1,11 +1,8 @@ -import 'dart:async'; -import 'dart:developer'; - -import 'package:app_links/app_links.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/mixins/switcher_mixin.dart'; -import 'package:hub/shared/utils/storage_util.dart'; import '/components/templates_components/welcome_template_component/welcome_template_component_widget.dart'; import '/flutter_flow/flutter_flow_theme.dart'; @@ -26,36 +23,36 @@ class _WelcomePageWidgetState extends State { final scaffoldKey = GlobalKey(); - @override void initState() { + @override + void initState() { super.initState(); _model = createModel(context, () => WelcomePageModel()); // On page load action. SchedulerBinding.instance.addPostFrameCallback((_) async { if (isAndroid == true) { - StorageUtil().deviceType = 'Android'; + await StorageHelper().set(SecureStorageKey.deviceType.value, 'Android', Storage.SecureStorage); setState(() {}); } else if (isiOS == true) { - StorageUtil().deviceType = 'iOS'; + await StorageHelper().set(SecureStorageKey.deviceType.value, 'iOS', Storage.SecureStorage); setState(() {}); } else { - StorageUtil().deviceType = 'Web'; + await StorageHelper().set(SecureStorageKey.deviceType.value, 'Web', Storage.SecureStorage); setState(() {}); } }); } - @override void dispose() { + @override + void dispose() { _model.dispose(); super.dispose(); } - - @override Widget build(BuildContext context) { - StorageUtil().context = context; + StorageHelper().context = context; return GestureDetector( onTap: () => _model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(_model.unfocusNode) diff --git a/lib/shared/components/atoms/atom_terms_of_use.dart b/lib/shared/components/atoms/atom_terms_of_use.dart index 3c3cf090..645691a1 100644 --- a/lib/shared/components/atoms/atom_terms_of_use.dart +++ b/lib/shared/components/atoms/atom_terms_of_use.dart @@ -6,7 +6,6 @@ import '../../../flutter_flow/flutter_flow_theme.dart'; import '../../../flutter_flow/flutter_flow_util.dart'; class AtomTermsOfUse extends StatelessWidget { - const AtomTermsOfUse({super.key}); @override @@ -16,27 +15,16 @@ class AtomTermsOfUse extends StatelessWidget { FFLocalizations.of(context).getText( 'olf967cj' /* Termo de Uso */, ), - style: FlutterFlowTheme.of(context) - .bodyMedium - .override( - fontFamily: - FlutterFlowTheme.of(context) - .bodyMediumFamily, - color: - FlutterFlowTheme.of(context) - .primaryText, - fontSize: LimitedFontSizeUtil.getInputFontSize( + style: FlutterFlowTheme.of(context).bodyMedium.override( + fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, + color: FlutterFlowTheme.of(context).primaryText, + fontSize: LimitedFontSizeUtil.getInputFontSize( context), - letterSpacing: 0.0, - useGoogleFonts: GoogleFonts - .asMap() - .containsKey( - FlutterFlowTheme.of( - context) - .bodyMediumFamily), - ), + letterSpacing: 0.0, + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), + ), ), onTap: () => launchURL('https://freaccess.com.br/pp'), ); } -} \ No newline at end of file +} diff --git a/lib/shared/enums/enum_throw_exception.dart b/lib/shared/enums/enum_throw_exception.dart index f1bf2a08..d8c19af1 100644 --- a/lib/shared/enums/enum_throw_exception.dart +++ b/lib/shared/enums/enum_throw_exception.dart @@ -1,5 +1 @@ -enum EnumThrowException { - success, - error, - warning -} \ No newline at end of file +enum EnumThrowException { success, error, warning } diff --git a/lib/shared/extensions/dialog_extensions.dart b/lib/shared/extensions/dialog_extensions.dart index b4c4e86b..222154dc 100644 --- a/lib/shared/extensions/dialog_extensions.dart +++ b/lib/shared/extensions/dialog_extensions.dart @@ -16,8 +16,7 @@ extension DialogUnavailable on DialogUtil { static Future unavailableCredentials(BuildContext context) { final message = FFLocalizations.of(context).getVariableText( - ptText: - "Credenciais inválidas. Selecione um local ou faça o login novamente.", + ptText: "Credenciais inválidas. Selecione um local ou faça o login novamente.", enText: "Invalid credentials. Select a location or log in again.", ); return DialogUtil.warning(context, message); diff --git a/lib/shared/extensions/flutter_secure_storage_extensions.dart b/lib/shared/extensions/flutter_secure_storage_extensions.dart index 8bba2507..e689535d 100644 --- a/lib/shared/extensions/flutter_secure_storage_extensions.dart +++ b/lib/shared/extensions/flutter_secure_storage_extensions.dart @@ -6,30 +6,23 @@ import 'package:synchronized/synchronized.dart'; extension FlutterSecureStorageExtensions on FlutterSecureStorage { static final _lock = Lock(); - Future writeSync({required String key, String? value}) async => - await _lock.synchronized(() async { + Future writeSync({required String key, String? value}) async => await _lock.synchronized(() async { await write(key: key, value: value); }); void remove(String key) => delete(key: key); Future getString(String key) async => await read(key: key); - Future setString(String key, String value) async => - await writeSync(key: key, value: value); + Future setString(String key, String value) async => await writeSync(key: key, value: value); Future getBool(String key) async => (await read(key: key)) == 'true'; - Future setBool(String key, bool? value) async => - await writeSync(key: key, value: value.toString()); + Future setBool(String key, bool? value) async => await writeSync(key: key, value: value.toString()); - Future getInt(String key) async => - int.tryParse(await read(key: key) ?? ''); - Future setInt(String key, int value) async => - await writeSync(key: key, value: value.toString()); + Future getInt(String key) async => int.tryParse(await read(key: key) ?? ''); + Future setInt(String key, int value) async => await writeSync(key: key, value: value.toString()); - Future getDouble(String key) async => - double.tryParse(await read(key: key) ?? ''); - Future setDouble(String key, double value) async => - await writeSync(key: key, value: value.toString()); + Future getDouble(String key) async => double.tryParse(await read(key: key) ?? ''); + Future setDouble(String key, double value) async => await writeSync(key: key, value: value.toString()); Future getObject(String key) async { final value = await read(key: key); @@ -39,18 +32,12 @@ extension FlutterSecureStorageExtensions on FlutterSecureStorage { return value as BuildContext; } - Future?> getStringList(String key) async => - await read(key: key).then((result) { + Future?> getStringList(String key) async => await read(key: key).then((result) { if (result == null || result.isEmpty) { return null; } - return const CsvToListConverter() - .convert(result) - .first - .map((e) => e.toString()) - .toList(); + return const CsvToListConverter().convert(result).first.map((e) => e.toString()).toList(); }); Future setStringList(String key, List value) async => - await writeSync( - key: key, value: const ListToCsvConverter().convert([value])); + await writeSync(key: key, value: const ListToCsvConverter().convert([value])); } diff --git a/lib/shared/helpers/base_storage.dart b/lib/shared/helpers/base_storage.dart new file mode 100644 index 00000000..11bc2509 --- /dev/null +++ b/lib/shared/helpers/base_storage.dart @@ -0,0 +1,143 @@ +abstract class BaseStorage { + Future init(); + + Future set(String key, String value); + + Future get(String key); + + Future delete(String key); + + Future clearAll(); +} + +enum Storage { + SecureStorage, + SharedPreferences, + SQLiteStorage, +} + +enum SharedPreferencesKey { + isFirstRun, +} + +extension SharedPreferencesKeyExtension on SharedPreferencesKey { + String get value { + switch (this) { + case SharedPreferencesKey.isFirstRun: + return 'fre_isFirstRun'; + default: + return ''; + } + } +} + +enum SecureStorageKey { + isLogged, + email, + password, + deviceType, + token, + accessPass, + panicPass, + fingerprintPass, + haveLocal, + deviceDescription, +} + +extension SecureStorageKeyExtension on SecureStorageKey { + String get value { + switch (this) { + case SecureStorageKey.isLogged: + return 'fre_isLogged'; + case SecureStorageKey.email: + return 'fre_email'; + case SecureStorageKey.password: + return 'fre_passwd'; + case SecureStorageKey.deviceType: + return 'fre_deviceType'; + case SecureStorageKey.token: + return 'fre_token'; + case SecureStorageKey.accessPass: + return 'fre_accessPass'; + case SecureStorageKey.panicPass: + return 'fre_panicPass'; + case SecureStorageKey.fingerprintPass: + return 'fre_fingerprintPass'; + case SecureStorageKey.haveLocal: + return 'fre_have_local'; + case SecureStorageKey.deviceDescription: + return 'fre_deviceDescription'; + default: + return ''; + } + } +} + +enum SQLiteStorageKey { + devUUID, + userUUID, + userDevUUID, + status, + userName, + clientUUID, + ownerUUID, + clientName, + petAmount, + whatsapp, + provisional, + pets, + local, + notify, + fingerprint, + access, + panic, + person, + requestOSNotification, +} + +extension SQLIteStorageKeyExtension on SQLiteStorageKey { + String get value { + switch (this) { + case SQLiteStorageKey.devUUID: + return 'fre_devUUID'; + case SQLiteStorageKey.userUUID: + return 'fre_userUUID'; + case SQLiteStorageKey.userDevUUID: + return 'fre_userDevUUID'; + case SQLiteStorageKey.status: + return 'fre_status'; + case SQLiteStorageKey.userName: + return 'fre_userName'; + case SQLiteStorageKey.clientUUID: + return 'fre_cliUUID'; + case SQLiteStorageKey.ownerUUID: + return 'fre_ownerUUID'; + case SQLiteStorageKey.clientName: + return 'fre_cliName'; + case SQLiteStorageKey.petAmount: + return 'fre_petAmountRegister'; + case SQLiteStorageKey.whatsapp: + return 'fre_whatsapp'; + case SQLiteStorageKey.provisional: + return 'fre_provisional'; + case SQLiteStorageKey.pets: + return 'fre_pets'; + case SQLiteStorageKey.local: + return 'fre_local'; + case SQLiteStorageKey.notify: + return 'fre_notify'; + case SQLiteStorageKey.fingerprint: + return 'fre_fingerprint'; + case SQLiteStorageKey.access: + return 'fre_access'; + case SQLiteStorageKey.panic: + return 'fre_panic'; + case SQLiteStorageKey.person: + return 'fre_person'; + case SQLiteStorageKey.requestOSNotification: + return 'fre_requestOSnotification'; + default: + return ''; + } + } +} diff --git a/lib/shared/helpers/secure_storage.dart b/lib/shared/helpers/secure_storage.dart new file mode 100644 index 00000000..24181fc9 --- /dev/null +++ b/lib/shared/helpers/secure_storage.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_secure_storage/flutter_secure_storage.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; + +class SecureStorage extends ChangeNotifier implements BaseStorage { + SecureStorage._(); + + static final SecureStorage instance = SecureStorage._(); + + late final FlutterSecureStorage _secureStorage; + + @override + Future init() async { + _secureStorage = const FlutterSecureStorage(); + } + + @override + Future get(String key) async { + return await _secureStorage.read(key: key); + } + + @override + Future set(String key, String value) async { + await _secureStorage.write(key: key, value: value); + notifyListeners(); + } + + @override + Future delete(String key) async { + await _secureStorage.delete(key: key); + notifyListeners(); + } + + @override + Future clearAll() async { + await _secureStorage.deleteAll(); + notifyListeners(); + } +} diff --git a/lib/shared/helpers/secure_storage_helper.dart b/lib/shared/helpers/secure_storage_helper.dart deleted file mode 100644 index 5cf403ab..00000000 --- a/lib/shared/helpers/secure_storage_helper.dart +++ /dev/null @@ -1,114 +0,0 @@ -import 'dart:developer'; - -import 'package:flutter/material.dart'; -import 'package:flutter_secure_storage/flutter_secure_storage.dart'; -import 'package:hub/shared/utils/cache_util.dart'; -import 'package:hub/shared/utils/storage_util.dart'; - -class SecureStorageHelper extends ChangeNotifier implements Storage { - static final SecureStorageHelper _instance = SecureStorageHelper._internal(); - final FlutterSecureStorage _secureStorage = const FlutterSecureStorage(); - - factory SecureStorageHelper() => _instance; - - SecureStorageHelper._internal(); - - static SecureStorageHelper get instance => _instance; - - Future setAndCacheString( - String key, String value, Function(String) cacheSetter) async { - log('SecureStorageHelper -> setAndCacheString value for key: $key to $value'); - await _secureStorage.write(key: key, value: value); - CacheUtil.instance.set(key, value); - cacheSetter(value); - } - - Future setAndCacheBool( - String key, bool value, Function(bool) cacheSetter) async { - log('SecureStorageHelper -> setAndCacheBool value for key: $key to $value'); - await _secureStorage.write(key: key, value: value.toString()); - CacheUtil.instance.set(key, value); - cacheSetter(value); - } - - Future setAndCacheObject( - String key, String value, Function(String) cacheSetter) async { - log('SecureStorageHelper -> setAndCacheObject value for key: $key to $value'); - await _secureStorage.write(key: key, value: value); - CacheUtil.instance.set(key, value); - cacheSetter(value); - } - - Future getString(String key) async { - var value = CacheUtil.instance.get(key); - if (value == null) { - value = await _secureStorage.read(key: key); - CacheUtil.instance.set(key, value); - } - log('SecureStorageHelper -> getString $value for key: $key'); - return value; - } - - Future getBool(String key) async { - var value = CacheUtil.instance.get(key); - if (value == null || value == 'null') { - value = await _secureStorage.read(key: key); - CacheUtil.instance.set(key, value); - log('SecureStorageHelper -> getBool $value for key: $key'); - return value == 'true'; - } - log('SecureStorageHelper -> getBool $value for key: $key'); - return value == 'true' || value == true; - } - - Future getObject(String key) async { - var value = CacheUtil.instance.get(key); - if (value == null) { - value = await _secureStorage.read(key: key); - CacheUtil.instance.set(key, value); - } - log('SecureStorageHelper -> getObject $value for key: $key'); - return value as BuildContext?; - } - - @override - Future set( - String key, dynamic value, Function(dynamic) cacheSetter) async { - if (value is String? || value is String) { - await setAndCacheString(key, value!, cacheSetter); - } else if (value is bool? || value is bool) { - await setAndCacheBool(key, value, cacheSetter); - } else if (value is BuildContext || value is BuildContext?) { - await setAndCacheObject(key, value.toString(), cacheSetter); - } - } - - @override - Future get(String key) async { - log('SecureStorageHelper -> get value for key: $key'); - var stringValue = await getString(key); - if (stringValue != null) return stringValue; - - var boolValue = await getBool(key); - if (boolValue != null) return boolValue; - - var objectValue = await getObject(key); - if (objectValue != null) return objectValue; - - return null; - } - - @override - Future delete(String key) async { - log('SecureStorageHelper -> delete value for key: $key'); - await _secureStorage.delete(key: key); - CacheUtil.instance.delete(key); - } - - Future purge() async { - log('SecureStorageHelper -> Purging secure storage'); - await _secureStorage.deleteAll(); - - CacheUtil.instance.clear(); - } -} diff --git a/lib/shared/helpers/shared_preferences_storage.dart b/lib/shared/helpers/shared_preferences_storage.dart new file mode 100644 index 00000000..0dd19da1 --- /dev/null +++ b/lib/shared/helpers/shared_preferences_storage.dart @@ -0,0 +1,39 @@ +import 'package:flutter/material.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +class SharedPreferencesStorage extends ChangeNotifier implements BaseStorage { + SharedPreferencesStorage._(); + + static final SharedPreferencesStorage instance = SharedPreferencesStorage._(); + + late final SharedPreferences _prefs; + + @override + Future init() async { + _prefs = await SharedPreferences.getInstance(); + } + + @override + Future get(String key) async { + return _prefs.get(key).toString(); + } + + @override + Future set(String key, String value) async { + await _prefs.setString(key, value); + notifyListeners(); + } + + @override + Future delete(String key) async { + await _prefs.remove(key); + notifyListeners(); + } + + @override + Future clearAll() async { + await _prefs.clear(); + notifyListeners(); + } +} diff --git a/lib/shared/helpers/shared_preferences_storage_helper.dart b/lib/shared/helpers/shared_preferences_storage_helper.dart deleted file mode 100644 index 635e61be..00000000 --- a/lib/shared/helpers/shared_preferences_storage_helper.dart +++ /dev/null @@ -1,87 +0,0 @@ -import 'dart:developer'; -import 'package:hub/shared/utils/storage_util.dart'; -import 'package:shared_preferences/shared_preferences.dart'; -import 'package:hub/shared/utils/cache_util.dart'; - -class SharedPreferencesStorageHelper implements Storage { - static final SharedPreferencesStorageHelper _instance = - SharedPreferencesStorageHelper._internal(); - SharedPreferences? _prefs; - - SharedPreferences? get prefs => _prefs; - set prefs(SharedPreferences? value) => _prefs = value; - - factory SharedPreferencesStorageHelper() => _instance; - - SharedPreferencesStorageHelper._internal(); - - static SharedPreferencesStorageHelper get instance => _instance; - - Future initialize() async => _prefs = await SharedPreferences.getInstance(); - - - Future _setAndCache(String key, T value, Function(T) cacheSetter, Future Function(String, T) setFunc) async { - log('setAndCache value for key: $key to $value'); - await setFunc(key, value); - CacheUtil.instance.set(key, value); - cacheSetter(value); - } - Future _setAndCacheString(String key, String value, Function(String) cacheSetter) async { - log('setAndCacheString value for key: $key to $value'); - await _setAndCache(key, value, cacheSetter, _prefs!.setString); - } - Future _setAndCacheBool(String key, bool value, Function(bool) cacheSetter) async { - log('setAndCacheBool value for key: $key to $value'); - await _setAndCache(key, value, cacheSetter, _prefs!.setBool); - } - Future _setAndCacheInt(String key, int value, Function(int) cacheSetter) async { - log('setAndCacheInt value for key: $key to $value'); - await _setAndCache(key, value, cacheSetter, _prefs!.setInt); - } - Future _setAndCacheDouble(String key, double value, Function(double) cacheSetter) async { - log('setAndCacheDouble value for key: $key to $value'); - await _setAndCache(key, value, cacheSetter, _prefs!.setDouble); - } - Future _setAndCacheStringList(String key, List value, Function(List) cacheSetter) async { - log('setAndCacheStringList value for key: $key to $value'); - await _setAndCache(key, value, cacheSetter, _prefs!.setStringList); - } - - - @override Future set(String key, dynamic value, Function(dynamic) cacheSetter) async { - if (value is bool) { - log('() => setAndCacheBool $key to $value'); - await _prefs?.setBool(key, value); - } else if (value is String) { - await _prefs?.setString(key, value); - } else if (value is int) { - await _prefs?.setInt(key, value); - } else if (value is double) { - await _prefs?.setDouble(key, value); - } else if (value is List) { - await _prefs?.setStringList(key, value); - } - CacheUtil.instance.set(key, value); - } - @override Future get(String key) async { - log('Getting value for key: $key'); - var value = CacheUtil.instance.get(key); - if (value == null) { - value = _prefs?.get(key); - CacheUtil.instance.set(key, value); - } - return value; - } - @override Future delete(String key) async { - log('Deleting value for key: $key'); - await _prefs?.remove(key); - CacheUtil.instance.delete(key); - } - @override Future purge() async { - log('Purging shared preferences'); - await _prefs?.clear(); - CacheUtil.instance.clear(); - } - - -} diff --git a/lib/shared/helpers/sqlite_storage.dart b/lib/shared/helpers/sqlite_storage.dart new file mode 100644 index 00000000..6f387759 --- /dev/null +++ b/lib/shared/helpers/sqlite_storage.dart @@ -0,0 +1,128 @@ +import 'package:flutter/material.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:sqflite/sqflite.dart'; +import 'package:sqflite/sqlite_api.dart'; +import 'package:path/path.dart'; + +class SQLiteStorage extends ChangeNotifier implements BaseStorage { + SQLiteStorage._(); + + final String _dbName = 'database.db'; + final int _dbVersion = 1; + + static final SQLiteStorage instance = SQLiteStorage._(); + + late final _database; + + @override + Future init() async { + _database = await openDatabase( + join(await getDatabasesPath(), _dbName), + version: _dbVersion, + onCreate: _onCreate, + onUpgrade: _onUpdate, + onDowngrade: _onDowngrade, + ); + + await _onInitLocalVariables(_database); + } + + _onCreate(Database database, int version) async { + await database.execute(_tableKeychain); + } + + _onUpdate(Database database, int oldVersion, int newVersion) async {} + + _onDowngrade(Database database, int oldVersion, int newVersion) async {} + + _onInitLocalVariables(Database database) async { + // TODO: Talvez precise colocar um transaction aqui como o + // database.batch() para melhorar a performance + + for (var variable in _localVariables) { + var isConfig = await database.query('keychain', where: 'key = ?', whereArgs: [variable['key']]); + + if (isConfig.isEmpty) { + await database.insert('keychain', variable); + } + } + } + + String get _tableKeychain => ''' + CREATE TABLE keychain ( + key TEXT UNIQUE, + value TEXT, + type TEXT, + updateAt TEXT, + resolvedAt TEXT, + createdAt TEXT + ); + '''; + + List> get _localVariables => [ + {'key': SQLiteStorageKey.devUUID.value, 'value': '', 'type': 'user'}, + {'key': SQLiteStorageKey.userUUID.value, 'value': '', 'type': 'user'}, + {'key': SQLiteStorageKey.userDevUUID.value, 'value': '', 'type': 'user'}, + {'key': SQLiteStorageKey.status.value, 'value': '', 'type': 'user'}, + {'key': SQLiteStorageKey.userName.value, 'value': '', 'type': 'user'}, + {'key': SQLiteStorageKey.clientUUID.value, 'value': '', 'type': 'local'}, + {'key': SQLiteStorageKey.ownerUUID.value, 'value': '', 'type': 'local'}, + {'key': SQLiteStorageKey.clientName.value, 'value': '', 'type': 'local'}, + {'key': SQLiteStorageKey.whatsapp.value, 'value': 'false', 'type': 'util'}, + {'key': SQLiteStorageKey.provisional.value, 'value': 'false', 'type': 'util'}, + {'key': SQLiteStorageKey.pets.value, 'value': 'false', 'type': 'util'}, + {'key': SQLiteStorageKey.local.value, 'value': 'false', 'type': 'util'}, + {'key': SQLiteStorageKey.notify.value, 'value': 'false', 'type': 'util'}, + {'key': SQLiteStorageKey.fingerprint.value, 'value': 'false', 'type': 'util'}, + {'key': SQLiteStorageKey.access.value, 'value': 'false', 'type': 'util'}, + {'key': SQLiteStorageKey.panic.value, 'value': 'false', 'type': 'util'}, + {'key': SQLiteStorageKey.person.value, 'value': 'false', 'type': 'util'}, + {'key': SQLiteStorageKey.requestOSNotification.value, 'value': 'false', 'type': 'util'}, + {'key': SQLiteStorageKey.petAmount.value, 'value': '', 'type': 'local'}, + ]; + + @override + Future get(String key) async { + var response = await _database.query('keychain', where: 'key = ?', whereArgs: [key]); + + if (response.isEmpty) { + return null; + } + + return response.first['value']; + } + + @override + Future set(String key, String value) async { + var date = DateTime.now().toIso8601String(); + await _database.insert( + 'keychain', + { + 'key': key, + 'value': value, + 'type': 'local', + 'updateAt': date, + 'resolvedAt': date, + 'createdAt': date, + }, + conflictAlgorithm: ConflictAlgorithm.replace); + notifyListeners(); + } + + @override + Future delete(String key) async { + var isConfig = await _database.query('keychain', where: 'key = ?', whereArgs: [key]); + + if (isConfig.isNotEmpty) { + await _database.delete('keychain', where: 'key = ?', whereArgs: [key]); + } + + notifyListeners(); + } + + @override + Future clearAll() async { + await _database.delete('keychain'); + notifyListeners(); + } +} diff --git a/lib/shared/helpers/sqlite_storage_helper.dart b/lib/shared/helpers/sqlite_storage_helper.dart deleted file mode 100644 index 402413ba..00000000 --- a/lib/shared/helpers/sqlite_storage_helper.dart +++ /dev/null @@ -1,276 +0,0 @@ -import 'package:hub/shared/utils/cache_util.dart'; -import 'package:hub/shared/utils/storage_util.dart'; -import 'package:sqflite/sqflite.dart'; -import 'dart:developer'; -import 'package:path/path.dart'; - -class DatabaseConfig { - static const String dbName = 'database.db'; - static const int dbVersion = 1; - - static const String tableKeychain = 'keychain'; - static const String columnKey = 'key'; - static const String columnValue = 'value'; - static const String columnType = 'type'; - static const String columnUpdateAt = 'updateAt'; - static const String columnResolvedAt = 'resolvedAt'; - static const String columnCreatedAt = 'createdAt'; - - static const List> initialData = [ - {'key': 'devUUID', 'value': '', 'type': 'user'}, - {'key': 'userUUID', 'value': '', 'type': 'user'}, - {'key': 'userDevUUID', 'value': '', 'type': 'user'}, - {'key': 'status', 'value': '', 'type': 'user'}, - {'key': 'userName', 'value': '', 'type': 'user'}, - {'key': 'cliUUID', 'value': '', 'type': 'local'}, - {'key': 'ownerUUID', 'value': '', 'type': 'local'}, - {'key': 'cliName', 'value': '', 'type': 'local'}, - {'key': 'whatsapp', 'value': 'false', 'type': 'util'}, - {'key': 'provisional', 'value': 'false', 'type': 'util'}, - {'key': 'pets', 'value': 'false', 'type': 'util'}, - {'key': 'local', 'value': 'false', 'type': 'util'}, - {'key': 'notify', 'value': 'false', 'type': 'util'}, - {'key': 'fingerprint', 'value': 'false', 'type': 'util'}, - {'key': 'access', 'value': 'false', 'type': 'util'}, - {'key': 'panic', 'value': 'false', 'type': 'util'}, - {'key': 'person', 'value': 'false', 'type': 'util'}, - {'key': 'requestOSnotification', 'value': 'false', 'type': 'util'}, - {'key': 'petAmountRegister', 'value': '', 'type': 'local'}, - ]; -} - -class SQLiteStorageHelper implements Storage { - static final SQLiteStorageHelper _instance = SQLiteStorageHelper._internal(); - static Database? _database; - static String? _databasePath; - - factory SQLiteStorageHelper() => _instance; - - SQLiteStorageHelper._internal(); - - static SQLiteStorageHelper get instance => _instance; - - Future get database async { - log('Getting database instance'); - if (_database != null) return _database!; - _database = await _initDatabase(); - return _database!; - } - - Future _getDatabasePath() async { - log('Getting database path'); - if (_databasePath != null) return _databasePath!; - final databasesPath = await getDatabasesPath(); - _databasePath = join(databasesPath, DatabaseConfig.dbName); - log('Database path: $_databasePath'); - return _databasePath!; - } - - Future _initDatabase() async { - log('Initializing database'); - final path = await _getDatabasePath(); - return await openDatabase( - path, - version: DatabaseConfig.dbVersion, - onCreate: _onCreate, - onOpen: _onOpen, - onUpgrade: _onUpgrade, - onDowngrade: _onDowngrade, - onConfigure: _onConfigure, - ).catchError((error) { - log('Error initializing database: $error'); - throw error; - }).whenComplete(() async { - log('Database initialization complete'); - await setupLocalVariables(); - }); - } - - Future _onCreate(Database db, int version) async { - log('Creating tables...'); - await db.execute(''' - CREATE TABLE ${DatabaseConfig.tableKeychain} ( - ${DatabaseConfig.columnKey} TEXT UNIQUE, - ${DatabaseConfig.columnValue} TEXT, - ${DatabaseConfig.columnType} TEXT, - ${DatabaseConfig.columnUpdateAt} TEXT, - ${DatabaseConfig.columnResolvedAt} TEXT, - ${DatabaseConfig.columnCreatedAt} TEXT - ); - '''); - await _insertInitialData(db); - log('Tables created'); - } - - Future _insertInitialData(Database db) async { - log('Inserting initial data'); - final batch = db.batch(); - for (var data in DatabaseConfig.initialData) { - batch.insert(DatabaseConfig.tableKeychain, data); - } - await batch.commit(noResult: true); - log('Initial data inserted'); - } - - Future _onOpen(Database db) async { - log('Opening database'); - await _checkExistingData(db); - } - - Future _onUpgrade(Database db, int oldVersion, int newVersion) async { - log('Upgrading database from version $oldVersion to $newVersion'); - } - - Future _onDowngrade(Database db, int oldVersion, int newVersion) async { - log('Downgrading database from version $oldVersion to $newVersion'); - } - - Future _onConfigure(Database db) async { - log('Configuring database'); - } - - Future _checkExistingData(Database db) async { - log('Checking existing data'); - try { - final maps = await db.query(DatabaseConfig.tableKeychain); - log('Existing data: $maps'); - } catch (error) { - log('Error checking existing data: $error'); - } - } - - Future setupLocalVariables() async { - log('Setting up local variables'); - try { - await _database?.transaction((txn) async { - final keys = [ - 'devUUID', - 'userUUID', - 'userDevUUID', - 'status', - 'userName', - 'cliUUID', - 'ownerUUID', - 'cliName', - 'petAmountRegister', - 'whatsapp', - 'provisional', - 'pets', - 'local', - 'notify', - 'fingerprint', - 'access', - 'panic', - 'person', - 'requestOSnotification' - ]; - - for (var key in keys) { - log('Fetching value for key: $key'); - final result = await txn.query( - DatabaseConfig.tableKeychain, - where: '${DatabaseConfig.columnKey} = ?', - whereArgs: [key], - ); - log('Result for key $key: $result'); - } - }); - log('Local variables setup complete'); - } catch (error) { - log('Error setting up local variables: $error'); - } - } - - Future getBoolean(String key) async { - log('Getting boolean value for key: $key'); - final value = await get(key); - return value == 'true'; - } - - @override - Future get(String key) async { - log('Getting value for key: $key'); - final cachedValue = CacheUtil().get(key); - if (cachedValue != null) { - log('Found cached value for key: $key'); - return cachedValue; - } - - try { - final db = await database; - final result = await db.query( - DatabaseConfig.tableKeychain, - columns: [DatabaseConfig.columnValue], - where: '${DatabaseConfig.columnKey} = ?', - whereArgs: [key], - ); - - if (result.isNotEmpty) { - final value = result.first[DatabaseConfig.columnValue]; - CacheUtil().set(key, value); - log('Value for key $key: $value'); - return value; - } - log('No value found for key: $key'); - return null; - } catch (error) { - log('Error getting value for key $key: $error'); - return null; - } - } - - @override - Future set( - String key, dynamic value, Function(dynamic) cacheSetter) async { - log('Setting value for key: $key to $value'); - CacheUtil().set(key, value); - final db = await database; - final data = { - DatabaseConfig.columnKey: key, - DatabaseConfig.columnValue: value.toString(), - DatabaseConfig.columnUpdateAt: DateTime.now().toIso8601String(), - DatabaseConfig.columnCreatedAt: DateTime.now().toIso8601String(), - }; - - final result = await db.insert( - DatabaseConfig.tableKeychain, - data, - conflictAlgorithm: ConflictAlgorithm.replace, - ); - log('Value $value set for key: $key with result: $result'); - return result; - } - - @override - Future delete(String key) async { - log('Deleting value for key: $key'); - final db = await database; - final result = await db.transaction((txn) async { - return await txn.delete( - DatabaseConfig.tableKeychain, - where: '${DatabaseConfig.columnKey} = ?', - whereArgs: [key], - ); - }); - log('Value deleted for key: $key'); - return result; - } - - @override - Future purge() async { - log('Purging SQLite storage'); - await deleteDatabaseDB(); - await database; - log('Database purged'); - } - - Future deleteDatabaseDB() async { - log('Deleting database'); - final path = await _getDatabasePath(); - await deleteDatabase(path); - log('Database deleted'); - _database = null; - } -} - -class SqliteStorageDelegate {} diff --git a/lib/shared/helpers/storage_helper.dart b/lib/shared/helpers/storage_helper.dart new file mode 100644 index 00000000..e245d468 --- /dev/null +++ b/lib/shared/helpers/storage_helper.dart @@ -0,0 +1,82 @@ +import 'package:flutter/cupertino.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/secure_storage.dart'; +import 'package:hub/shared/helpers/shared_preferences_storage.dart'; +import 'package:hub/shared/helpers/sqlite_storage.dart'; + + +class StorageHelper { + + + static final StorageHelper _instance = StorageHelper._internal(); + factory StorageHelper() => _instance; + StorageHelper._internal(); + + + late BuildContext? _context; + late bool _isRecovered = false; + BuildContext? get context => _context; + set context(BuildContext? context) => _context = context; + + bool get isRecovered => _isRecovered; + set isRecovered(bool isRecovered) => _isRecovered = isRecovered; + + Future init() async { + await SecureStorage.instance.init(); + await SharedPreferencesStorage.instance.init(); + await SQLiteStorage.instance.init(); + + String? isFirstRun = await SharedPreferencesStorage.instance.get(SharedPreferencesKey.isFirstRun.value); + + if (isFirstRun == 'true') { + await SharedPreferencesStorage.instance.set(SharedPreferencesKey.isFirstRun.value, 'false'); + await SecureStorage.instance.set(SecureStorageKey.isLogged.value, 'false'); + } + } + + Future get(String key, Storage storage) { + switch (storage) { + case Storage.SecureStorage: + return SecureStorage.instance.get(key); + case Storage.SharedPreferences: + return SharedPreferencesStorage.instance.get(key); + case Storage.SQLiteStorage: + return SQLiteStorage.instance.get(key); + } + } + + Future set(String key, String value, Storage storage) { + switch (storage) { + case Storage.SecureStorage: + return SecureStorage.instance.set(key, value); + case Storage.SharedPreferences: + return SharedPreferencesStorage.instance.set(key, value); + case Storage.SQLiteStorage: + return SQLiteStorage.instance.set(key, value); + } + } + + Future delete(String key, Storage storage) { + switch (storage) { + case Storage.SecureStorage: + return SecureStorage.instance.delete(key); + case Storage.SharedPreferences: + return SharedPreferencesStorage.instance.delete(key); + case Storage.SQLiteStorage: + return SQLiteStorage.instance.delete(key); + } + } + + Future clearAll(Storage storage) { + switch (storage) { + case Storage.SecureStorage: + return SecureStorage.instance.clearAll(); + case Storage.SharedPreferences: + return SharedPreferencesStorage.instance.clearAll(); + case Storage.SQLiteStorage: + return SQLiteStorage.instance.clearAll(); + } + } + + +} diff --git a/lib/shared/services/authentication/authentication_service.dart b/lib/shared/services/authentication/authentication_service.dart index 11821a73..b81eb6d2 100644 --- a/lib/shared/services/authentication/authentication_service.dart +++ b/lib/shared/services/authentication/authentication_service.dart @@ -1,7 +1,7 @@ - - import 'package:flutter/material.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/utils/snackbar_util.dart'; import '../../../backend/api_requests/api_calls.dart'; @@ -10,12 +10,8 @@ import '../../../flutter_flow/random_data_util.dart'; import '../../utils/device_util.dart'; import '../../utils/dialog_util.dart'; import '../../utils/log_util.dart'; -import '../../utils/storage_util.dart'; class AuthenticationService { - - - static Future login(BuildContext context) async { final GetLocalsCall callback = PhpGroup.getLocalsCall; @@ -28,27 +24,27 @@ class AuthenticationService { List locals = response.jsonBody['locais'] ?? []; if (locals.isEmpty) { - StorageUtil().haveLocal = false; + await StorageHelper().set(SecureStorageKey.haveLocal.value, 'false', Storage.SecureStorage); context.go('/receptionPage'); } else { - StorageUtil().haveLocal = true; + await StorageHelper().set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage); context.go('/homePage'); } - StorageUtil().isLogged = true; + await StorageHelper().set(SecureStorageKey.isLogged.value, 'true', Storage.SecureStorage); } - static Future signIn(BuildContext context, FlutterFlowModel model, {String? emailAdress, String? password,}) async { + static Future signIn( + BuildContext context, + FlutterFlowModel model, { + String? emailAdress, + String? password, + }) async { try { final ApiCallResponse? response; final LoginCall callback = PhpGroup.loginCall; - StorageUtil().deviceDescription = randomString( - 10, - 10, - true, - false, - false, - ); + String deviceDescription = randomString(10, 10, true, false, false); + await StorageHelper().set(SecureStorageKey.deviceDescription.value, deviceDescription, Storage.SecureStorage); final String? devUUID; final String userUUID; @@ -63,9 +59,9 @@ class AuthenticationService { devUUID = await DeviceUtil.getDevUUID(); if ((email != '') && (passwd != '')) { - StorageUtil().email = email; - StorageUtil().passwd = passwd; - StorageUtil().devUUID = devUUID!; + await StorageHelper().set(SecureStorageKey.email.value, email, Storage.SecureStorage); + await StorageHelper().set(SecureStorageKey.password.value, passwd, Storage.SecureStorage); + await StorageHelper().set(SQLiteStorageKey.devUUID.value, devUUID!, Storage.SQLiteStorage); response = await callback.call(); if (response.jsonBody['error'] == false) { @@ -74,34 +70,39 @@ class AuthenticationService { userDevUUID = response.jsonBody['user']['dev_id']; userName = response.jsonBody['user']['name']; - StorageUtil().userUUID = userUUID; - StorageUtil().userDevUUID = userDevUUID; - StorageUtil().status = status; - StorageUtil().userName = userName; + await StorageHelper().set(SQLiteStorageKey.userUUID.value, userUUID, Storage.SQLiteStorage); + await StorageHelper().set(SQLiteStorageKey.userDevUUID.value, userDevUUID, Storage.SQLiteStorage); + await StorageHelper().set(SQLiteStorageKey.status.value, status, Storage.SQLiteStorage); + await StorageHelper().set(SQLiteStorageKey.userName.value, userName, Storage.SQLiteStorage); await login(context); } else { if (response.jsonBody['error'] == null) { DialogUtil.errorDefault(context); } else { - DialogUtil.error( - context, response.jsonBody['error_msg'].toString()); + DialogUtil.error(context, response.jsonBody['error_msg'].toString()); + DialogUtil.error(context, response.jsonBody['error_msg'].toString()); } } - } - - return; + } return; } catch (e, s) { DialogUtil.errorDefault(context); - LogUtil.requestAPIFailed( - 'login.php', emailAdress.toString(), "Login", e, s); + LogUtil.requestAPIFailed('login.php', emailAdress.toString(), "Login", e, s); } } - static Future signUp(BuildContext context, {required String? name, String? passwd, required String? email, String? device,}) async { + static Future signUp( + BuildContext context, { + required String? name, + String? passwd, + required String? email, + String? device, + }) async { try { ApiCallResponse? response; - if ((email != null && email != '') && (passwd != null && passwd != '' && passwd.length > 7) && (name != null && name != '')) { + if ((email != null && email != '') && + (passwd != null && passwd != '' && passwd.length > 7) && + (name != null && name != '')) { response = await PhpGroup.registerCall.call( name: name, password: passwd, @@ -127,25 +128,25 @@ class AuthenticationService { } static Future signOut(BuildContext context) async { - await PhpGroup.unregisterDevice.call(); - final Map extra = { - kTransitionInfoKey: const TransitionInfo( - hasTransition: true, - transitionType: PageTransitionType.scale, - alignment: Alignment.bottomCenter, - ), - }; - await StorageUtil.purge(); - context.go( '/welcomePage', extra: extra); - } + await PhpGroup.unregisterDevice.call(); + final Map extra = { + kTransitionInfoKey: const TransitionInfo( + hasTransition: true, + transitionType: PageTransitionType.scale, + alignment: Alignment.bottomCenter, + ), + }; + await StorageHelper().clearAll(Storage.SecureStorage); + await StorageHelper().clearAll(Storage.SQLiteStorage); + context.go('/welcomePage', extra: extra); + } static Future forgotPassword(BuildContext context, String email) async { try { final ApiCallResponse? response; final ForgotPasswordCall callback = PhpGroup.forgotPasswordCall; - final String message = FFLocalizations.of(context).getVariableText( - enText: "Send E-mail Successful!", - ptText: "E-mail Enviado com Sucesso!"); + final String message = FFLocalizations.of(context) + .getVariableText(enText: "Send E-mail Successful!", ptText: "E-mail Enviado com Sucesso!"); response = await callback.call(email: email); @@ -156,37 +157,35 @@ class AuthenticationService { } } catch (e, s) { DialogUtil.errorDefault(context); - LogUtil.requestAPIFailed( - 'forgotPassword.php', email, "Forgot Password", e, s); + LogUtil.requestAPIFailed('forgotPassword.php', email, "Forgot Password", e, s); } } static Future changePassword(BuildContext context, String email, String password, String token) async { try { - final ApiCallResponse response = await PhpGroup.changePasswordCall.call(email: email, psswd: password, token: token); + final ApiCallResponse response = + await PhpGroup.changePasswordCall.call(email: email, psswd: password, token: token); - if (response.jsonBody['error'] == false) { - final String message = FFLocalizations.of(context).getVariableText( - enText: "Password changed successfully!", - ptText: "Senha alterada com sucesso!", - ); - DialogUtil.success(context, message).then((_) => context.pop); - } else { - final String message = response.jsonBody['error_msg']; - DialogUtil.error(context, message); - } } catch (e, s) { + if (response.jsonBody['error'] == false) { + final String message = FFLocalizations.of(context).getVariableText( + enText: "Password changed successfully!", + ptText: "Senha alterada com sucesso!", + ); + DialogUtil.success(context, message).then((_) => context.pop); + } else { + final String message = response.jsonBody['error_msg']; + DialogUtil.error(context, message); + } + } catch (e, s) { DialogUtil.errorDefault(context); - LogUtil.requestAPIFailed( - 'changePassword.php', email, "Change Password", e, s); + LogUtil.requestAPIFailed('changePassword.php', email, "Change Password", e, s); } - - } static Future deleteAccount(BuildContext context) async { String content; try { - await PhpGroup.deleteAccount.call().then((value) { + await PhpGroup.deleteAccount.call().then((value) async { final Map extra = { kTransitionInfoKey: const TransitionInfo( hasTransition: true, @@ -199,7 +198,7 @@ class AuthenticationService { enText: 'Account deleted successfully', ptText: 'Conta deletada com sucesso', ); - StorageUtil.purge(); + await StorageHelper().clearAll(Storage.SecureStorage); context.pop(); context.go('/welcomePage', extra: extra); } @@ -220,5 +219,4 @@ class AuthenticationService { SnackBarUtil.showSnackBar(context, content, isError: true); } } - } \ No newline at end of file diff --git a/lib/shared/services/localization/localization_service.dart b/lib/shared/services/localization/localization_service.dart index 089e005b..4b1196c6 100644 --- a/lib/shared/services/localization/localization_service.dart +++ b/lib/shared/services/localization/localization_service.dart @@ -1,9 +1,12 @@ +// ignore_for_file: curly_braces_in_flow_control_structures, use_build_context_synchronously, unrelated_type_equality_checks + import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:hub/shared/utils/dialog_util.dart'; -import 'package:hub/shared/utils/storage_util.dart'; import '../../../backend/api_requests/api_calls.dart'; import '../../../components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart'; @@ -13,8 +16,6 @@ import '../../utils/snackbar_util.dart'; import '../authentication/authentication_service.dart'; class LocalizationService { - - static Future checkLocals(BuildContext context) async { try { final GetLocalsCall callback = PhpGroup.getLocalsCall; @@ -32,20 +33,20 @@ class LocalizationService { final bool isEnable = !isEmpty && isActive; if (isEnable) { - StorageUtil().haveLocal = true; - StorageUtil().isLogged = true; + await StorageHelper().set(SecureStorageKey.haveLocal.value, 'true', Storage.SecureStorage); + await StorageHelper().set(SecureStorageKey.isLogged.value, 'true', Storage.SecureStorage); await WidgetsBinding.instance.endOfFrame; - StorageUtil().cliUUID = ''; - StorageUtil().ownerUUID = ''; - StorageUtil().context?.go('/homePage'); + await StorageHelper().set(SQLiteStorageKey.clientUUID.value, '', Storage.SQLiteStorage); + await StorageHelper().set(SQLiteStorageKey.ownerUUID.value, '', Storage.SQLiteStorage); + StorageHelper().context?.go('/homePage'); } } catch (e, s) { log(e.toString(), stackTrace: s); } } + static Future processLocals(BuildContext context) async { try { - await StorageUtil().ensureInitialization(); final GetLocalsCall callback = PhpGroup.getLocalsCall; final ApiCallResponse response = await callback.call(); final bool isError = response.jsonBody['error']; @@ -60,16 +61,16 @@ class LocalizationService { _logLocalsStatus(locals); final bool isActive = _isActive(locals); - final bool isInactived = _isInactived(locals); + 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 isEnabled = isUnique && isActive; final bool isDisabled = isUnique && isBlocked; - final bool isUnselected = _isUnselected(); - final bool isSelected = _isSelected(isInactived); + final bool isUnselected = await _isUnselected(); + final bool isSelected = await _isSelected(isInactived); final bool isUnavailable = isPending && isUnselected && isUnique; - final bool isAvailable = _isAvailable(); + final bool isAvailable = await _isAvailable(); if (isDisabled) { AuthenticationService.signOut(context); @@ -87,12 +88,12 @@ class LocalizationService { } else if (isAvailable) { log('() => isAvailable'); return await processData(context); - } else { - if (!isUnique && !isActive) log('() => not unique and not active'); - if (!isUnique && isInactived) log('() => not unique and inactived'); - if (!isUnique && isPending) log('() => not unique and pending'); - if (!isUnique && isBlocked) log('() => not unique and blocked'); - log('() => else'); + } else { + if (!isUnique && !isActive) log('() => not unique and not active'); + if (!isUnique && isInactived) log('() => not unique and inactived'); + if (!isUnique && isPending) log('() => not unique and pending'); + if (!isUnique && isBlocked) log('() => not unique and blocked'); + log('() => else'); return await selectLocal(context); } } catch (e, s) { @@ -107,9 +108,9 @@ class LocalizationService { return false; } } + static Future processData(BuildContext context) async { try { - await StorageUtil().ensureInitialization(); final GetDadosCall callback = PhpGroup.getDadosCall; var response = await callback.call(); final bool error = response.jsonBody['error']; @@ -118,9 +119,8 @@ class LocalizationService { final String errorMsg = response.jsonBody['error_msg']; DialogUtil.error(context, errorMsg).whenComplete(() => selectLocal(context)); return false; - } - else { - _updateStorageUtil(response.jsonBody); + } else { + await _updateStorageUtil(response.jsonBody); return true; } } catch (e, s) { @@ -134,6 +134,7 @@ class LocalizationService { return false; } } + static Future selectLocal(BuildContext context) async { return await showModalBottomSheet( isScrollControlled: true, @@ -152,6 +153,7 @@ class LocalizationService { ), ).then((_) async => await processData(context)); } + static Future unlinkLocal(BuildContext context) async { String content; try { @@ -160,10 +162,10 @@ class LocalizationService { ptText: 'Dispositivo desvinculado com sucesso', ); - await PhpGroup.resopndeVinculo.call(tarefa: 'I').then((value) { + await PhpGroup.resopndeVinculo.call(tarefa: 'I').then((value) async { if (value.jsonBody['error'] == false) { - StorageUtil().cliName = ''; - StorageUtil().cliUUID = ''; + await StorageHelper().set(SQLiteStorageKey.clientName.value, '', Storage.SQLiteStorage); + await StorageHelper().set(SQLiteStorageKey.clientUUID.value, '', Storage.SQLiteStorage); context.pop(); context.go( '/homePage', @@ -196,22 +198,42 @@ class LocalizationService { } } - static void _handleError(BuildContext context, String errorMsg) { - AuthenticationService.signOut(context); - DialogUtil.error(context, errorMsg); - LogUtil.requestAPIFailed('getLocals.php', '{devUUID: ${StorageUtil().devUUID}, cliUUID: ${StorageUtil().userUUID}}', 'Get Locals', errorMsg, StackTrace.current); + static void _handleError(BuildContext context, String errorMsg) async { + final String devUUID = await StorageHelper().get(SQLiteStorageKey.devUUID.value, Storage.SQLiteStorage) ?? ''; + final String userUUID = await StorageHelper().get(SQLiteStorageKey.userUUID.value, Storage.SQLiteStorage) ?? ''; + final bool isAuthenticated = userUUID.isNotEmpty && devUUID.isNotEmpty; + final bool isDevLinked = !errorMsg.contains('Esse dispositivo nao pertence a esse usuario'); + log('() => isLinked: $errorMsg'); + if (!isAuthenticated) { + errorMsg = FFLocalizations.of(context).getVariableText( + ptText: 'Erro ao obter credenciais de autenticação', + enText: 'Error getting authentication credentials', + ); + await DialogUtil.error(context, errorMsg); + // await DialogUtil.error(context, errorMsg).whenComplete(() async => await AuthenticationService.signOut(context)); + } + else if (isAuthenticated && !isDevLinked) { + errorMsg = FFLocalizations.of(context).getVariableText( + ptText: 'Não foi possível vincular o dispositivo, tente novamente.', + enText: 'Unable to link device, try again', + ); + await DialogUtil.warning(context, errorMsg); + } + else if (isAuthenticated && isDevLinked) await DialogUtil.error(context, errorMsg).whenComplete(() async => await selectLocal(context)); + } + static Future _handleUnavailable(BuildContext context, List locals) async { log('() => isUnavailable'); try { - StorageUtil().cliUUID = locals[0]['CLI_ID']; - StorageUtil().ownerUUID = locals[0]['CLU_OWNER_ID']; - StorageUtil().cliName = locals[0]['CLI_NOME']; + await StorageHelper().set(SQLiteStorageKey.clientUUID.value, locals[0]['CLI_ID'], Storage.SQLiteStorage); + await StorageHelper().set(SQLiteStorageKey.ownerUUID.value, locals[0]['CLU_OWNER_ID'], Storage.SQLiteStorage); + await StorageHelper().set(SQLiteStorageKey.clientName.value, locals[0]['CLI_NOME'], Storage.SQLiteStorage); var response = await PhpGroup.resopndeVinculo.call(tarefa: 'A'); if (response.jsonBody['error'] == true) { - StorageUtil().cliUUID = ''; - StorageUtil().cliName = ''; - StorageUtil().ownerUUID = ''; + await StorageHelper().set(SQLiteStorageKey.clientUUID.value, '', Storage.SQLiteStorage); + await StorageHelper().set(SQLiteStorageKey.ownerUUID.value, '', Storage.SQLiteStorage); + await StorageHelper().set(SQLiteStorageKey.clientName.value, '', Storage.SQLiteStorage); return false; } if (response.jsonBody['error'] == false) return await processData(context).then((value) => value); @@ -222,12 +244,13 @@ class LocalizationService { } return false; } + static Future _handleEnabled(BuildContext context, dynamic local) async { log('() => isEnabled'); - StorageUtil().cliName = local['CLI_NOME']; - StorageUtil().userName = local['USU_NOME']; - StorageUtil().cliUUID = local['CLI_ID']; - StorageUtil().ownerUUID = local['CLU_OWNER_ID']; + await StorageHelper().set(SQLiteStorageKey.clientUUID.value, local['CLI_ID'], Storage.SQLiteStorage); + await StorageHelper().set(SQLiteStorageKey.ownerUUID.value, local['CLU_OWNER_ID'], Storage.SQLiteStorage); + await StorageHelper().set(SQLiteStorageKey.clientName.value, local['CLI_NOME'], Storage.SQLiteStorage); + await StorageHelper().set(SQLiteStorageKey.userName.value, local['USU_NOME'], Storage.SQLiteStorage); return await processData(context); } @@ -237,31 +260,55 @@ class LocalizationService { 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 Future _isInactived(List locals) async { + String cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + 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; } - 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) { - StorageUtil().whatsapp = jsonBody['whatsapp'] ?? false; - StorageUtil().provisional = jsonBody['provisional'] ?? false; - StorageUtil().pets = jsonBody['pet'] ?? false; - StorageUtil().petAmountRegister = jsonBody['petAmountRegister'].toString().isEmpty ? '0' : jsonBody['petAmountRegister'].toString(); - StorageUtil().userName = jsonBody['visitado']['VDO_NOME']; + + static Future _isUnselected() async { + String cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + String cliName = (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? ''; + String ownerUUID = + (await StorageHelper().get(SQLiteStorageKey.ownerUUID.value, Storage.SQLiteStorage)) ?? ''; + return cliUUID.isEmpty && cliName.isEmpty && ownerUUID.isEmpty; } + static Future _isSelected(bool isInactived) async { + String cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + String cliName = (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? ''; + return cliUUID.isNotEmpty && cliName.isNotEmpty && isInactived; + } + static Future _isAvailable() async { + String cliUUID = (await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage)) ?? ''; + String cliName = (await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage)) ?? ''; + return cliUUID.isNotEmpty && cliName.isNotEmpty; + } + + static Future _updateStorageUtil(Map jsonBody) async { + await StorageHelper().set(SQLiteStorageKey.whatsapp.value, + jsonBody['whatsapp'] != null && jsonBody['whatsapp'] ? 'true' : 'false', Storage.SQLiteStorage); + await StorageHelper().set(SQLiteStorageKey.provisional.value, + jsonBody['provisional'] != null && jsonBody['provisional'] ? 'true' : 'false', Storage.SQLiteStorage); + await StorageHelper().set(SQLiteStorageKey.pets.value, + jsonBody['pet'] != null && jsonBody['pet'] ? 'true' : 'false', Storage.SQLiteStorage); + await StorageHelper().set( + SQLiteStorageKey.petAmount.value, + jsonBody['petAmountRegister'] != null && jsonBody['petAmountRegister'].toString().isEmpty + ? '0' + : jsonBody['petAmountRegister'].toString(), + Storage.SQLiteStorage + ); + await StorageHelper() + .set(SQLiteStorageKey.userName.value, jsonBody['visitado']['VDO_NOME'], Storage.SQLiteStorage); + } } \ No newline at end of file diff --git a/lib/shared/utils/cache_util.dart b/lib/shared/utils/cache_util.dart deleted file mode 100644 index 4baf2128..00000000 --- a/lib/shared/utils/cache_util.dart +++ /dev/null @@ -1,34 +0,0 @@ -class CacheUtil { - static final CacheUtil _instance = CacheUtil._internal(); - static final Map _cache = {}; - - CacheUtil._internal(); - - factory CacheUtil() => _instance; - - static CacheUtil get instance => _instance; - - void set(String key, dynamic value) { - _cache[key] = value; - } - - dynamic get(String key) { - return _cache[key]; - } - - bool containsKey(String key) { - return _cache.containsKey(key); - } - - dynamic getOrElse(String key, dynamic fallback) { - return _cache.containsKey(key) ? _cache[key] : fallback; - } - - void delete(String key) { - _cache.remove(key); - } - - void clear() { - _cache.clear(); - } -} \ No newline at end of file diff --git a/lib/shared/utils/device_util.dart b/lib/shared/utils/device_util.dart index 1009e9e7..8d52fcc2 100644 --- a/lib/shared/utils/device_util.dart +++ b/lib/shared/utils/device_util.dart @@ -1,4 +1,3 @@ - import 'dart:io'; import 'package:device_info_plus/device_info_plus.dart'; @@ -40,6 +39,5 @@ class DeviceUtil { return androidDeviceInfo.version.release; // unique ID on Android. e.g . 11 } return null; - - } + } } diff --git a/lib/shared/utils/dialog_util.dart b/lib/shared/utils/dialog_util.dart index 6804443a..d9f1c64d 100644 --- a/lib/shared/utils/dialog_util.dart +++ b/lib/shared/utils/dialog_util.dart @@ -32,8 +32,7 @@ class DialogUtil { height: _height, child: Padding( padding: MediaQuery.viewInsetsOf(context), - child: ThrowExceptionWidget( - msg: message, type: EnumThrowException.error)))); + child: ThrowExceptionWidget(msg: message, type: EnumThrowException.error)))); }); } @@ -46,8 +45,7 @@ class DialogUtil { height: _height, child: Padding( padding: MediaQuery.viewInsetsOf(context), - child: ThrowExceptionWidget( - msg: message, type: EnumThrowException.warning)))); + child: ThrowExceptionWidget(msg: message, type: EnumThrowException.warning)))); }); } @@ -60,8 +58,7 @@ class DialogUtil { height: _height, child: Padding( padding: MediaQuery.viewInsetsOf(context), - child: ThrowExceptionWidget( - msg: message, type: EnumThrowException.success)))); + child: ThrowExceptionWidget(msg: message, type: EnumThrowException.success)))); }); } } diff --git a/lib/shared/utils/image_util.dart b/lib/shared/utils/image_util.dart index 4c55c0dd..f180004e 100644 --- a/lib/shared/utils/image_util.dart +++ b/lib/shared/utils/image_util.dart @@ -9,8 +9,7 @@ import 'package:path_provider/path_provider.dart'; import '../../flutter_flow/uploaded_file.dart'; class ImageUtils { - static Future convertImageFileToBase64( - FFUploadedFile imageFile) async { + static Future convertImageFileToBase64(FFUploadedFile imageFile) async { List? imageBytes = imageFile.bytes; if (imageBytes != null) { String base64Image = base64Encode(imageBytes); diff --git a/lib/shared/utils/log_util.dart b/lib/shared/utils/log_util.dart index d4db4569..5b9e2dc2 100644 --- a/lib/shared/utils/log_util.dart +++ b/lib/shared/utils/log_util.dart @@ -5,18 +5,15 @@ import 'package:hub/backend/api_requests/api_calls.dart'; class LogUtil { static void requestAPIFailed(String url, String body, String reason, dynamic error, StackTrace stack) async { - log("URL: ${PhpGroup.getBaseUrl()}/$url"); log("Body: $body"); log("Motivo: $reason"); log("Error: ${error.toString()}"); log("Stack: ${stack.toString()}"); - FirebaseCrashlytics.instance - .setCustomKey('URL', "${PhpGroup.getBaseUrl()}/$url"); + FirebaseCrashlytics.instance.setCustomKey('URL', "${PhpGroup.getBaseUrl()}/$url"); FirebaseCrashlytics.instance.setCustomKey('Body', body); - await FirebaseCrashlytics.instance - .recordError(error, stack, reason: reason); + await FirebaseCrashlytics.instance.recordError(error, stack, reason: reason); } } diff --git a/lib/shared/utils/share_util.dart b/lib/shared/utils/share_util.dart index 31cc52ef..0922c268 100644 --- a/lib/shared/utils/share_util.dart +++ b/lib/shared/utils/share_util.dart @@ -1,10 +1,11 @@ -import 'package:hub/shared/utils/storage_util.dart'; +import 'package:hub/shared/helpers/base_storage.dart'; +import 'package:hub/shared/helpers/storage_helper.dart'; import 'package:share_plus/share_plus.dart'; class ShareUtil { static Future showShare(payload) async { - final cliName = StorageUtil().cliName; - final cliUUID = StorageUtil().cliUUID; + final cliName = await StorageHelper().get(SQLiteStorageKey.clientName.value, Storage.SQLiteStorage); + final cliUUID = await StorageHelper().get(SQLiteStorageKey.clientUUID.value, Storage.SQLiteStorage); for (var i = 0; i < payload['convites'].length; i++) { await Share.share(''' diff --git a/lib/shared/utils/snackbar_util.dart b/lib/shared/utils/snackbar_util.dart index 60618d7a..27150db6 100644 --- a/lib/shared/utils/snackbar_util.dart +++ b/lib/shared/utils/snackbar_util.dart @@ -3,8 +3,6 @@ import 'package:flutter/material.dart'; import '../../flutter_flow/flutter_flow_theme.dart'; class SnackBarUtil { - - static void showSnackBar(BuildContext context, String text, {bool isError = false}) { ScaffoldMessenger.of(context).showSnackBar( SnackBar( @@ -12,9 +10,7 @@ class SnackBarUtil { text, style: TextStyle(color: FlutterFlowTheme.of(context).info), ), - backgroundColor: isError - ? FlutterFlowTheme.of(context).error - : FlutterFlowTheme.of(context).success, + backgroundColor: isError ? FlutterFlowTheme.of(context).error : FlutterFlowTheme.of(context).success, duration: const Duration(seconds: 3), behavior: SnackBarBehavior.floating, shape: RoundedRectangleBorder( @@ -23,6 +19,4 @@ class SnackBarUtil { ), ); } - - -} \ No newline at end of file +} diff --git a/lib/shared/utils/storage_util.dart b/lib/shared/utils/storage_util.dart deleted file mode 100644 index 43839dfe..00000000 --- a/lib/shared/utils/storage_util.dart +++ /dev/null @@ -1,446 +0,0 @@ -import 'dart:developer'; -import 'dart:ffi'; - -import 'package:flutter/material.dart'; -import 'package:hub/shared/helpers/secure_storage_helper.dart'; -import 'package:hub/shared/helpers/shared_preferences_storage_helper.dart'; -import 'package:hub/shared/helpers/sqlite_storage_helper.dart'; -import 'package:hub/shared/utils/cache_util.dart'; -import 'package:hub/shared/utils/dialog_util.dart'; -import 'package:hub/shared/utils/log_util.dart'; -import 'package:shared_preferences/shared_preferences.dart'; - -enum StorageType { secureStorage, sharedPreferences, dbSQLite3 } - -abstract class Storage { - Future set(String key, dynamic value, Function(dynamic) cacheSetter); - Future get(String key); - Future delete(String key); - Future purge(); -} - -class StorageData { - final String key; - final dynamic value; - final StorageType type; - StorageData(this.key, this.value, this.type); -} - -class StorageUtil { - static final StorageUtil _instance = StorageUtil._internal(); - - factory StorageUtil() { - return _instance; - } - - StorageUtil._internal(); - - late final SQLiteStorageHelper _sqliteStorage; - late final SecureStorageHelper _secureStorage; - late final SharedPreferencesStorageHelper _sharedPreferences; - bool _initialized = true; - - static Future set(StorageData data) async { - try { - var currentValue = CacheUtil().get(data.key); - if (currentValue != null && currentValue == data.value) { - log('Value for key ${data.key} is already set to ${data.value}, skipping update.'); - return; - } - - switch (data.type) { - case StorageType.secureStorage: - await SecureStorageHelper().set(data.key, data.value, (v) {}); - break; - case StorageType.sharedPreferences: - await SharedPreferencesStorageHelper() - .set(data.key, data.value, (v) {}); - break; - case StorageType.dbSQLite3: - await SQLiteStorageHelper().set(data.key, data.value, (v) {}); - break; - } - CacheUtil().set(data.key, data.value); - } catch (e) { - log('Error setting data: $e'); - } - } - - static Future get(StorageData data) async { - try { - var value = CacheUtil().get(data.key); - if (value == null) { - switch (data.type) { - case StorageType.secureStorage: - value = await SecureStorageHelper().get(data.key); - break; - case StorageType.sharedPreferences: - value = await SharedPreferencesStorageHelper().get(data.key); - break; - case StorageType.dbSQLite3: - value = await SQLiteStorageHelper().get(data.key); - break; - } - CacheUtil().set(data.key, value); - } - return value; - } catch (e) { - log('Error getting data: $e'); - return null; - } - } - - static Future delete(StorageData data) async { - try { - CacheUtil().delete(data.key); - switch (data.type) { - case StorageType.secureStorage: - await SecureStorageHelper().delete(data.key); - break; - case StorageType.sharedPreferences: - await SharedPreferencesStorageHelper().delete(data.key); - break; - case StorageType.dbSQLite3: - await SQLiteStorageHelper().delete(data.key); - break; - } - } catch (e) { - log('Error deleting data: $e'); - } - } - - static Future purge() async { - try { - await SecureStorageHelper().purge(); - await SQLiteStorageHelper().purge(); - // await SharedPreferencesStorageHelper().purge(); - } catch (e) { - log('Error purging data: $e'); - } - } - - Future ensureInitialization() async { - try { - log('StorageUtil: Starting initialization'); - if(!_initialized) return true; - await initSharedPreferences(); - await initSecureStorage(); - await initSQLiteStorage(); - if(_initialized) _initialized = false; - if(_initialized) return true; - return false; - } catch (e, s) { - log('Error initializing storage: $e'); - LogUtil.requestAPIFailed('$UniqueKey', '$UniqueKey', 'StorageUtil', e, s); - return false; - } - } - - Future initSharedPreferences() async { - try { - if(_initialized) _sharedPreferences = SharedPreferencesStorageHelper(); - _sharedPreferences.prefs ??= await SharedPreferences.getInstance(); - final bool milestone = - _sharedPreferences.prefs?.getBool('fre_isFirstRun') ?? true; - if (milestone) { - isFirstRun = false; - await _sharedPreferences.prefs?.setBool('fre_isFirstRun', false); - isLogged = false; - final String message = ''; - - // _secureStorage.purge(); - // _sqliteStorage.purge(); - } - } catch (e, s) { - log('SharedPreferencesStorageHelper: Error during initialization'); - LogUtil.requestAPIFailed( - '$UniqueKey', '$UniqueKey', 'SharedPreferencesStorageHelper', e, s); - } - } - - Future initSecureStorage() async { - log('SecureStorageHelper: Starting initialization'); - try { - if(_initialized) _secureStorage = SecureStorageHelper(); - _email = await _secureStorage.getString('fre_email'); - _passwd = await _secureStorage.getString('fre_passwd'); - _deviceType = await _secureStorage.getString('fre_deviceType'); - _isLogged = await _secureStorage.getBool('fre_isLogged') ?? false; - _tokenAPNS = await _secureStorage.getString('fre_tokenAPNS'); - _accessPass = await _secureStorage.getString('fre_accessPass'); - _panicPass = await _secureStorage.getString('fre_panicPass'); - _fingerprintPass = await _secureStorage.getString('fre_fingerprintPass'); - _haveLocal = await _secureStorage.getBool('fre_have_local') ?? false; - _deviceDescription = - await _secureStorage.getString('fre_deviceDescription'); - } catch (e, s) { - log('SecureStorageHelper: Error during initialization: $e'); - LogUtil.requestAPIFailed( - '$UniqueKey', '$UniqueKey', 'SecureStorageHelper', e, s); - } - log('SecureStorageHelper: Initialization complete'); - } - - Future initSQLiteStorage() async { - log('SQLiteStorageHelper: Starting initialization'); - try { - if(_initialized) _sqliteStorage = SQLiteStorageHelper(); - await _sqliteStorage.database; - _devUUID = await _sqliteStorage.get('fre_devUUID') ?? ''; - _userUUID = await _sqliteStorage.get('fre_userUUID') ?? ''; - _userDevUUID = await _sqliteStorage.get('fre_userDevUUID') ?? ''; - _status = await _sqliteStorage.get('fre_status') ?? ''; - _userName = await _sqliteStorage.get('fre_userName') ?? ''; - _cliUUID = await _sqliteStorage.get('fre_cliUUID') ?? ''; - _ownerUUID = await _sqliteStorage.get('fre_ownerUUID') ?? ''; - _cliName = await _sqliteStorage.get('fre_cliName') ?? ''; - _petAmountRegister = await _sqliteStorage.get('fre_petAmountRegister') ?? ''; - _whatsapp = await _sqliteStorage.getBoolean('fre_whatsapp'); - _provisional = await _sqliteStorage.getBoolean('fre_provisional'); - _pets = await _sqliteStorage.getBoolean('fre_pets'); - _local = await _sqliteStorage.getBoolean('fre_local'); - _notify = await _sqliteStorage.getBoolean('fre_notify'); - _fingerprint = await _sqliteStorage.getBoolean('fre_fingerprint'); - _access = await _sqliteStorage.getBoolean('fre_access'); - _panic = await _sqliteStorage.getBoolean('fre_panic'); - _person = await _sqliteStorage.getBoolean('fre_person'); - _requestOSnotification = - await _sqliteStorage.getBoolean('fre_requestOSnotification'); - } catch (e, s) { - log('SQLiteStorageHelper: Error during initialization: $e'); - LogUtil.requestAPIFailed( - '$UniqueKey', '$UniqueKey', 'SQLiteStorageHelper', e, s); - } - log('SQLiteStorageHelper: Initialization complete'); - } - - bool _isRecovered = false; - bool get isRecovered => _isRecovered; - set isRecovered(bool value) => _isRecovered = value; - - bool _isFirstRun = true; - bool get isFirstRun => _isFirstRun; - set isFirstRun(bool value) { - _isFirstRun = value; - _sharedPreferences.set('fre_isFirstRun', value, (v) => _isFirstRun = v); - } - - String? _deviceDescription; - String get deviceDescription => _deviceDescription ?? ''; - set deviceDescription(String value) { - _deviceDescription = value; - _secureStorage.set('fre_deviceDescription', value, (v) => _deviceDescription = v); - } - - BuildContext? _context; - BuildContext? get context => _context; - set context(BuildContext? value) { - _context = value; - _secureStorage.set('fre_context', value.toString(), (v) => _context = value); - } - - bool _haveLocal = false; - bool get haveLocal => _haveLocal; - set haveLocal(bool value) { - _haveLocal = value; - _secureStorage.set('fre_have_local', value ?? false, (v) => _haveLocal = value); - } - - String? _fingerprintPass; - String get fingerprintPass => _fingerprintPass ?? ''; - set fingerprintPass(String value) { - _fingerprintPass = value; - _secureStorage.set('fre_fingerprintPass', value, (v) => _fingerprintPass = v); - } - - String? _accessPass; - String get accessPass => _accessPass ?? ''; - set accessPass(String value) { - _accessPass = value; - _secureStorage.set('fre_accessPass', value, (v) => _accessPass = v); - } - - String? _panicPass; - String get panicPass => _panicPass ?? ''; - set panicPass(String value) { - _panicPass = value; - _secureStorage.set('fre_panicPass', value, (v) => _panicPass = v); - } - - String? _tokenAPNS; - String? get tokenAPNS => _tokenAPNS; - set tokenAPNS(String? value) { - _tokenAPNS = value; - _secureStorage.set('fre_tokenAPNS', value ?? '', (v) => _tokenAPNS = v); - } - - String? _email; - String get email => _email ?? ''; - set email(String value) { - _email = value; - _secureStorage.set('fre_email', value, (v) => _email = v); - } - - String? _passwd; - String get passwd => _passwd ?? ''; - set passwd(String value) { - _passwd = value; - _secureStorage.set('fre_passwd', value, (v) => _passwd = v); - } - - String? _deviceType; - String get deviceType => _deviceType ?? ''; - set deviceType(String value) { - _deviceType = value; - _secureStorage.set('fre_deviceType', value, (v) => _deviceType = v); - } - - bool _isLogged = false; - bool get isLogged => _isLogged; - set isLogged(bool value) { - _isLogged = value; - _secureStorage.set('fre_isLogged', value, (v) => _isLogged = v); - } - - String? _token; - String get token => _token ?? ''; - set token(String value) { - _token = value; - _secureStorage.set('fre_token', value, (v) => _token = v); - } - - String _devUUID = ''; - String get devUUID => _devUUID; - set devUUID(String value) { - _devUUID = value; - _sqliteStorage.set('fre_devUUID', value, (v) {}); - } - - String _userUUID = ''; - String get userUUID => _userUUID; - set userUUID(String value) { - _userUUID = value; - _sqliteStorage.set('fre_userUUID', value, (v) {}); - } - - String _userDevUUID = ''; - String get userDevUUID => _userDevUUID; - set userDevUUID(String value) { - _userDevUUID = value; - _sqliteStorage.set('fre_userDevUUID', value, (v) {}); - } - - String _status = ''; - String get status => _status; - set status(String value) { - _status = value; - _sqliteStorage.set('fre_status', value, (v) {}); - } - - String _userName = ''; - String get userName => _userName; - set userName(String value) { - _userName = value; - _sqliteStorage.set('fre_userName', value, (v) {}); - } - - String _cliUUID = ''; - String get cliUUID => _cliUUID; - set cliUUID(String value) { - _cliUUID = value; - _sqliteStorage.set('fre_cliUUID', value, (v) {}); - } - - String _ownerUUID = ''; - String get ownerUUID => _ownerUUID; - set ownerUUID(String value) { - _ownerUUID = value; - _sqliteStorage.set('fre_ownerUUID', value, (v) {}); - } - - String _cliName = ''; - String get cliName => _cliName; - set cliName(String value) { - _cliName = value; - _sqliteStorage.set('fre_cliName', value, (v) {}); - } - - String _petAmountRegister = ''; - String get petAmountRegister => _petAmountRegister; - set petAmountRegister(String value) { - _petAmountRegister = value; - _sqliteStorage.set('fre_petAmountRegister', value, (v) {}); - } - - bool _whatsapp = false; - bool get whatsapp => _whatsapp; - set whatsapp(bool value) { - _whatsapp = value; - _sqliteStorage.set('fre_whatsapp', value, (v) {}); - } - - bool _provisional = false; - bool get provisional => _provisional; - set provisional(bool value) { - _provisional = value; - _sqliteStorage.set('fre_provisional', value, (v) {}); - } - - bool _pets = false; - bool get pets => _pets; - set pets(bool value) { - _pets = value; - _sqliteStorage.set('fre_pets', value, (v) {}); - } - - bool _local = false; - bool get local => _local; - set local(bool value) { - _local = value; - _sqliteStorage.set('fre_local', value, (v) {}); - } - - bool _notify = false; - bool get notify => _notify; - set notify(bool value) { - _notify = value; - _sqliteStorage.set('fre_notify', value, (v) {}); - } - - bool _fingerprint = false; - bool get fingerprint => _fingerprint; - set fingerprint(bool value) { - _fingerprint = value; - _sqliteStorage.set('fre_fingerprint', value, (v) {}); - } - - bool _access = false; - bool get access => _access; - set access(bool value) { - _access = value; - _sqliteStorage.set('fre_access', value, (v) {}); - } - - bool _panic = false; - bool get panic => _panic; - set panic(bool value) { - _panic = value; - _sqliteStorage.set('fre_panic', value, (v) {}); - } - - bool _person = false; - bool get person => _person; - set person(bool value) { - _person = value; - _sqliteStorage.set('fre_person', value, (v) {}); - } - - bool _requestOSnotification = false; - bool get requestOSnotification => _requestOSnotification; - set requestOSnotification(bool value) { - _requestOSnotification = value; - _sqliteStorage.set('fre_requestOSnotification', value, (v) {}); - } - - String get createdAt => '0000-00-00 00:00:00'; -} diff --git a/lib/shared/utils/validator_util.dart b/lib/shared/utils/validator_util.dart index 41fafcd7..51abce74 100644 --- a/lib/shared/utils/validator_util.dart +++ b/lib/shared/utils/validator_util.dart @@ -1,4 +1,3 @@ - import 'package:intl/intl.dart'; class ValidatorUtil { diff --git a/lib/shared/widgets/drawer_widget/drawer_widget.dart b/lib/shared/widgets/drawer_widget/drawer_widget.dart index 5636717f..6518abb6 100644 --- a/lib/shared/widgets/drawer_widget/drawer_widget.dart +++ b/lib/shared/widgets/drawer_widget/drawer_widget.dart @@ -64,11 +64,9 @@ class CustomDrawer extends StatelessWidget { height: 80.0, fit: BoxFit.cover, alignment: Alignment.center, - placeholder: (context, url) => - Image.asset('assets/images/person.jpg'), + placeholder: (context, url) => Image.asset('assets/images/person.jpg'), errorListener: (_) => Image.asset('assets/images/person.jpg'), - errorWidget: (_, __, ___) => - Image.asset('assets/images/person.jpg'), + errorWidget: (_, __, ___) => Image.asset('assets/images/person.jpg'), ), ), ), diff --git a/lib/shared/widgets/image_cropper_widget/image_cropper.dart b/lib/shared/widgets/image_cropper_widget/image_cropper.dart index 36cefae4..ac8dd871 100644 --- a/lib/shared/widgets/image_cropper_widget/image_cropper.dart +++ b/lib/shared/widgets/image_cropper_widget/image_cropper.dart @@ -12,7 +12,7 @@ // import 'package:crop_your_image/crop_your_image.dart'; // import 'package:google_fonts/google_fonts.dart'; -// import '/backend/firebase_storage/storage.dart'; +// import '/backend/firebase_storage/base_storage.dart'; // ///////////////// diff --git a/lib/shared/widgets/menu.dart b/lib/shared/widgets/menu.dart index affa655f..7624f6e3 100644 --- a/lib/shared/widgets/menu.dart +++ b/lib/shared/widgets/menu.dart @@ -1,7 +1,5 @@ - - // // LinkedHashMap menu = LinkedHashMap.from({ -// "Schedule": +// "Schedule": // [{ // "title": "Schedule\nVisit", // "icon": Icons.settings, @@ -22,7 +20,7 @@ // "icon": Icons.calendar_today, // "route": "/Fast", // }], -// "Consult": +// "Consult": // [{ // "title": "Consult", // "icon": Icons.search, @@ -48,11 +46,11 @@ // "icon": Icons.search, // "route": "/qrcode", // }], -// "Preferences": +// "Preferences": // [{ // "title": "Preferences", // "icon": Icons.settings, // "route": "/preferences", // }], -// }); \ No newline at end of file +// });