From b50cc83534077424a6cd303a94f20dd63a2d6ca0 Mon Sep 17 00:00:00 2001 From: Tamara Slosarek Date: Mon, 18 Dec 2023 14:58:44 +0100 Subject: [PATCH] feat(#677): remove privacy screen based on lifecycle (not working on Android) --- app/lib/common/pages/privacy/privacy.dart | 17 -------- app/lib/common/routing/router.dart | 2 - app/lib/common/widgets/app.dart | 41 +++++++++---------- .../common/widgets/lifecycle_observer.dart | 28 ------------- app/lib/common/widgets/module.dart | 1 - 5 files changed, 19 insertions(+), 70 deletions(-) delete mode 100644 app/lib/common/pages/privacy/privacy.dart delete mode 100644 app/lib/common/widgets/lifecycle_observer.dart diff --git a/app/lib/common/pages/privacy/privacy.dart b/app/lib/common/pages/privacy/privacy.dart deleted file mode 100644 index 05e8a7b1..00000000 --- a/app/lib/common/pages/privacy/privacy.dart +++ /dev/null @@ -1,17 +0,0 @@ -import '../../module.dart'; - -const privacyRoutes = CustomRoute( - path: 'privacy', - name: 'PrivacyRouter', - page: PrivacyPage, - transitionsBuilder: TransitionsBuilders.zoomIn, -); - -class PrivacyPage extends StatelessWidget { - const PrivacyPage({Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return PharMeLogoPage(); - } -} \ No newline at end of file diff --git a/app/lib/common/routing/router.dart b/app/lib/common/routing/router.dart index c92567d7..2545fa7f 100644 --- a/app/lib/common/routing/router.dart +++ b/app/lib/common/routing/router.dart @@ -7,7 +7,6 @@ import '../../report/module.dart'; import '../../search/module.dart'; import '../../settings/module.dart'; import '../pages/main/main.dart'; -import '../pages/privacy/privacy.dart'; part 'router.gr.dart'; @@ -17,7 +16,6 @@ part 'router.gr.dart'; drugSelectionRoutes, loginRoutes, onboardingRoutes, - privacyRoutes, AutoRoute( path: 'main', page: MainPage, diff --git a/app/lib/common/widgets/app.dart b/app/lib/common/widgets/app.dart index f7d81cc8..9ba3bfd2 100644 --- a/app/lib/common/widgets/app.dart +++ b/app/lib/common/widgets/app.dart @@ -20,29 +20,26 @@ class PharMeApp extends StatelessWidget { @override Widget build(BuildContext context) { - return LifecycleObserver( - appRouter: _appRouter, - child: MaterialApp.router( - debugShowCheckedModeBanner: false, - routeInformationParser: _appRouter.defaultRouteParser(), - routerDelegate: _appRouter.delegate( - initialDeepLink: !_isLoggedIn - ? 'login' - : !_onboardingDone - ? 'onboarding' - : !_initialDrugSelectionDone - ? 'drugselection' - : 'main', - ), - theme: PharMeTheme.light, - localizationsDelegates: [ - AppLocalizations.delegate, - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - GlobalCupertinoLocalizations.delegate, - ], - supportedLocales: [Locale('en', '')], + return MaterialApp.router( + debugShowCheckedModeBanner: false, + routeInformationParser: _appRouter.defaultRouteParser(), + routerDelegate: _appRouter.delegate( + initialDeepLink: !_isLoggedIn + ? 'login' + : !_onboardingDone + ? 'onboarding' + : !_initialDrugSelectionDone + ? 'drugselection' + : 'main', ), + theme: PharMeTheme.light, + localizationsDelegates: [ + AppLocalizations.delegate, + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], + supportedLocales: [Locale('en', '')], ); } } diff --git a/app/lib/common/widgets/lifecycle_observer.dart b/app/lib/common/widgets/lifecycle_observer.dart deleted file mode 100644 index 4516b3ab..00000000 --- a/app/lib/common/widgets/lifecycle_observer.dart +++ /dev/null @@ -1,28 +0,0 @@ -import '../module.dart'; - -class LifecycleObserver extends HookWidget { - const LifecycleObserver({ - Key? key, - required this.appRouter, - required this.child, - }) : super(key: key); - - final AppRouter appRouter; - final Widget child; - - @override - Widget build(BuildContext context) { - useOnAppLifecycleStateChange((previous, current) async { - if (current == AppLifecycleState.resumed) { - appRouter.navigateBack(); - } - if ( - current == AppLifecycleState.inactive || - current == AppLifecycleState.paused - ) { - await appRouter.push(PrivacyRouter()); - } - }); - return child; - } -} \ No newline at end of file diff --git a/app/lib/common/widgets/module.dart b/app/lib/common/widgets/module.dart index a2cc429e..2a6cb570 100644 --- a/app/lib/common/widgets/module.dart +++ b/app/lib/common/widgets/module.dart @@ -4,7 +4,6 @@ export 'drug_list/builder.dart'; export 'drug_list/cubit.dart'; export 'headings.dart'; export 'indicators.dart'; -export 'lifecycle_observer.dart'; export 'page_scaffold.dart'; export 'pharme_logo_page.dart'; export 'radiant_gradient_mask.dart';