Skip to content

Commit

Permalink
refactor(app): pass whether to remove focus and to resize content to …
Browse files Browse the repository at this point in the history
…both scaffold types
  • Loading branch information
tamslo committed Nov 21, 2024
1 parent c598625 commit 6633964
Showing 1 changed file with 32 additions and 26 deletions.
58 changes: 32 additions & 26 deletions app/lib/common/widgets/page_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,42 @@ Widget buildTitle(String text, { String? tooltipText }) {
);
}

Scaffold pageScaffold({
Widget pageScaffold({
required List<Widget> body,
required String title,
List<Widget>? actions,
bool canNavigateBack = true,
BuildContext? contextToDismissFocusOnTap,
bool resizeToAvoidBottomInset = false,
Key? key,
}) {
return Scaffold(
key: key,
resizeToAvoidBottomInset: false,
body: CustomScrollView(slivers: [
SliverAppBar(
scrolledUnderElevation: 0,
backgroundColor: PharMeTheme.appBarTheme.backgroundColor,
foregroundColor: PharMeTheme.appBarTheme.foregroundColor,
elevation: PharMeTheme.appBarTheme.elevation,
leadingWidth: PharMeTheme.appBarTheme.leadingWidth,
automaticallyImplyLeading: canNavigateBack,
floating: true,
pinned: true,
snap: false,
centerTitle: PharMeTheme.appBarTheme.centerTitle,
title: buildTitle(title),
actions: actions,
titleSpacing: _getTitleSpacing(backButtonPresent: canNavigateBack),
),
SliverPadding(
padding: pagePadding(),
sliver: SliverList(delegate: SliverChildListDelegate(body)),
),
]),
return GestureDetector(
onTap: () => _maybeRemoveFocus(contextToDismissFocusOnTap),
child: Scaffold(
key: key,
resizeToAvoidBottomInset: resizeToAvoidBottomInset,
body: CustomScrollView(slivers: [
SliverAppBar(
scrolledUnderElevation: 0,
backgroundColor: PharMeTheme.appBarTheme.backgroundColor,
foregroundColor: PharMeTheme.appBarTheme.foregroundColor,
elevation: PharMeTheme.appBarTheme.elevation,
leadingWidth: PharMeTheme.appBarTheme.leadingWidth,
automaticallyImplyLeading: canNavigateBack,
floating: true,
pinned: true,
snap: false,
centerTitle: PharMeTheme.appBarTheme.centerTitle,
title: buildTitle(title),
actions: actions,
titleSpacing: _getTitleSpacing(backButtonPresent: canNavigateBack),
),
SliverPadding(
padding: pagePadding(),
sliver: SliverList(delegate: SliverChildListDelegate(body)),
),
]),
),
);
}

Expand All @@ -75,6 +80,7 @@ Widget unscrollablePageScaffold({
List<Widget>? actions,
bool canNavigateBack = true,
BuildContext? contextToDismissFocusOnTap,
bool resizeToAvoidBottomInset = false,
Key? key,
}) {
final appBar = title == null
Expand All @@ -96,7 +102,7 @@ Widget unscrollablePageScaffold({
child: Scaffold(
key: key,
appBar: appBar,
resizeToAvoidBottomInset: false,
resizeToAvoidBottomInset: resizeToAvoidBottomInset,
body: SafeArea(
child: Padding(
padding: pagePadding(),
Expand Down

0 comments on commit 6633964

Please sign in to comment.