Skip to content

Commit

Permalink
feat(#677): add privacy screen
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Dec 15, 2023
1 parent 4355e37 commit e056b0f
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 45 deletions.
17 changes: 17 additions & 0 deletions app/lib/common/pages/privacy/privacy.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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();
}
}
2 changes: 2 additions & 0 deletions app/lib/common/routing/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ 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';

Expand All @@ -16,6 +17,7 @@ part 'router.gr.dart';
drugSelectionRoutes,
loginRoutes,
onboardingRoutes,
privacyRoutes,
AutoRoute(
path: 'main',
page: MainPage,
Expand Down
41 changes: 22 additions & 19 deletions app/lib/common/widgets/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,29 @@ class PharMeApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
return MaterialApp.router(
debugShowCheckedModeBanner: false,
routeInformationParser: _appRouter.defaultRouteParser(),
routerDelegate: _appRouter.delegate(
initialDeepLink: !_isLoggedIn
? 'login'
: !_onboardingDone
? 'onboarding'
: !_initialDrugSelectionDone
? 'drugselection'
: 'main',
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', '')],
),
theme: PharMeTheme.light,
localizationsDelegates: [
AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [Locale('en', '')],
);
}
}
28 changes: 28 additions & 0 deletions app/lib/common/widgets/lifecycle_observer.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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;
}
}
2 changes: 2 additions & 0 deletions app/lib/common/widgets/module.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ 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';
export 'rounded_card.dart';
export 'scroll_list.dart';
Expand Down
33 changes: 33 additions & 0 deletions app/lib/common/widgets/pharme_logo_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import '../module.dart';

class PharMeLogoPage extends StatelessWidget {
const PharMeLogoPage({
Key? key,
this.child,
}) : super(key: key);

final Widget? child;

@override
Widget build(BuildContext context) {
return unscrollablePageScaffold(
padding: PharMeTheme.largeSpace,
body: Column(
children: [
Expanded(
child: Container(
alignment: Alignment.center,
child: SvgPicture.asset(
'assets/images/logo.svg',
),
),
),
Container(
alignment: Alignment.center,
child: child ?? SizedBox.shrink(),
),
],
),
);
}
}
34 changes: 8 additions & 26 deletions app/lib/login/pages/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,14 @@ class LoginPage extends HookWidget {
create: (context) => cubit ?? LoginPageCubit(activeDrugs),
child: BlocBuilder<LoginPageCubit, LoginPageState>(
builder: (context, state) {
return unscrollablePageScaffold(
padding: PharMeTheme.largeSpace,
body: Stack(
children: [
Positioned.fill(
child: Align(
alignment: Alignment.center,
child: SvgPicture.asset(
'assets/images/logo.svg',
),
),
),
Positioned(
child: Align(
alignment: Alignment.bottomCenter,
child: state.when(
initial: () =>
_buildInitialScreen(context, dropdownValue),
loadingUserData: CircularProgressIndicator.new,
loadedUserData: () => _buildLoadedScreen(context),
error: (message) =>
_buildErrorScreen(context, message),
),
),
),
],
return PharMeLogoPage(
child: state.when(
initial: () =>
_buildInitialScreen(context, dropdownValue),
loadingUserData: CircularProgressIndicator.new,
loadedUserData: () => _buildLoadedScreen(context),
error: (message) =>
_buildErrorScreen(context, message),
),
);
},
Expand Down

0 comments on commit e056b0f

Please sign in to comment.