Skip to content

Commit

Permalink
feat(#708): hide keyboard on screen interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Nov 21, 2024
1 parent e73bd73 commit 3051680
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
22 changes: 14 additions & 8 deletions app/lib/common/widgets/page_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ Scaffold pageScaffold({
);
}

Scaffold unscrollablePageScaffold({
Widget unscrollablePageScaffold({
required Widget body,
String? title,
String? titleTooltip,
List<Widget>? actions,
bool canNavigateBack = true,
BuildContext? contextToDismissFocusOnTap,
Key? key,
}) {
final appBar = title == null
Expand All @@ -84,13 +85,18 @@ Scaffold unscrollablePageScaffold({
scrolledUnderElevation: 0,
titleSpacing: _getTitleSpacing(backButtonPresent: canNavigateBack),
);
return Scaffold(
key: key,
appBar: appBar,
body: SafeArea(
child: Padding(
padding: pagePadding(),
child: body,
return GestureDetector(
onTap: () => contextToDismissFocusOnTap != null
? FocusScope.of(contextToDismissFocusOnTap).unfocus()
: null,
child: Scaffold(
key: key,
appBar: appBar,
body: SafeArea(
child: Padding(
padding: pagePadding(),
child: body,
),
),
),
);
Expand Down
1 change: 1 addition & 0 deletions app/lib/common/widgets/scroll_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Widget scrollList(List<Widget> body, { bool keepPosition = false }) {
child: Padding(
padding: EdgeInsets.only(right: PharMeTheme.mediumSpace),
child: FlutterListView(
keyboardDismissBehavior: ScrollViewKeyboardDismissBehavior.onDrag,
delegate: FlutterListViewDelegate(
(context, index) => body[index],
childCount: body.length,
Expand Down
1 change: 1 addition & 0 deletions app/lib/drug_selection/pages/drug_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class DrugSelectionPage extends HookWidget {
return unscrollablePageScaffold(
title: context.l10n.drug_selection_header,
canNavigateBack: !concludesOnboarding,
contextToDismissFocusOnTap: context,
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expand Down
1 change: 1 addition & 0 deletions app/lib/search/pages/search.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class SearchPage extends HookWidget {
child: unscrollablePageScaffold(
title: context.l10n.tab_drugs,
canNavigateBack: false,
contextToDismissFocusOnTap: context,
body: DrugSearch(
key: Key('drug-search'),
showFilter: true,
Expand Down

0 comments on commit 3051680

Please sign in to comment.