diff --git a/integration_test/app_test.dart b/integration_test/app_test.dart index c0b27937..d3d0a9b0 100644 --- a/integration_test/app_test.dart +++ b/integration_test/app_test.dart @@ -12,8 +12,7 @@ import 'package:hub/features/local/index.dart'; import 'package:hub/features/menu/index.dart'; import 'package:hub/features/module/data/index.dart'; import 'package:hub/features/module/domain/index.dart'; -import 'package:hub/features/storage/enums/index.dart'; -import 'package:hub/features/storage/repositories/storage_repository_impl.dart'; +import 'package:hub/features/storage/index.dart'; import 'package:hub/flutter_flow/index.dart' as ff; import 'package:hub/initialization.dart'; import 'package:hub/main.dart'; @@ -31,10 +30,7 @@ part 'profile_test.dart'; part 'property_test.dart'; part 'setting_test.dart'; part 'storage_test.dart'; -part 'utils_test.dart';rage_test.dart'; - part 'utils_test.dart'; - part 'welcome_test.dart'; late PatrolTester $; @@ -43,20 +39,29 @@ void main() { //init integration test IntegrationTestWidgetsFlutterBinding.ensureInitialized(); - WelcomeTest.signInToSignUp(); - WelcomeTest.signUpToSignIn(); + setUp(() {}); + tearDown(() async { + // await StorageHelper().clean(Storage.databaseStorage); + // await StorageHelper().clean(Storage.secureStorage); + // + // DatabaseService.isInitialized = false; + // await DatabaseService.instance.init(); + }); - AuthenticationTest.signIn(); - AuthenticationTest.signUp(); - AuthenticationTest.signOut(); + // WelcomeTest.signInToSignUp(); + // WelcomeTest.signUpToSignIn(); + // + // AuthenticationTest.signIn(); + // AuthenticationTest.signUp(); + // AuthenticationTest.signOut(); + // + // ModularizationTest.switchLicense(); + // ModularizationTest.containLicense(); - ModularizationTest.switchLicense(); - ModularizationTest.containLicense(); - - MenuTest.navToEntries(); - MenuTest.containEntries(); + // MenuTest.navToEntries(); + // MenuTest.containEntries(); MenuTest.labels2AppbarConsistency(); - LocalsTest.setLocal(); - LocalsTest.unlinkLocal(); + // LocalsTest.setLocal(); + // LocalsTest.unlinkLocal(); } diff --git a/integration_test/locals_test.dart b/integration_test/locals_test.dart index 2d9311e4..661c6bc1 100644 --- a/integration_test/locals_test.dart +++ b/integration_test/locals_test.dart @@ -76,7 +76,10 @@ class LocalsTest { expect(unlinkButton, findsOneWidget); await $(unlinkButton).tap(); - await $('Sim') // + final PatrolFinder alertDialog = await $(#AlertDialogKey) // + .waitUntilVisible(); + await alertDialog + .$(#AcceptOptionKey) // .waitUntilVisible() .tap(settlePolicy: SettlePolicy.noSettle); @@ -139,7 +142,12 @@ class LocalsTest { if (entriesFinder.evaluate().isNotEmpty) { await $(entriesFinder.first).waitUntilVisible().tap(); - await $(#AcceptOptionKey).waitUntilVisible().tap(); + final PatrolFinder alertDialog = await $(#AlertDialogKey) // + .waitUntilVisible(); + await alertDialog + .$(#AcceptOptionKey) // + .waitUntilVisible() + .tap(settlePolicy: SettlePolicy.noSettle); } await Future.delayed(const Duration(milliseconds: 500)); diff --git a/integration_test/menu_test.dart b/integration_test/menu_test.dart index c185c159..9966318f 100644 --- a/integration_test/menu_test.dart +++ b/integration_test/menu_test.dart @@ -25,11 +25,12 @@ class MenuTest { final LinkedHashMap routesTitles = LinkedHashMap.fromIterables(routes, titles); + late String route; + late String title; for (final entry in routesTitles.entries) { - await $.pumpAndSettle(); - final String route = entry.key; - final String title = entry.value; + route = entry.key; + title = entry.value; print('route: $route'); print('title: $title'); @@ -38,14 +39,15 @@ class MenuTest { if (route == '/fastPassPage') continue; if (route == '/reservation') continue; - await $.pumpAndSettle(); ff.navigatorKey.currentContext!.go(route); - await $.pumpAndSettle(); Future.delayed(const Duration(milliseconds: 500)); - await $.waitUntilExists($(AppBar)); - final PatrolFinder appBar = $(title); - expect(appBar, findsOneWidget); + final PatrolFinder appBar = await $(AppBar) // + .waitUntilExists(); + final PatrolFinder titleAppBar = await appBar // + .$(title) + .waitUntilVisible(); + expect(titleAppBar, findsOneWidget); } await Future.delayed(const Duration(milliseconds: 500)); }, diff --git a/lib/features/auth/authentication_service.dart b/lib/features/auth/authentication_service.dart index 12393545..24f5c0c9 100644 --- a/lib/features/auth/authentication_service.dart +++ b/lib/features/auth/authentication_service.dart @@ -1,14 +1,11 @@ import 'package:flutter/material.dart'; import 'package:hub/features/backend/index.dart'; import 'package:hub/features/local/index.dart'; -import 'package:hub/features/module/data/repositories/license_repository_impl.dart'; import 'package:hub/features/storage/index.dart'; - import 'package:hub/flutter_flow/nav/nav.dart'; import 'package:hub/shared/utils/device_util.dart'; import 'package:hub/shared/utils/dialog_util.dart'; import 'package:hub/shared/utils/log_util.dart'; - import 'package:hub/shared/utils/snackbar_util.dart'; import '../../../flutter_flow/flutter_flow_util.dart'; @@ -151,7 +148,7 @@ class AuthenticationService { await StorageHelper().clean(Storage.databaseStorage); await StorageHelper().clean(Storage.secureStorage); - await LicenseRepositoryImpl().cleanLicense(); + DatabaseService.isInitialized = false; await DatabaseService.instance.init(); diff --git a/lib/features/history/presentation/pages/provisional_history_page.dart b/lib/features/history/presentation/pages/provisional_history_page.dart index 3984d58d..734ca844 100644 --- a/lib/features/history/presentation/pages/provisional_history_page.dart +++ b/lib/features/history/presentation/pages/provisional_history_page.dart @@ -159,8 +159,8 @@ class ProvisionalHistoryState extends State { { 'title': FFLocalizations.of(context) .getVariableText( - ptText: 'Convidado', - enText: 'Guest', + ptText: 'Concluído', + enText: 'Completed', ), 'value': 'CO', }, diff --git a/lib/features/menu/presentation/mappers/menu_entry.dart b/lib/features/menu/presentation/mappers/menu_entry.dart index aec4f987..7e1a4b00 100644 --- a/lib/features/menu/presentation/mappers/menu_entry.dart +++ b/lib/features/menu/presentation/mappers/menu_entry.dart @@ -37,7 +37,7 @@ class MenuEntry implements BaseModule { icon: Icons.sports_motorsports_outlined, name: FFLocalizations.of(navigatorKey.currentContext!).getVariableText( ptText: 'Agendar Entregas', - enText: 'Schedule Delivery', + enText: 'Delivery Schedule', ), route: '/deliverySchedule', types: [MenuEntryType.Home, MenuEntryType.Drawer], diff --git a/lib/features/module/data/data_sources/license_remote_data_source.dart b/lib/features/module/data/data_sources/license_remote_data_source.dart index 982b5ebe..dae3ab80 100644 --- a/lib/features/module/data/data_sources/license_remote_data_source.dart +++ b/lib/features/module/data/data_sources/license_remote_data_source.dart @@ -9,9 +9,7 @@ import 'package:hub/features/module/index.dart'; abstract class LicenseRemoteDataSource { Future fetchLicenses(bool isNewVersion); - Future cleanLicense(); - Future processLicense(); } diff --git a/lib/features/module/data/repositories/license_repository_impl.dart b/lib/features/module/data/repositories/license_repository_impl.dart index 097c7710..c578608f 100644 --- a/lib/features/module/data/repositories/license_repository_impl.dart +++ b/lib/features/module/data/repositories/license_repository_impl.dart @@ -1,11 +1,12 @@ import 'dart:developer'; -import 'package:hub/features/backend/index.dart'; import 'package:hub/features/module/data/data_sources/index.dart'; import 'package:hub/features/module/domain/index.dart'; import 'package:hub/features/storage/index.dart'; import 'package:sqflite/sqflite.dart'; +import '../../../backend/index.dart'; + typedef LicenseStatus = bool; class LicenseRepositoryImpl implements LicenseRepository { @@ -21,14 +22,6 @@ class LicenseRepositoryImpl implements LicenseRepository { remoteDataSource = LicenseRemoteDataSourceImpl(this.api); } - @override - Future resetLicense() async { - bool result = false; - final bool isNewVersion = await localDataSource.isNewVersion(); - result = await localDataSource.setupLicense(isNewVersion); - return result; - } - @override Future updateLicense() async { log('updateLicense'); @@ -36,6 +29,7 @@ class LicenseRepositoryImpl implements LicenseRepository { final bool isNewVersion = await localDataSource.isNewVersion(); if (isNewVersion) { + await localDataSource.setupLicense(isNewVersion); result = await remoteDataSource.fetchLicenses(isNewVersion); } else { result = await localDataSource.setupLicense(isNewVersion); @@ -64,4 +58,12 @@ class LicenseRepositoryImpl implements LicenseRepository { Future> getLicense() async { return await localDataSource.getLicense(); } + + @override + Future resetLicense() async { + bool result = false; + final bool isNewVersion = await localDataSource.isNewVersion(); + result = await localDataSource.setupLicense(isNewVersion); + return result; + } } diff --git a/lib/features/storage/helpers/dabase_storage_helper.dart b/lib/features/storage/helpers/dabase_storage_helper.dart index 5a0d572e..7bf0ba2c 100644 --- a/lib/features/storage/helpers/dabase_storage_helper.dart +++ b/lib/features/storage/helpers/dabase_storage_helper.dart @@ -4,6 +4,7 @@ import 'package:hub/features/storage/index.dart'; class DatabaseStorage implements BaseStorage { DatabaseStorage._(); + static final DatabaseStorage instance = DatabaseStorage._(); // static final DatabaseStorage instance = DatabaseStorage._(); @@ -30,12 +31,15 @@ class DatabaseStorage implements BaseStorage { @override Future delete(String key) async => await getInstanceByKey(key).delete(key); + @override Future get(String key) async => // await getInstanceByKey(key).get(key); + @override Future init() async => // await DatabaseService.instance.init(); + @override Future set(String key, T value) async => await getInstanceByKey(key).set(key, value); diff --git a/lib/flutter_flow/internationalization.dart b/lib/flutter_flow/internationalization.dart index ffb64dcd..fb63a3fc 100644 --- a/lib/flutter_flow/internationalization.dart +++ b/lib/flutter_flow/internationalization.dart @@ -15,20 +15,25 @@ class FFLocalizations { static List languages() => ['pt', 'en']; static late SharedPreferences _prefs; + static Future initialize() async => _prefs = await SharedPreferences.getInstance(); + static Future storeLocale(String locale) => _prefs.setString(_kLocaleStorageKey, locale); + static Locale? getStoredLocale() { final locale = _prefs.getString(_kLocaleStorageKey); return locale != null && locale.isNotEmpty ? createLocale(locale) : null; } String get languageCode => locale.toString(); + String? get languageShortCode => _languagesWithShortCode.contains(locale.toString()) ? '${locale.toString()}_short' : null; + int get languageIndex => languages().contains(languageCode) ? languages().indexOf(languageCode) : 0; @@ -443,7 +448,7 @@ final kTranslationsMap = >>[ }, '784f83pc': { 'pt': 'Consultar Liberações', - 'en': 'Liberation History', + 'en': 'Liberations History', }, '1skj43ye': { 'pt': 'Home', diff --git a/lib/main.dart b/lib/main.dart index b5e3690f..c9941df7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,15 +8,14 @@ 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:flutter_riverpod/flutter_riverpod.dart'; import 'package:hub/features/notification/index.dart'; import 'package:hub/features/storage/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/utils/test_util.dart'; - import 'package:responsive_framework/responsive_framework.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'initialization.dart'; @@ -176,7 +175,9 @@ class _AppState extends State { _router = createRouter(_appStateNotifier); Future.delayed( const Duration(milliseconds: 1000), - () => setState(() => _appStateNotifier.stopShowingSplashImage()), + () => mounted + ? setState(() => _appStateNotifier.stopShowingSplashImage()) + : null, ); _setupFirebaseMessaging(); 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 1662c4e3..70ba13b0 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 @@ -136,7 +136,7 @@ class _VisitsOnThePropertyState extends State title: Text( FFLocalizations.of(context).getVariableText( ptText: 'Visitas Abertas', - enText: 'Opened visits', + enText: 'Opened Visits', ), style: FlutterFlowTheme.of(context).headlineMedium.override( fontFamily: FlutterFlowTheme.of(context).headlineMediumFamily, diff --git a/lib/test/test.dart b/lib/test/test.dart new file mode 100644 index 00000000..7c24d49d --- /dev/null +++ b/lib/test/test.dart @@ -0,0 +1,179 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; + +/// Flutter code sample for [PageView]. + +void main() => runApp(const PageViewExampleApp()); + +class PageViewExampleApp extends StatelessWidget { + const PageViewExampleApp({super.key}); + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('PageView Sample')), + body: const PageViewExample(), + ), + ); + } +} + +class PageViewExample extends StatefulWidget { + const PageViewExample({super.key}); + + @override + State createState() => _PageViewExampleState(); +} + +class _PageViewExampleState extends State + with TickerProviderStateMixin { + late PageController _pageViewController; + late TabController _tabController; + int _currentPageIndex = 0; + + @override + void initState() { + super.initState(); + _pageViewController = PageController(); + _tabController = TabController(length: 3, vsync: this); + } + + @override + void dispose() { + super.dispose(); + _pageViewController.dispose(); + _tabController.dispose(); + } + + @override + Widget build(BuildContext context) { + final TextTheme textTheme = Theme.of(context).textTheme; + + return Stack( + alignment: Alignment.bottomCenter, + children: [ + PageView( + /// [PageView.scrollDirection] defaults to [Axis.horizontal]. + /// Use [Axis.vertical] to scroll vertically. + controller: _pageViewController, + onPageChanged: _handlePageViewChanged, + children: [ + Center(child: Text('First Page', style: textTheme.titleLarge)), + Center(child: Text('Second Page', style: textTheme.titleLarge)), + Center(child: Text('Third Page', style: textTheme.titleLarge)), + ], + ), + PageIndicator( + tabController: _tabController, + currentPageIndex: _currentPageIndex, + onUpdateCurrentPageIndex: _updateCurrentPageIndex, + isOnDesktopAndWeb: _isOnDesktopAndWeb, + ), + ], + ); + } + + void _handlePageViewChanged(int currentPageIndex) { + if (!_isOnDesktopAndWeb) { + return; + } + _tabController.index = currentPageIndex; + setState(() { + _currentPageIndex = currentPageIndex; + }); + } + + void _updateCurrentPageIndex(int index) { + _tabController.index = index; + _pageViewController.animateToPage( + index, + duration: const Duration(milliseconds: 400), + curve: Curves.easeInOut, + ); + } + + bool get _isOnDesktopAndWeb => + kIsWeb || + switch (defaultTargetPlatform) { + TargetPlatform.macOS || + TargetPlatform.linux || + TargetPlatform.windows => + true, + TargetPlatform.android || + TargetPlatform.iOS || + TargetPlatform.fuchsia => + false, + }; +} + +/// Page indicator for desktop and web platforms. +/// +/// On Desktop and Web, drag gesture for horizontal scrolling in a PageView is disabled by default. +/// You can defined a custom scroll behavior to activate drag gestures, +/// see https://docs.flutter.dev/release/breaking-changes/default-scroll-behavior-drag. +/// +/// In this sample, we use a TabPageSelector to navigate between pages, +/// in order to build natural behavior similar to other desktop applications. +class PageIndicator extends StatelessWidget { + const PageIndicator({ + super.key, + required this.tabController, + required this.currentPageIndex, + required this.onUpdateCurrentPageIndex, + required this.isOnDesktopAndWeb, + }); + + final int currentPageIndex; + final TabController tabController; + final void Function(int) onUpdateCurrentPageIndex; + final bool isOnDesktopAndWeb; + + @override + Widget build(BuildContext context) { + if (!isOnDesktopAndWeb) { + return const SizedBox.shrink(); + } + final ColorScheme colorScheme = Theme.of(context).colorScheme; + + return Padding( + padding: const EdgeInsets.all(8.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + IconButton( + splashRadius: 16.0, + padding: EdgeInsets.zero, + onPressed: () { + if (currentPageIndex == 0) { + return; + } + onUpdateCurrentPageIndex(currentPageIndex - 1); + }, + icon: const Icon(Icons.arrow_left_rounded, size: 32.0), + ), + TabPageSelector( + controller: tabController, + color: colorScheme.surface, + selectedColor: colorScheme.primary, + ), + IconButton( + splashRadius: 16.0, + padding: EdgeInsets.zero, + onPressed: () { + if (currentPageIndex == 2) { + return; + } + onUpdateCurrentPageIndex(currentPageIndex + 1); + }, + icon: const Icon(Icons.arrow_right_rounded, size: 32.0), + ), + ], + ), + ); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index c05b2dd1..b76ab51b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: A new Flutter project. publish_to: "none" -version: 1.3.0+19 +version: 1.3.2+21 environment: sdk: ">=3.0.0 <4.0.0"