diff --git a/app/lib/common/widgets/page_scaffold.dart b/app/lib/common/widgets/page_scaffold.dart index 05be28823..13cb215e5 100644 --- a/app/lib/common/widgets/page_scaffold.dart +++ b/app/lib/common/widgets/page_scaffold.dart @@ -4,6 +4,16 @@ Text buildTitle(String text) { return Text(text, style: PharMeTheme.textTheme.headlineLarge); } +AppBar? buildBarBottom(Widget? barBottom) { + return barBottom == null + ? null + : AppBar( + backgroundColor: PharMeTheme.appBarTheme.backgroundColor, + elevation: PharMeTheme.appBarTheme.elevation, + title: barBottom, + ); +} + Scaffold pageScaffold({ required String title, required List body, @@ -25,13 +35,7 @@ Scaffold pageScaffold({ centerTitle: PharMeTheme.appBarTheme.centerTitle, title: buildTitle(title), actions: actions, - bottom: barBottom == null - ? null - : AppBar( - backgroundColor: PharMeTheme.backgroundColor, - elevation: 0, - title: barBottom, - ), + bottom: buildBarBottom(barBottom), ), SliverList(delegate: SliverChildListDelegate(body)) ]), @@ -41,24 +45,25 @@ Scaffold pageScaffold({ Scaffold unscrollablePageScaffold({ required Widget body, String? title, - PreferredSizeWidget? barBottom, + Widget? barBottom, List? actions, Key? key, }) { - return Scaffold( - key: key, - appBar: AppBar( + final appBar = title == null + ? null + : AppBar( backgroundColor: PharMeTheme.appBarTheme.backgroundColor, foregroundColor: PharMeTheme.appBarTheme.foregroundColor, elevation: PharMeTheme.appBarTheme.elevation, leadingWidth: PharMeTheme.appBarTheme.leadingWidth, centerTitle: PharMeTheme.appBarTheme.centerTitle, - title: title == null - ? null - : buildTitle(title), + title: buildTitle(title), actions: actions, - bottom: barBottom, - ), + bottom: buildBarBottom(barBottom), + ); + return Scaffold( + key: key, + appBar: appBar, body: SafeArea( child: Padding( padding: const EdgeInsets.all(PharMeTheme.smallSpace), diff --git a/app/lib/drug_selection/pages/drug_selection.dart b/app/lib/drug_selection/pages/drug_selection.dart index da4fb07aa..f1d6b2431 100644 --- a/app/lib/drug_selection/pages/drug_selection.dart +++ b/app/lib/drug_selection/pages/drug_selection.dart @@ -19,20 +19,16 @@ class DrugSelectionPage extends HookWidget { create: (context) => cubit ?? DrugSelectionPageCubit(), child: BlocBuilder( builder: (context, state) { - return Scaffold( - body: SafeArea( - child: Padding( - padding: const EdgeInsets.all(16), - child: Column( - children: [ - _buildHeader(context), - SizedBox(height: PharMeTheme.mediumSpace), - Expanded(child:_buildDrugList(context, state)), - SizedBox(height: PharMeTheme.mediumSpace), - _buildButton(context, state), - ], - ), - ), + return unscrollablePageScaffold( + title: context.l10n.drug_selection_header, + body: Column( + children: [ + _buildDescription(context), + SizedBox(height: PharMeTheme.mediumSpace), + Expanded(child:_buildDrugList(context, state)), + SizedBox(height: PharMeTheme.mediumSpace), + _buildButton(context, state), + ], ), ); } @@ -47,15 +43,11 @@ class DrugSelectionPage extends HookWidget { ); } - Widget _buildHeader(BuildContext context) { + Widget _buildDescription(BuildContext context) { return Padding( padding: const EdgeInsets.all(8), child: Column( children: [ - Text( - context.l10n.drug_selection_header, - style: PharMeTheme.textTheme.headlineLarge), - SizedBox(height: PharMeTheme.mediumSpace), Text( context.l10n.drug_selection_description, style: PharMeTheme.textTheme.bodyLarge), diff --git a/app/lib/login/pages/login.dart b/app/lib/login/pages/login.dart index 58bc8ef67..6b0ac4555 100644 --- a/app/lib/login/pages/login.dart +++ b/app/lib/login/pages/login.dart @@ -21,36 +21,34 @@ class LoginPage extends HookWidget { create: (context) => cubit ?? LoginPageCubit(), child: BlocBuilder( builder: (context, state) { - return Scaffold( - body: SafeArea( - child: Stack( - children: [ - Positioned.fill( - child: Align( - alignment: Alignment.center, - child: SvgPicture.asset( - 'assets/images/logo.svg', - ), + return unscrollablePageScaffold( + body: Stack( + children: [ + Positioned.fill( + child: Align( + alignment: Alignment.center, + child: SvgPicture.asset( + 'assets/images/logo.svg', ), ), - Positioned( - child: Align( - alignment: Alignment.bottomCenter, - child: Padding( - padding: const EdgeInsets.all(16), - child: state.when( - initial: () => - _buildInitialScreen(context, dropdownValue), - loadingUserData: CircularProgressIndicator.new, - loadedUserData: () => _buildLoadedScreen(context), - error: (message) => - _buildErrorScreen(context, message), - ), + ), + Positioned( + child: Align( + alignment: Alignment.bottomCenter, + child: Padding( + padding: const EdgeInsets.all(PharMeTheme.smallSpace), + child: state.when( + initial: () => + _buildInitialScreen(context, dropdownValue), + loadingUserData: CircularProgressIndicator.new, + loadedUserData: () => _buildLoadedScreen(context), + error: (message) => + _buildErrorScreen(context, message), ), ), ), - ], - ), + ), + ], ), ); }, diff --git a/app/lib/onboarding/pages/onboarding.dart b/app/lib/onboarding/pages/onboarding.dart index 79ceee072..cb62f9654 100644 --- a/app/lib/onboarding/pages/onboarding.dart +++ b/app/lib/onboarding/pages/onboarding.dart @@ -161,7 +161,7 @@ class OnboardingPage extends HookWidget { key: Key('nextButton'), onPressed: () { if (isLastPage) { - context.router.replace(DrugSelectionRouter()); + context.router.push(DrugSelectionRouter()); } else { pageController.nextPage( duration: Duration(milliseconds: 500),