Skip to content

Commit

Permalink
chore(#646): use unscrollablePageScaffold in pages where reasonable
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Aug 23, 2023
1 parent 77192c7 commit 15d1de3
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 61 deletions.
37 changes: 21 additions & 16 deletions app/lib/common/widgets/page_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Widget> body,
Expand All @@ -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))
]),
Expand All @@ -41,24 +45,25 @@ Scaffold pageScaffold({
Scaffold unscrollablePageScaffold({
required Widget body,
String? title,
PreferredSizeWidget? barBottom,
Widget? barBottom,
List<Widget>? 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),
Expand Down
30 changes: 11 additions & 19 deletions app/lib/drug_selection/pages/drug_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,16 @@ class DrugSelectionPage extends HookWidget {
create: (context) => cubit ?? DrugSelectionPageCubit(),
child: BlocBuilder<DrugSelectionPageCubit, DrugSelectionPageState>(
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),
],
),
);
}
Expand All @@ -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),
Expand Down
48 changes: 23 additions & 25 deletions app/lib/login/pages/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,34 @@ class LoginPage extends HookWidget {
create: (context) => cubit ?? LoginPageCubit(),
child: BlocBuilder<LoginPageCubit, LoginPageState>(
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),
),
),
),
],
),
),
],
),
);
},
Expand Down
2 changes: 1 addition & 1 deletion app/lib/onboarding/pages/onboarding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 15d1de3

Please sign in to comment.