diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart deleted file mode 100644 index 28e5df89..00000000 --- a/integration_test/app_test.dart +++ /dev/null @@ -1,209 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:hub/flutter_flow/random_data_util.dart'; -import 'package:hub/initialization.dart'; -import 'package:hub/main.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; -import 'package:integration_test/integration_test.dart'; - -late WidgetTester widget; - -void main() { - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - - group( - 'Initialization', - () { - group('Navigation', () { - setUpAll(() async => await initializeApp().then((_) async => await StorageHelper().set(SecureStorageKey.isLogged.value, 'false'))); - testWidgets('Test Welcome', (WidgetTester tester) async { - widget = tester; - await _testWelcome(); - }); - }); - - group('Terms of Use', () { - // Add tests for Terms of Use here - }); - }, - ); - - group('Authentication', () { - group('Sign in', () { - setUpAll(() async => await initializeApp().then((_) async => await StorageHelper().set(SecureStorageKey.isLogged.value, 'false'))); - testWidgets('Test Sign In', (WidgetTester tester) async { - widget = tester; - await _testSignIn(); - }); - }); - group('Sign up', () { - setUpAll(() async => await initializeApp().then((_) async => await StorageHelper().set(SecureStorageKey.isLogged.value, 'false'))); - testWidgets('Test Sign Up', (WidgetTester tester) async { - widget = tester; - await _testSignUp(); - }); - }); - group('Sign Out', () { - // Add tests for Sign Out here - }); - group('Forgot Password', () { - // setUpAll(() async => await initializeApp().then((_) => StorageUtil().isLogged = false)); - // testWidgets('Test Forgot Password', (WidgetTester tester) async { - // widget = tester; - // await _testForgotPassword(); - // }); - }); - }); - group('Localization', () { - // Add tests for Localization here - }); - group('Networking', () { - // Add tests for Networking here - }); - group('Functionality', () { - // Add tests for Functionality here - }); - group('Usability', () { - // Add tests for Usability here - }); - group('Performance', () { - // Add tests for Performance here - }); - group('Security', () { - // Add tests for Security here - }); - group('Accessibility', () { - // Add tests for Accessibility here - }); - group('Compatibility', () { - // Add tests for Compatibility here - }); - group('Internationalization', () { - // Add tests for Internationalization here - }); -} - -Future _testWelcome() async { - await widget.pumpWidget(const App()); - await widget.pumpAndSettle(); - await _navigateToSignIn(); - await _navigateToSignUp(); - await widget.pumpAndSettle(); - await widget.pumpWidget(const App()); - await widget.pumpAndSettle(); - await _navigateToSignUp(); - await _navigateToSignIn(); - await widget.pumpAndSettle(); -} - -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'}); -} - -Future _testSignUp() async { - await widget.pumpWidget(const App()); - await _navigateToSignUp(); - - var credentials = {'nameTextFormField': 'app', 'emailTextFormField': 'email_app@exemplo.com', 'passwordTextFormField': '12345678'}; - await _auth(credentials); - - var name = randomString(7, 7, true, true, true); - var email = '$name@example.com'; - var password = '12345678'; - credentials = {'nameTextFormField': name, 'emailTextFormField': email, 'passwordTextFormField': password}; - await _navigateToSignUp(); - await _auth(credentials); - credentials = {'emailTextFormField': email, 'passwordTextFormField': password}; - await _auth(credentials); -} - -Future _testForgotPassword() async { - await widget.pumpWidget(const App()); - await _navigateToSignIn(); - await _recoveryPassword(); - - var addr = randomString(5, 5, true, true, true); - var credentials = {'recoveryTextFormField': '$addr@exemple.com'}; - await _send(credentials); - - await Future.delayed(const Duration(seconds: 2)); - - await _recoveryPassword(); - credentials = {'recoveryTextFormField': 'email_app@exemple.com'}; - await _send(credentials); -} - -Future _recoveryPassword() async { - await widget.pumpAndSettle(); - 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); -Future _navigateToSignUp() async { - await widget.pumpAndSettle(); - final Finder navToSignUp = find.byKey(const ValueKey('toggleSignUpPage')); - if (navToSignUp.evaluate().isNotEmpty) { - await widget.tap(navToSignUp); - await widget.pumpAndSettle(); - } -} - -Future _navigateToSignIn() async { - await widget.pumpAndSettle(); - final Finder navToSignIn = find.byKey(const ValueKey('toggleSignInPage')); - expect(navToSignIn, findsOneWidget); - if (navToSignIn.evaluate().isNotEmpty) { - await widget.tap(navToSignIn); - await widget.pumpAndSettle(); - } -} - -Future _auth(Map credentials) async { - await _enterCredentials(credentials); - await _submit('SubmitButtonWidget'); -} - -Future _send(Map credentials) async { - await _enterCredentials(credentials); - await _submit('SendButtonWidget'); -} - -Future _enterCredentials(Map credentials) async { - await widget.pumpAndSettle(); - for (var entry in credentials.entries) { - final Finder field = find.byKey(ValueKey(entry.key)); - await widget.pumpAndSettle(); - expect(field, findsOneWidget); - await widget.enterText(field, entry.value); - await widget.pumpAndSettle(); - } - await widget.pumpAndSettle(); -} - -Future _submit(String key) async { - await widget.pumpAndSettle(); - final Finder submitButton = find.byKey(ValueKey(key)); - await widget.pumpAndSettle(); - if (submitButton.evaluate().isNotEmpty) { - await widget.tap(submitButton); - await widget.pumpAndSettle(); - } - - final Finder throwExceptionWidget = find.byKey(const ValueKey('ThrowExceptionWidget')); - await widget.pumpAndSettle(); - if (throwExceptionWidget.evaluate().isNotEmpty) { - await widget.ensureVisible(throwExceptionWidget); - await widget.tap(throwExceptionWidget); - await widget.pumpAndSettle(); - } else { - await _navigateBackUsingSystemGesture(); - } -} diff --git a/integration_test/features/provisional_history_test.dart b/integration_test/features/provisional_history_test.dart deleted file mode 100644 index a95362d5..00000000 --- a/integration_test/features/provisional_history_test.dart +++ /dev/null @@ -1,45 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; -import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; -import 'package:hub/initialization.dart'; -import 'package:hub/main.dart' as app; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; -import 'package:integration_test/integration_test.dart'; - -void main() { - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - - group('ProvisionalHistoryPage Integration Test', () { - setUpAll(() async => await initializeApp().then((_) async { - await StorageHelper().set(SecureStorageKey.isLogged.value, 'true'); - await StorageHelper().set(SecureStorageKey.haveLocal.value, 'true'); - await StorageHelper().set(KeychainStorageKey.devUUID.value, 'b5c3818753e76d85'); - await StorageHelper().set(KeychainStorageKey.userUUID.value, '649c45d7514a28.85876308'); - await StorageHelper().set(KeychainStorageKey.clientUUID.value, '7'); - })); - - testWidgets('Filter Provisional History', (WidgetTester tester) async { - app.main(); - await tester.pumpAndSettle(); - - final Finder menuButton = find.byIcon(Icons.person_search_outlined); - await tester.tap(menuButton); - await tester.pumpAndSettle(); - - final Finder filterButton = find.byIcon(Icons.filter_list); - await tester.tap(filterButton); - await tester.pumpAndSettle(); - - final Finder activeFilterOption = find.text('Active'); - await tester.tap(activeFilterOption); - await tester.pumpAndSettle(); - - final Finder applyFilterButton = find.text('Apply'); - await tester.tap(applyFilterButton); - await tester.pumpAndSettle(); - - expect(find.byType(CardItemTemplateComponentWidget), findsWidgets); - }); - }); -} diff --git a/lib/backend/schema/structs/index.dart b/lib/backend/schema/structs/index.dart deleted file mode 100644 index 4affa264..00000000 --- a/lib/backend/schema/structs/index.dart +++ /dev/null @@ -1,3 +0,0 @@ -export '/backend/schema/util/schema_util.dart'; - -export 'device_struct.dart'; diff --git a/lib/shared/components/molecules/locals/data/models/index.dart b/lib/components/_template_/bloc/bloc.dart similarity index 100% rename from lib/shared/components/molecules/locals/data/models/index.dart rename to lib/components/_template_/bloc/bloc.dart diff --git a/lib/shared/components/molecules/locals/domain/entities/index.dart b/lib/components/_template_/bloc/event.dart similarity index 100% rename from lib/shared/components/molecules/locals/domain/entities/index.dart rename to lib/components/_template_/bloc/event.dart diff --git a/lib/shared/components/molecules/locals/domain/usecases/index.dart b/lib/components/_template_/bloc/index.dart similarity index 100% rename from lib/shared/components/molecules/locals/domain/usecases/index.dart rename to lib/components/_template_/bloc/index.dart diff --git a/lib/shared/components/molecules/menu/data/models/index.dart b/lib/components/_template_/bloc/state.dart similarity index 100% rename from lib/shared/components/molecules/menu/data/models/index.dart rename to lib/components/_template_/bloc/state.dart diff --git a/lib/shared/components/molecules/menu/domain/respositories/index.dart b/lib/components/_template_/index.dart similarity index 100% rename from lib/shared/components/molecules/menu/domain/respositories/index.dart rename to lib/components/_template_/index.dart diff --git a/lib/shared/components/molecules/menu/domain/usecases/index.dart b/lib/components/_template_/view_model/index.dart similarity index 100% rename from lib/shared/components/molecules/menu/domain/usecases/index.dart rename to lib/components/_template_/view_model/index.dart diff --git a/lib/shared/components/molecules/modules/domain/usecases/index.dart b/lib/components/_template_/view_model/view_model.dart similarity index 100% rename from lib/shared/components/molecules/modules/domain/usecases/index.dart rename to lib/components/_template_/view_model/view_model.dart diff --git a/lib/shared/components/molecules/modules/presentation/blocs/index.dart b/lib/components/_template_/widgets/index.dart similarity index 100% rename from lib/shared/components/molecules/modules/presentation/blocs/index.dart rename to lib/components/_template_/widgets/index.dart diff --git a/lib/shared/components/molecules/modules/presentation/widgets/index.dart b/lib/components/_template_/widgets/screen.dart similarity index 100% rename from lib/shared/components/molecules/modules/presentation/widgets/index.dart rename to lib/components/_template_/widgets/screen.dart diff --git a/lib/shared/components/templates/history/history_page_template.dart b/lib/components/_template_/widgets/widget.dart similarity index 100% rename from lib/shared/components/templates/history/history_page_template.dart rename to lib/components/_template_/widgets/widget.dart diff --git a/lib/shared/components/atoms/image_cropper/image_cropper.dart b/lib/components/atomic_components/image_cropper/image_cropper.dart similarity index 100% rename from lib/shared/components/atoms/image_cropper/image_cropper.dart rename to lib/components/atomic_components/image_cropper/image_cropper.dart diff --git a/lib/shared/components/atoms/term_of_use/atom_terms_of_use.dart b/lib/components/atomic_components/term_of_use/atom_terms_of_use.dart similarity index 100% rename from lib/shared/components/atoms/term_of_use/atom_terms_of_use.dart rename to lib/components/atomic_components/term_of_use/atom_terms_of_use.dart 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 58be572b..69222d34 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 @@ -1,16 +1,15 @@ import 'package:flutter/material.dart'; import 'package:hub/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_model.dart'; import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; +import 'package:hub/features/backend/index.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/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 '../../../shared/services/authentication/authentication_service.dart'; -import '/backend/api_requests/api_calls.dart'; import '/flutter_flow/flutter_flow_theme.dart'; class BottomArrowLinkedLocalsComponentWidget extends StatefulWidget { @@ -105,10 +104,10 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State _fetchResponseLink(String status, String cliID) async { try { - await StorageHelper().set(KeychainStorageKey.clientUUID.value, cliID); + await StorageHelper().set(ProfileStorageKey.clientUUID.key, cliID); 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") - }; + return {'error': false, 'error_msg': FFLocalizations.of(context).getVariableText(ptText: "Vínculo Ativado com Sucesso", enText: "Link Activated Successfully")}; } else { - await StorageHelper().set(KeychainStorageKey.clientUUID.value, ''); + await StorageHelper().set(ProfileStorageKey.clientUUID.key, ''); return response.jsonBody; } } catch (e, s) { @@ -156,9 +151,8 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State _labelsHashMap(dynamic local) { - return Map.from({ - '${local['CLI_PREFIXO']}:': local['CLI_NOME'], - '${FFLocalizations.of(context).getVariableText(ptText: 'Propriedade', enText: 'Property')}:': - local['CLU_OWNER_DSC'] - }); + return Map.from( + {'${local['CLI_PREFIXO']}:': local['CLI_NOME'], '${FFLocalizations.of(context).getVariableText(ptText: 'Propriedade', enText: 'Property')}:': local['CLU_OWNER_DSC']}); } 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 }); } @@ -196,10 +184,10 @@ class _BottomArrowLinkedLocalsComponentWidgetState extends State initDB() async { - devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; } @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 29f8f48d..508e10d6 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 @@ -1,8 +1,8 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/components/organism_components/schedule_visit_detail/schedule_visit_detail_model.dart'; +import 'package:hub/features/backend/index.dart'; import 'package:hub/flutter_flow/custom_functions.dart'; import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; @@ -199,15 +199,13 @@ class _ScheduleVisitDetailWidgetState 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), ), 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( @@ -241,8 +239,7 @@ class _ScheduleVisitDetailWidgetState 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), ), validator: _model.textController1Validator.asValidator(context), ), @@ -273,8 +270,7 @@ class _ScheduleVisitDetailWidgetState 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: FFLocalizations.of(context).getText( '0cp1e31d' /* dd/mm/yyyy */, @@ -283,8 +279,7 @@ class _ScheduleVisitDetailWidgetState 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), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( @@ -319,8 +314,7 @@ class _ScheduleVisitDetailWidgetState extends State { fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, fontSize: 12, - useGoogleFonts: GoogleFonts.asMap() - .containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), textAlign: TextAlign.center, validator: _model.textController2Validator.asValidator(context), @@ -345,8 +339,7 @@ class _ScheduleVisitDetailWidgetState 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: FFLocalizations.of(context).getText( 'kqralft4' /* dd/mm/yyyy */, @@ -355,8 +348,7 @@ class _ScheduleVisitDetailWidgetState 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), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( @@ -391,8 +383,7 @@ class _ScheduleVisitDetailWidgetState extends State { fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, fontSize: 12, - useGoogleFonts: GoogleFonts.asMap() - .containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), textAlign: TextAlign.center, validator: _model.textController3Validator.asValidator(context), @@ -426,8 +417,7 @@ class _ScheduleVisitDetailWidgetState 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: FFLocalizations.of(context).getText( '47oezdm6' /* Motivo */, @@ -436,8 +426,7 @@ class _ScheduleVisitDetailWidgetState 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), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( @@ -471,8 +460,7 @@ class _ScheduleVisitDetailWidgetState 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), ), textAlign: TextAlign.center, validator: _model.textController4Validator.asValidator(context), @@ -497,8 +485,7 @@ class _ScheduleVisitDetailWidgetState 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: FFLocalizations.of(context).getText( '3emmbbfv' /* Nível de Acesso */, @@ -507,8 +494,7 @@ class _ScheduleVisitDetailWidgetState 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), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( @@ -542,8 +528,7 @@ class _ScheduleVisitDetailWidgetState 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), ), textAlign: TextAlign.center, validator: _model.textController5Validator.asValidator(context), @@ -572,15 +557,13 @@ class _ScheduleVisitDetailWidgetState 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), ), 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( @@ -614,8 +597,7 @@ class _ScheduleVisitDetailWidgetState 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), ), validator: _model.textController6Validator.asValidator(context), ), 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 87665faa..b07f502c 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,8 +1,7 @@ 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/features/storage/index.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; class UpArrowLinkedLocalsComponentModel extends FlutterFlowModel { late final String devUUID; @@ -16,10 +15,10 @@ class UpArrowLinkedLocalsComponentModel extends FlutterFlowModel initDB() async { - devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; - cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; + devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; + cliName = (await StorageHelper().get(ProfileStorageKey.clientName.key)) ?? ''; } @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 d371a85b..2cadee92 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 @@ -2,8 +2,8 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/components/organism_components/up_arrow_linked_locals_component/up_arrow_linked_locals_component_model.dart'; +import 'package:hub/features/backend/index.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'; @@ -166,8 +166,7 @@ class _UpArrowLinkedLocalsComponentWidgetState extends State { +class AccessNotificationModalTemplateComponentModel extends FlutterFlowModel { late final String devUUID; late final String userUUID; late final String cliUUID; @@ -32,9 +30,9 @@ class AccessNotificationModalTemplateComponentModel } Future initDB() async { - devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; } @override 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 e361442d..872d04e7 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 @@ -2,9 +2,8 @@ import 'package:easy_debounce/easy_debounce.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; @@ -148,8 +147,7 @@ class _PassKeyTemplateWidgetState extends State { Padding( 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'), + FFLocalizations.of(context).getVariableText(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, @@ -246,9 +244,7 @@ class _PassKeyTemplateWidgetState extends State { ), focusNode: FocusNode(skipTraversal: true), child: Icon( - _model.keyTextFieldVisibility1 - ? Icons.visibility_outlined - : Icons.visibility_off_outlined, + _model.keyTextFieldVisibility1 ? Icons.visibility_outlined : Icons.visibility_off_outlined, color: FlutterFlowTheme.of(context).accent1, size: 22.0, ), @@ -288,9 +284,7 @@ class _PassKeyTemplateWidgetState extends State { return; } await widget.toggleActionStatus?.call( - _model.keyTextFieldTextController1.text.isEmpty - ? _model.keyTextFieldTextController2.text - : _model.keyTextFieldTextController1.text, + _model.keyTextFieldTextController1.text.isEmpty ? _model.keyTextFieldTextController2.text : _model.keyTextFieldTextController1.text, ); // Navigator.pop(context, true); context.pop(true); 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 aff803ff..17bb87d4 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 @@ -1,6 +1,6 @@ +import 'package:hub/features/backend/index.dart'; 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 'package:flutter/material.dart'; 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 9feeeed9..ce4e0d6e 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 @@ -1,8 +1,8 @@ import 'package:easy_debounce/easy_debounce.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; +import 'package:hub/features/authentication/index.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/services/authentication/authentication_service.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; import 'package:hub/shared/utils/validator_util.dart'; @@ -237,8 +237,7 @@ class _ForgotPasswordTemplateComponentWidgetState extends State('SendButtonWidget'), - onPressed: (_model.emailAddressTextController.text == '' || - !ValidatorUtil.isValidEmail(_model.emailAddressTextController.text)) + onPressed: (_model.emailAddressTextController.text == '' || !ValidatorUtil.isValidEmail(_model.emailAddressTextController.text)) ? null : () async => await AuthenticationService.forgotPassword( context, 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 4a9c55bb..de73c3d2 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,9 @@ 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/features/storage/index.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; -class LiberationHistoryItemDetailsTemplateComponentModel - extends FlutterFlowModel { +class LiberationHistoryItemDetailsTemplateComponentModel extends FlutterFlowModel { late final String devUUID; late final String userUUID; late final String cliUUID; @@ -27,9 +25,9 @@ class LiberationHistoryItemDetailsTemplateComponentModel void initState(BuildContext context) {} Future initDatabase() async { - devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; ; } 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 95937bac..9c75170a 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,10 @@ 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/features/backend/index.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; class ScheduleProvisionalVisitPageModel extends FlutterFlowModel { String cliUUID = ''; @@ -88,8 +87,7 @@ class ScheduleProvisionalVisitPageModel extends FlutterFlowModel init() async { - devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; - ownerName = (await StorageHelper().get(KeychainStorageKey.ownerName.value)) ?? ''; - ownerUUID = (await StorageHelper().get(KeychainStorageKey.ownerUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; + ownerName = (await StorageHelper().get(ProfileStorageKey.ownerName.key)) ?? ''; + ownerUUID = (await StorageHelper().get(ProfileStorageKey.ownerUUID.key)) ?? ''; 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 debd346b..46c14402 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 @@ -4,11 +4,11 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/components/templates_components/provisional_schedule_template/provisional_schedule_template_model.dart'; +import 'package:hub/features/backend/index.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 '/backend/api_requests/api_calls.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; import '/flutter_flow/flutter_flow_widgets.dart'; @@ -75,8 +75,7 @@ class _ScheduleProvisionalVisitPageWidgetState extends State initializeDatabase() async { - devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; ; } 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 b1c7d7ad..992e1b10 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 @@ -3,13 +3,13 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/components/atomic_components/shared_components_atoms/media_upload_button.dart'; +import 'package:hub/features/backend/index.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/validator_util.dart'; import 'package:rxdart/rxdart.dart'; -import '/backend/api_requests/api_calls.dart'; import '/flutter_flow/flutter_flow_drop_down.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; @@ -103,9 +103,7 @@ class _RegisiterVistorTemplateComponentWidgetState extends State { } Future initializeDatabase() async { - devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; ; } 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 ead69613..f8149467 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 @@ -1,11 +1,11 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; +import 'package:hub/features/backend/index.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:share_plus/share_plus.dart'; -import '/backend/api_requests/api_calls.dart'; import '/flutter_flow/flutter_flow_icon_button.dart'; import '/flutter_flow/flutter_flow_theme.dart'; import '/flutter_flow/flutter_flow_util.dart'; @@ -85,8 +85,7 @@ 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); @@ -257,15 +256,13 @@ class _ViewVisitDetailWidgetState 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), ), 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( @@ -299,8 +296,7 @@ class _ViewVisitDetailWidgetState 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), ), validator: _model.textController1Validator.asValidator(context), ), @@ -332,8 +328,7 @@ class _ViewVisitDetailWidgetState 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: FFLocalizations.of(context).getText( 'ub084nhy' /* dd/mm/yyyy */, @@ -342,8 +337,7 @@ class _ViewVisitDetailWidgetState 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), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( @@ -377,8 +371,7 @@ class _ViewVisitDetailWidgetState 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), ), textAlign: TextAlign.center, validator: _model.textController2Validator.asValidator(context), @@ -405,8 +398,7 @@ class _ViewVisitDetailWidgetState 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: FFLocalizations.of(context).getText( 'ixs67mrz' /* dd/mm/yyyy */, @@ -415,8 +407,7 @@ class _ViewVisitDetailWidgetState 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), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( @@ -450,8 +441,7 @@ class _ViewVisitDetailWidgetState 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), ), textAlign: TextAlign.center, validator: _model.textController3Validator.asValidator(context), @@ -487,8 +477,7 @@ class _ViewVisitDetailWidgetState 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: FFLocalizations.of(context).getText( 'ypeydbem' /* Motivo */, @@ -497,8 +486,7 @@ class _ViewVisitDetailWidgetState 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), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( @@ -532,8 +520,7 @@ class _ViewVisitDetailWidgetState 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), ), textAlign: TextAlign.center, validator: _model.textController4Validator.asValidator(context), @@ -560,8 +547,7 @@ class _ViewVisitDetailWidgetState 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: FFLocalizations.of(context).getText( 'rs3d4gb8' /* Nível de Acesso */, @@ -570,8 +556,7 @@ class _ViewVisitDetailWidgetState 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), ), enabledBorder: OutlineInputBorder( borderSide: BorderSide( @@ -605,8 +590,7 @@ class _ViewVisitDetailWidgetState 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), ), textAlign: TextAlign.center, validator: _model.textController5Validator.asValidator(context), @@ -637,15 +621,13 @@ class _ViewVisitDetailWidgetState 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), ), 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( @@ -679,8 +661,7 @@ class _ViewVisitDetailWidgetState 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), ), validator: _model.textController6Validator.asValidator(context), ), @@ -754,10 +735,7 @@ class _ViewVisitDetailWidgetState extends State { ), ], ); - } else if ((widget.visitStatusStr == 'C') || - (widget.visitStatusStr == 'F') || - (widget.visitStatusStr == 'B') || - (widget.visitStatusStr == 'I')) { + } else if ((widget.visitStatusStr == 'C') || (widget.visitStatusStr == 'F') || (widget.visitStatusStr == 'B') || (widget.visitStatusStr == 'I')) { return InkWell( splashColor: Colors.transparent, focusColor: Colors.transparent, 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 e71a2c86..b6301fee 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 @@ -1,9 +1,8 @@ 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/features/backend/index.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; class VisitorSearchModalTemplateComponentModel extends FlutterFlowModel { late final String devUUID; @@ -35,9 +34,9 @@ class VisitorSearchModalTemplateComponentModel extends FlutterFlowModel initDatabase() async { - devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; ; } 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 6c3ea0f2..6ceaf2c1 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 @@ -1,14 +1,12 @@ -import 'dart:developer'; - import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/components/atomic_components/shared_components_atoms/toast.dart'; import 'package:hub/components/molecular_components/visitor_not_found_component/visitor_not_found_component_widget.dart'; import 'package:hub/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_model.dart'; +import 'package:hub/features/backend/index.dart'; 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'; @@ -30,8 +28,7 @@ class VisitorSearchModalTemplateComponentWidget extends StatefulWidget { State createState() => _VisitorSearchModalTemplateComponentWidgetState(); } -class _VisitorSearchModalTemplateComponentWidgetState extends State - with TickerProviderStateMixin { +class _VisitorSearchModalTemplateComponentWidgetState extends State with TickerProviderStateMixin { late VisitorSearchModalTemplateComponentModel _model; safeSetState(VoidCallback callback) { @@ -106,34 +103,22 @@ class _VisitorSearchModalTemplateComponentWidgetState extends State login(BuildContext context) async { @@ -74,7 +67,7 @@ class AuthenticationService { if ((email != '') && (passwd != '')) { await StorageHelper().set(SecureStorageKey.email.value, email); await StorageHelper().set(SecureStorageKey.password.value, passwd); - await StorageHelper().set(KeychainStorageKey.devUUID.value, devUUID!); + await StorageHelper().set(ProfileStorageKey.devUUID.key, devUUID!); response = await callback.call(); if (response.jsonBody['error'] == false) { @@ -83,10 +76,10 @@ class AuthenticationService { userDevUUID = response.jsonBody['user']['dev_id']; userName = response.jsonBody['user']['name']; - await StorageHelper().set(KeychainStorageKey.userUUID.value, userUUID); - await StorageHelper().set(KeychainStorageKey.userDevUUID.value, userDevUUID); - await StorageHelper().set(KeychainStorageKey.status.value, status); - await StorageHelper().set(KeychainStorageKey.userName.value, userName); + await StorageHelper().set(ProfileStorageKey.userUUID.key, userUUID); + await StorageHelper().set(ProfileStorageKey.userDevUUID.key, userDevUUID); + await StorageHelper().set(ProfileStorageKey.status.key, status); + await StorageHelper().set(ProfileStorageKey.userName.key, userName); await login(context); } else { @@ -113,9 +106,7 @@ class AuthenticationService { }) 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, @@ -153,7 +144,7 @@ class AuthenticationService { await StorageHelper().clean(Storage.databaseStorage); await StorageHelper().clean(Storage.secureStorage); await LicenseRepositoryImpl().cleanLicense(); - DatabaseStorage.isInitialized = false; + DatabaseService.isInitialized = false; await StorageHelper().init(); context.go('/welcomePage', extra: extra); @@ -163,8 +154,7 @@ class AuthenticationService { 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); @@ -184,8 +174,7 @@ class AuthenticationService { 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( @@ -216,7 +205,6 @@ class AuthenticationService { ptText: 'Conta deletada com sucesso', ); return await signOut(context); - } }).catchError((err) { context.pop(); @@ -224,8 +212,8 @@ class AuthenticationService { enText: 'Error deleting account', ptText: 'Erro ao deletar conta', ); - SnackBarUtil.showSnackBar(context, content); - return; + SnackBarUtil.showSnackBar(context, content); + return; }); } catch (err) { context.pop(); diff --git a/lib/features/authentication/index.dart b/lib/features/authentication/index.dart new file mode 100644 index 00000000..c2aa7540 --- /dev/null +++ b/lib/features/authentication/index.dart @@ -0,0 +1 @@ +export 'authentication_service.dart'; diff --git a/lib/backend/api_requests/api_calls.dart b/lib/features/backend/api_requests/api_calls.dart similarity index 86% rename from lib/backend/api_requests/api_calls.dart rename to lib/features/backend/api_requests/api_calls.dart index 06f7bf5b..70f1aee6 100644 --- a/lib/backend/api_requests/api_calls.dart +++ b/lib/features/backend/api_requests/api_calls.dart @@ -3,9 +3,9 @@ import 'dart:convert'; import 'dart:developer'; import 'package:flutter/foundation.dart'; -import 'package:hub/backend/notifications/firebase_messaging_service.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; +import 'package:hub/features/notifications/index.dart'; +import 'package:hub/features/storage/index.dart'; + import 'package:hub/shared/utils/log_util.dart'; import 'package:hub/shared/utils/validator_util.dart'; @@ -65,9 +65,9 @@ class PhpGroup { class GetProvSchedules { Future call(final String page, final String status) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'getAgendamentoProv'; const String pageSize = '10'; final bool isFiltered = status != '' && status != '.*'; @@ -100,9 +100,9 @@ class GetProvSchedules { class GetOpenedVisits { Future call(final String page) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'getOpenedVisits'; const String pageSize = '10'; return await ApiManager.instance.makeApiCall( @@ -132,9 +132,9 @@ class GetOpenedVisits { class GetResidentsByProperty { Future call(final String page) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = await StorageHelper().get(KeychainStorageKey.devUUID.value) ?? ''; - final String userUUID = await StorageHelper().get(KeychainStorageKey.userUUID.value) ?? ''; - final String cliID = await StorageHelper().get(KeychainStorageKey.clientUUID.value) ?? ''; + final String devUUID = await StorageHelper().get(ProfileStorageKey.devUUID.key) ?? ''; + final String userUUID = await StorageHelper().get(ProfileStorageKey.userUUID.key) ?? ''; + final String cliID = await StorageHelper().get(ProfileStorageKey.clientUUID.key) ?? ''; const String atividade = 'getResidentsByProperty'; const String pageSize = '10'; return await ApiManager.instance.makeApiCall( @@ -163,9 +163,9 @@ class GetResidentsByProperty { class GetVehiclesByProperty { Future call(final String page) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'getVehiclesByProperty'; const String pageSize = '10'; return await ApiManager.instance.makeApiCall( @@ -196,9 +196,9 @@ class GetVehiclesByProperty { class GetLicense { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; return await ApiManager.instance.makeApiCall( callName: 'getLicense', @@ -227,8 +227,8 @@ class GetLicense { class UnregisterDevice { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; return await ApiManager.instance.makeApiCall( callName: 'unregisterDevice', @@ -255,9 +255,9 @@ class UnregisterDevice { class DeletePet { Future call({final int? petID = 0}) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'excluirPet'; return await ApiManager.instance.makeApiCall( @@ -300,9 +300,9 @@ class UpdatePet { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'atualizarPet'; return await ApiManager.instance.makeApiCall( @@ -346,9 +346,9 @@ class GetPets { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'consultaPets'; return await ApiManager.instance.makeApiCall( @@ -380,9 +380,9 @@ class GetPetPhoto { Future call({final int? petId}) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'consultaFotoPet'; return await ApiManager.instance.makeApiCall( @@ -423,9 +423,9 @@ class RegisterPet { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'cadastrarPet'; return await ApiManager.instance.makeApiCall( @@ -468,9 +468,9 @@ class BuscaEnconcomendas { final String? adresseeType, final String? status, }) async { - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'getEncomendas'; final String baseUrl = PhpGroup.getBaseUrl(); @@ -512,9 +512,9 @@ class CancelaVisita { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'cancelaVisita'; return await ApiManager.instance.makeApiCall( @@ -546,8 +546,8 @@ class CancelaVisita { class DeleteAccount { Future call() async { - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; final String baseUrl = PhpGroup.getBaseUrl(); return await ApiManager.instance.makeApiCall( @@ -578,9 +578,9 @@ class ChangePanic { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'updVisitado'; return await ApiManager.instance.makeApiCall( @@ -614,9 +614,9 @@ class ChangePass { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'updVisitado'; return await ApiManager.instance.makeApiCall( @@ -650,9 +650,9 @@ class RespondeVinculo { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; return await ApiManager.instance.makeApiCall( callName: 'respondeVinculo', @@ -684,9 +684,9 @@ class ChangeNotifica { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'updVisitado'; return await ApiManager.instance.makeApiCall( @@ -718,10 +718,10 @@ class UpdateIDE { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; - final String newIde = (await StorageHelper().get(KeychainStorageKey.userDevUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; + final String newIde = (await StorageHelper().get(ProfileStorageKey.userDevUUID.key)) ?? ''; const String atividade = 'updVisitado'; return await ApiManager.instance.makeApiCall( @@ -753,8 +753,8 @@ class UpdToken { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; final String token = (await StorageHelper().get(SecureStorageKey.token.value)) ?? ''; return await ApiManager.instance.makeApiCall( @@ -782,7 +782,7 @@ class UpdToken { class LoginCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; final String email = (await StorageHelper().get(SecureStorageKey.email.value)) ?? ''; final String password = (await StorageHelper().get(SecureStorageKey.password.value)) ?? ''; final String type = (await StorageHelper().get(SecureStorageKey.deviceType.value)) ?? ''; @@ -869,9 +869,9 @@ class ChangePasswordCall { required final String psswd, }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; return await ApiManager.instance.makeApiCall( callName: 'changePassword', @@ -930,8 +930,8 @@ class GetLocalsCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = await StorageHelper().get(KeychainStorageKey.devUUID.value) ?? ''; - final String userUUID = await StorageHelper().get(KeychainStorageKey.userUUID.value) ?? ''; + final String devUUID = await StorageHelper().get(ProfileStorageKey.devUUID.key) ?? ''; + final String userUUID = await StorageHelper().get(ProfileStorageKey.userUUID.key) ?? ''; return await ApiManager.instance .makeApiCall( @@ -972,9 +972,9 @@ class PostScheduleVisitorCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'putVisitante'; return await ApiManager.instance.makeApiCall( @@ -1027,9 +1027,9 @@ class PostScheduleVisitCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'putVisita'; return await ApiManager.instance.makeApiCall( @@ -1081,9 +1081,9 @@ class GetScheduleVisitCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'getVisitas'; return await ApiManager.instance.makeApiCall( @@ -1355,32 +1355,34 @@ class GetDadosCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'getDados'; - return await ApiManager.instance.makeApiCall( - callName: 'getDados', - apiUrl: '$baseUrl/processRequest.php', - callType: ApiCallType.POST, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - }, - params: { - 'devUUID': devUUID, - 'userUUID': userUUID, - 'cliID': cliUUID, - 'atividade': atividade, - }, - bodyType: BodyType.X_WWW_FORM_URL_ENCODED, - returnBody: true, - encodeBodyUtf8: false, - decodeUtf8: false, - cache: false, - isStreamingApi: false, - alwaysAllowBody: false, - ).timeout(const Duration(seconds: 30)); + return await ApiManager.instance + .makeApiCall( + callName: 'getDados', + apiUrl: '$baseUrl/processRequest.php', + callType: ApiCallType.POST, + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + params: { + 'devUUID': devUUID, + 'userUUID': userUUID, + 'cliID': cliUUID, + 'atividade': atividade, + }, + bodyType: BodyType.X_WWW_FORM_URL_ENCODED, + returnBody: true, + encodeBodyUtf8: false, + decodeUtf8: false, + cache: false, + isStreamingApi: false, + alwaysAllowBody: false, + ) + .timeout(const Duration(seconds: 30)); } bool? errorBolean(dynamic response) => castToType(getJsonField( @@ -1588,9 +1590,9 @@ class GetVisitorByDocCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'getVisitante'; return await ApiManager.instance.makeApiCall( @@ -1642,9 +1644,9 @@ class GetFotoVisitanteCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'getFotoVisitante'; return await ApiManager.instance.makeApiCall( @@ -1681,9 +1683,9 @@ class PostProvVisitSchedulingCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'putAgendamentoProv'; return await ApiManager.instance.makeApiCall( @@ -1730,9 +1732,9 @@ class GetVisitsCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'getVisitas'; return await ApiManager.instance.makeApiCall( @@ -1993,9 +1995,9 @@ class DeleteVisitCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'cancelaVisita'; return await ApiManager.instance.makeApiCall( @@ -2036,10 +2038,10 @@ class GetPessoasLocalCall { Future call() async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String ownerUUID = (await StorageHelper().get(KeychainStorageKey.ownerUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String ownerUUID = (await StorageHelper().get(ProfileStorageKey.ownerUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; return await ApiManager.instance.makeApiCall( callName: 'getPessoasLocal', @@ -2102,9 +2104,9 @@ class RespondeSolicitacaoCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'respondeSolicitacao'; return await ApiManager.instance.makeApiCall( @@ -2152,9 +2154,9 @@ class GetAccessCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'getAcessos'; return await ApiManager.instance.makeApiCall( @@ -2401,9 +2403,9 @@ class GetLiberationsCall { final StreamController controller = StreamController(); Future.microtask(() async { - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'getSolicitacoes'; try { @@ -2593,9 +2595,9 @@ class GetMessagesCall { }) async { final String baseUrl = PhpGroup.getBaseUrl(); - final String devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final String userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final String devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final String userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final String cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const String atividade = 'getMensagens'; return await ApiManager.instance.makeApiCall( diff --git a/lib/backend/api_requests/api_manager.dart b/lib/features/backend/api_requests/api_manager.dart similarity index 100% rename from lib/backend/api_requests/api_manager.dart rename to lib/features/backend/api_requests/api_manager.dart diff --git a/lib/backend/api_requests/get_streamed_response.dart b/lib/features/backend/api_requests/get_streamed_response.dart similarity index 100% rename from lib/backend/api_requests/get_streamed_response.dart rename to lib/features/backend/api_requests/get_streamed_response.dart diff --git a/lib/features/backend/api_requests/index.dart b/lib/features/backend/api_requests/index.dart new file mode 100644 index 00000000..880f01b3 --- /dev/null +++ b/lib/features/backend/api_requests/index.dart @@ -0,0 +1,3 @@ +export 'api_calls.dart'; +export 'api_manager.dart'; +export 'get_streamed_response.dart'; diff --git a/lib/features/backend/index.dart b/lib/features/backend/index.dart new file mode 100644 index 00000000..1301ec34 --- /dev/null +++ b/lib/features/backend/index.dart @@ -0,0 +1,2 @@ +export 'api_requests/index.dart'; +export 'schema/index.dart'; diff --git a/lib/backend/schema/enums/enums.dart b/lib/features/backend/schema/enums/enums.dart similarity index 100% rename from lib/backend/schema/enums/enums.dart rename to lib/features/backend/schema/enums/enums.dart diff --git a/lib/features/backend/schema/enums/index.dart b/lib/features/backend/schema/enums/index.dart new file mode 100644 index 00000000..815115d9 --- /dev/null +++ b/lib/features/backend/schema/enums/index.dart @@ -0,0 +1 @@ +export 'enums.dart'; diff --git a/lib/features/backend/schema/index.dart b/lib/features/backend/schema/index.dart new file mode 100644 index 00000000..5b15343c --- /dev/null +++ b/lib/features/backend/schema/index.dart @@ -0,0 +1,3 @@ +export 'enums/index.dart'; +export 'structs/index.dart'; +export 'util/index.dart'; diff --git a/lib/backend/schema/structs/device_struct.dart b/lib/features/backend/schema/structs/device_struct.dart similarity index 89% rename from lib/backend/schema/structs/device_struct.dart rename to lib/features/backend/schema/structs/device_struct.dart index 620863c4..102703cb 100644 --- a/lib/backend/schema/structs/device_struct.dart +++ b/lib/features/backend/schema/structs/device_struct.dart @@ -1,5 +1,6 @@ // ignore_for_file: unnecessary_getters_setters +import 'package:hub/features/backend/index.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; import 'index.dart'; @@ -40,8 +41,7 @@ class DeviceStruct extends BaseStruct { description: data['description'] as String?, ); - static DeviceStruct? maybeFromMap(dynamic data) => - data is Map ? DeviceStruct.fromMap(data.cast()) : null; + static DeviceStruct? maybeFromMap(dynamic data) => data is Map ? DeviceStruct.fromMap(data.cast()) : null; Map toMap() => { 'devUUID': _devUUID, @@ -88,10 +88,7 @@ class DeviceStruct extends BaseStruct { @override bool operator ==(Object other) { - return other is DeviceStruct && - devUUID == other.devUUID && - version == other.version && - description == other.description; + return other is DeviceStruct && devUUID == other.devUUID && version == other.version && description == other.description; } @override diff --git a/lib/features/backend/schema/structs/index.dart b/lib/features/backend/schema/structs/index.dart new file mode 100644 index 00000000..5bd18316 --- /dev/null +++ b/lib/features/backend/schema/structs/index.dart @@ -0,0 +1 @@ +export 'device_struct.dart'; diff --git a/lib/features/backend/schema/util/index.dart b/lib/features/backend/schema/util/index.dart new file mode 100644 index 00000000..ff023bbe --- /dev/null +++ b/lib/features/backend/schema/util/index.dart @@ -0,0 +1 @@ +export 'schema_util.dart'; diff --git a/lib/backend/schema/util/schema_util.dart b/lib/features/backend/schema/util/schema_util.dart similarity index 86% rename from lib/backend/schema/util/schema_util.dart rename to lib/features/backend/schema/util/schema_util.dart index d6c251d9..e969983e 100644 --- a/lib/backend/schema/util/schema_util.dart +++ b/lib/features/backend/schema/util/schema_util.dart @@ -1,8 +1,6 @@ import 'dart:convert'; -import 'package:flutter/material.dart'; -import 'package:from_css_color/from_css_color.dart'; -import 'package:hub/backend/schema/enums/enums.dart'; +import 'package:hub/features/backend/index.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/nav/serialization_util.dart'; @@ -35,9 +33,7 @@ dynamic deserializeStructParam( if (paramValues is! Iterable) { return null; } - return paramValues - .map((e) => deserializeStructParam(e, paramType, false, structBuilder: structBuilder)) - .toList(); + return paramValues.map((e) => deserializeStructParam(e, paramType, false, structBuilder: structBuilder)).toList(); } else if (param is Map) { return structBuilder(param); } else { diff --git a/lib/features/history/presentation/blocs/access_history_bloc.dart b/lib/features/history/presentation/blocs/access_history_bloc.dart index dd513e6b..61c1b9c4 100644 --- a/lib/features/history/presentation/blocs/access_history_bloc.dart +++ b/lib/features/history/presentation/blocs/access_history_bloc.dart @@ -1,10 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:hub/backend/api_requests/api_manager.dart'; +import 'package:hub/features/backend/index.dart'; import 'package:hub/features/history/index.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/flutter_flow/request_manager.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; class AcessHistoryPageModel extends FlutterFlowModel { late final String devUUID; @@ -32,9 +31,9 @@ class AcessHistoryPageModel extends FlutterFlowModel { } Future initDatabase() async { - devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; } @override diff --git a/lib/features/history/presentation/blocs/provisional_history_bloc.dart b/lib/features/history/presentation/blocs/provisional_history_bloc.dart index 2601bb51..8dfd7315 100644 --- a/lib/features/history/presentation/blocs/provisional_history_bloc.dart +++ b/lib/features/history/presentation/blocs/provisional_history_bloc.dart @@ -1,6 +1,5 @@ import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; +import 'package:hub/features/storage/index.dart'; class ProvisionalHistoryEvent {} @@ -44,9 +43,9 @@ class ProvisionalHistoryBloc extends Bloc emit, ) async { emit(state.copyWith(isLoading: true)); - final devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; emit(state.copyWith(devUUID: devUUID, userUUID: userUUID, cliUUID: cliUUID, isLoading: false)); } } diff --git a/lib/features/history/presentation/pages/acess_history_page_widget.dart b/lib/features/history/presentation/pages/acess_history_page_widget.dart index 81501e99..4c11f7f7 100644 --- a/lib/features/history/presentation/pages/acess_history_page_widget.dart +++ b/lib/features/history/presentation/pages/acess_history_page_widget.dart @@ -3,8 +3,8 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; +import 'package:hub/features/backend/index.dart'; import 'package:hub/features/history/index.dart'; import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; diff --git a/lib/features/history/presentation/pages/provisional_history_page.dart b/lib/features/history/presentation/pages/provisional_history_page.dart index bca19aec..02aca8be 100644 --- a/lib/features/history/presentation/pages/provisional_history_page.dart +++ b/lib/features/history/presentation/pages/provisional_history_page.dart @@ -4,8 +4,8 @@ import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; +import 'package:hub/features/backend/index.dart'; import 'package:hub/features/history/index.dart'; import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; diff --git a/lib/features/home/presentation/blocs/home_bloc.dart b/lib/features/home/presentation/blocs/home_bloc.dart index 5829df5f..3eb2219b 100644 --- a/lib/features/home/presentation/blocs/home_bloc.dart +++ b/lib/features/home/presentation/blocs/home_bloc.dart @@ -1,28 +1,26 @@ - import 'dart:async'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; +import 'package:hub/features/locals/index.dart'; +import 'package:hub/features/storage/index.dart'; -import '../../../../shared/components/molecules/locals/index.dart'; import 'index.dart'; class HomeBloc extends Bloc { late StreamSubscription _completer; - + HomeBloc() : super(HomeState()) { on(_onHomeEvent); _completer = LocalsRepositoryImpl.license.stream.listen((v) { add(HomeEvent()); }); - } + } - Future _onHomeEvent(HomeEvent event, Emitter emit) async { - final devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; - final userName = (await StorageHelper().get(KeychainStorageKey.userName.value)) ?? ''; + Future _onHomeEvent(HomeEvent event, Emitter emit) async { + final devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; + final userName = (await StorageHelper().get(ProfileStorageKey.userName.key)) ?? ''; final userEmail = (await StorageHelper().get(SecureStorageKey.email.value)) ?? ''; emit(state.copyWith( @@ -34,5 +32,3 @@ class HomeBloc extends Bloc { )); } } - - diff --git a/lib/features/home/presentation/pages/home_page.dart b/lib/features/home/presentation/pages/home_page.dart index 64442d3d..a4e20486 100644 --- a/lib/features/home/presentation/pages/home_page.dart +++ b/lib/features/home/presentation/pages/home_page.dart @@ -2,12 +2,12 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/features/home/presentation/widgets/drawer_widget.dart'; +import 'package:hub/features/menu/index.dart'; 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/components/molecules/locals/index.dart'; -import 'package:hub/shared/components/molecules/menu/index.dart'; +import 'package:hub/features/locals/index.dart'; class HomePageWidget extends StatefulWidget { const HomePageWidget(this.update, {super.key}); diff --git a/lib/features/home/presentation/widgets/drawer_widget.dart b/lib/features/home/presentation/widgets/drawer_widget.dart index f221d183..1a0ac823 100644 --- a/lib/features/home/presentation/widgets/drawer_widget.dart +++ b/lib/features/home/presentation/widgets/drawer_widget.dart @@ -2,12 +2,12 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:hub/features/home/index.dart'; +import 'package:hub/features/menu/index.dart'; +import 'package:hub/features/modules/data/index.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; -import 'package:hub/shared/components/molecules/locals/index.dart'; -import 'package:hub/shared/components/molecules/menu/index.dart'; -import 'package:hub/shared/components/molecules/modules/index.dart'; +import 'package:hub/features/locals/index.dart'; class DrawerWidget extends StatelessWidget { const DrawerWidget({super.key}); diff --git a/lib/shared/components/molecules/locals/data/data_sources/index.dart b/lib/features/locals/data/data_sources/index.dart similarity index 100% rename from lib/shared/components/molecules/locals/data/data_sources/index.dart rename to lib/features/locals/data/data_sources/index.dart diff --git a/lib/features/locals/data/data_sources/locals_local_data_source.dart b/lib/features/locals/data/data_sources/locals_local_data_source.dart new file mode 100644 index 00000000..32445b40 --- /dev/null +++ b/lib/features/locals/data/data_sources/locals_local_data_source.dart @@ -0,0 +1,13 @@ +import 'package:hub/features/storage/index.dart'; + +abstract class LocalsLocalDataSource { + Future unlinkLocal(); +} + +class LocalsLocalDataSourceImpl { + Future unlinkLocal() async { + await StorageHelper().set(ProfileStorageKey.clientUUID.key, ''); + await StorageHelper().set(ProfileStorageKey.clientName.key, ''); + await StorageHelper().set(ProfileStorageKey.ownerName.key, ''); + } +} diff --git a/lib/shared/components/molecules/locals/data/data_sources/locals_remote_data_source.dart b/lib/features/locals/data/data_sources/locals_remote_data_source.dart similarity index 89% rename from lib/shared/components/molecules/locals/data/data_sources/locals_remote_data_source.dart rename to lib/features/locals/data/data_sources/locals_remote_data_source.dart index 2520b990..7ccea96d 100644 --- a/lib/shared/components/molecules/locals/data/data_sources/locals_remote_data_source.dart +++ b/lib/features/locals/data/data_sources/locals_remote_data_source.dart @@ -3,26 +3,23 @@ import 'dart:developer'; import 'package:flutter/material.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/components/organism_components/bottom_arrow_linked_locals_component/bottom_arrow_linked_locals_component_widget.dart'; +import 'package:hub/features/authentication/index.dart'; +import 'package:hub/features/backend/index.dart'; +import 'package:hub/features/modules/data/index.dart'; +import 'package:hub/features/storage/index.dart'; 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/shared/components/molecules/locals/index.dart'; -import 'package:hub/shared/components/molecules/modules/index.dart'; - -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; -import 'package:hub/shared/services/authentication/authentication_service.dart'; -import 'package:hub/shared/utils/dialog_util.dart'; +import 'package:hub/features/locals/index.dart'; import 'package:hub/shared/utils/snackbar_util.dart'; abstract class LocalsRemoteDataSource { Future linkLocal(BuildContext context); Future checkLocals(BuildContext context); - Future processLocals(BuildContext context) ; + Future processLocals(BuildContext context); Future processData(BuildContext context); - Future selectLocal(BuildContext context, ApiCallResponse? response) ; + Future selectLocal(BuildContext context, ApiCallResponse? response); Future detachLocal(BuildContext context); } @@ -60,8 +57,8 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { await StorageHelper().set(SecureStorageKey.haveLocal.value, true); await StorageHelper().set(SecureStorageKey.isLogged.value, true); await WidgetsBinding.instance.endOfFrame; - await StorageHelper().set(KeychainStorageKey.clientUUID.value, ''); - await StorageHelper().set(KeychainStorageKey.ownerUUID.value, ''); + await StorageHelper().set(ProfileStorageKey.clientUUID.key, ''); + await StorageHelper().set(ProfileStorageKey.ownerUUID.key, ''); StorageHelper().context?.go('/homePage'); } } catch (e, s) { @@ -71,7 +68,7 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { @override Future processLocals(BuildContext context) async { - log('() => processLocals'); + log('() => processLocals'); try { final GetLocalsCall callback = PhpGroup.getLocalsCall; final ApiCallResponse response = await callback.call(); @@ -145,8 +142,8 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { @override Future checkLocals(BuildContext context) async { - String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; - String cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; + String cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; + String cliName = (await StorageHelper().get(ProfileStorageKey.clientName.key)) ?? ''; return cliUUID.isEmpty && cliName.isEmpty; } @@ -219,9 +216,9 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { await PhpGroup.resopndeVinculo.call(tarefa: 'I').then((value) async { if (value.jsonBody['error'] == false) { - await StorageHelper().set(KeychainStorageKey.clientName.value, ''); - await StorageHelper().set(KeychainStorageKey.ownerName.value, ''); - await StorageHelper().set(KeychainStorageKey.clientUUID.value, ''); + await StorageHelper().set(ProfileStorageKey.clientName.key, ''); + await StorageHelper().set(ProfileStorageKey.ownerName.key, ''); + await StorageHelper().set(ProfileStorageKey.clientUUID.key, ''); context.pop(); context.go('/homePage', extra: {'update': LocalsRepositoryImpl().update}); SnackBarUtil.showSnackBar(context, content); @@ -244,6 +241,4 @@ class LocalsRemoteDataSourceImpl implements LocalsRemoteDataSource { SnackBarUtil.showSnackBar(context, content, isError: true); } } - - } diff --git a/lib/shared/components/molecules/locals/data/index.dart b/lib/features/locals/data/index.dart similarity index 100% rename from lib/shared/components/molecules/locals/data/index.dart rename to lib/features/locals/data/index.dart diff --git a/lib/features/locals/data/models/index.dart b/lib/features/locals/data/models/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/components/molecules/locals/data/repositories/index.dart b/lib/features/locals/data/repositories/index.dart similarity index 100% rename from lib/shared/components/molecules/locals/data/repositories/index.dart rename to lib/features/locals/data/repositories/index.dart diff --git a/lib/shared/components/molecules/locals/data/repositories/locals_repository_impl.dart b/lib/features/locals/data/repositories/locals_repository_impl.dart similarity index 73% rename from lib/shared/components/molecules/locals/data/repositories/locals_repository_impl.dart rename to lib/features/locals/data/repositories/locals_repository_impl.dart index 51c48596..74d8fb55 100644 --- a/lib/shared/components/molecules/locals/data/repositories/locals_repository_impl.dart +++ b/lib/features/locals/data/repositories/locals_repository_impl.dart @@ -2,12 +2,12 @@ import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:hub/backend/notifications/firebase_messaging_service.dart'; -import 'package:hub/shared/components/molecules/locals/index.dart'; -import 'package:hub/shared/components/molecules/menu/presentation/blocs/menu_bloc.dart'; -import 'package:hub/shared/components/molecules/modules/index.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; +import 'package:hub/features/locals/index.dart'; +import 'package:hub/features/menu/index.dart'; +import 'package:hub/features/modules/data/index.dart'; +import 'package:hub/features/notifications/index.dart'; +import 'package:hub/features/storage/index.dart'; + import 'package:hub/shared/utils/dialog_util.dart'; import 'package:rxdart/rxdart.dart'; @@ -32,21 +32,21 @@ class LocalsRepositoryImpl implements LocalsRepository { } Future select(BuildContext context) async { - await localDataSource.unlinkLocal(); - await update(context); + await localDataSource.unlinkLocal(); + await update(context); } Future check(BuildContext context) async { - final String? cliUUID = await StorageHelper().get(KeychainStorageKey.clientUUID.value); - final String? ownerUUID = await StorageHelper().get(KeychainStorageKey.ownerUUID.value); + final String? cliUUID = await StorageHelper().get(ProfileStorageKey.clientUUID.key); + final String? ownerUUID = await StorageHelper().get(ProfileStorageKey.ownerUUID.key); final bool haveCli = cliUUID != null && cliUUID.isNotEmpty; final bool haveOwner = ownerUUID != null && ownerUUID.isNotEmpty; if (!haveCli && !haveOwner) { - await update(context); - await FirebaseMessagingService().updateDeviceToken(); + await update(context); + await FirebaseMessagingService().updateDeviceToken(); } } - + Future _handleReponse(BuildContext context) async { bool response = false; final bool isUnselected = await remoteDataSource.checkLocals(context); @@ -69,16 +69,14 @@ class LocalsRepositoryImpl implements LocalsRepository { } Future _handleUpdateError(BuildContext context) async { - await StorageHelper().set(KeychainStorageKey.clientUUID.value, ''); + await StorageHelper().set(ProfileStorageKey.clientUUID.key, ''); const String errorMsg = 'Erro ao atualizar locais'; await DialogUtil.error(context, errorMsg); } Future _notifyBlocs(BuildContext context) async { - context.read().add(LocalProfileEvent()); context.read().add(MenuEvent()); - } @override diff --git a/lib/features/locals/domain/entities/index.dart b/lib/features/locals/domain/entities/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/components/molecules/locals/domain/index.dart b/lib/features/locals/domain/index.dart similarity index 100% rename from lib/shared/components/molecules/locals/domain/index.dart rename to lib/features/locals/domain/index.dart diff --git a/lib/shared/components/molecules/locals/domain/respositories/index.dart b/lib/features/locals/domain/respositories/index.dart similarity index 100% rename from lib/shared/components/molecules/locals/domain/respositories/index.dart rename to lib/features/locals/domain/respositories/index.dart diff --git a/lib/shared/components/molecules/locals/domain/respositories/locals_repository.dart b/lib/features/locals/domain/respositories/locals_repository.dart similarity index 100% rename from lib/shared/components/molecules/locals/domain/respositories/locals_repository.dart rename to lib/features/locals/domain/respositories/locals_repository.dart diff --git a/lib/features/locals/domain/usecases/index.dart b/lib/features/locals/domain/usecases/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/components/molecules/locals/index.dart b/lib/features/locals/index.dart similarity index 100% rename from lib/shared/components/molecules/locals/index.dart rename to lib/features/locals/index.dart diff --git a/lib/shared/components/molecules/locals/presentation/blocs/index.dart b/lib/features/locals/presentation/blocs/index.dart similarity index 100% rename from lib/shared/components/molecules/locals/presentation/blocs/index.dart rename to lib/features/locals/presentation/blocs/index.dart diff --git a/lib/shared/components/molecules/locals/presentation/blocs/local_profile_bloc.dart b/lib/features/locals/presentation/blocs/local_profile_bloc.dart similarity index 68% rename from lib/shared/components/molecules/locals/presentation/blocs/local_profile_bloc.dart rename to lib/features/locals/presentation/blocs/local_profile_bloc.dart index d19459a1..69201d30 100644 --- a/lib/shared/components/molecules/locals/presentation/blocs/local_profile_bloc.dart +++ b/lib/features/locals/presentation/blocs/local_profile_bloc.dart @@ -3,16 +3,12 @@ import 'dart:developer'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter/material.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/components/molecules/locals/index.dart'; -import 'package:hub/shared/components/molecules/menu/index.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; +import 'package:hub/features/locals/index.dart'; -class LocalProfileEvent { - -} +class LocalProfileEvent {} class LocalProfileState { final String cliName; @@ -22,7 +18,6 @@ class LocalProfileState { LocalProfileState({this.cliName = '', this.cliUUID = '', this.ownerName = ''}); LocalProfileState copyWith({String? cliName, String? ownerName, String? cliUUID}) { - return LocalProfileState( cliName: cliName ?? this.cliName, ownerName: ownerName ?? this.ownerName, @@ -42,9 +37,9 @@ class LocalProfileBloc extends Bloc { } Future _onLocalProfileEvent(LocalProfileEvent event, Emitter emit) async { - final cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; - final ownerName = (await StorageHelper().get(KeychainStorageKey.ownerName.value)) ?? ''; - final cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final cliName = (await StorageHelper().get(ProfileStorageKey.clientName.key)) ?? ''; + final ownerName = (await StorageHelper().get(ProfileStorageKey.ownerName.key)) ?? ''; + final cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; emit(state.copyWith(cliName: cliName, cliUUID: cliUUID, ownerName: ownerName)); } @@ -68,9 +63,9 @@ class LocalProfileComponentModel extends FlutterFlowModel getData() async { - cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; - ownerName = (await StorageHelper().get(KeychainStorageKey.ownerName.value)) ?? ''; - cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + cliName = (await StorageHelper().get(ProfileStorageKey.clientName.key)) ?? ''; + ownerName = (await StorageHelper().get(ProfileStorageKey.ownerName.key)) ?? ''; + cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; setStateCallback?.call(); } diff --git a/lib/shared/components/molecules/locals/presentation/index.dart b/lib/features/locals/presentation/index.dart similarity index 100% rename from lib/shared/components/molecules/locals/presentation/index.dart rename to lib/features/locals/presentation/index.dart diff --git a/lib/shared/components/molecules/locals/presentation/widgets/index.dart b/lib/features/locals/presentation/widgets/index.dart similarity index 100% rename from lib/shared/components/molecules/locals/presentation/widgets/index.dart rename to lib/features/locals/presentation/widgets/index.dart diff --git a/lib/shared/components/molecules/locals/presentation/widgets/local_profile/index.dart b/lib/features/locals/presentation/widgets/local_profile/index.dart similarity index 100% rename from lib/shared/components/molecules/locals/presentation/widgets/local_profile/index.dart rename to lib/features/locals/presentation/widgets/local_profile/index.dart diff --git a/lib/features/locals/presentation/widgets/local_profile/local_profile_widget.dart b/lib/features/locals/presentation/widgets/local_profile/local_profile_widget.dart new file mode 100644 index 00000000..cf343964 --- /dev/null +++ b/lib/features/locals/presentation/widgets/local_profile/local_profile_widget.dart @@ -0,0 +1,258 @@ +import 'package:cached_network_image/cached_network_image.dart'; +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hub/features/modules/index.dart'; +import 'package:hub/flutter_flow/custom_functions.dart'; +import 'package:hub/flutter_flow/flutter_flow_theme.dart'; +import 'package:hub/flutter_flow/flutter_flow_util.dart'; +import 'package:hub/features/locals/index.dart'; + +class LocalProfileComponentWidget extends StatefulWidget { + const LocalProfileComponentWidget({super.key}); + + @override + State createState() => _LocalProfileComponentWidgetState(); +} + +class _LocalProfileComponentWidgetState extends State { + bool _isLoading = false; + + Future retrieveProfileInfo() async { + setState(() { + _isLoading = true; + }); + await LocalsRepositoryImpl().select(context); + setState(() { + _isLoading = false; + }); + } + + @override + Widget build(BuildContext context) { + return StreamBuilder( + stream: LocalsRepositoryImpl.stream, + builder: (context, snapshot) { + final textScaler = MediaQuery.textScalerOf(context); + final double baseFontSize = 14.0; + final double scaledFontSize = baseFontSize * textScaler.scale(1); + final double limitedFontSize = scaledFontSize > 20 ? 12 : scaledFontSize; + if (snapshot.connectionState == ConnectionState.waiting) { + return const Center(child: CircularProgressIndicator()); + } else if (snapshot.hasError) { + return Center(child: Text('Error: ${snapshot.error}')); + } else if (!snapshot.hasData || snapshot.data! == false) { + return BlocBuilder( + builder: (context, state) { + return _buildDefaultLocalProfile(context, limitedFontSize); + }, + ); + } + + return BlocBuilder( + builder: (context, state) { + return _buildAsyncLocalProfile(context, state, limitedFontSize); + }, + ); + }, + ); + } + + Container _buildDefaultLocalProfile(BuildContext context, double limitedFontSize) { + return Container( + decoration: const BoxDecoration(), + child: Align( + alignment: const AlignmentDirectional(0.0, -1.0), + child: Material( + color: Colors.transparent, + elevation: 0.0, + child: Container( + width: double.infinity, + height: 119.0, + decoration: BoxDecoration( + color: FlutterFlowTheme.of(context).primary, + border: Border.all( + color: FlutterFlowTheme.of(context).primary, + ), + ), + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Align( + alignment: const AlignmentDirectional(-1.0, 0.0), + child: Padding( + padding: const EdgeInsets.all(2.0), + child: InkWell( + splashColor: Colors.transparent, + focusColor: Colors.transparent, + hoverColor: Colors.transparent, + highlightColor: Colors.transparent, + onTap: _isLoading ? null : retrieveProfileInfo, + child: ClipRRect( + borderRadius: BorderRadius.circular(200.0), + child: CachedNetworkImage( + imageBuilder: (context, imageProvider) => Container( + decoration: BoxDecoration( + image: DecorationImage( + image: imageProvider, + fit: BoxFit.cover, + ), + ), + ), + imageUrl: 'assets/images/home.png', + width: 80.0, + 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'), + ), + )), + ), + ), + Expanded( + child: Tooltip( + message: FFLocalizations.of(context).getVariableText( + ptText: 'SEM LOCAL VINCULADO', + enText: 'NO LINKED LOCAL', + ), + child: Text( + FFLocalizations.of(context).getVariableText( + ptText: 'SEM LOCAL VINCULADO', + enText: 'NO LINKED LOCAL', + ), + overflow: TextOverflow.ellipsis, + maxLines: 1, + style: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: 'Nunito', + color: FlutterFlowTheme.of(context).info, + fontSize: limitedFontSize, + letterSpacing: 0.0, + fontWeight: FontWeight.w500, + useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), + ), + ), + ), + ), + ].divide(const SizedBox(width: 20.0)).addToStart(const SizedBox(width: 20.0)).addToEnd(const SizedBox(width: 20.0)), + ), + ), + ), + ), + ); + } + + Container _buildAsyncLocalProfile(BuildContext context, LocalProfileState state, double limitedFontSize) { + return Container( + decoration: const BoxDecoration(), + child: Align( + alignment: const AlignmentDirectional(0.0, -1.0), + child: Material( + color: Colors.transparent, + elevation: 0.0, + child: Container( + width: double.infinity, + height: 119.0, + decoration: BoxDecoration( + color: FlutterFlowTheme.of(context).primary, + border: Border.all( + color: FlutterFlowTheme.of(context).primary, + ), + ), + child: Row( + mainAxisSize: MainAxisSize.max, + children: [ + Align( + alignment: const AlignmentDirectional(-1.0, 0.0), + child: Padding( + padding: const EdgeInsets.all(2.0), + child: InkWell( + splashColor: Colors.transparent, + focusColor: Colors.transparent, + hoverColor: Colors.transparent, + highlightColor: Colors.transparent, + onTap: _isLoading ? null : retrieveProfileInfo, + child: ClipRRect( + borderRadius: BorderRadius.circular(200.0), + child: CachedNetworkImage( + imageBuilder: (context, imageProvider) => Container( + decoration: BoxDecoration( + image: DecorationImage( + image: imageProvider, + fit: BoxFit.cover, + ), + ), + ), + imageUrl: valueOrDefault('https://freaccess.com.br/freaccess/Images/Clients/${state.cliUUID}.png', 'assets/images/home.png'), + width: 80.0, + 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'), + ), + )), + ), + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Tooltip( + message: valueOrDefault( + convertToUppercase(state.cliName), + FFLocalizations.of(context).getVariableText( + ptText: 'SEM LOCAL VINCULADO', + enText: 'NO LINKED LOCAL', + ), + ), + child: Text( + valueOrDefault( + convertToUppercase(state.cliName), + FFLocalizations.of(context).getVariableText( + ptText: 'SEM LOCAL VINCULADO', + enText: 'NO LINKED LOCAL', + ), + ), + overflow: TextOverflow.ellipsis, + maxLines: 1, + style: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: 'Nunito', + color: FlutterFlowTheme.of(context).info, + fontSize: limitedFontSize, + letterSpacing: 0.0, + fontWeight: FontWeight.w500, + useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), + ), + ), + ), + Tooltip( + message: valueOrDefault(' ' + state.ownerName, ''), + child: Text( + valueOrDefault(state.ownerName.length > 30 ? '${state.ownerName.substring(0, 20)}...' : state.ownerName, ''), + overflow: TextOverflow.ellipsis, + maxLines: 1, + style: FlutterFlowTheme.of(context).labelMedium.override( + fontFamily: 'Nunito', + color: FlutterFlowTheme.of(context).info, + fontSize: limitedFontSize, + letterSpacing: 0.0, + fontWeight: FontWeight.w500, + useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), + ), + ), + ), + ], + ), + ), + ].divide(const SizedBox(width: 20.0)).addToStart(const SizedBox(width: 20.0)).addToEnd(const SizedBox(width: 20.0)), + ), + ), + ), + ), + ); + } +} diff --git a/lib/shared/components/molecules/locals/utils/index.dart b/lib/features/locals/utils/index.dart similarity index 100% rename from lib/shared/components/molecules/locals/utils/index.dart rename to lib/features/locals/utils/index.dart diff --git a/lib/shared/components/molecules/locals/utils/local_util.dart b/lib/features/locals/utils/local_util.dart similarity index 52% rename from lib/shared/components/molecules/locals/utils/local_util.dart rename to lib/features/locals/utils/local_util.dart index 9aaa7772..45438432 100644 --- a/lib/shared/components/molecules/locals/utils/local_util.dart +++ b/lib/features/locals/utils/local_util.dart @@ -1,21 +1,18 @@ - - import 'dart:developer'; import 'package:flutter/material.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; +import 'package:hub/features/backend/index.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/internationalization.dart'; -import 'package:hub/shared/components/molecules/locals/index.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; +import 'package:hub/features/locals/index.dart'; + import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/log_util.dart'; class LocalUtil { - static void handleError(BuildContext context, String errorMsg) async { - final String devUUID = await StorageHelper().get(KeychainStorageKey.devUUID.value) ?? ''; - final String userUUID = await StorageHelper().get(KeychainStorageKey.userUUID.value) ?? ''; + final String devUUID = await StorageHelper().get(ProfileStorageKey.devUUID.key) ?? ''; + final String userUUID = await StorageHelper().get(ProfileStorageKey.userUUID.key) ?? ''; final bool isAuthenticated = userUUID.isNotEmpty && devUUID.isNotEmpty; final bool isDevLinked = !errorMsg.contains('Esse dispositivo nao pertence a esse usuario'); log('() => isLinked: $errorMsg'); @@ -42,17 +39,17 @@ class LocalUtil { static Future handleUnavailable(BuildContext context, List locals) async { log('() => isUnavailable'); try { - await StorageHelper().set(KeychainStorageKey.clientUUID.value, locals[0]['CLI_ID']); - await StorageHelper().set(KeychainStorageKey.ownerUUID.value, locals[0]['CLU_OWNER_ID']); - await StorageHelper().set(KeychainStorageKey.clientName.value, locals[0]['CLI_NOME']); - await StorageHelper().set(KeychainStorageKey.ownerName.value, locals[0]['CLU_OWNER_DSC']); + await StorageHelper().set(ProfileStorageKey.clientUUID.key, locals[0]['CLI_ID']); + await StorageHelper().set(ProfileStorageKey.ownerUUID.key, locals[0]['CLU_OWNER_ID']); + await StorageHelper().set(ProfileStorageKey.clientName.key, locals[0]['CLI_NOME']); + await StorageHelper().set(ProfileStorageKey.ownerName.key, locals[0]['CLU_OWNER_DSC']); var response = await PhpGroup.resopndeVinculo.call(tarefa: 'A'); if (response.jsonBody['error'] == true) { - await StorageHelper().set(KeychainStorageKey.clientUUID.value, ''); - await StorageHelper().set(KeychainStorageKey.ownerUUID.value, ''); - await StorageHelper().set(KeychainStorageKey.clientName.value, ''); - await StorageHelper().set(KeychainStorageKey.ownerName.value, ''); + await StorageHelper().set(ProfileStorageKey.clientUUID.key, ''); + await StorageHelper().set(ProfileStorageKey.ownerUUID.key, ''); + await StorageHelper().set(ProfileStorageKey.clientName.key, ''); + await StorageHelper().set(ProfileStorageKey.ownerName.key, ''); return false; } @@ -67,11 +64,11 @@ class LocalUtil { static Future handleEnabled(BuildContext context, dynamic local) async { log('() => isEnabled'); - await StorageHelper().set(KeychainStorageKey.clientUUID.value, local['CLI_ID']); - await StorageHelper().set(KeychainStorageKey.ownerUUID.value, local['CLU_OWNER_ID']); - await StorageHelper().set(KeychainStorageKey.clientName.value, local['CLI_NOME']); - await StorageHelper().set(KeychainStorageKey.ownerName.value, local['CLU_OWNER_DSC']); - await StorageHelper().set(KeychainStorageKey.userName.value, local['USU_NOME']); + await StorageHelper().set(ProfileStorageKey.clientUUID.key, local['CLI_ID']); + await StorageHelper().set(ProfileStorageKey.ownerUUID.key, local['CLU_OWNER_ID']); + await StorageHelper().set(ProfileStorageKey.clientName.key, local['CLI_NOME']); + await StorageHelper().set(ProfileStorageKey.ownerName.key, local['CLU_OWNER_DSC']); + await StorageHelper().set(ProfileStorageKey.userName.key, local['USU_NOME']); return await LocalsRemoteDataSourceImpl().processData(context); } @@ -84,16 +81,15 @@ class LocalUtil { static Future updateStorageUtil(Map jsonBody) async { try { - await StorageHelper().set(KeychainStorageKey.whatsapp.value, jsonBody['whatsapp'] ?? false); - await StorageHelper().set(KeychainStorageKey.provisional.value, jsonBody['provisional'] ?? false); - await StorageHelper().set(KeychainStorageKey.pets.value, jsonBody['pet'] ?? false); - await StorageHelper().set(KeychainStorageKey.petAmount.value, - jsonBody['petAmountRegister']?.toString().isEmpty ?? true ? '0' : jsonBody['petAmountRegister'].toString()); - await StorageHelper().set(KeychainStorageKey.userName.value, jsonBody['visitado']['VDO_NOME'] ?? ''); - await StorageHelper().set(KeychainStorageKey.userEmail.value, jsonBody['visitado']['VDO_EMAIL'] ?? ''); + await StorageHelper().set(LocalsStorageKey.whatsapp.key, jsonBody['whatsapp'] ?? false); + await StorageHelper().set(LocalsStorageKey.provisional.key, jsonBody['provisional'] ?? false); + await StorageHelper().set(LocalsStorageKey.pets.key, jsonBody['pet'] ?? false); + await StorageHelper().set(LocalsStorageKey.petAmount.key, jsonBody['petAmountRegister']?.toString().isEmpty ?? true ? '0' : jsonBody['petAmountRegister'].toString()); + await StorageHelper().set(ProfileStorageKey.userName.key, jsonBody['visitado']['VDO_NOME'] ?? ''); + await StorageHelper().set(ProfileStorageKey.userEmail.key, jsonBody['visitado']['VDO_EMAIL'] ?? ''); final bool isNewVersion = jsonBody['newVersion'] ?? false; - await StorageHelper().set(KeychainStorageKey.isNewVersion.value, isNewVersion); + await StorageHelper().set(LocalsStorageKey.isNewVersion.key, isNewVersion); return isNewVersion; } catch (e, s) { log('Error in _updateStorageUtil: $e', stackTrace: s); @@ -106,7 +102,7 @@ class LocalUtil { } static Future isInactived(List locals) async { - String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + String cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; return locals.where((local) => local['CLI_ID'] != cliUUID && local['CLU_STATUS'] == 'A').isNotEmpty; } @@ -115,22 +111,21 @@ class LocalUtil { } static Future isUnselected() async { - String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; - String cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; - String ownerUUID = (await StorageHelper().get(KeychainStorageKey.ownerUUID.value)) ?? ''; + String cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; + String cliName = (await StorageHelper().get(ProfileStorageKey.clientName.key)) ?? ''; + String ownerUUID = (await StorageHelper().get(ProfileStorageKey.ownerUUID.key)) ?? ''; return cliUUID.isEmpty && cliName.isEmpty && ownerUUID.isEmpty; } static Future isSelected(bool isInactived) async { - String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; - String cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; + String cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; + String cliName = (await StorageHelper().get(ProfileStorageKey.clientName.key)) ?? ''; return cliUUID.isNotEmpty && cliName.isNotEmpty && isInactived; } static Future isAvailable() async { - String cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; - String cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; + String cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; + String cliName = (await StorageHelper().get(ProfileStorageKey.clientName.key)) ?? ''; return cliUUID.isNotEmpty && cliName.isNotEmpty; } - -} \ No newline at end of file +} diff --git a/lib/shared/components/molecules/menu/data/data_sources/index.dart b/lib/features/menu/data/data_sources/index.dart similarity index 100% rename from lib/shared/components/molecules/menu/data/data_sources/index.dart rename to lib/features/menu/data/data_sources/index.dart diff --git a/lib/shared/components/molecules/menu/data/data_sources/menu_local_data_source.dart b/lib/features/menu/data/data_sources/menu_local_data_source.dart similarity index 89% rename from lib/shared/components/molecules/menu/data/data_sources/menu_local_data_source.dart rename to lib/features/menu/data/data_sources/menu_local_data_source.dart index 113df0e4..ed9b3e2f 100644 --- a/lib/shared/components/molecules/menu/data/data_sources/menu_local_data_source.dart +++ b/lib/features/menu/data/data_sources/menu_local_data_source.dart @@ -1,18 +1,16 @@ - - import 'dart:developer'; import 'package:flutter/material.dart'; +import 'package:hub/features/authentication/index.dart'; +import 'package:hub/features/menu/index.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/components/molecules/menu/index.dart'; import 'package:hub/shared/extensions/dialog_extensions.dart'; -import 'package:hub/shared/services/authentication/authentication_service.dart'; import 'package:hub/shared/utils/path_util.dart'; import '../../../modules/domain/entities/index.dart'; abstract class MenuLocalDataSource { - Future addMenuEntry(EnumMenuItem item, List entries, IconData icon, String text, Function() action); + Future addMenuEntry(EnumMenuItem item, List entries, IconData icon, String text, Function() action); Future processDisplayDefault(EnumMenuItem item, MenuEntry opt, List entries); Future handleMenu(EnumMenuItem item, EnumDisplay display, MenuEntry opt, List entries); Future processStartDate(String startDate, MenuEntry entry); @@ -36,7 +34,7 @@ class MenuLocalDataSourceImpl implements MenuLocalDataSource { } return null; } - + @override Future processDisplayDefault(EnumMenuItem item, MenuEntry opt, List entries) async { if (opt.key == 'FRE-HUB-LOGOUT') { @@ -44,9 +42,8 @@ class MenuLocalDataSourceImpl implements MenuLocalDataSource { await AuthenticationService.signOut(navigatorKey.currentContext!); }); return true; - - } - else return false; + } else + return false; } @override @@ -75,14 +72,14 @@ class MenuLocalDataSourceImpl implements MenuLocalDataSource { Future processStartDate(String startDate, MenuEntry opt) async { try { if (startDate.isEmpty) return true; - final start = DateTime.tryParse(startDate); + final start = DateTime.tryParse(startDate); if (start == null) return false; return DateTime.now().isAfter(start); } catch (e) { log('Error processing start date for module ${opt.key}: $e'); } return false; - } + } @override Future processExpirationDate(String expirationDate, MenuEntry opt) async { @@ -95,7 +92,4 @@ class MenuLocalDataSourceImpl implements MenuLocalDataSource { } return false; } - - - -} \ No newline at end of file +} diff --git a/lib/shared/components/molecules/menu/data/index.dart b/lib/features/menu/data/index.dart similarity index 100% rename from lib/shared/components/molecules/menu/data/index.dart rename to lib/features/menu/data/index.dart diff --git a/lib/features/menu/data/models/index.dart b/lib/features/menu/data/models/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/components/molecules/menu/data/repositories/index.dart b/lib/features/menu/data/repositories/index.dart similarity index 100% rename from lib/shared/components/molecules/menu/data/repositories/index.dart rename to lib/features/menu/data/repositories/index.dart diff --git a/lib/shared/components/molecules/menu/data/repositories/menu_repository_impl.dart b/lib/features/menu/data/repositories/menu_repository_impl.dart similarity index 77% rename from lib/shared/components/molecules/menu/data/repositories/menu_repository_impl.dart rename to lib/features/menu/data/repositories/menu_repository_impl.dart index 2a05bb85..37c9217e 100644 --- a/lib/shared/components/molecules/menu/data/repositories/menu_repository_impl.dart +++ b/lib/features/menu/data/repositories/menu_repository_impl.dart @@ -1,23 +1,12 @@ - - -import 'dart:convert'; import 'dart:developer'; +import 'package:hub/features/menu/index.dart'; +import 'package:hub/features/modules/index.dart'; import 'package:hub/flutter_flow/custom_functions.dart'; -import 'package:hub/main.dart'; -import 'package:hub/shared/components/molecules/menu/data/data_sources/menu_local_data_source.dart'; -import 'package:hub/shared/components/molecules/menu/domain/respositories/menu_repository.dart'; -import 'package:hub/shared/components/molecules/menu/index.dart'; -import 'package:hub/shared/components/molecules/modules/index.dart'; -import 'package:hub/shared/extensions/string_extensions.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; - class MenuRepositoryImpl implements MenuRepository { final MenuLocalDataSource menuDataSource = MenuLocalDataSourceImpl(); - @override Future> generateMenuEntries(List menuEntries, EnumMenuItem item) async { List entries = []; @@ -55,8 +44,6 @@ class MenuRepositoryImpl implements MenuRepository { } Future processDisplay(Map module, bool isNewVersion) async { - - if (await _shouldUpdateDisplay(module, isNewVersion)) { final displayValue = module['display'] == EnumDisplay.active ? 'VISIVEL' : 'INVISIVEL'; await LicenseLocalDataSourceImpl().setDisplayByKey(['FRE-HUB-ABOUT-PROPERTY'], displayValue); @@ -67,13 +54,7 @@ class MenuRepositoryImpl implements MenuRepository { } Future _shouldUpdateDisplay(Map module, bool isNewVersion) async { - const keysToCheck = [ - LicenseKeys.residents, - LicenseKeys.vehicles, - LicenseKeys.openedVisits - ]; + const keysToCheck = [LicenseKeys.residents, LicenseKeys.vehicles, LicenseKeys.openedVisits]; return isNewVersion && keysToCheck.any((key) => module['key'] == key.value); } - - -} \ No newline at end of file +} diff --git a/lib/shared/components/molecules/menu/domain/entities/index.dart b/lib/features/menu/domain/entities/index.dart similarity index 100% rename from lib/shared/components/molecules/menu/domain/entities/index.dart rename to lib/features/menu/domain/entities/index.dart diff --git a/lib/shared/components/molecules/menu/domain/entities/menu_item.dart b/lib/features/menu/domain/entities/menu_item.dart similarity index 93% rename from lib/shared/components/molecules/menu/domain/entities/menu_item.dart rename to lib/features/menu/domain/entities/menu_item.dart index 31b36da6..842eab13 100644 --- a/lib/shared/components/molecules/menu/domain/entities/menu_item.dart +++ b/lib/features/menu/domain/entities/menu_item.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:hub/shared/components/molecules/menu/index.dart'; +import 'package:hub/features/menu/index.dart'; enum EnumMenuItem { button, @@ -29,7 +29,6 @@ abstract class MenuItem extends StatefulWidget { final Function() action; final String title; final IconData icon; - factory MenuItem.create( EnumMenuItem type, { diff --git a/lib/shared/components/molecules/menu/domain/index.dart b/lib/features/menu/domain/index.dart similarity index 100% rename from lib/shared/components/molecules/menu/domain/index.dart rename to lib/features/menu/domain/index.dart diff --git a/lib/features/menu/domain/respositories/index.dart b/lib/features/menu/domain/respositories/index.dart new file mode 100644 index 00000000..28b980f4 --- /dev/null +++ b/lib/features/menu/domain/respositories/index.dart @@ -0,0 +1 @@ +export 'menu_repository.dart'; diff --git a/lib/features/menu/domain/respositories/menu_repository.dart b/lib/features/menu/domain/respositories/menu_repository.dart new file mode 100644 index 00000000..bccd444a --- /dev/null +++ b/lib/features/menu/domain/respositories/menu_repository.dart @@ -0,0 +1,5 @@ +import 'package:hub/features/menu/index.dart'; + +abstract class MenuRepository { + Future> generateMenuEntries(List menuEntries, EnumMenuItem item); +} diff --git a/lib/features/menu/domain/usecases/index.dart b/lib/features/menu/domain/usecases/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/components/molecules/menu/index.dart b/lib/features/menu/index.dart similarity index 100% rename from lib/shared/components/molecules/menu/index.dart rename to lib/features/menu/index.dart diff --git a/lib/shared/components/molecules/menu/presentation/blocs/index.dart b/lib/features/menu/presentation/blocs/index.dart similarity index 100% rename from lib/shared/components/molecules/menu/presentation/blocs/index.dart rename to lib/features/menu/presentation/blocs/index.dart diff --git a/lib/shared/components/molecules/menu/presentation/blocs/menu_bloc.dart b/lib/features/menu/presentation/blocs/menu_bloc.dart similarity index 74% rename from lib/shared/components/molecules/menu/presentation/blocs/menu_bloc.dart rename to lib/features/menu/presentation/blocs/menu_bloc.dart index ed513784..9b701787 100644 --- a/lib/shared/components/molecules/menu/presentation/blocs/menu_bloc.dart +++ b/lib/features/menu/presentation/blocs/menu_bloc.dart @@ -1,17 +1,9 @@ - import 'dart:async'; -import 'dart:developer'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/components/molecules/locals/index.dart'; - -import 'package:hub/shared/components/molecules/menu/data/repositories/menu_repository_impl.dart'; -import 'package:hub/shared/components/molecules/menu/index.dart'; -import 'package:hub/shared/components/molecules/modules/index.dart'; - -import 'package:flutter_bloc/flutter_bloc.dart'; - +import 'package:hub/features/menu/index.dart'; +import 'package:hub/features/modules/index.dart'; +import 'package:hub/features/locals/index.dart'; class MenuEvent {} @@ -44,7 +36,7 @@ class MenuBloc extends Bloc { Future _onMenuEvent(MenuEvent event, Emitter emit) async { await LicenseRemoteDataSourceImpl().waitForSaveCompletion(); - + final List newEntries = await MenuRepositoryImpl().generateMenuEntries(entries, item); emit(state.copyWith(menuEntries: newEntries)); } @@ -54,6 +46,4 @@ class MenuBloc extends Bloc { _completer.cancel(); return super.close(); } - - } diff --git a/lib/shared/components/molecules/menu/presentation/blocs/menu_item_bloc.dart b/lib/features/menu/presentation/blocs/menu_item_bloc.dart similarity index 100% rename from lib/shared/components/molecules/menu/presentation/blocs/menu_item_bloc.dart rename to lib/features/menu/presentation/blocs/menu_item_bloc.dart diff --git a/lib/shared/components/molecules/menu/presentation/blocs/menu_view_bloc.dart b/lib/features/menu/presentation/blocs/menu_view_bloc.dart similarity index 100% rename from lib/shared/components/molecules/menu/presentation/blocs/menu_view_bloc.dart rename to lib/features/menu/presentation/blocs/menu_view_bloc.dart diff --git a/lib/shared/components/molecules/menu/presentation/index.dart b/lib/features/menu/presentation/index.dart similarity index 100% rename from lib/shared/components/molecules/menu/presentation/index.dart rename to lib/features/menu/presentation/index.dart diff --git a/lib/shared/components/molecules/menu/presentation/mappers/index.dart b/lib/features/menu/presentation/mappers/index.dart similarity index 100% rename from lib/shared/components/molecules/menu/presentation/mappers/index.dart rename to lib/features/menu/presentation/mappers/index.dart diff --git a/lib/shared/components/molecules/menu/presentation/mappers/menu_entry.dart b/lib/features/menu/presentation/mappers/menu_entry.dart similarity index 98% rename from lib/shared/components/molecules/menu/presentation/mappers/menu_entry.dart rename to lib/features/menu/presentation/mappers/menu_entry.dart index 6d7ac800..0b443f7a 100644 --- a/lib/shared/components/molecules/menu/presentation/mappers/menu_entry.dart +++ b/lib/features/menu/presentation/mappers/menu_entry.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:hub/features/modules/index.dart'; import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/components/molecules/modules/domain/entities/base_module.dart'; enum MenuEntryType { Home, Drawer, Property } diff --git a/lib/shared/components/molecules/menu/presentation/widgets/index.dart b/lib/features/menu/presentation/widgets/index.dart similarity index 100% rename from lib/shared/components/molecules/menu/presentation/widgets/index.dart rename to lib/features/menu/presentation/widgets/index.dart diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_factory.dart b/lib/features/menu/presentation/widgets/menu_factory.dart similarity index 85% rename from lib/shared/components/molecules/menu/presentation/widgets/menu_factory.dart rename to lib/features/menu/presentation/widgets/menu_factory.dart index 79bf3454..3092a115 100644 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_factory.dart +++ b/lib/features/menu/presentation/widgets/menu_factory.dart @@ -1,11 +1,9 @@ -import 'package:hub/flutter_flow/nav/nav.dart'; +import 'package:hub/features/locals/index.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:hub/features/menu/index.dart'; +import 'package:hub/features/modules/index.dart'; -import 'package:hub/flutter_flow/flutter_flow_theme.dart'; -import 'package:hub/shared/components/molecules/locals/index.dart'; -import 'package:hub/shared/components/molecules/modules/index.dart'; -import 'package:hub/shared/components/molecules/menu/index.dart'; import 'package:hub/shared/utils/loading_util.dart'; class Menufactory extends StatelessWidget { @@ -41,8 +39,6 @@ class Menufactory extends StatelessWidget { return _buildMenuBloc(context); } - - Widget _buildMenuBloc(BuildContext context) { return BlocProvider( create: (context) => MenuBloc( diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_item/index.dart b/lib/features/menu/presentation/widgets/menu_item/index.dart similarity index 100% rename from lib/shared/components/molecules/menu/presentation/widgets/menu_item/index.dart rename to lib/features/menu/presentation/widgets/menu_item/index.dart diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_button.dart b/lib/features/menu/presentation/widgets/menu_item/menu_item_button.dart similarity index 98% rename from lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_button.dart rename to lib/features/menu/presentation/widgets/menu_item/menu_item_button.dart index 7e861894..2b0d5576 100644 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_button.dart +++ b/lib/features/menu/presentation/widgets/menu_item/menu_item_button.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; +import 'package:hub/features/menu/index.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; -import 'package:hub/shared/components/molecules/menu/index.dart'; - class ButtonMenuItem extends MenuItem { const ButtonMenuItem({ diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_card.dart b/lib/features/menu/presentation/widgets/menu_item/menu_item_card.dart similarity index 97% rename from lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_card.dart rename to lib/features/menu/presentation/widgets/menu_item/menu_item_card.dart index b120a09d..6ea197ce 100644 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_item/menu_item_card.dart +++ b/lib/features/menu/presentation/widgets/menu_item/menu_item_card.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; +import 'package:hub/features/menu/index.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; -import 'package:hub/shared/components/molecules/menu/index.dart'; - class CardMenuItem extends MenuItem { const CardMenuItem({ diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_view/index.dart b/lib/features/menu/presentation/widgets/menu_view/index.dart similarity index 100% rename from lib/shared/components/molecules/menu/presentation/widgets/menu_view/index.dart rename to lib/features/menu/presentation/widgets/menu_view/index.dart diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_list_view.dart b/lib/features/menu/presentation/widgets/menu_view/menu_list_view.dart similarity index 98% rename from lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_list_view.dart rename to lib/features/menu/presentation/widgets/menu_view/menu_list_view.dart index 277fd2c3..cd301a64 100644 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_list_view.dart +++ b/lib/features/menu/presentation/widgets/menu_view/menu_list_view.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:hub/shared/components/molecules/menu/index.dart'; +import 'package:hub/features/menu/domain/index.dart'; import '/flutter_flow/flutter_flow_icon_button.dart'; import '/flutter_flow/flutter_flow_theme.dart'; diff --git a/lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_staggered_view.dart b/lib/features/menu/presentation/widgets/menu_view/menu_staggered_view.dart similarity index 98% rename from lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_staggered_view.dart rename to lib/features/menu/presentation/widgets/menu_view/menu_staggered_view.dart index fbaf5056..4a81ac5b 100644 --- a/lib/shared/components/molecules/menu/presentation/widgets/menu_view/menu_staggered_view.dart +++ b/lib/features/menu/presentation/widgets/menu_view/menu_staggered_view.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:hub/shared/components/molecules/menu/index.dart'; +import 'package:hub/features/menu/index.dart'; 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'; diff --git a/lib/shared/components/molecules/modules/constants/index.dart b/lib/features/modules/constants/index.dart similarity index 100% rename from lib/shared/components/molecules/modules/constants/index.dart rename to lib/features/modules/constants/index.dart diff --git a/lib/shared/components/molecules/modules/constants/license_constants.dart b/lib/features/modules/constants/license_constants.dart similarity index 100% rename from lib/shared/components/molecules/modules/constants/license_constants.dart rename to lib/features/modules/constants/license_constants.dart diff --git a/lib/shared/components/molecules/modules/data/data_sources/index.dart b/lib/features/modules/data/data_sources/index.dart similarity index 100% rename from lib/shared/components/molecules/modules/data/data_sources/index.dart rename to lib/features/modules/data/data_sources/index.dart diff --git a/lib/shared/components/molecules/modules/data/data_sources/license_local_data_source.dart b/lib/features/modules/data/data_sources/license_local_data_source.dart similarity index 72% rename from lib/shared/components/molecules/modules/data/data_sources/license_local_data_source.dart rename to lib/features/modules/data/data_sources/license_local_data_source.dart index ff502e5f..ff2390c4 100644 --- a/lib/shared/components/molecules/modules/data/data_sources/license_local_data_source.dart +++ b/lib/features/modules/data/data_sources/license_local_data_source.dart @@ -1,12 +1,6 @@ - -import 'dart:developer'; - -import 'package:hub/shared/components/molecules/modules/index.dart'; -import 'package:hub/shared/helpers/database/database_helper.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; +import 'package:hub/features/modules/index.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/shared/extensions/string_extensions.dart'; -import 'package:sqflite/sqflite.dart'; abstract class LicenseLocalDataSource { Future init(); @@ -23,10 +17,9 @@ class LicenseLocalDataSourceImpl implements LicenseLocalDataSource { factory LicenseLocalDataSourceImpl() => _instance; LicenseLocalDataSourceImpl._internal(); - @override Future init() async { - await DatabaseStorage.instance.init(); + await DatabaseService.instance.init(); } @override @@ -45,19 +38,18 @@ class LicenseLocalDataSourceImpl implements LicenseLocalDataSource { @override Future isNewVersion() async { - final String? reponse = await StorageHelper().get(KeychainStorageKey.isNewVersion.value); + final String? reponse = await StorageHelper().get(LocalsStorageKey.isNewVersion.key); final bool isNewVersion = reponse.toBoolean(); return isNewVersion; } @override Future get(String key) async { - var response = await DatabaseStorage.database.query(tableLicense, where: 'key = ?', whereArgs: [key]); + var response = await DatabaseService.database.query(tableLicense, where: 'key = ?', whereArgs: [key]); if (response.isEmpty) { return null; } - - + return response.toString(); } @@ -66,8 +58,8 @@ class LicenseLocalDataSourceImpl implements LicenseLocalDataSource { value as Map; if (value.isEmpty) return; if (key == 'null') return; - - await DatabaseStorage.database.rawInsert( + + await DatabaseService.database.rawInsert( 'INSERT OR REPLACE INTO $tableLicense (key, display, expirationDate, startDate, quantity) VALUES (?, ?, ?, ?, ?)', [key, value['display'], value['expirationDate'], value['startDate'], value['quantity']], ); @@ -76,12 +68,11 @@ class LicenseLocalDataSourceImpl implements LicenseLocalDataSource { @override Future del(String key) async { - await DatabaseStorage.database.delete(tableLicense, where: 'key = ?', whereArgs: [key]); + await DatabaseService.database.delete(tableLicense, where: 'key = ?', whereArgs: [key]); } @override Future clear() async { - await DatabaseStorage.database.delete(tableLicense); - + await DatabaseService.database.delete(tableLicense); } } diff --git a/lib/shared/components/molecules/modules/data/data_sources/license_remote_data_source.dart b/lib/features/modules/data/data_sources/license_remote_data_source.dart similarity index 65% rename from lib/shared/components/molecules/modules/data/data_sources/license_remote_data_source.dart rename to lib/features/modules/data/data_sources/license_remote_data_source.dart index 9927d370..9bee2849 100644 --- a/lib/shared/components/molecules/modules/data/data_sources/license_remote_data_source.dart +++ b/lib/features/modules/data/data_sources/license_remote_data_source.dart @@ -3,10 +3,9 @@ import 'dart:async'; import 'dart:developer'; -import 'package:hub/backend/api_requests/api_calls.dart'; -import 'package:hub/shared/components/molecules/locals/index.dart'; -import 'package:hub/shared/components/molecules/modules/index.dart'; -import 'package:hub/shared/helpers/database/database_helper.dart'; +import 'package:hub/features/backend/index.dart'; +import 'package:hub/features/locals/data/repositories/locals_repository_impl.dart'; +import 'package:hub/features/modules/index.dart'; import 'package:sqflite/sqflite.dart'; @@ -22,47 +21,31 @@ class LicenseRemoteDataSourceImpl implements LicenseRemoteDataSource { factory LicenseRemoteDataSourceImpl() => _instance; LicenseRemoteDataSourceImpl._internal(); - - - - @override Future processLicense() async {} @override Future cleanLicense() async { LocalsRepositoryImpl.license.add(false); - } - @override + @override Future setupLicense(Database database, bool isNewVersion) async { log('Setting up license...'); try { - final License license = await License.getLicense(isNewVersion); + final License license = await License.getLicense(isNewVersion); - final List inactiveModuleKey = license.modules - .where((module) => module.display == ModuleStatus.inactive.key) - .map((module) => module.key) - .toList(); + final List inactiveModuleKey = license.modules.where((module) => module.display == ModuleStatus.inactive.key).map((module) => module.key).toList(); - final List activeModuleKey = license.modules - .where((module) => module.display == ModuleStatus.active.key) - .map((module) => module.key) - .toList(); + final List activeModuleKey = license.modules.where((module) => module.display == ModuleStatus.active.key).map((module) => module.key).toList(); - final List disabledModuleKey = license.modules - .where((module) => module.display == ModuleStatus.disabled.key) - .map((module) => module.key) - .toList(); + final List disabledModuleKey = license.modules.where((module) => module.display == ModuleStatus.disabled.key).map((module) => module.key).toList(); - await LicenseLocalDataSourceImpl().setDisplayByKey(inactiveModuleKey, 'INVISIVEL'); - await LicenseLocalDataSourceImpl().setDisplayByKey(activeModuleKey, 'VISIVEL'); - await LicenseLocalDataSourceImpl().setDisplayByKey(disabledModuleKey, 'DESABILITADO'); - - - - return true; + await LicenseLocalDataSourceImpl().setDisplayByKey(inactiveModuleKey, 'INVISIVEL'); + await LicenseLocalDataSourceImpl().setDisplayByKey(activeModuleKey, 'VISIVEL'); + await LicenseLocalDataSourceImpl().setDisplayByKey(disabledModuleKey, 'DESABILITADO'); + + return true; } catch (e, s) { log('Erro ao configurar licenças: $e', stackTrace: s); return false; @@ -76,11 +59,9 @@ class LicenseRemoteDataSourceImpl implements LicenseRemoteDataSource { final response = await PhpGroup.getLicense(); final dynamic responseBody = response.jsonBody; - if (responseBody == []) { return true; - } - else if (response.jsonBody is! List) { + } else if (response.jsonBody is! List) { late final String error; if (response.jsonBody is Map) error = response.jsonBody['error_msg']; @@ -90,8 +71,6 @@ class LicenseRemoteDataSourceImpl implements LicenseRemoteDataSource { throw Exception('Erro ao consultar licenças: $error'); } - - List> saveOperations = []; for (var element in responseBody) { if (licenseContainsKey(element['key'])) { @@ -112,7 +91,6 @@ class LicenseRemoteDataSourceImpl implements LicenseRemoteDataSource { } static bool licenseContainsKey(final String key) { - return LicenseKeys.values.map((e) => e.value).toList().contains(key); } diff --git a/lib/shared/components/molecules/modules/data/index.dart b/lib/features/modules/data/index.dart similarity index 100% rename from lib/shared/components/molecules/modules/data/index.dart rename to lib/features/modules/data/index.dart diff --git a/lib/shared/components/molecules/modules/data/models/index.dart b/lib/features/modules/data/models/index.dart similarity index 100% rename from lib/shared/components/molecules/modules/data/models/index.dart rename to lib/features/modules/data/models/index.dart diff --git a/lib/shared/components/molecules/modules/data/models/license_model.dart b/lib/features/modules/data/models/license_model.dart similarity index 100% rename from lib/shared/components/molecules/modules/data/models/license_model.dart rename to lib/features/modules/data/models/license_model.dart diff --git a/lib/shared/components/molecules/modules/data/models/license_model.freezed.dart b/lib/features/modules/data/models/license_model.freezed.dart similarity index 100% rename from lib/shared/components/molecules/modules/data/models/license_model.freezed.dart rename to lib/features/modules/data/models/license_model.freezed.dart diff --git a/lib/shared/components/molecules/modules/data/models/license_model.g.dart b/lib/features/modules/data/models/license_model.g.dart similarity index 100% rename from lib/shared/components/molecules/modules/data/models/license_model.g.dart rename to lib/features/modules/data/models/license_model.g.dart diff --git a/lib/shared/components/molecules/modules/data/models/module_model.dart b/lib/features/modules/data/models/module_model.dart similarity index 100% rename from lib/shared/components/molecules/modules/data/models/module_model.dart rename to lib/features/modules/data/models/module_model.dart diff --git a/lib/shared/components/molecules/modules/data/models/module_model.freezed.dart b/lib/features/modules/data/models/module_model.freezed.dart similarity index 100% rename from lib/shared/components/molecules/modules/data/models/module_model.freezed.dart rename to lib/features/modules/data/models/module_model.freezed.dart diff --git a/lib/shared/components/molecules/modules/data/models/module_model.g.dart b/lib/features/modules/data/models/module_model.g.dart similarity index 100% rename from lib/shared/components/molecules/modules/data/models/module_model.g.dart rename to lib/features/modules/data/models/module_model.g.dart diff --git a/lib/shared/components/molecules/modules/data/repositories/index.dart b/lib/features/modules/data/repositories/index.dart similarity index 100% rename from lib/shared/components/molecules/modules/data/repositories/index.dart rename to lib/features/modules/data/repositories/index.dart diff --git a/lib/shared/components/molecules/modules/data/repositories/license_repository_impl.dart b/lib/features/modules/data/repositories/license_repository_impl.dart similarity index 63% rename from lib/shared/components/molecules/modules/data/repositories/license_repository_impl.dart rename to lib/features/modules/data/repositories/license_repository_impl.dart index 1ef3589a..bc33f656 100644 --- a/lib/shared/components/molecules/modules/data/repositories/license_repository_impl.dart +++ b/lib/features/modules/data/repositories/license_repository_impl.dart @@ -1,9 +1,8 @@ import 'dart:developer'; -import 'package:hub/shared/components/molecules/modules/data/data_sources/license_local_data_source.dart'; -import 'package:hub/shared/components/molecules/modules/data/data_sources/license_remote_data_source.dart'; -import 'package:hub/shared/components/molecules/modules/domain/respositories/license_repository.dart'; -import 'package:hub/shared/helpers/database/database_helper.dart'; +import 'package:hub/features/modules/data/data_sources/index.dart'; +import 'package:hub/features/modules/domain/index.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:sqflite/sqflite.dart'; typedef LicenseStatus = bool; @@ -11,25 +10,21 @@ typedef LicenseStatus = bool; class LicenseRepositoryImpl implements LicenseRepository { final LicenseLocalDataSource localDataSource = LicenseLocalDataSourceImpl(); final LicenseRemoteDataSource remoteDataSource = LicenseRemoteDataSourceImpl(); - final Database database = DatabaseStorage.database; + final Database database = DatabaseService.database; LicenseRepositoryImpl(); - - @override Future updateLicense() async { log('updateLicense'); bool result = false; final bool isNewVersion = await localDataSource.isNewVersion(); result = await remoteDataSource.setupLicense(database, isNewVersion); - if (isNewVersion) { - result = await remoteDataSource.fetchLicenses(isNewVersion); - } + if (isNewVersion) { + result = await remoteDataSource.fetchLicenses(isNewVersion); + } - return result; - } @override diff --git a/lib/shared/components/molecules/modules/domain/entities/base_module.dart b/lib/features/modules/domain/entities/base_module.dart similarity index 100% rename from lib/shared/components/molecules/modules/domain/entities/base_module.dart rename to lib/features/modules/domain/entities/base_module.dart diff --git a/lib/shared/components/molecules/modules/domain/entities/index.dart b/lib/features/modules/domain/entities/index.dart similarity index 100% rename from lib/shared/components/molecules/modules/domain/entities/index.dart rename to lib/features/modules/domain/entities/index.dart diff --git a/lib/shared/components/molecules/modules/domain/entities/license.dart b/lib/features/modules/domain/entities/license.dart similarity index 93% rename from lib/shared/components/molecules/modules/domain/entities/license.dart rename to lib/features/modules/domain/entities/license.dart index 045e5559..d7e4524f 100644 --- a/lib/shared/components/molecules/modules/domain/entities/license.dart +++ b/lib/features/modules/domain/entities/license.dart @@ -1,6 +1,5 @@ +import 'package:hub/features/storage/index.dart'; import 'package:hub/shared/extensions/string_extensions.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'module.dart'; @@ -61,7 +60,7 @@ class License { } static Future _precessWpp() async { - final bool whatsapp = await StorageHelper().get(KeychainStorageKey.whatsapp.value).then((v) => v.toBoolean()); + final bool whatsapp = await StorageHelper().get(LocalsStorageKey.whatsapp.key).then((v) => v.toBoolean()); if (whatsapp) return ModuleStatus.active.key; else @@ -69,7 +68,7 @@ class License { } static Future _processProvisional() async { - final bool provisional = await StorageHelper().get(KeychainStorageKey.provisional.value).then((v) => v.toBoolean()); + final bool provisional = await StorageHelper().get(LocalsStorageKey.provisional.key).then((v) => v.toBoolean()); if (provisional) return ModuleStatus.active.key; else @@ -77,7 +76,7 @@ class License { } static Future _processPets() async { - final bool pets = await StorageHelper().get(KeychainStorageKey.pets.value).then((v) => v.toBoolean()); + final bool pets = await StorageHelper().get(LocalsStorageKey.pets.key).then((v) => v.toBoolean()); if (pets) return ModuleStatus.active.key; else diff --git a/lib/shared/components/molecules/modules/domain/entities/module.dart b/lib/features/modules/domain/entities/module.dart similarity index 94% rename from lib/shared/components/molecules/modules/domain/entities/module.dart rename to lib/features/modules/domain/entities/module.dart index 7dc2e8c2..43cff382 100644 --- a/lib/shared/components/molecules/modules/domain/entities/module.dart +++ b/lib/features/modules/domain/entities/module.dart @@ -1,5 +1,4 @@ -import 'package:hub/shared/components/molecules/modules/data/models/module_model.dart'; - +import 'package:hub/features/modules/index.dart'; enum ModuleStatus { active, inactive, disabled } @@ -26,7 +25,6 @@ enum EnumDisplay { } } - extension ModuleStatusExtension on ModuleStatus { String get key { switch (this) { @@ -40,7 +38,6 @@ extension ModuleStatusExtension on ModuleStatus { } } - class Module { final String key; final String display; @@ -48,14 +45,12 @@ class Module { final String startDate; final int quantity; - Module({ required this.key, required this.display, required this.expirationDate, required this.startDate, required this.quantity, - }); factory Module.fromModel(ModuleModel model) { @@ -77,6 +72,4 @@ class Module { quantity: quantity, ); } - - } diff --git a/lib/shared/components/molecules/modules/domain/index.dart b/lib/features/modules/domain/index.dart similarity index 100% rename from lib/shared/components/molecules/modules/domain/index.dart rename to lib/features/modules/domain/index.dart diff --git a/lib/shared/components/molecules/modules/domain/respositories/index.dart b/lib/features/modules/domain/respositories/index.dart similarity index 100% rename from lib/shared/components/molecules/modules/domain/respositories/index.dart rename to lib/features/modules/domain/respositories/index.dart diff --git a/lib/shared/components/molecules/modules/domain/respositories/license_repository.dart b/lib/features/modules/domain/respositories/license_repository.dart similarity index 100% rename from lib/shared/components/molecules/modules/domain/respositories/license_repository.dart rename to lib/features/modules/domain/respositories/license_repository.dart diff --git a/lib/features/modules/domain/usecases/index.dart b/lib/features/modules/domain/usecases/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/components/molecules/modules/index.dart b/lib/features/modules/index.dart similarity index 100% rename from lib/shared/components/molecules/modules/index.dart rename to lib/features/modules/index.dart diff --git a/lib/features/modules/presentation/blocs/index.dart b/lib/features/modules/presentation/blocs/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/components/molecules/modules/presentation/index.dart b/lib/features/modules/presentation/index.dart similarity index 100% rename from lib/shared/components/molecules/modules/presentation/index.dart rename to lib/features/modules/presentation/index.dart diff --git a/lib/features/modules/presentation/widgets/index.dart b/lib/features/modules/presentation/widgets/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/services/deeplink/deep_link_service.dart b/lib/features/notifications/deep_link_service.dart similarity index 97% rename from lib/shared/services/deeplink/deep_link_service.dart rename to lib/features/notifications/deep_link_service.dart index 5df6ff67..5712a7ae 100644 --- a/lib/shared/services/deeplink/deep_link_service.dart +++ b/lib/features/notifications/deep_link_service.dart @@ -2,10 +2,10 @@ import 'dart:async'; import 'dart:developer'; import 'package:app_links/app_links.dart'; import 'package:flutter/material.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.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/storage/storage_helper.dart'; class DeepLinkService { static final DeepLinkService _instance = DeepLinkService._internal(); diff --git a/lib/backend/notifications/firebase_messaging_service.dart b/lib/features/notifications/firebase_messaging_service.dart similarity index 82% rename from lib/backend/notifications/firebase_messaging_service.dart rename to lib/features/notifications/firebase_messaging_service.dart index 3b768ad2..07fe7df5 100644 --- a/lib/backend/notifications/firebase_messaging_service.dart +++ b/lib/features/notifications/firebase_messaging_service.dart @@ -1,18 +1,15 @@ import 'dart:developer'; import 'package:firebase_messaging/firebase_messaging.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; +import 'package:hub/features/backend/index.dart'; +import 'package:hub/features/storage/data/index.dart'; + import 'package:hub/shared/utils/log_util.dart'; import 'notification_service.dart'; Future handleMessage(RemoteMessage message) async { - NotificationService.show( - title: message.notification!.title!, - body: message.notification!.body!, - payload: Map.from(message.data)); + NotificationService.show(title: message.notification!.title!, body: message.notification!.body!, payload: Map.from(message.data)); } class FirebaseMessagingService { diff --git a/lib/features/notifications/index.dart b/lib/features/notifications/index.dart new file mode 100644 index 00000000..0fa0fda8 --- /dev/null +++ b/lib/features/notifications/index.dart @@ -0,0 +1,3 @@ +export 'deep_link_service.dart'; +export 'firebase_messaging_service.dart'; +export 'notification_service.dart'; diff --git a/lib/backend/notifications/notification_service.dart b/lib/features/notifications/notification_service.dart similarity index 91% rename from lib/backend/notifications/notification_service.dart rename to lib/features/notifications/notification_service.dart index c771a378..06f77ff9 100644 --- a/lib/backend/notifications/notification_service.dart +++ b/lib/features/notifications/notification_service.dart @@ -1,28 +1,22 @@ import 'package:awesome_notifications/awesome_notifications.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/components/templates_components/details_component/details_component_widget.dart'; import 'package:hub/components/templates_components/message_notificaion_modal_template_component/message_notification_widget.dart'; +import 'package:hub/features/backend/index.dart'; +import 'package:hub/features/storage/index.dart'; 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/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:hub/shared/utils/dialog_util.dart'; Future onMessageReceived(Map payload, String? extra, String? handleClick) async { final localId = jsonDecode(payload['local']!)['CLI_ID']; - final cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; - answersRequest( - {required BuildContext context, - required String? ref, - required String? task, - required String? response, - required String? id}) async { + answersRequest({required BuildContext context, required String? ref, required String? task, required String? response, required String? id}) async { final ApiCallResponse? respondeSolicitacaoCall; final RespondeSolicitacaoCall callback = PhpGroup.respondeSolicitacaoCall; @@ -144,8 +138,7 @@ Future onMessageReceived(Map payload, String? extra, Stri ptText: 'Mensagem', ): payload['mensagem'], }), - imagePath: - 'https://freaccess.com.br/freaccess/getImage.php?cliID=$cliUUID&atividade=getFoto&Documento=${payload['documento'] ?? ''}&tipo=E', + imagePath: 'https://freaccess.com.br/freaccess/getImage.php?cliID=$cliUUID&atividade=getFoto&Documento=${payload['documento'] ?? ''}&tipo=E', statusHashMap: [ { FFLocalizations.of(context).getVariableText( @@ -177,8 +170,7 @@ Future onMessageReceived(Map payload, String? extra, Stri return Dialog( backgroundColor: Colors.transparent, child: DetailsComponentWidget( - imagePath: - 'https://freaccess.com.br/freaccess/getImage.php?cliID=$cliUUID&atividade=getFoto&Documento=$id&tipo=$type', + imagePath: 'https://freaccess.com.br/freaccess/getImage.php?cliID=$cliUUID&atividade=getFoto&Documento=$id&tipo=$type', labelsHashMap: Map.from({ FFLocalizations.of(context).getVariableText( enText: 'Name', @@ -270,12 +262,11 @@ class NotificationService { debug: kDebugMode); await AwesomeNotifications().isNotificationAllowed().then((isAllowed) async { - final bool requestOSnotification = - (await StorageHelper().get(KeychainStorageKey.requestOSNotification.value)) == 'true'; + final bool requestOSnotification = (await StorageHelper().get(LocalsStorageKey.requestOSNotification.key)) == 'true'; if (requestOSnotification == false) { if (isAllowed == false) { - await StorageHelper().set(KeychainStorageKey.requestOSNotification.value, true); + await StorageHelper().set(LocalsStorageKey.requestOSNotification.key, true); await AwesomeNotifications().requestPermissionToSendNotifications(); } } @@ -332,10 +323,7 @@ class NotificationService { ), actionButtons: actionButtons, schedule: scheduled - ? NotificationInterval( - interval: Duration(seconds: interval!), - timeZone: await AwesomeNotifications().getLocalTimeZoneIdentifier(), - preciseAlarm: true) + ? NotificationInterval(interval: Duration(seconds: interval!), timeZone: await AwesomeNotifications().getLocalTimeZoneIdentifier(), preciseAlarm: true) : null); } } diff --git a/lib/features/profile/data/data_sources/index.dart b/lib/features/profile/data/data_sources/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/helpers/storage/keychain_storage.dart b/lib/features/profile/data/data_sources/profile_local_data_source.dart similarity index 60% rename from lib/shared/helpers/storage/keychain_storage.dart rename to lib/features/profile/data/data_sources/profile_local_data_source.dart index b86cb7f9..99393e17 100644 --- a/lib/shared/helpers/storage/keychain_storage.dart +++ b/lib/features/profile/data/data_sources/profile_local_data_source.dart @@ -1,30 +1,37 @@ import 'dart:developer'; import 'package:hub/shared/constants/index.dart'; -import 'package:hub/shared/helpers/database/database_helper.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; + import 'package:sqflite/sqflite.dart'; -class KeychainHelper implements BaseStorage { - KeychainHelper._(); +import '../../../storage/application/service/database_service.dart'; +import '../../../storage/domain/entities/base_storage.dart'; - static final KeychainHelper instance = KeychainHelper._(); +abstract class ProfileLocalDataSource { + Future init(); + Future get(String key); + Future set(String key, T value); + Future delete(String key); + Future clearAll(); +} + +class ProfileLocalDataSourceImpl implements BaseStorage { + ProfileLocalDataSourceImpl._(); + + static final ProfileLocalDataSourceImpl instance = ProfileLocalDataSourceImpl._(); bool _isInitialized = false; - - @override Future init() async { if (_isInitialized) return; - await DatabaseStorage.instance.init(); + await DatabaseService.instance.init(); _isInitialized = true; } @override Future get(String key) async { - - var response = await DatabaseStorage.database.query(tableKeychain, where: 'key = ?', whereArgs: [key]); + var response = await DatabaseService.database.query(tableKeychain, where: 'key = ?', whereArgs: [key]); if (response.isEmpty) { return null; } @@ -34,9 +41,8 @@ class KeychainHelper implements BaseStorage { @override Future set(String key, T value) async { - var date = DateTime.now().toIso8601String(); - await DatabaseStorage.database.insert( + await DatabaseService.database.insert( tableKeychain, { 'key': key, @@ -52,19 +58,15 @@ class KeychainHelper implements BaseStorage { @override Future delete(String key) async { - await DatabaseStorage.database.delete(tableKeychain, where: 'key = ?', whereArgs: [key]); + await DatabaseService.database.delete(tableKeychain, where: 'key = ?', whereArgs: [key]); } @override Future clearAll() async { try { - await DatabaseStorage.database.delete(tableKeychain); - - + await DatabaseService.database.delete(tableKeychain); } catch (e, s) { log('() => clearAll keychain: $e', stackTrace: s); } } - - } diff --git a/lib/features/profile/data/index.dart b/lib/features/profile/data/index.dart new file mode 100644 index 00000000..186dfac9 --- /dev/null +++ b/lib/features/profile/data/index.dart @@ -0,0 +1,3 @@ +export 'data_sources/index.dart'; +export 'repositories/index.dart'; +export 'models/index.dart'; diff --git a/lib/features/profile/data/models/index.dart b/lib/features/profile/data/models/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/profile/data/repositories/index.dart b/lib/features/profile/data/repositories/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/profile/domain/entities/index.dart b/lib/features/profile/domain/entities/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/profile/domain/index.dart b/lib/features/profile/domain/index.dart new file mode 100644 index 00000000..00b76d59 --- /dev/null +++ b/lib/features/profile/domain/index.dart @@ -0,0 +1,3 @@ +export 'entities/index.dart'; +export 'respositories/index.dart'; +export 'usecases/index.dart'; diff --git a/lib/features/profile/domain/respositories/index.dart b/lib/features/profile/domain/respositories/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/profile/domain/usecases/index.dart b/lib/features/profile/domain/usecases/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/profile/index.dart b/lib/features/profile/index.dart new file mode 100644 index 00000000..aa560630 --- /dev/null +++ b/lib/features/profile/index.dart @@ -0,0 +1,3 @@ +export 'data/index.dart'; +export 'domain/index.dart'; +export 'presentation/index.dart'; diff --git a/lib/features/profile/presentation/blocs/index.dart b/lib/features/profile/presentation/blocs/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/profile/presentation/index.dart b/lib/features/profile/presentation/index.dart new file mode 100644 index 00000000..48b6447a --- /dev/null +++ b/lib/features/profile/presentation/index.dart @@ -0,0 +1,3 @@ +export 'blocs/index.dart'; +export 'pages/index.dart'; +export 'widgets/index.dart'; diff --git a/lib/features/profile/presentation/pages/index.dart b/lib/features/profile/presentation/pages/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/profile/presentation/widgets/index.dart b/lib/features/profile/presentation/widgets/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/property/presentation/pages/about_property_screen.dart b/lib/features/property/presentation/pages/about_property_screen.dart index 7560cc25..a4180b6a 100644 --- a/lib/features/property/presentation/pages/about_property_screen.dart +++ b/lib/features/property/presentation/pages/about_property_screen.dart @@ -1,13 +1,11 @@ // ignore: must_be_immutable import 'package:flutter/material.dart'; -import 'package:hub/backend/schema/enums/enums.dart'; import 'package:hub/components/atomic_components/shared_components_atoms/appbar.dart'; +import 'package:hub/features/menu/index.dart'; import 'package:hub/flutter_flow/flutter_flow_model.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/components/molecules/menu/index.dart'; -import 'package:hub/shared/components/molecules/modules/index.dart'; class AboutPropertyModel extends FlutterFlowModel { dynamic item; diff --git a/lib/features/storage/application/index.dart b/lib/features/storage/application/index.dart new file mode 100644 index 00000000..adb07df6 --- /dev/null +++ b/lib/features/storage/application/index.dart @@ -0,0 +1 @@ +export 'service/index.dart'; diff --git a/lib/shared/helpers/database/database_helper.dart b/lib/features/storage/application/service/database_service.dart similarity index 86% rename from lib/shared/helpers/database/database_helper.dart rename to lib/features/storage/application/service/database_service.dart index 1fe11f02..25124bbc 100644 --- a/lib/shared/helpers/database/database_helper.dart +++ b/lib/features/storage/application/service/database_service.dart @@ -1,17 +1,15 @@ -import 'package:hub/shared/components/molecules/modules/index.dart'; +import 'package:hub/features/modules/index.dart'; import 'package:hub/shared/constants/index.dart'; -import 'package:hub/shared/helpers/storage/keychain_storage.dart'; import 'package:sqflite/sqflite.dart'; import 'package:path/path.dart'; -import 'dart:developer'; -class DatabaseStorage { +class DatabaseService { static const String _dbName = 'database.db'; static const int _dbVersion = 2; - static final DatabaseStorage instance = DatabaseStorage._internal(); - factory DatabaseStorage() => instance; - DatabaseStorage._internal(); + static final DatabaseService instance = DatabaseService._internal(); + factory DatabaseService() => instance; + DatabaseService._internal(); static Database? _database; static Database get database { @@ -33,7 +31,7 @@ class DatabaseStorage { onUpgrade: _onUpgrade, onDowngrade: _onDowngrade, onOpen: _onOpen, - onConfigure: _onConfigure, + onConfigure: _onConfigure, ); await LicenseRepositoryImpl().updateLicense(); isInitialized = true; @@ -61,7 +59,7 @@ class DatabaseStorage { } Future _onDowngrade(Database database, int oldVersion, int newVersion) async { - print('Downgrading database from version $oldVersion to $newVersion...'); + print('Downgrading database from version $oldVersion to $newVersion...'); if (oldVersion >= 2 && newVersion < 2) { await _dropTables(database); } diff --git a/lib/features/storage/application/service/index.dart b/lib/features/storage/application/service/index.dart new file mode 100644 index 00000000..43178711 --- /dev/null +++ b/lib/features/storage/application/service/index.dart @@ -0,0 +1 @@ +export 'database_service.dart'; diff --git a/lib/features/storage/data/data_sources/database_storage_helper.dart b/lib/features/storage/data/data_sources/database_storage_helper.dart new file mode 100644 index 00000000..653506b9 --- /dev/null +++ b/lib/features/storage/data/data_sources/database_storage_helper.dart @@ -0,0 +1,33 @@ +import 'package:hub/features/storage/index.dart'; + +class DatabaseStorage implements BaseStorage { + @override + Future clearAll() { + // TODO: implement clearAll + throw UnimplementedError(); + } + + @override + Future delete(String key) { + // TODO: implement delete + throw UnimplementedError(); + } + + @override + Future get(String key) { + // TODO: implement get + throw UnimplementedError(); + } + + @override + Future init() { + // TODO: implement init + throw UnimplementedError(); + } + + @override + Future set(String key, T value) { + // TODO: implement set + throw UnimplementedError(); + } +} diff --git a/lib/features/storage/data/data_sources/index.dart b/lib/features/storage/data/data_sources/index.dart new file mode 100644 index 00000000..39123043 --- /dev/null +++ b/lib/features/storage/data/data_sources/index.dart @@ -0,0 +1,3 @@ +export 'database_storage_helper.dart'; +export 'secure_storage_helper.dart'; +export 'shared_storage_helper.dart'; diff --git a/lib/shared/helpers/storage/secure_storage.dart b/lib/features/storage/data/data_sources/secure_storage_helper.dart similarity index 85% rename from lib/shared/helpers/storage/secure_storage.dart rename to lib/features/storage/data/data_sources/secure_storage_helper.dart index e1138229..b3732665 100644 --- a/lib/shared/helpers/storage/secure_storage.dart +++ b/lib/features/storage/data/data_sources/secure_storage_helper.dart @@ -1,7 +1,7 @@ import 'dart:developer'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/features/storage/index.dart'; class SecureStorage implements BaseStorage { SecureStorage._(); @@ -41,14 +41,13 @@ class SecureStorage implements BaseStorage { @override Future clearAll() async { log('Clearing SecureStorage'); - try{ - await _secureStorage.deleteAll( - aOptions: AndroidOptions(), - iOptions: IOSOptions(), - ); + try { + await _secureStorage.deleteAll( + aOptions: AndroidOptions(), + iOptions: IOSOptions(), + ); } catch (e, s) { log('Error clearing all: $e', stackTrace: s); } - } } diff --git a/lib/shared/helpers/storage/shared_preferences_storage.dart b/lib/features/storage/data/data_sources/shared_storage_helper.dart similarity index 93% rename from lib/shared/helpers/storage/shared_preferences_storage.dart rename to lib/features/storage/data/data_sources/shared_storage_helper.dart index a2561e2a..293205d2 100644 --- a/lib/shared/helpers/storage/shared_preferences_storage.dart +++ b/lib/features/storage/data/data_sources/shared_storage_helper.dart @@ -1,4 +1,4 @@ -import 'package:hub/shared/helpers/storage/base_storage.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:shared_preferences/shared_preferences.dart'; class SharedPreferencesStorage implements BaseStorage { diff --git a/lib/features/storage/data/index.dart b/lib/features/storage/data/index.dart new file mode 100644 index 00000000..186dfac9 --- /dev/null +++ b/lib/features/storage/data/index.dart @@ -0,0 +1,3 @@ +export 'data_sources/index.dart'; +export 'repositories/index.dart'; +export 'models/index.dart'; diff --git a/lib/features/storage/data/models/database_storage.dart b/lib/features/storage/data/models/database_storage.dart new file mode 100644 index 00000000..8c2ff39e --- /dev/null +++ b/lib/features/storage/data/models/database_storage.dart @@ -0,0 +1,125 @@ +import 'package:hub/features/storage/index.dart'; + +abstract class DatabaseStorageKey implements IDatabaseStorage { + final String key; + const DatabaseStorageKey(this.key); +} + +class ProfileStorageKey extends DatabaseStorageKey { + const ProfileStorageKey._(String key) : super(key); + + static const ProfileStorageKey userEmail = ProfileStorageKey._('fre_userEmail'); + static const ProfileStorageKey devUUID = ProfileStorageKey._('fre_devUUID'); + static const ProfileStorageKey userUUID = ProfileStorageKey._('fre_userUUID'); + static const ProfileStorageKey userDevUUID = ProfileStorageKey._('fre_userDevUUID'); + static const ProfileStorageKey status = ProfileStorageKey._('fre_status'); + static const ProfileStorageKey userName = ProfileStorageKey._('fre_userName'); + static const ProfileStorageKey clientUUID = ProfileStorageKey._('fre_cliUUID'); + static const ProfileStorageKey ownerUUID = ProfileStorageKey._('fre_ownerUUID'); + static const ProfileStorageKey clientName = ProfileStorageKey._('fre_cliName'); + static const ProfileStorageKey ownerName = ProfileStorageKey._('fre_ownerName'); +} + +class LocalsStorageKey extends DatabaseStorageKey { + const LocalsStorageKey._(String key) : super(key); + + static const LocalsStorageKey petAmount = LocalsStorageKey._('fre_petAmountRegister'); + static const LocalsStorageKey whatsapp = LocalsStorageKey._('fre_whatsapp'); + static const LocalsStorageKey provisional = LocalsStorageKey._('fre_provisional'); + static const LocalsStorageKey pets = LocalsStorageKey._('fre_pets'); + static const LocalsStorageKey local = LocalsStorageKey._('fre_local'); + static const LocalsStorageKey notify = LocalsStorageKey._('fre_notify'); + static const LocalsStorageKey fingerprint = LocalsStorageKey._('fre_fingerprint'); + static const LocalsStorageKey access = LocalsStorageKey._('fre_access'); + static const LocalsStorageKey panic = LocalsStorageKey._('fre_panic'); + static const LocalsStorageKey person = LocalsStorageKey._('fre_person'); + static const LocalsStorageKey requestOSNotification = LocalsStorageKey._('fre_requestOSnotification'); + static const LocalsStorageKey isNewVersion = LocalsStorageKey._('fre_isNewVersion'); +} + +// enum DatabaseStorageKey implements IDatabaseStorage { +// devUUID, +// userUUID, +// userDevUUID, +// status, +// userName, +// userEmail, +// clientUUID, +// ownerName, +// ownerUUID, +// clientName, +// petAmount, +// whatsapp, +// provisional, +// pets, +// local, +// notify, +// fingerprint, +// access, +// panic, +// person, +// requestOSNotification, +// isNewVersion, +// } + +// extension ProfileStorageKeyExtension on DatabaseStorageKey { +// String get profile { +// switch (this) { +// case DatabaseStorageKey.userEmail: +// return 'fre_userEmail'; +// case DatabaseStorageKey.devUUID: +// return 'fre_devUUID'; +// case DatabaseStorageKey.userUUID: +// return 'fre_userUUID'; +// case DatabaseStorageKey.userDevUUID: +// return 'fre_userDevUUID'; +// case DatabaseStorageKey.status: +// return 'fre_status'; +// case DatabaseStorageKey.userName: +// return 'fre_userName'; +// case DatabaseStorageKey.clientUUID: +// return 'fre_cliUUID'; +// case DatabaseStorageKey.ownerUUID: +// return 'fre_ownerUUID'; +// case DatabaseStorageKey.clientName: +// return 'fre_cliName'; +// case DatabaseStorageKey.ownerName: +// return 'fre_ownerName'; +// default: +// return ''; +// } +// } +// } + +// extension LocalsStorageKeyExtension on DatabaseStorageKey { +// String get locals { +// switch (this) { +// case DatabaseStorageKey.petAmount: +// return 'fre_petAmountRegister'; +// case DatabaseStorageKey.whatsapp: +// return 'fre_whatsapp'; +// case DatabaseStorageKey.provisional: +// return 'fre_provisional'; +// case DatabaseStorageKey.pets: +// return 'fre_pets'; +// case DatabaseStorageKey.local: +// return 'fre_local'; +// case DatabaseStorageKey.notify: +// return 'fre_notify'; +// case DatabaseStorageKey.fingerprint: +// return 'fre_fingerprint'; +// case DatabaseStorageKey.access: +// return 'fre_access'; +// case DatabaseStorageKey.panic: +// return 'fre_panic'; +// case DatabaseStorageKey.person: +// return 'fre_person'; +// case DatabaseStorageKey.requestOSNotification: +// return 'fre_requestOSnotification'; +// case DatabaseStorageKey.isNewVersion: +// return 'fre_isNewVersion'; +// default: +// return ''; +// } +// } +// } diff --git a/lib/features/storage/data/models/index.dart b/lib/features/storage/data/models/index.dart new file mode 100644 index 00000000..c840252e --- /dev/null +++ b/lib/features/storage/data/models/index.dart @@ -0,0 +1,4 @@ +export 'database_storage.dart'; +export 'secure_storage.dart'; +export 'shared_storage.dart'; +export 'storage.dart'; diff --git a/lib/features/storage/data/models/secure_storage.dart b/lib/features/storage/data/models/secure_storage.dart new file mode 100644 index 00000000..bd6d6dde --- /dev/null +++ b/lib/features/storage/data/models/secure_storage.dart @@ -0,0 +1,43 @@ +import 'package:hub/features/storage/index.dart'; + +enum SecureStorageKey implements ISecureStorageKey { + 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 ''; + } + } +} diff --git a/lib/features/storage/data/models/shared_storage.dart b/lib/features/storage/data/models/shared_storage.dart new file mode 100644 index 00000000..7cd1dc3e --- /dev/null +++ b/lib/features/storage/data/models/shared_storage.dart @@ -0,0 +1,16 @@ +import 'package:hub/features/storage/index.dart'; + +enum SharedPreferencesKey implements ISharedPreferencesKey { + isFirstRun, +} + +extension SharedPreferencesKeyExtension on SharedPreferencesKey { + String get value { + switch (this) { + case SharedPreferencesKey.isFirstRun: + return 'fre_isFirstRun'; + default: + return ''; + } + } +} diff --git a/lib/features/storage/data/models/storage.dart b/lib/features/storage/data/models/storage.dart new file mode 100644 index 00000000..b881cf3f --- /dev/null +++ b/lib/features/storage/data/models/storage.dart @@ -0,0 +1,7 @@ +import 'package:hub/features/storage/index.dart'; + +enum Storage implements IStorage { + secureStorage, + sharedPreferences, + databaseStorage, +} diff --git a/lib/features/storage/data/repositories/index.dart b/lib/features/storage/data/repositories/index.dart new file mode 100644 index 00000000..1a23c63f --- /dev/null +++ b/lib/features/storage/data/repositories/index.dart @@ -0,0 +1 @@ +export 'storage_repository.dart'; diff --git a/lib/shared/helpers/storage/storage_helper.dart b/lib/features/storage/data/repositories/storage_repository.dart similarity index 80% rename from lib/shared/helpers/storage/storage_helper.dart rename to lib/features/storage/data/repositories/storage_repository.dart index c157698f..af5953af 100644 --- a/lib/shared/helpers/storage/storage_helper.dart +++ b/lib/features/storage/data/repositories/storage_repository.dart @@ -1,10 +1,8 @@ import 'dart:developer'; import 'package:flutter/cupertino.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/keychain_storage.dart'; -import 'package:hub/shared/helpers/storage/secure_storage.dart'; -import 'package:hub/shared/helpers/storage/shared_preferences_storage.dart'; +import 'package:hub/features/profile/data/data_sources/profile_local_data_source.dart'; +import 'package:hub/features/storage/index.dart'; class StorageHelper { static final StorageHelper _instance = StorageHelper._internal(); @@ -22,14 +20,14 @@ class StorageHelper { Future init() async { await SecureStorage.instance.init(); await SharedPreferencesStorage.instance.init(); - await KeychainHelper.instance.init(); + await ProfileLocalDataSourceImpl.instance.init(); String? isFirstRun = await SharedPreferencesStorage.instance.get(SharedPreferencesKey.isFirstRun.value); if (isFirstRun != 'false') { log('First run'); await SharedPreferencesStorage.instance.set(SharedPreferencesKey.isFirstRun.value, false); - await SecureStorage.instance.set(SecureStorageKey.isLogged.value, false); + await SecureStorage.instance.set(SecureStorageKey.isLogged.value, false); } } @@ -40,7 +38,7 @@ class StorageHelper { case Storage.sharedPreferences: return SharedPreferencesStorage.instance; default: - return KeychainHelper.instance; + return ProfileLocalDataSourceImpl.instance; } } @@ -50,7 +48,7 @@ class StorageHelper { } else if (SharedPreferencesKey.values.map((e) => e.value).toList().contains(key)) { return SharedPreferencesStorage.instance; } else { - return KeychainHelper.instance; + return ProfileLocalDataSourceImpl.instance; } } diff --git a/lib/features/storage/domain/entities/base_storage.dart b/lib/features/storage/domain/entities/base_storage.dart new file mode 100644 index 00000000..c1cb6f45 --- /dev/null +++ b/lib/features/storage/domain/entities/base_storage.dart @@ -0,0 +1,11 @@ +abstract class BaseStorage { + Future init(); + + Future set(String key, T value); + + Future get(String key); + + Future delete(String key); + + Future clearAll(); +} diff --git a/lib/features/storage/domain/entities/database_storage.dart b/lib/features/storage/domain/entities/database_storage.dart new file mode 100644 index 00000000..36dafd89 --- /dev/null +++ b/lib/features/storage/domain/entities/database_storage.dart @@ -0,0 +1,3 @@ +import 'package:hub/features/storage/index.dart'; + +abstract class IDatabaseStorage implements IStorage {} diff --git a/lib/features/storage/domain/entities/index.dart b/lib/features/storage/domain/entities/index.dart new file mode 100644 index 00000000..582e38ee --- /dev/null +++ b/lib/features/storage/domain/entities/index.dart @@ -0,0 +1,5 @@ +export 'base_storage.dart'; +export 'database_storage.dart'; +export 'secure_storage.dart'; +export 'shared_storage.dart'; +export 'storage.dart'; diff --git a/lib/features/storage/domain/entities/secure_storage.dart b/lib/features/storage/domain/entities/secure_storage.dart new file mode 100644 index 00000000..a78a931d --- /dev/null +++ b/lib/features/storage/domain/entities/secure_storage.dart @@ -0,0 +1,3 @@ +import 'package:hub/features/storage/index.dart'; + +abstract class ISecureStorageKey implements IStorage {} diff --git a/lib/features/storage/domain/entities/shared_storage.dart b/lib/features/storage/domain/entities/shared_storage.dart new file mode 100644 index 00000000..f1e9fb35 --- /dev/null +++ b/lib/features/storage/domain/entities/shared_storage.dart @@ -0,0 +1,3 @@ +import 'package:hub/features/storage/index.dart'; + +abstract class ISharedPreferencesKey implements IStorage {} diff --git a/lib/features/storage/domain/entities/storage.dart b/lib/features/storage/domain/entities/storage.dart new file mode 100644 index 00000000..d1902c81 --- /dev/null +++ b/lib/features/storage/domain/entities/storage.dart @@ -0,0 +1 @@ +abstract class IStorage {} diff --git a/lib/features/storage/domain/index.dart b/lib/features/storage/domain/index.dart new file mode 100644 index 00000000..00b76d59 --- /dev/null +++ b/lib/features/storage/domain/index.dart @@ -0,0 +1,3 @@ +export 'entities/index.dart'; +export 'respositories/index.dart'; +export 'usecases/index.dart'; diff --git a/lib/features/storage/domain/respositories/index.dart b/lib/features/storage/domain/respositories/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/storage/domain/usecases/index.dart b/lib/features/storage/domain/usecases/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/features/storage/index.dart b/lib/features/storage/index.dart new file mode 100644 index 00000000..65f22682 --- /dev/null +++ b/lib/features/storage/index.dart @@ -0,0 +1,3 @@ +export 'data/index.dart'; +export 'domain/index.dart'; +export 'application/index.dart'; diff --git a/lib/flutter_flow/flutter_flow_button_tabbar.dart b/lib/flutter_flow/flutter_flow_button_tabbar.dart index 45bee44f..d8860120 100644 --- a/lib/flutter_flow/flutter_flow_button_tabbar.dart +++ b/lib/flutter_flow/flutter_flow_button_tabbar.dart @@ -586,7 +586,7 @@ class _FlutterFlowButtonTabBarState extends State with } Widget _buildStyledTab(Widget child, int index) { - final TabBarTheme tabBarTheme = TabBarTheme.of(context); + final TabBarTheme tabBarTheme = TabBarTheme.of(context) as TabBarTheme; final double animationValue; if (index == _currentIndex) { diff --git a/lib/flutter_flow/index.dart b/lib/flutter_flow/index.dart new file mode 100644 index 00000000..d27a3f04 --- /dev/null +++ b/lib/flutter_flow/index.dart @@ -0,0 +1,23 @@ +export 'custom_functions.dart'; +export 'custom_icons.dart'; +export 'flutter_flow_animations.dart'; +export 'flutter_flow_button_tabbar.dart'; +export 'flutter_flow_checkbox_group.dart'; +export 'flutter_flow_drop_down.dart'; +export 'flutter_flow_icon_button.dart'; +export 'flutter_flow_model.dart'; +export 'flutter_flow_theme.dart'; +export 'flutter_flow_util.dart'; +export 'flutter_flow_widgets.dart'; +export 'form_field_controller.dart'; +export 'internationalization.dart'; +export 'keep_alive_wrapper.dart'; +export 'lat_lng.dart'; +export 'permissions_util.dart'; +export 'place.dart'; +export 'random_data_util.dart'; +export 'request_manager.dart'; +export 'uploaded_file.dart'; +export 'upload_data.dart'; + +export 'nav/index.dart'; diff --git a/lib/flutter_flow/nav/index.dart b/lib/flutter_flow/nav/index.dart new file mode 100644 index 00000000..e1ef24f5 --- /dev/null +++ b/lib/flutter_flow/nav/index.dart @@ -0,0 +1,2 @@ +export 'nav.dart'; +export 'serialization_util.dart'; diff --git a/lib/flutter_flow/nav/nav.dart b/lib/flutter_flow/nav/nav.dart index ae2e56c4..8af1b46b 100644 --- a/lib/flutter_flow/nav/nav.dart +++ b/lib/flutter_flow/nav/nav.dart @@ -1,13 +1,15 @@ import 'dart:async'; -import 'dart:developer'; import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:hub/backend/schema/util/schema_util.dart'; +import 'package:hub/features/backend/index.dart'; import 'package:hub/features/history/index.dart'; import 'package:hub/features/home/index.dart'; +import 'package:hub/features/locals/index.dart'; +import 'package:hub/features/menu/index.dart'; import 'package:hub/features/property/index.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/pages/delivery_schedule_page/delivery_schedule_widget.dart'; @@ -32,14 +34,6 @@ import 'package:hub/pages/sign_up_page/sign_up_page_widget.dart'; import 'package:hub/pages/vehicles_on_the_property/vehicles_on_the_property.dart'; import 'package:hub/pages/visits_on_the_property/visits_on_the_property_screen.dart'; import 'package:hub/pages/welcome_page/welcome_page_widget.dart'; -import 'package:hub/shared/components/molecules/locals/data/repositories/locals_repository_impl.dart'; -import 'package:hub/shared/components/molecules/locals/presentation/blocs/local_profile_bloc.dart'; -import 'package:hub/shared/components/molecules/menu/domain/entities/menu_item.dart'; -import 'package:hub/shared/components/molecules/menu/presentation/blocs/menu_bloc.dart'; -import 'package:hub/shared/components/molecules/menu/presentation/mappers/menu_entry.dart'; -import 'package:hub/shared/components/molecules/menu/presentation/widgets/menu_view/menu_list_view.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:provider/provider.dart'; export 'package:go_router/go_router.dart'; @@ -94,8 +88,8 @@ GoRouter createRouter(AppStateNotifier appStateNotifier) { future: () async { final bool isLogged = await StorageHelper().get(SecureStorageKey.isLogged.value) == 'true'; final bool haveLocal = await StorageHelper().get(SecureStorageKey.haveLocal.value) == 'true'; - final bool haveUserUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value))?.isNotEmpty ?? false; - final bool haveDevUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value))?.isNotEmpty ?? false; + final bool haveUserUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key))?.isNotEmpty ?? false; + final bool haveDevUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key))?.isNotEmpty ?? false; if (isLogged && haveDevUUID && haveUserUUID) { return haveLocal diff --git a/lib/flutter_flow/nav/serialization_util.dart b/lib/flutter_flow/nav/serialization_util.dart index 18018306..97a91ecf 100644 --- a/lib/flutter_flow/nav/serialization_util.dart +++ b/lib/flutter_flow/nav/serialization_util.dart @@ -1,9 +1,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; - -import '/backend/schema/structs/index.dart'; -import '/backend/schema/enums/enums.dart'; +import 'package:hub/features/backend/index.dart'; import '../../flutter_flow/lat_lng.dart'; import '../../flutter_flow/place.dart'; @@ -39,11 +37,7 @@ String? serializeParam( return null; } if (isList) { - final serializedValues = (param as Iterable) - .map((p) => serializeParam(p, paramType, isList: false)) - .where((p) => p != null) - .map((p) => p!) - .toList(); + final serializedValues = (param as Iterable).map((p) => serializeParam(p, paramType, isList: false)).where((p) => p != null).map((p) => p!).toList(); return json.encode(serializedValues); } String? data; @@ -115,9 +109,7 @@ LatLng? latLngFromString(String? latLngStr) { FFPlace placeFromString(String placeStr) { final serializedData = jsonDecode(placeStr) as Map; final data = { - 'latLng': serializedData.containsKey('latLng') - ? latLngFromString(serializedData['latLng'] as String) - : const LatLng(0.0, 0.0), + 'latLng': serializedData.containsKey('latLng') ? latLngFromString(serializedData['latLng'] as String) : const LatLng(0.0, 0.0), 'name': serializedData['name'] ?? '', 'address': serializedData['address'] ?? '', 'city': serializedData['city'] ?? '', diff --git a/lib/initialization.dart b/lib/initialization.dart index 564b073f..cdc93bc0 100644 --- a/lib/initialization.dart +++ b/lib/initialization.dart @@ -7,11 +7,12 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_web_plugins/url_strategy.dart'; -import 'package:hub/backend/notifications/notification_service.dart'; +import 'package:hub/features/notifications/index.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/storage/storage_helper.dart'; + +import 'features/storage/index.dart'; Future initializeApp() async { WidgetsFlutterBinding.ensureInitialized(); diff --git a/lib/main.dart b/lib/main.dart index 00c6e724..23e155e3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -6,16 +6,15 @@ import 'package:firebase_crashlytics/firebase_crashlytics.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/material.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; -import 'package:hub/backend/notifications/notification_service.dart'; +import 'package:hub/features/notifications/index.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; -import 'package:hub/shared/services/deeplink/deep_link_service.dart'; + import 'package:responsive_framework/responsive_framework.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'features/storage/index.dart'; import 'initialization.dart'; final GlobalKey navigatorKey = GlobalKey(); 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 31bb70eb..5c88e7a7 100644 --- a/lib/pages/fast_pass_page/fast_pass_page_widget.dart +++ b/lib/pages/fast_pass_page/fast_pass_page_widget.dart @@ -5,10 +5,9 @@ import 'dart:io' show Platform; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/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'; @@ -26,10 +25,10 @@ class _FastPassPageWidgetState extends State { Future> initVariables() async { final email = (await StorageHelper().get(SecureStorageKey.email.value)) ?? ''; - final name = (await StorageHelper().get(KeychainStorageKey.userName.value)) ?? ''; - final devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final name = (await StorageHelper().get(ProfileStorageKey.userName.key)) ?? ''; + final devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const createdAt = '0000-00-00 00:00:00'; final url = 'https://hub.freaccess.com.br/hub/fast-pass/$cliUUID'; final freUserData = @@ -56,17 +55,13 @@ class _FastPassPageWidgetState extends State { if (snapshot.connectionState == ConnectionState.waiting) { return const Center(child: CircularProgressIndicator()); } else if (snapshot.hasError || !snapshot.hasData || snapshot.data!.isEmpty) { - return Center( - child: Text(FFLocalizations.of(context) - .getVariableText(enText: 'Unexpected error', ptText: 'Erro inesperado'))); + return Center(child: Text(FFLocalizations.of(context).getVariableText(enText: 'Unexpected error', ptText: 'Erro inesperado'))); } else { final data = snapshot.data!; final url = data['url']!; final userUUID = data['userUUID']!; final freUserData = data['freUserData']!; - return Platform.isIOS - ? _buildIOSWebView(url, userUUID, freUserData) - : _buildAndroidWebView(url, userUUID, freUserData); + return Platform.isIOS ? _buildIOSWebView(url, userUUID, freUserData) : _buildAndroidWebView(url, userUUID, freUserData); } }, ), @@ -120,9 +115,7 @@ class _FastPassPageWidgetState extends State { } }, onNavigationRequest: (NavigationRequest request) { - if (request.url.startsWith('http') || - request.url.startsWith('https://api.whatsapp.com/send') || - request.url.startsWith('https://wa.me')) { + 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; } diff --git a/lib/pages/forgot_password_page/forgot_password_screen.dart b/lib/pages/forgot_password_page/forgot_password_screen.dart index d63d2017..e5742371 100644 --- a/lib/pages/forgot_password_page/forgot_password_screen.dart +++ b/lib/pages/forgot_password_page/forgot_password_screen.dart @@ -2,8 +2,9 @@ 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/features/authentication/index.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; import '../../flutter_flow/flutter_flow_animations.dart'; import '../../flutter_flow/flutter_flow_icon_button.dart'; @@ -11,7 +12,6 @@ import '../../flutter_flow/flutter_flow_model.dart'; 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 'forgot_password_model.dart'; class ForgotPasswordScreen extends StatefulWidget { @@ -183,8 +183,7 @@ class _ForgotPasswordScreenState extends State with Ticker style: FlutterFlowTheme.of(context).bodyMedium.override( fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, fontWeight: FontWeight.bold, - useGoogleFonts: - GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), ), ), @@ -200,12 +199,9 @@ 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( @@ -213,12 +209,9 @@ 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), ), ], diff --git a/lib/pages/liberation_history/liberation_history_model.dart b/lib/pages/liberation_history/liberation_history_model.dart index 8c016069..f51d5d65 100644 --- a/lib/pages/liberation_history/liberation_history_model.dart +++ b/lib/pages/liberation_history/liberation_history_model.dart @@ -1,10 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; +import 'package:hub/features/backend/index.dart'; +import 'package:hub/features/storage/index.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/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; class LiberationHistoryModel extends FlutterFlowModel { late final String devUUID; @@ -36,17 +35,12 @@ class LiberationHistoryModel extends FlutterFlowModel { } Future init() async { - devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; } - Future answersRequest( - {required BuildContext context, - required String? ref, - required String? task, - required String? response, - required String? id}) async { + Future answersRequest({required BuildContext context, required String? ref, required String? task, required String? response, required String? id}) async { final ApiCallResponse? respondeSolicitacaoCall; final RespondeSolicitacaoCall callback = PhpGroup.respondeSolicitacaoCall; diff --git a/lib/pages/liberation_history/liberation_history_widget.dart b/lib/pages/liberation_history/liberation_history_widget.dart index 4eba3c0a..50f060d4 100644 --- a/lib/pages/liberation_history/liberation_history_widget.dart +++ b/lib/pages/liberation_history/liberation_history_widget.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; import 'package:hub/components/templates_components/details_component/details_component_widget.dart'; +import 'package:hub/features/backend/index.dart'; 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'; @@ -56,27 +56,20 @@ class _LiberationHistoryWidgetState extends State { return Map.from({ '${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']) - : '', + request['NOT_DTENVIO'] != null ? ValidatorUtil.toLocalDateTime('yyyy-MM-dd HH:mm:ss', request['NOT_DTENVIO']) : '', '${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'], + if (details == true) '${FFLocalizations.of(context).getVariableText(ptText: 'Mensagem', enText: 'Message')}:': request['NOT_MSGENVIO'], }); } 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 }); } @@ -142,8 +135,7 @@ 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")), ) ], ), 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 1a2cd70d..81ec3075 100644 --- a/lib/pages/message_history_page/message_history_page_model.dart +++ b/lib/pages/message_history_page/message_history_page_model.dart @@ -1,10 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:hub/backend/api_requests/api_manager.dart'; +import 'package:hub/features/backend/index.dart'; +import 'package:hub/features/storage/index.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/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; class MessageHistoryPageModel extends FlutterFlowModel { late final String devUUID; @@ -39,9 +38,9 @@ class MessageHistoryPageModel extends FlutterFlowModel } Future init() async { - devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; } @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 84624c22..74682ac9 100644 --- a/lib/pages/message_history_page/message_history_page_widget.dart +++ b/lib/pages/message_history_page/message_history_page_widget.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; +import 'package:hub/features/backend/index.dart'; 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'; @@ -226,9 +226,7 @@ class _MessageHistoryPageWidgetState extends State wit mainAxisSize: MainAxisSize.max, children: [ Center( - child: Text( - FFLocalizations.of(context) - .getVariableText(ptText: "Nenhuma mensagem encontrada!", enText: "No message found"), + child: Text(FFLocalizations.of(context).getVariableText(ptText: "Nenhuma mensagem encontrada!", enText: "No message found"), style: TextStyle( color: FlutterFlowTheme.of(context).primaryText, fontSize: limitedSubHeaderFontSize, diff --git a/lib/pages/package_order_page/package_order_page.dart b/lib/pages/package_order_page/package_order_page.dart index 980c5c0b..0ac4b95d 100644 --- a/lib/pages/package_order_page/package_order_page.dart +++ b/lib/pages/package_order_page/package_order_page.dart @@ -2,15 +2,15 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/components/molecular_components/order_filter_modal/order_filter_modal_widget.dart'; import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; import 'package:hub/components/templates_components/details_component/details_component_widget.dart'; +import 'package:hub/features/backend/index.dart'; +import 'package:hub/features/storage/index.dart'; 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/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/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'; @@ -64,7 +64,7 @@ class _PackageOrderPage extends State { } Future initDatabase() async { - cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value) ?? ''); + cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key) ?? ''); } @override @@ -96,10 +96,7 @@ class _PackageOrderPage extends State { setState(() => _loading = true); var response = await PhpGroup.buscaEnconcomendas.call( - pageSize: _pageSize.toString(), - page: _pageNumber.toString(), - adresseeType: _adresseeType == '.*' ? 'TOD' : _adresseeType, - status: _status == '.*' ? 'all' : _status); + pageSize: _pageSize.toString(), page: _pageNumber.toString(), adresseeType: _adresseeType == '.*' ? 'TOD' : _adresseeType, status: _status == '.*' ? 'all' : _status); final List orders = response.jsonBody['value']['list'] ?? []; @@ -255,8 +252,7 @@ class _PackageOrderPage extends State { children: [ Center( child: Text( - FFLocalizations.of(context) - .getVariableText(ptText: "Nenhuma encomenda encontrada!", enText: "No orders found!"), + FFLocalizations.of(context).getVariableText(ptText: "Nenhuma encomenda encontrada!", enText: "No orders found!"), style: TextStyle( color: FlutterFlowTheme.of(context).primaryText, fontSize: LimitedFontSizeUtil.getHeaderFontSize(context), @@ -306,42 +302,26 @@ class _PackageOrderPage extends State { Map _labelsHashMap(dynamic order) { return Map.from({ - if (order['isPending'] == true) - '${FFLocalizations.of(context).getVariableText(ptText: 'Cód. Retirada', enText: 'Pickup Code')}:': - order['id'].toString(), - '${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']), + if (order['isPending'] == true) '${FFLocalizations.of(context).getVariableText(ptText: 'Cód. Retirada', enText: 'Pickup Code')}:': order['id'].toString(), + '${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']), 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']), + '${FFLocalizations.of(context).getVariableText(ptText: 'Retirado em', enText: 'Picked up on')}:': ValidatorUtil.toLocalDateTime('yyyy-MM-dd HH:mm:ss', order['dtPickUp']), }); } Map _labelsHashMapDialog(dynamic order) { return Map.from({ - if (order['isPending'] == true) - '${FFLocalizations.of(context).getVariableText(ptText: 'Cód. Retirada', enText: 'Pickup Code')}:': - order['id'].toString(), - '${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: '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']), + if (order['isPending'] == true) '${FFLocalizations.of(context).getVariableText(ptText: 'Cód. Retirada', enText: 'Pickup Code')}:': order['id'].toString(), + '${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: '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']), + 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 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']), - if (order['message'] != null) - '${FFLocalizations.of(context).getVariableText(ptText: 'Mensagem', enText: 'Message')}:': order['message'] + '${FFLocalizations.of(context).getVariableText(ptText: 'Retirado em', enText: 'Picked up on')}:': ValidatorUtil.toLocalDateTime('yyyy-MM-dd HH:mm:ss', order['dtPickUp']), + if (order['message'] != null) '${FFLocalizations.of(context).getVariableText(ptText: 'Mensagem', enText: 'Message')}:': order['message'] }); } @@ -349,13 +329,11 @@ 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({ @@ -391,14 +369,11 @@ class _PackageOrderPage extends State { statusHashMap: [ 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, }), ], buttons: const [], @@ -417,4 +392,4 @@ class _PackageOrderPage extends State { body: _appBody(context), ); } -} \ No newline at end of file +} 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 a1146aeb..1c4b13ec 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 @@ -2,7 +2,7 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; +import 'package:hub/features/backend/index.dart'; 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'; diff --git a/lib/pages/pets_on_the_property_page/pets_history_screen.dart b/lib/pages/pets_on_the_property_page/pets_history_screen.dart index b32ba509..d66ff2b8 100644 --- a/lib/pages/pets_on_the_property_page/pets_history_screen.dart +++ b/lib/pages/pets_on_the_property_page/pets_history_screen.dart @@ -1,15 +1,15 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; -import 'package:hub/backend/api_requests/api_manager.dart'; + import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; +import 'package:hub/features/backend/index.dart'; +import 'package:hub/features/storage/index.dart'; 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/pets_page/pets_page_model.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/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'; @@ -58,10 +58,11 @@ class _PetsHistoryScreenState extends State with TickerProvid return AppBar( backgroundColor: FlutterFlowTheme.of(context).primaryBackground, automaticallyImplyLeading: false, - title: Text(FFLocalizations.of(context).getVariableText( - ptText: 'Pets', - enText: 'Pets', - ), + title: Text( + FFLocalizations.of(context).getVariableText( + ptText: 'Pets', + enText: 'Pets', + ), style: FlutterFlowTheme.of(context).headlineMedium.override( fontFamily: 'Nunito', color: FlutterFlowTheme.of(context).primaryText, @@ -176,9 +177,7 @@ class _PetsHistoryScreenState extends State with TickerProvid mainAxisSize: MainAxisSize.max, children: [ Center( - child: Text( - FFLocalizations.of(context) - .getVariableText(ptText: "Nenhum Pet encontrado!", enText: "No pets found"), + child: Text(FFLocalizations.of(context).getVariableText(ptText: "Nenhum Pet encontrado!", enText: "No pets found"), style: TextStyle( fontFamily: 'Nunito', fontSize: limitedHeaderTextSize, @@ -294,10 +293,10 @@ class _PetsHistoryScreenState extends State with TickerProvid } ], onTapCardItemAction: () async { - final devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; - final cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; + final devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; + final cliName = (await StorageHelper().get(ProfileStorageKey.clientName.key)) ?? ''; await showDialog( useSafeArea: true, context: context, diff --git a/lib/pages/pets_page/pets_page_model.dart b/lib/pages/pets_page/pets_page_model.dart index aeb213a9..0b1f93b0 100644 --- a/lib/pages/pets_page/pets_page_model.dart +++ b/lib/pages/pets_page/pets_page_model.dart @@ -4,16 +4,16 @@ import 'dart:developer'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/components/templates_components/details_component/details_component_widget.dart'; +import 'package:hub/features/backend/index.dart'; +import 'package:hub/features/storage/data/index.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; 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/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/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'; @@ -147,21 +147,20 @@ class PetsPageModel extends FlutterFlowModel { textControllerObservation = TextEditingController(); WidgetsBinding.instance.addPostFrameCallback((_) async { - devUUID = await StorageHelper().get(KeychainStorageKey.devUUID.value) ?? ''; - userUUID = await StorageHelper().get(KeychainStorageKey.userUUID.value) ?? ''; - cliUUID = await StorageHelper().get(KeychainStorageKey.clientUUID.value) ?? ''; - petAmountRegister = await StorageHelper().get(KeychainStorageKey.petAmount.value) ?? ''; + devUUID = await StorageHelper().get(ProfileStorageKey.devUUID.key) ?? ''; + userUUID = await StorageHelper().get(ProfileStorageKey.userUUID.key) ?? ''; + cliUUID = await StorageHelper().get(ProfileStorageKey.clientUUID.key) ?? ''; + petAmountRegister = await StorageHelper().get(LocalsStorageKey.petAmount.key) ?? ''; }); } void setEditForm() { - if (item != null) petId = item['id']; // updateImage!(); (() async { - Response response = await get(Uri.parse( - 'https://freaccess.com.br/freaccess/getImage.php?devUUID=$devUUID&userUUID=$userUUID&cliID=$cliUUID&atividade=consultaFotoPet&petId=$petId')); + Response response = + await get(Uri.parse('https://freaccess.com.br/freaccess/getImage.php?devUUID=$devUUID&userUUID=$userUUID&cliID=$cliUUID&atividade=consultaFotoPet&petId=$petId')); String base64 = base64Encode(response.bodyBytes); uploadedTempFile = await ImageUtils.convertToUploadFile(base64); updateImage?.call(); @@ -238,14 +237,10 @@ class PetsPageModel extends FlutterFlowModel { return false; } - if (dropDownValueController1!.value == defaultDropDownText || - dropDownValueController1!.value == '' || - dropDownValueController1!.value == null) { + if (dropDownValueController1!.value == defaultDropDownText || dropDownValueController1!.value == '' || dropDownValueController1!.value == null) { return false; } - if (dropDownValueController2!.value == defaultDropDownText || - dropDownValueController2!.value == '' || - dropDownValueController2!.value == null) { + if (dropDownValueController2!.value == defaultDropDownText || dropDownValueController2!.value == '' || dropDownValueController2!.value == null) { return false; } @@ -263,8 +258,7 @@ class PetsPageModel extends FlutterFlowModel { Future updatePet() async { var img = await ImageUtils.convertImageFileToBase64(uploadedLocalFile!); img = "base64;jpeg,$img"; - final url = - 'https://freaccess.com.br/freaccess/getImage.php?devUUID=$devUUID&userUUID=$userUUID&cliID=$cliUUID&atividade=consultaFotoPet&petId=$petId'; + final url = 'https://freaccess.com.br/freaccess/getImage.php?devUUID=$devUUID&userUUID=$userUUID&cliID=$cliUUID&atividade=consultaFotoPet&petId=$petId'; final response = await PhpGroup.updatePet.call( petID: petId, image: img, @@ -507,17 +501,12 @@ class PetsPageModel extends FlutterFlowModel { : [], labelsHashMap: Map.from({ if (item['species'] != null && item['species'] != '') - '${FFLocalizations.of(context).getVariableText(ptText: "Espécie", enText: "Species")}:': - item['species'].toString().toUpperCase(), + '${FFLocalizations.of(context).getVariableText(ptText: "Espécie", enText: "Species")}:': item['species'].toString().toUpperCase(), if (item['breed'] != null && item['breed'] != '') - '${FFLocalizations.of(context).getVariableText(ptText: "Raça", enText: "Breed")}:': - item['breed'].toString().toUpperCase(), - if (item['color'] != null && item['color'] != '') - '${FFLocalizations.of(context).getVariableText(ptText: "Cor", enText: "Color")}:': - item['color'].toString().toUpperCase(), + '${FFLocalizations.of(context).getVariableText(ptText: "Raça", enText: "Breed")}:': item['breed'].toString().toUpperCase(), + if (item['color'] != null && item['color'] != '') '${FFLocalizations.of(context).getVariableText(ptText: "Cor", enText: "Color")}:': item['color'].toString().toUpperCase(), if (item['birthdayDate'] != null && item['birthdayDate'] != '') - '${FFLocalizations.of(context).getVariableText(ptText: "Data de Nascimento", enText: "Date of Birth")}:': - ValidatorUtil.formatDateTimePicker(item['birthdayDate']), + '${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') @@ -534,11 +523,9 @@ class PetsPageModel extends FlutterFlowModel { : 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'] ?? '', + if (item['notes'] != null && 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'] ?? ''}', + imagePath: 'https://freaccess.com.br/freaccess/getImage.php?devUUID=$devUUID&userUUID=$userUUID&cliID=$cliUUID&atividade=consultaFotoPet&petId=${item['id'] ?? ''}', statusHashMap: [ if (item['gender'] == "MAC") Map.from({ diff --git a/lib/pages/preferences_settings_page/preferences_settings_model.dart b/lib/pages/preferences_settings_page/preferences_settings_model.dart index 6f52a602..dec63120 100644 --- a/lib/pages/preferences_settings_page/preferences_settings_model.dart +++ b/lib/pages/preferences_settings_page/preferences_settings_model.dart @@ -1,14 +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/features/authentication/index.dart'; +import 'package:hub/features/backend/index.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/components/molecules/locals/index.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; -import 'package:hub/shared/services/authentication/authentication_service.dart'; +import 'package:hub/features/locals/index.dart'; + import 'package:hub/shared/utils/path_util.dart'; import 'package:share_plus/share_plus.dart'; @@ -24,11 +24,11 @@ class PreferencesPageModel with ChangeNotifier { late bool isPanic = false; Future _initialize() async { - isFingerprint = await StorageHelper().get(KeychainStorageKey.fingerprint.value) == 'true'; - isPerson = await StorageHelper().get(KeychainStorageKey.person.value) == 'true'; - isNotify = await StorageHelper().get(KeychainStorageKey.notify.value) == 'true'; - isAccess = await StorageHelper().get(KeychainStorageKey.access.value) == 'true'; - isPanic = await StorageHelper().get(KeychainStorageKey.panic.value) == 'true'; + isFingerprint = await StorageHelper().get(LocalsStorageKey.fingerprint.key) == 'true'; + isPerson = await StorageHelper().get(LocalsStorageKey.person.key) == 'true'; + isNotify = await StorageHelper().get(LocalsStorageKey.notify.key) == 'true'; + isAccess = await StorageHelper().get(LocalsStorageKey.access.key) == 'true'; + isPanic = await StorageHelper().get(LocalsStorageKey.panic.key) == 'true'; notifyListeners(); } @@ -37,7 +37,7 @@ class PreferencesPageModel with ChangeNotifier { } Future enablePerson(BuildContext context) async { - final String userDevUUID = (await StorageHelper().get(KeychainStorageKey.userDevUUID.value)) ?? ''; + final String userDevUUID = (await StorageHelper().get(ProfileStorageKey.userDevUUID.key)) ?? ''; notifyListeners(); Share.share( FFLocalizations.of(context).getVariableText( @@ -64,7 +64,7 @@ class PreferencesPageModel with ChangeNotifier { .call(notifica: value) .then((value) async { if (value.jsonBody['error'] == false) { - await StorageHelper().set(KeychainStorageKey.notify.value, isNotify ? 'false' : 'true'); + await StorageHelper().set(LocalsStorageKey.notify.key, isNotify ? 'false' : 'true'); content = FFLocalizations.of(context).getVariableText( enText: 'Notification changed successfully', ptText: 'Notificação alterada com sucesso', @@ -86,7 +86,7 @@ class PreferencesPageModel with ChangeNotifier { ); SnackBarUtil.showSnackBar(context, content, isError: true); }) - .then((_) async => isNotify = await StorageHelper().get(KeychainStorageKey.notify.value) == 'true') + .then((_) async => isNotify = await StorageHelper().get(LocalsStorageKey.notify.key) == 'true') .whenComplete(() => notifyListeners()); context.pop(); } @@ -99,6 +99,7 @@ class PreferencesPageModel with ChangeNotifier { 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?', @@ -141,7 +142,7 @@ class PreferencesPageModel with ChangeNotifier { .then((value) async { final String content; if (jsonDecode(value.jsonBody['error'].toString()) == false) { - await StorageHelper().set(KeychainStorageKey.access.value, isAccess ? 'false' : 'true'); + await StorageHelper().set(LocalsStorageKey.access.key, isAccess ? 'false' : 'true'); notifyListeners(); content = FFLocalizations.of(context).getVariableText( enText: 'Access pass changed successfully', @@ -163,7 +164,7 @@ class PreferencesPageModel with ChangeNotifier { ); SnackBarUtil.showSnackBar(context, content, isError: true); }) - .then((_) async => isAccess = await StorageHelper().get(KeychainStorageKey.access.value) == 'true') + .then((_) async => isAccess = await StorageHelper().get(LocalsStorageKey.access.key) == 'true') .whenComplete(() => notifyListeners()); } @@ -178,7 +179,7 @@ class PreferencesPageModel with ChangeNotifier { .then((value) async { final String content; if (jsonDecode(value.jsonBody['error'].toString()) == false) { - await StorageHelper().set(KeychainStorageKey.panic.value, isPanic ? 'false' : 'true'); + await StorageHelper().set(LocalsStorageKey.panic.key, isPanic ? 'false' : 'true'); notifyListeners(); content = FFLocalizations.of(context).getVariableText( enText: 'Panic password changed successfully', @@ -200,7 +201,7 @@ class PreferencesPageModel with ChangeNotifier { ); SnackBarUtil.showSnackBar(context, content, isError: true); }) - .then((_) async => isPanic = await StorageHelper().get(KeychainStorageKey.panic.value) == 'true') + .then((_) async => isPanic = await StorageHelper().get(LocalsStorageKey.panic.key) == 'true') .whenComplete(() => notifyListeners()); } @@ -216,10 +217,10 @@ class PreferencesPageModel with ChangeNotifier { onChange(String? key) async { isFingerprint = !isFingerprint; await StorageHelper().set(SecureStorageKey.fingerprintPass.value, key ?? ''); - await StorageHelper().set(KeychainStorageKey.fingerprint.value, isFingerprint ? 'true' : 'false'); + await StorageHelper().set(LocalsStorageKey.fingerprint.key, isFingerprint ? 'true' : 'false'); notifyListeners(); SnackBarUtil.showSnackBar(context, content); - isFingerprint = await StorageHelper().get(KeychainStorageKey.fingerprint.value) == 'true'; + isFingerprint = await StorageHelper().get(LocalsStorageKey.fingerprint.key) == 'true'; } isFingerprint ? onChange(null) : _showPassKey(context, onChange); 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 41df6e77..857728c9 100644 --- a/lib/pages/qr_code_page/qr_code_page_model.dart +++ b/lib/pages/qr_code_page/qr_code_page_model.dart @@ -2,10 +2,10 @@ import 'dart:async'; import 'dart:typed_data'; import 'package:flutter/material.dart'; +import 'package:hub/features/storage/index.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/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; + import 'package:qr_flutter/qr_flutter.dart'; class QrCodePageModel extends FlutterFlowModel { @@ -29,8 +29,8 @@ class QrCodePageModel extends FlutterFlowModel { } Future initVariable() async { - isFingerprint = await StorageHelper().get(KeychainStorageKey.fingerprint.value) == 'true'; - userDevUUID = await StorageHelper().get(KeychainStorageKey.userDevUUID.value) ?? ''; + isFingerprint = await StorageHelper().get(LocalsStorageKey.fingerprint.key) == 'true'; + userDevUUID = await StorageHelper().get(ProfileStorageKey.userDevUUID.key) ?? ''; safeSetState?.call(); } @@ -101,18 +101,12 @@ class QrCodePageModel extends FlutterFlowModel { return String.fromCharCodes(bytes); } - Widget buildQrCode( - {required int errorCorrectLevel, - required double dimension, - required String identifier, - required String pass, - required int direction}) { + Widget buildQrCode({required int errorCorrectLevel, required double dimension, required String identifier, required String pass, required int direction}) { try { const Color backgroundColor = Colors.white; const Color foregroundColor = Colors.black; return QrImageView.withQr( - qr: QrCode.fromUint8List( - data: assembleQRPacket(direction, identifier, pass), errorCorrectLevel: errorCorrectLevel), + qr: QrCode.fromUint8List(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 6aad1599..f71f9b5c 100644 --- a/lib/pages/qr_code_page/qr_code_page_widget.dart +++ b/lib/pages/qr_code_page/qr_code_page_widget.dart @@ -9,6 +9,7 @@ import 'package:flutter/scheduler.dart'; import 'package:flutter_animate/flutter_animate.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:hub/components/templates_components/qr_code_pass_key_template_component/qr_code_pass_key_template_component_widget.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/custom_functions.dart'; import 'package:hub/flutter_flow/flutter_flow_animations.dart'; import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; @@ -17,8 +18,6 @@ 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/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:hub/shared/utils/biometric_util.dart'; import 'package:hub/shared/utils/limited_text_size.dart'; @@ -125,8 +124,7 @@ class _QrCodePageWidgetState extends State with TickerProvider fontSize: limitedHeaderTextSize, letterSpacing: 0.0, fontWeight: FontWeight.bold, - useGoogleFonts: - GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), ), ), ), @@ -141,9 +139,7 @@ class _QrCodePageWidgetState extends State with TickerProvider _resetAnimationAndToggleAccess(); }); - _model.isFingerprint - ? await _showBiometricsAuth(context) - : await _showQrCodeBottomSheet(context); + _model.isFingerprint ? await _showBiometricsAuth(context) : await _showQrCodeBottomSheet(context); }, child: _model.buildQrCode( dimension: dimension, @@ -196,9 +192,7 @@ class _QrCodePageWidgetState extends State with TickerProvider alignment: const AlignmentDirectional(0.0, 0.0), child: FFButtonWidget( onPressed: () async { - _model.isFingerprint - ? await _showBiometricsAuth(context) - : await _showQrCodeBottomSheet(context); + _model.isFingerprint ? await _showBiometricsAuth(context) : await _showQrCodeBottomSheet(context); }, text: FFLocalizations.of(context).getVariableText( ptText: 'Gerar QR Code', @@ -213,8 +207,7 @@ class _QrCodePageWidgetState extends State with TickerProvider 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: LimitedFontSizeUtil.getCalculateFontSize(context, 12, 12, 10), ), elevation: 3.0, @@ -249,8 +242,7 @@ class _QrCodePageWidgetState extends State with TickerProvider 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: limitedBodyFontSize, ), ), @@ -286,8 +278,7 @@ class _QrCodePageWidgetState extends State with TickerProvider fontFamily: FlutterFlowTheme.of(context).bodyMediumFamily, letterSpacing: 0.0, fontWeight: FontWeight.w600, - useGoogleFonts: - GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).bodyMediumFamily), fontSize: LimitedFontSizeUtil.getNoResizeFont(context, 14), ), ), @@ -327,8 +318,7 @@ class _QrCodePageWidgetState extends State with TickerProvider fontFamily: FlutterFlowTheme.of(context).headlineSmallFamily, fontSize: LimitedFontSizeUtil.getNoResizeFont(context, 14), letterSpacing: 0.0, - useGoogleFonts: GoogleFonts.asMap() - .containsKey(FlutterFlowTheme.of(context).headlineSmallFamily), + useGoogleFonts: GoogleFonts.asMap().containsKey(FlutterFlowTheme.of(context).headlineSmallFamily), ), ), startAngle: 20.0, @@ -378,9 +368,7 @@ class _QrCodePageWidgetState extends State with TickerProvider context: context, builder: (context) { return GestureDetector( - onTap: () => _model.unfocusNode.canRequestFocus - ? FocusScope.of(context).requestFocus(_model.unfocusNode) - : FocusScope.of(context).unfocus(), + onTap: () => _model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(_model.unfocusNode) : FocusScope.of(context).unfocus(), child: Padding( padding: MediaQuery.viewInsetsOf(context), child: QrCodePassKeyTemplateComponentWidget( diff --git a/lib/pages/reception_page/reception_page_model.dart b/lib/pages/reception_page/reception_page_model.dart index 239f675a..c4834564 100644 --- a/lib/pages/reception_page/reception_page_model.dart +++ b/lib/pages/reception_page/reception_page_model.dart @@ -1,12 +1,11 @@ import 'package:flutter/material.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/internationalization.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; import 'package:share_plus/share_plus.dart'; class ReceptionPageModel with ChangeNotifier { Future getIdenfifier(BuildContext context) async { - final String userDevUUID = (await StorageHelper().get(KeychainStorageKey.userDevUUID.value)) ?? ''; + final String userDevUUID = (await StorageHelper().get(ProfileStorageKey.userDevUUID.key)) ?? ''; notifyListeners(); Share.share( diff --git a/lib/pages/reception_page/reception_page_widget.dart b/lib/pages/reception_page/reception_page_widget.dart index a29e194b..d48c10cf 100644 --- a/lib/pages/reception_page/reception_page_widget.dart +++ b/lib/pages/reception_page/reception_page_widget.dart @@ -3,16 +3,18 @@ import 'dart:developer'; import 'package:awesome_notifications/awesome_notifications.dart'; import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; -import 'package:hub/backend/notifications/firebase_messaging_service.dart'; + import 'package:hub/components/atomic_components/shared_components_atoms/atom_image_svg_theme.dart'; +import 'package:hub/features/authentication/index.dart'; +import 'package:hub/features/backend/index.dart'; +import 'package:hub/features/notifications/index.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/flutter_flow_util.dart'; import 'package:hub/flutter_flow/flutter_flow_widgets.dart'; import 'package:hub/pages/reception_page/reception_page_model.dart'; -import 'package:hub/shared/components/molecules/locals/index.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; -import 'package:hub/shared/services/authentication/authentication_service.dart'; +import 'package:hub/features/locals/index.dart'; + import 'package:hub/shared/utils/limited_text_size.dart'; import 'package:provider/provider.dart'; diff --git a/lib/pages/reservation_page/reservation_page_widget.dart b/lib/pages/reservation_page/reservation_page_widget.dart index 4d9091ac..0a388062 100644 --- a/lib/pages/reservation_page/reservation_page_widget.dart +++ b/lib/pages/reservation_page/reservation_page_widget.dart @@ -3,10 +3,10 @@ import 'dart:io' show Platform; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/flutter_flow/nav/nav.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/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'; @@ -23,10 +23,10 @@ class _ReservationPageWidgetState extends State { Future> initVariables() async { final email = (await StorageHelper().get(SecureStorageKey.email.value)) ?? ''; - final name = (await StorageHelper().get(KeychainStorageKey.userName.value)) ?? ''; - final devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final clientId = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + final name = (await StorageHelper().get(ProfileStorageKey.userName.key)) ?? ''; + final devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final clientId = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; const createdAt = '0000-00-00 00:00:00'; final url = 'https://hub.freaccess.com.br/hub/reservation/$clientId'; final freUserData = @@ -53,17 +53,13 @@ class _ReservationPageWidgetState extends State { if (snapshot.connectionState == ConnectionState.waiting) { return const Center(child: CircularProgressIndicator()); } else if (snapshot.hasError || !snapshot.hasData || snapshot.data!.isEmpty) { - return Center( - child: Text(FFLocalizations.of(context) - .getVariableText(enText: 'Unexpected error', ptText: 'Erro inesperado'))); + return Center(child: Text(FFLocalizations.of(context).getVariableText(enText: 'Unexpected error', ptText: 'Erro inesperado'))); } else { final data = snapshot.data!; final url = data['url']!; final userUUID = data['userUUID']!; final freUserData = data['freUserData']!; - return Platform.isIOS - ? _buildIOSWebView(url, userUUID, freUserData) - : _buildAndroidWebView(url, userUUID, freUserData); + return Platform.isIOS ? _buildIOSWebView(url, userUUID, freUserData) : _buildAndroidWebView(url, userUUID, freUserData); } }, ), @@ -116,9 +112,7 @@ class _ReservationPageWidgetState extends State { } }, onNavigationRequest: (NavigationRequest request) { - if (request.url.startsWith('http') || - request.url.startsWith('https://api.whatsapp.com/send') || - request.url.startsWith('https://wa.me')) { + 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; } diff --git a/lib/pages/residents_on_the_property/residents_on_the_property_model.dart b/lib/pages/residents_on_the_property/residents_on_the_property_model.dart index 4883ceb3..cf0e1966 100644 --- a/lib/pages/residents_on_the_property/residents_on_the_property_model.dart +++ b/lib/pages/residents_on_the_property/residents_on_the_property_model.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/pages/residents_on_the_property/residents_on_the_property_screen.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; class ResidentsOnThePropertyModel extends FlutterFlowModel { ResidentsOnThePropertyModel({this.onRefresh}); @@ -18,8 +17,8 @@ class ResidentsOnThePropertyModel extends FlutterFlowModel 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 updateVisitorJsonListAtIndex(int index, Function(dynamic) updateFn) => - visitorJsonList[index] = updateFn(visitorJsonList[index]); + void updateVisitorJsonListAtIndex(int index, Function(dynamic) updateFn) => visitorJsonList[index] = updateFn(visitorJsonList[index]); bool isValid() { - if (textController1!.text.isEmpty || - textController2!.text.isEmpty || - dropDownValue1 == null || - dropDownValue1!.isEmpty || - dropDownValue2 == null || - dropDownValue2!.isEmpty) { + if (textController1!.text.isEmpty || textController2!.text.isEmpty || dropDownValue1 == null || dropDownValue1!.isEmpty || dropDownValue2 == null || dropDownValue2!.isEmpty) { return false; } @@ -152,9 +145,7 @@ class ScheduleCompleteVisitPageModel extends FlutterFlowModel ); } } catch (e) { - return FFLocalizations.of(context).getVariableText( - ptText: 'Preencha corretamente o campo de término da visita!', - enText: 'Fill in the end of visit field correctly!'); + return FFLocalizations.of(context).getVariableText(ptText: 'Preencha corretamente o campo de término da visita!', enText: 'Fill in the end of visit field correctly!'); } } return null; @@ -195,9 +186,7 @@ class ScheduleCompleteVisitPageModel extends FlutterFlowModel ); } } catch (e) { - return FFLocalizations.of(context).getVariableText( - ptText: 'Preencha corretamente o campo de início da visita!', - enText: 'Fill in the visit start field correctly!'); + return FFLocalizations.of(context).getVariableText(ptText: 'Preencha corretamente o campo de início da visita!', enText: 'Fill in the visit start field correctly!'); } } return null; @@ -218,9 +207,9 @@ class ScheduleCompleteVisitPageModel extends FlutterFlowModel } Future _initVariables() async { - devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; } @override @@ -333,8 +322,7 @@ class ScheduleCompleteVisitPageModel extends FlutterFlowModel } } - Future visitCancelAction(BuildContext context, - {required int? idDestino, required int? idVisita, required String? accessKey, required String? email}) async { + Future visitCancelAction(BuildContext context, {required int? idDestino, required int? idVisita, required String? accessKey, required String? email}) async { final ApiCallResponse? response; final CancelaVisita callback = PhpGroup.cancelaVisita; @@ -567,16 +555,11 @@ 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: "Inicio", enText: "Start")}:': - item['VAW_DTINICIO'] != '' && item['VAW_DTINICIO'] != null - ? ValidatorUtil.toLocalDateTime('yyyy-MM-dd HH:mm:ss', item['VAW_DTINICIO']) - : '', + item['VAW_DTINICIO'] != '' && item['VAW_DTINICIO'] != null ? 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']) - : '', + item['VAW_DTFIM'] != '' && item['VAW_DTFIM'] != null ? ValidatorUtil.toLocalDateTime('yyyy-MM-dd HH:mm:ss', item['VAW_DTFIM']) : '', }), - imagePath: - 'https://freaccess.com.br/freaccess/getImage.php?cliID=$cliUUID&atividade=getFoto&Documento=${item['VTE_DOCUMENTO'] ?? ''}&tipo=E', + imagePath: 'https://freaccess.com.br/freaccess/getImage.php?cliID=$cliUUID&atividade=getFoto&Documento=${item['VTE_DOCUMENTO'] ?? ''}&tipo=E', statusHashMap: [ if (Status.getStatus(item['VAW_STATUS']) == StatusEnum.active) Map.from({ 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 2cf0c1cb..71050c2d 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 @@ -3,10 +3,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/components/atomic_components/shared_components_atoms/toast.dart'; import 'package:hub/components/templates_components/details_component/details_component_widget.dart'; import 'package:hub/components/templates_components/visitor_search_modal_template_component/visitor_search_modal_template_component_widget.dart'; +import 'package:hub/features/backend/index.dart'; import 'package:hub/flutter_flow/custom_functions.dart'; import 'package:hub/flutter_flow/flutter_flow_drop_down.dart'; import 'package:hub/flutter_flow/flutter_flow_icon_button.dart'; @@ -35,8 +35,7 @@ class ScheduleCompleteVisitPageWidget extends ScheduleComplete { State createState() => _ScheduleCompleteVisitPageWidgetState(); } -class _ScheduleCompleteVisitPageWidgetState extends State - with TickerProviderStateMixin { +class _ScheduleCompleteVisitPageWidgetState extends State with TickerProviderStateMixin { bool _isLoading = false; late ScheduleCompleteVisitPageModel _model; int _visitHistoryLoadingIdx = 0; @@ -100,9 +99,7 @@ class _ScheduleCompleteVisitPageWidgetState extends State _model.unfocusNode.canRequestFocus - ? FocusScope.of(context).requestFocus(_model.unfocusNode) - : FocusScope.of(context).unfocus(), + onTap: () => _model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(_model.unfocusNode) : FocusScope.of(context).unfocus(), child: Scaffold( key: scaffoldKey, backgroundColor: FlutterFlowTheme.of(context).primaryBackground, @@ -240,8 +237,7 @@ class _ScheduleCompleteVisitPageWidgetState extends State model.unfocusNode.canRequestFocus - ? FocusScope.of(context).requestFocus(model.unfocusNode) - : FocusScope.of(context).unfocus(), + onTap: () => model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(model.unfocusNode) : FocusScope.of(context).unfocus(), child: SizedBox( height: MediaQuery.of(context).size.height * 0.8, width: MediaQuery.of(context).size.width, @@ -812,8 +792,7 @@ class _ScheduleCompleteVisitPageWidgetState extends State( @@ -991,8 +961,7 @@ class _ScheduleCompleteVisitPageWidgetState extends State model.unfocusNode.canRequestFocus - ? FocusScope.of(context).requestFocus(model.unfocusNode) - : FocusScope.of(context).unfocus(), + onTap: () => model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(model.unfocusNode) : FocusScope.of(context).unfocus(), child: Dialog( alignment: Alignment.topCenter, child: SizedBox( @@ -1356,19 +1314,10 @@ class _ScheduleCompleteVisitPageWidgetState extends State.from({ 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 e706f92f..b75dd4b3 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 @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; +import 'package:hub/features/backend/index.dart'; +import 'package:hub/features/storage/index.dart'; 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/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/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'; @@ -35,9 +35,9 @@ class _VisitHistoryWidgetState extends State with TickerProv List _visitWrap = []; Future _initVariables() async { - devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; } @override @@ -142,13 +142,8 @@ class _VisitHistoryWidgetState extends State with TickerProv mainAxisSize: MainAxisSize.max, children: [ Center( - child: Text( - FFLocalizations.of(context) - .getVariableText(ptText: "Nenhuma visita encontrada!", enText: "No visit found"), - style: TextStyle( - color: FlutterFlowTheme.of(context).primaryText, - fontSize: limitedHeaderFontSize, - fontWeight: FontWeight.bold)), + child: Text(FFLocalizations.of(context).getVariableText(ptText: "Nenhuma visita encontrada!", enText: "No visit found"), + style: TextStyle(color: FlutterFlowTheme.of(context).primaryText, fontSize: limitedHeaderFontSize, fontWeight: FontWeight.bold)), ) ], ), @@ -189,16 +184,12 @@ class _VisitHistoryWidgetState extends State with TickerProv imagePath: 'https://freaccess.com.br/freaccess/getImage.php?devUUID=$devUUID&userUUID=$userUUID&cliID=$cliUUID&atividade=getFoto&Documento=${visitaWrapItem['VTE_DOCUMENTO'] ?? ''}&tipo=E', labelsHashMap: { - '${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']) - : '', + '${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']) + : '', '${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: [ if (Status.getStatus(visitaWrapItem['VAW_STATUS']) == StatusEnum.active) @@ -245,10 +236,10 @@ class _VisitHistoryWidgetState extends State with TickerProv }, ], onTapCardItemAction: () async { - final devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - final userUUID = (await StorageHelper().get(KeychainStorageKey.userUUID.value)) ?? ''; - final cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; - final cliName = (await StorageHelper().get(KeychainStorageKey.clientName.value)) ?? ''; + final devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + final userUUID = (await StorageHelper().get(ProfileStorageKey.userUUID.key)) ?? ''; + final cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; + final cliName = (await StorageHelper().get(ProfileStorageKey.clientName.key)) ?? ''; await showDialog( useSafeArea: true, 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 4ae72793..7e0dd2da 100644 --- a/lib/pages/sign_in_page/sign_in_page_widget.dart +++ b/lib/pages/sign_in_page/sign_in_page_widget.dart @@ -1,7 +1,5 @@ -import 'package:hub/shared/helpers/storage/storage_helper.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/shared/mixins/switcher_mixin.dart'; -import 'package:hub/shared/services/deeplink/deep_link_service.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'; @@ -37,9 +35,7 @@ class _SignInPageWidgetState extends State { Widget build(BuildContext context) { StorageHelper().context = context; return GestureDetector( - onTap: () => _model.unfocusNode.canRequestFocus - ? FocusScope.of(context).requestFocus(_model.unfocusNode) - : FocusScope.of(context).unfocus(), + onTap: () => _model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(_model.unfocusNode) : FocusScope.of(context).unfocus(), child: Scaffold( key: scaffoldKey, backgroundColor: FlutterFlowTheme.of(context).primaryBackground, 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 2eaed633..b1811ffe 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,6 @@ import 'package:flutter/material.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/shared/mixins/switcher_mixin.dart'; -import 'package:hub/shared/services/deeplink/deep_link_service.dart'; import '/components/templates_components/sign_up_template_component/sign_up_template_component_widget.dart'; import '/flutter_flow/flutter_flow_theme.dart'; @@ -39,9 +38,7 @@ class _SignUpPageWidgetState extends State { Widget build(BuildContext context) { StorageHelper().context = context; return GestureDetector( - onTap: () => _model.unfocusNode.canRequestFocus - ? FocusScope.of(context).requestFocus(_model.unfocusNode) - : FocusScope.of(context).unfocus(), + onTap: () => _model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(_model.unfocusNode) : FocusScope.of(context).unfocus(), child: Scaffold( key: scaffoldKey, backgroundColor: FlutterFlowTheme.of(context).primaryBackground, diff --git a/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart b/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart index 263eb263..b1ee15d5 100644 --- a/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart +++ b/lib/pages/vehicles_on_the_property/vehicles_on_the_property.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; +import 'package:hub/features/backend/index.dart'; 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'; @@ -227,8 +227,7 @@ class _VehicleOnThePropertyState extends State with Ticker return CardItemTemplateComponentWidget( imagePath: null, labelsHashMap: { - '${FFLocalizations.of(context).getVariableText(ptText: "Placa", enText: "License Plate")}:': - uItem['licensePlate'] ?? '', + '${FFLocalizations.of(context).getVariableText(ptText: "Placa", enText: "License Plate")}:': uItem['licensePlate'] ?? '', '${FFLocalizations.of(context).getVariableText(ptText: "Modelo", enText: "Model")}:': uItem['model'] ?? '', '${FFLocalizations.of(context).getVariableText(ptText: "Tag", enText: "Tag")}:': uItem['tag'] ?? '', }, diff --git a/lib/pages/visits_on_the_property/model.dart b/lib/pages/visits_on_the_property/model.dart index 357ab6dd..4c0e3770 100644 --- a/lib/pages/visits_on_the_property/model.dart +++ b/lib/pages/visits_on_the_property/model.dart @@ -1,11 +1,10 @@ import 'package:flutter/material.dart'; import 'package:hub/components/templates_components/details_component/details_component_widget.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/flutter_flow_model.dart'; import 'package:hub/flutter_flow/flutter_flow_theme.dart'; import 'package:hub/flutter_flow/internationalization.dart'; import 'package:hub/pages/vehicles_on_the_property/vehicles_on_the_property.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; class VisitsModel extends FlutterFlowModel { static VisitsModel? _instance; @@ -30,8 +29,8 @@ class VisitsModel extends FlutterFlowModel { void dispose() {} Future initAsync() async { - devUUID = (await StorageHelper().get(KeychainStorageKey.devUUID.value)) ?? ''; - cliUUID = (await StorageHelper().get(KeychainStorageKey.clientUUID.value)) ?? ''; + devUUID = (await StorageHelper().get(ProfileStorageKey.devUUID.key)) ?? ''; + cliUUID = (await StorageHelper().get(ProfileStorageKey.clientUUID.key)) ?? ''; onRefresh?.call(); } @@ -41,55 +40,52 @@ class VisitsModel extends FlutterFlowModel { required VisitsModel model, }) { return DetailsComponentWidget( - buttons: [], - labelsHashMap: Map.from({ - if (item['VTA_NOME'] != null && item['VTA_NOME'] != '') - '${FFLocalizations.of(context).getVariableText( - ptText: "Nome", - enText: "Name", - )}:': item['VTA_NOME'].toString().toUpperCase(), - if (item['MOT_DESCRICAO'] != null && item['MOT_DESCRICAO'] != '') - '${FFLocalizations.of(context).getVariableText( - ptText: "Motivo", - enText: "Reason", - )}:': item['MOT_DESCRICAO'].toString().toUpperCase(), - if (item['VTA_DTINICIO'] != null && item['VTA_DTINICIO'] != '') - '${FFLocalizations.of(context).getVariableText( - ptText: "Data de Início", - enText: "Start Date", - )}:': item['VTA_DTINICIO'].toString().toUpperCase(), - if (item['VTA_VALIDADE'] != null && item['VTA_VALIDADE'] != '') - '${FFLocalizations.of(context).getVariableText( - ptText: "Validade", - enText: "Validity", - )}:': item['VTA_VALIDADE'].toString().toUpperCase(), - if (item['VTA_FIXA'] != null && item['VTA_FIXA'] != '') - '${FFLocalizations.of(context).getVariableText( - ptText: "Entrada Única", - enText: "Single Entry", - )}:': item['VTA_FIXA'] == true - ? FFLocalizations.of(context).getVariableText( - ptText: "Sim", - enText: "Yes", - ) - : FFLocalizations.of(context).getVariableText( - ptText: "Não", - enText: "No", - ), - }), - imagePath: - 'https://freaccess.com.br/freaccess/getImage.php?devUUID=${devUUID}&cliID=${cliUUID}&atividade=getFoto&Documento=${item['VDO_DOCUMENTO']}&tipo=E', - statusHashMap: [ - Map.from({ - if (item['VTA_FIXA'] != null) - FFLocalizations.of(context).getVariableText( - ptText: item['VTA_FIXA'] ? "Entrada Única" : "Entrada Recorrente", - enText: item['VTA_FIXA'] ? "Single Entry" : "Recurrent Entry", - ): item['VTA_FIXA'] == true - ? FlutterFlowTheme.of(context).success - : FlutterFlowTheme.of(context).warning, - }) - ], - ); + buttons: [], + labelsHashMap: Map.from({ + if (item['VTA_NOME'] != null && item['VTA_NOME'] != '') + '${FFLocalizations.of(context).getVariableText( + ptText: "Nome", + enText: "Name", + )}:': item['VTA_NOME'].toString().toUpperCase(), + if (item['MOT_DESCRICAO'] != null && item['MOT_DESCRICAO'] != '') + '${FFLocalizations.of(context).getVariableText( + ptText: "Motivo", + enText: "Reason", + )}:': item['MOT_DESCRICAO'].toString().toUpperCase(), + if (item['VTA_DTINICIO'] != null && item['VTA_DTINICIO'] != '') + '${FFLocalizations.of(context).getVariableText( + ptText: "Data de Início", + enText: "Start Date", + )}:': item['VTA_DTINICIO'].toString().toUpperCase(), + if (item['VTA_VALIDADE'] != null && item['VTA_VALIDADE'] != '') + '${FFLocalizations.of(context).getVariableText( + ptText: "Validade", + enText: "Validity", + )}:': item['VTA_VALIDADE'].toString().toUpperCase(), + if (item['VTA_FIXA'] != null && item['VTA_FIXA'] != '') + '${FFLocalizations.of(context).getVariableText( + ptText: "Entrada Única", + enText: "Single Entry", + )}:': item['VTA_FIXA'] == true + ? FFLocalizations.of(context).getVariableText( + ptText: "Sim", + enText: "Yes", + ) + : FFLocalizations.of(context).getVariableText( + ptText: "Não", + enText: "No", + ), + }), + imagePath: 'https://freaccess.com.br/freaccess/getImage.php?devUUID=${devUUID}&cliID=${cliUUID}&atividade=getFoto&Documento=${item['VDO_DOCUMENTO']}&tipo=E', + statusHashMap: [ + Map.from({ + if (item['VTA_FIXA'] != null) + FFLocalizations.of(context).getVariableText( + ptText: item['VTA_FIXA'] ? "Entrada Única" : "Entrada Recorrente", + enText: item['VTA_FIXA'] ? "Single Entry" : "Recurrent Entry", + ): item['VTA_FIXA'] == true ? FlutterFlowTheme.of(context).success : FlutterFlowTheme.of(context).warning, + }) + ], + ); } } diff --git a/lib/pages/visits_on_the_property/visits_on_the_property_screen.dart b/lib/pages/visits_on_the_property/visits_on_the_property_screen.dart index ddc81d31..95a154a0 100644 --- a/lib/pages/visits_on_the_property/visits_on_the_property_screen.dart +++ b/lib/pages/visits_on_the_property/visits_on_the_property_screen.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; import 'package:hub/components/templates_components/card_item_template_component/card_item_template_component_widget.dart'; +import 'package:hub/features/backend/index.dart'; 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'; @@ -69,8 +69,7 @@ class _VisitsOnThePropertyState extends State with TickerPr children: [ Center( child: Text( - FFLocalizations.of(context).getVariableText( - ptText: "Nenhuma visita em aberto encontrada!", enText: "No opened visits found"), + FFLocalizations.of(context).getVariableText(ptText: "Nenhuma visita em aberto encontrada!", enText: "No opened visits found"), style: TextStyle( fontFamily: 'Nunito', fontSize: limitedHeaderTextSize, @@ -222,12 +221,10 @@ class _VisitsOnThePropertyState extends State with TickerPr Widget _item(BuildContext context, dynamic uItem) { return CardItemTemplateComponentWidget( - imagePath: - 'https://freaccess.com.br/freaccess/getImage.php?devUUID=${model.devUUID}&cliID=${model.cliUUID}&atividade=getFoto&Documento=${uItem['VDO_DOCUMENTO']}&tipo=E', + imagePath: 'https://freaccess.com.br/freaccess/getImage.php?devUUID=${model.devUUID}&cliID=${model.cliUUID}&atividade=getFoto&Documento=${uItem['VDO_DOCUMENTO']}&tipo=E', labelsHashMap: { '${FFLocalizations.of(context).getVariableText(ptText: "Nome", enText: "Name")}:': uItem['VTA_NOME'] ?? '', - '${FFLocalizations.of(context).getVariableText(ptText: "Validade", enText: "Valids")}:': - uItem['VTA_VALIDADE'] ?? '', + '${FFLocalizations.of(context).getVariableText(ptText: "Validade", enText: "Valids")}:': uItem['VTA_VALIDADE'] ?? '', '${FFLocalizations.of(context).getVariableText(ptText: "Motivo", enText: "Reason")}:': uItem['MOT_DESCRICAO'][0].toUpperCase() + uItem['MOT_DESCRICAO'].substring(1).toLowerCase(), }, diff --git a/lib/pages/welcome_page/welcome_page_widget.dart b/lib/pages/welcome_page/welcome_page_widget.dart index 53ac8018..b665ebe8 100644 --- a/lib/pages/welcome_page/welcome_page_widget.dart +++ b/lib/pages/welcome_page/welcome_page_widget.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; +import 'package:hub/features/storage/index.dart'; + import 'package:hub/shared/mixins/switcher_mixin.dart'; -import 'package:hub/shared/services/deeplink/deep_link_service.dart'; import '/components/templates_components/welcome_template_component/welcome_template_component_widget.dart'; import '/flutter_flow/flutter_flow_theme.dart'; @@ -54,9 +53,7 @@ class _WelcomePageWidgetState extends State { Widget build(BuildContext context) { StorageHelper().context = context; return GestureDetector( - onTap: () => _model.unfocusNode.canRequestFocus - ? FocusScope.of(context).requestFocus(_model.unfocusNode) - : FocusScope.of(context).unfocus(), + onTap: () => _model.unfocusNode.canRequestFocus ? FocusScope.of(context).requestFocus(_model.unfocusNode) : FocusScope.of(context).unfocus(), child: Scaffold( key: scaffoldKey, backgroundColor: FlutterFlowTheme.of(context).primaryBackground, diff --git a/lib/shared/components/molecules/locals/data/data_sources/locals_local_data_source.dart b/lib/shared/components/molecules/locals/data/data_sources/locals_local_data_source.dart deleted file mode 100644 index 64d78e27..00000000 --- a/lib/shared/components/molecules/locals/data/data_sources/locals_local_data_source.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; - -abstract class LocalsLocalDataSource { - Future unlinkLocal(); -} - -class LocalsLocalDataSourceImpl { - - Future unlinkLocal() async { - await StorageHelper().set(KeychainStorageKey.clientUUID.value, ''); - await StorageHelper().set(KeychainStorageKey.clientName.value, ''); - await StorageHelper().set(KeychainStorageKey.ownerName.value, ''); - } - -} diff --git a/lib/shared/components/molecules/locals/presentation/widgets/local_profile/local_profile_widget.dart b/lib/shared/components/molecules/locals/presentation/widgets/local_profile/local_profile_widget.dart deleted file mode 100644 index 77994112..00000000 --- a/lib/shared/components/molecules/locals/presentation/widgets/local_profile/local_profile_widget.dart +++ /dev/null @@ -1,273 +0,0 @@ -import 'dart:developer'; - -import 'package:cached_network_image/cached_network_image.dart'; -import 'package:flutter/material.dart'; -import 'package:google_fonts/google_fonts.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:hub/flutter_flow/custom_functions.dart'; -import 'package:hub/flutter_flow/flutter_flow_theme.dart'; -import 'package:hub/flutter_flow/flutter_flow_util.dart'; -import 'package:hub/shared/components/molecules/locals/index.dart'; -import 'package:hub/shared/components/molecules/modules/data/index.dart'; -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; -import 'package:provider/provider.dart'; - -class LocalProfileComponentWidget extends StatefulWidget { - const LocalProfileComponentWidget({super.key}); - - @override - State createState() => _LocalProfileComponentWidgetState(); -} - -class _LocalProfileComponentWidgetState extends State { - bool _isLoading = false; - - Future retrieveProfileInfo() async { - - setState(() {_isLoading = true;}); - await LocalsRepositoryImpl().select(context); - setState(() {_isLoading = false;}); - } - - @override - Widget build(BuildContext context) { - - - return StreamBuilder( - stream: LocalsRepositoryImpl.stream, - builder: (context, snapshot) { - final textScaler = MediaQuery.textScalerOf(context); - final double baseFontSize = 14.0; - final double scaledFontSize = baseFontSize * textScaler.scale(1); - final double limitedFontSize = scaledFontSize > 20 ? 12 : scaledFontSize; - if (snapshot.connectionState == ConnectionState.waiting) { - return const Center(child: CircularProgressIndicator()); - } else if (snapshot.hasError) { - return Center(child: Text('Error: ${snapshot.error}')); - } else if (!snapshot.hasData || snapshot.data! == false) { - - return BlocBuilder( - builder: (context, state) { - return _buildDefaultLocalProfile(context, limitedFontSize); - }, - ); - } - - return BlocBuilder( - builder: (context, state) { - return _buildAsyncLocalProfile(context, state, limitedFontSize); - }, - ); - - }, - ); - - } - - Container _buildDefaultLocalProfile(BuildContext context, double limitedFontSize) { - return Container( - decoration: const BoxDecoration(), - child: Align( - alignment: const AlignmentDirectional(0.0, -1.0), - child: Material( - color: Colors.transparent, - elevation: 0.0, - child: Container( - width: double.infinity, - height: 119.0, - decoration: BoxDecoration( - color: FlutterFlowTheme.of(context).primary, - border: Border.all( - color: FlutterFlowTheme.of(context).primary, - ), - ), - child: Row( - mainAxisSize: MainAxisSize.max, - children: [ - Align( - alignment: const AlignmentDirectional(-1.0, 0.0), - child: Padding( - padding: const EdgeInsets.all(2.0), - child: InkWell( - splashColor: Colors.transparent, - focusColor: Colors.transparent, - hoverColor: Colors.transparent, - highlightColor: Colors.transparent, - onTap: _isLoading ? null : retrieveProfileInfo, - child: ClipRRect( - borderRadius: BorderRadius.circular(200.0), - child: CachedNetworkImage( - imageBuilder: (context, imageProvider) => Container( - decoration: BoxDecoration( - image: DecorationImage( - image: imageProvider, - fit: BoxFit.cover, - ), - ), - ), - imageUrl: 'assets/images/home.png', - width: 80.0, - 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'), - ), - )), - ), - ), - Expanded( - child: Tooltip( - message: FFLocalizations.of(context).getVariableText( - ptText: 'SEM LOCAL VINCULADO', - enText: 'NO LINKED LOCAL', - ), - child: Text( - FFLocalizations.of(context).getVariableText( - ptText: 'SEM LOCAL VINCULADO', - enText: 'NO LINKED LOCAL', - ), - overflow: TextOverflow.ellipsis, - maxLines: 1, - style: FlutterFlowTheme.of(context).labelMedium.override( - fontFamily: 'Nunito', - color: FlutterFlowTheme.of(context).info, - fontSize: limitedFontSize, - letterSpacing: 0.0, - fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), - ), - ), - ), - ), - ].divide(const SizedBox(width: 20.0)).addToStart(const SizedBox(width: 20.0)).addToEnd(const SizedBox(width: 20.0)), - ), - ), - ), - ), - ); - } - - Container _buildAsyncLocalProfile(BuildContext context, LocalProfileState state, double limitedFontSize) { - return Container( - decoration: const BoxDecoration(), - child: Align( - alignment: const AlignmentDirectional(0.0, -1.0), - child: Material( - color: Colors.transparent, - elevation: 0.0, - child: Container( - width: double.infinity, - height: 119.0, - decoration: BoxDecoration( - color: FlutterFlowTheme.of(context).primary, - border: Border.all( - color: FlutterFlowTheme.of(context).primary, - ), - ), - child: Row( - mainAxisSize: MainAxisSize.max, - children: [ - Align( - alignment: const AlignmentDirectional(-1.0, 0.0), - child: Padding( - padding: const EdgeInsets.all(2.0), - child: InkWell( - splashColor: Colors.transparent, - focusColor: Colors.transparent, - hoverColor: Colors.transparent, - highlightColor: Colors.transparent, - onTap: _isLoading ? null : retrieveProfileInfo, - child: ClipRRect( - borderRadius: BorderRadius.circular(200.0), - child: CachedNetworkImage( - imageBuilder: (context, imageProvider) => Container( - decoration: BoxDecoration( - image: DecorationImage( - image: imageProvider, - fit: BoxFit.cover, - ), - ), - ), - imageUrl: valueOrDefault('https://freaccess.com.br/freaccess/Images/Clients/${state.cliUUID}.png', 'assets/images/home.png'), - width: 80.0, - 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'), - ), - )), - ), - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Tooltip( - message: valueOrDefault( - convertToUppercase(state.cliName), - FFLocalizations.of(context).getVariableText( - ptText: 'SEM LOCAL VINCULADO', - enText: 'NO LINKED LOCAL', - ), - ), - child: Text( - valueOrDefault( - convertToUppercase(state.cliName), - FFLocalizations.of(context).getVariableText( - ptText: 'SEM LOCAL VINCULADO', - enText: 'NO LINKED LOCAL', - ), - ), - overflow: TextOverflow.ellipsis, - maxLines: 1, - style: FlutterFlowTheme.of(context).labelMedium.override( - fontFamily: 'Nunito', - color: FlutterFlowTheme.of(context).info, - fontSize: limitedFontSize, - letterSpacing: 0.0, - fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), - ), - ), - ), - Tooltip( - message: valueOrDefault( - ' '+state.ownerName, - '' - ), - child: Text( - valueOrDefault( - state.ownerName.length > 30 ? '${state.ownerName.substring(0, 20)}...' : state.ownerName, - '' - ), - overflow: TextOverflow.ellipsis, - maxLines: 1, - style: FlutterFlowTheme.of(context).labelMedium.override( - fontFamily: 'Nunito', - color: FlutterFlowTheme.of(context).info, - fontSize: limitedFontSize, - letterSpacing: 0.0, - fontWeight: FontWeight.w500, - useGoogleFonts: GoogleFonts.asMap().containsKey('Nunito'), - ), - ), - ), - ], - ), - ), - ].divide(const SizedBox(width: 20.0)).addToStart(const SizedBox(width: 20.0)).addToEnd(const SizedBox(width: 20.0)), - ), - ), - ), - ), - ); - - - } -} diff --git a/lib/shared/components/molecules/menu/domain/respositories/menu_repository.dart b/lib/shared/components/molecules/menu/domain/respositories/menu_repository.dart deleted file mode 100644 index 495dc332..00000000 --- a/lib/shared/components/molecules/menu/domain/respositories/menu_repository.dart +++ /dev/null @@ -1,6 +0,0 @@ -import 'package:hub/shared/components/molecules/menu/domain/entities/menu_item.dart'; -import 'package:hub/shared/components/molecules/menu/index.dart'; - -abstract class MenuRepository { - Future> generateMenuEntries(List menuEntries, EnumMenuItem item); -} \ No newline at end of file diff --git a/lib/shared/enums/index.dart b/lib/shared/enums/index.dart new file mode 100644 index 00000000..585bd715 --- /dev/null +++ b/lib/shared/enums/index.dart @@ -0,0 +1 @@ +export 'enum_throw_exception.dart'; diff --git a/lib/shared/extensions/index.dart b/lib/shared/extensions/index.dart new file mode 100644 index 00000000..0f71878e --- /dev/null +++ b/lib/shared/extensions/index.dart @@ -0,0 +1,3 @@ +export 'dialog_extensions.dart'; +export 'flutter_secure_storage_extensions.dart'; +export 'string_extensions.dart'; diff --git a/lib/shared/helpers/index.dart b/lib/shared/helpers/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/helpers/storage/base_storage.dart b/lib/shared/helpers/storage/base_storage.dart deleted file mode 100644 index 27892246..00000000 --- a/lib/shared/helpers/storage/base_storage.dart +++ /dev/null @@ -1,152 +0,0 @@ -abstract class BaseStorage { - Future init(); - - Future set(String key, T value); - - Future get(String key); - - Future delete(String key); - - Future clearAll(); -} - -enum Storage { - secureStorage, - sharedPreferences, - databaseStorage, -} - -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 KeychainStorageKey { - devUUID, - userUUID, - userDevUUID, - status, - userName, - userEmail, - clientUUID, - ownerName, - ownerUUID, - clientName, - petAmount, - whatsapp, - provisional, - pets, - local, - notify, - fingerprint, - access, - panic, - person, - requestOSNotification, - isNewVersion, -} - -extension KeychainStorageKeyExtension on KeychainStorageKey { - String get value { - switch (this) { - case KeychainStorageKey.userEmail: - return 'fre_userEmail'; - case KeychainStorageKey.devUUID: - return 'fre_devUUID'; - case KeychainStorageKey.userUUID: - return 'fre_userUUID'; - case KeychainStorageKey.userDevUUID: - return 'fre_userDevUUID'; - case KeychainStorageKey.status: - return 'fre_status'; - case KeychainStorageKey.userName: - return 'fre_userName'; - case KeychainStorageKey.clientUUID: - return 'fre_cliUUID'; - case KeychainStorageKey.ownerUUID: - return 'fre_ownerUUID'; - case KeychainStorageKey.clientName: - return 'fre_cliName'; - case KeychainStorageKey.ownerName: - return 'fre_ownerName'; - case KeychainStorageKey.petAmount: - return 'fre_petAmountRegister'; - case KeychainStorageKey.whatsapp: - return 'fre_whatsapp'; - case KeychainStorageKey.provisional: - return 'fre_provisional'; - case KeychainStorageKey.pets: - return 'fre_pets'; - case KeychainStorageKey.local: - return 'fre_local'; - case KeychainStorageKey.notify: - return 'fre_notify'; - case KeychainStorageKey.fingerprint: - return 'fre_fingerprint'; - case KeychainStorageKey.access: - return 'fre_access'; - case KeychainStorageKey.panic: - return 'fre_panic'; - case KeychainStorageKey.person: - return 'fre_person'; - case KeychainStorageKey.requestOSNotification: - return 'fre_requestOSnotification'; - case KeychainStorageKey.isNewVersion: - return 'fre_isNewVersion'; - default: - return ''; - } - } -} diff --git a/lib/shared/mixins/index.dart b/lib/shared/mixins/index.dart new file mode 100644 index 00000000..f41f8c59 --- /dev/null +++ b/lib/shared/mixins/index.dart @@ -0,0 +1,2 @@ +export 'status_mixin.dart'; +export 'switcher_mixin.dart'; diff --git a/lib/shared/services/index.dart b/lib/shared/services/index.dart new file mode 100644 index 00000000..e69de29b diff --git a/lib/shared/utils/index.dart b/lib/shared/utils/index.dart new file mode 100644 index 00000000..3bbabf2a --- /dev/null +++ b/lib/shared/utils/index.dart @@ -0,0 +1,13 @@ +export 'biometric_util.dart'; +export 'device_util.dart'; +export 'dialog_util.dart'; +export 'image_util.dart'; +export 'limited_text_size.dart'; +export 'loading_util.dart'; +export 'log_util.dart'; +export 'path_util.dart'; +export 'share_util.dart'; +export 'snackbar_util.dart'; +export 'text_util.dart'; +export 'validator_util.dart'; +export 'webview_util.dart'; diff --git a/lib/shared/utils/log_util.dart b/lib/shared/utils/log_util.dart index 99dfab8e..24a5561d 100644 --- a/lib/shared/utils/log_util.dart +++ b/lib/shared/utils/log_util.dart @@ -1,7 +1,7 @@ import 'dart:developer'; import 'package:firebase_crashlytics/firebase_crashlytics.dart'; -import 'package:hub/backend/api_requests/api_calls.dart'; +import 'package:hub/features/backend/index.dart'; class LogUtil { static void requestAPIFailed(String url, String body, String reason, dynamic error, StackTrace stack) async { diff --git a/lib/shared/utils/share_util.dart b/lib/shared/utils/share_util.dart index e04e11bf..a9c410f7 100644 --- a/lib/shared/utils/share_util.dart +++ b/lib/shared/utils/share_util.dart @@ -1,11 +1,10 @@ -import 'package:hub/shared/helpers/storage/base_storage.dart'; -import 'package:hub/shared/helpers/storage/storage_helper.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:share_plus/share_plus.dart'; class ShareUtil { static Future showShare(payload) async { - final cliName = await StorageHelper().get(KeychainStorageKey.clientName.value); - final cliUUID = await StorageHelper().get(KeychainStorageKey.clientUUID.value); + final cliName = await StorageHelper().get(ProfileStorageKey.clientName.key); + final cliUUID = await StorageHelper().get(ProfileStorageKey.clientUUID.key); for (var i = 0; i < payload['convites'].length; i++) { await Share.share(''' diff --git a/test/widget_test.dart b/test/widget_test.dart deleted file mode 100644 index 76de18a9..00000000 --- a/test/widget_test.dart +++ /dev/null @@ -1,17 +0,0 @@ -// // This is a basic Flutter widget test. -// // -// // To perform an interaction with a widget in your test, use the WidgetTester -// // utility that Flutter provides. For example, you can send tap and scroll -// // gestures. You can also use WidgetTester to find child widgets in the widget -// // tree, read text, and verify that the values of widget properties are correct. - -// import 'package:flutter_test/flutter_test.dart'; - -// import 'package:f_r_e_hub/main.dart'; - -// void main() { -// testWidgets('Counter increments smoke test', (WidgetTester tester) async { -// // Build our app and trigger a frame. -// await tester.pumpWidget(MyApp()); -// }); -// }