Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into healthx-demo-deep-linking
Browse files Browse the repository at this point in the history
  • Loading branch information
tamslo committed Nov 22, 2024
2 parents e526d62 + f072f24 commit 8746a9c
Show file tree
Hide file tree
Showing 13 changed files with 608 additions and 223 deletions.
6 changes: 3 additions & 3 deletions app/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = H4NQ8HX57R;
DEVELOPMENT_TEAM = ML9QV973KL;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -495,7 +495,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = H4NQ8HX57R;
DEVELOPMENT_TEAM = ML9QV973KL;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down Expand Up @@ -525,7 +525,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = H4NQ8HX57R;
DEVELOPMENT_TEAM = ML9QV973KL;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
Expand Down
8 changes: 4 additions & 4 deletions app/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
Expand Down Expand Up @@ -29,6 +31,8 @@
</array>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand All @@ -46,9 +50,5 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
11 changes: 11 additions & 0 deletions app/lib/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class PharMeApp extends StatelessWidget {
}
return getInitialRoute();
},
navigatorObservers: () => [RemoveFocusOnNavigate()],
),
theme: PharMeTheme.light,
localizationsDelegates: [
Expand All @@ -52,3 +53,13 @@ class PharMeApp extends StatelessWidget {
);
}
}

// Based on https://github.com/flutter/flutter/issues/48464#issuecomment-586635827
class RemoveFocusOnNavigate extends NavigatorObserver {
@override
void didPush(Route route, Route? previousRoute) {
super.didPush(route, previousRoute);
final focus = FocusManager.instance.primaryFocus;
focus?.unfocus();
}
}
8 changes: 4 additions & 4 deletions app/lib/common/widgets/dialog_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import '../module.dart';
class DialogWrapper extends StatelessWidget {
const DialogWrapper({
super.key,
required this.title,
required this.content,
required this.actions,
this.title,
this.content,
});

final String title;
final String? title;
final Widget? content;
final List<DialogAction> actions;

Expand All @@ -22,7 +22,7 @@ class DialogWrapper extends StatelessWidget {
)
: content;
return AlertDialog.adaptive(
title: Text(title),
title: title != null ? Text(title!) : null,
content: materialContent,
actions: actions,
elevation: 0,
Expand Down
6 changes: 5 additions & 1 deletion app/lib/common/widgets/drug_activity_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ SwitchListTile buildDrugActivitySelection({
required bool isActive,
required bool disabled,
EdgeInsetsGeometry? contentPadding,
bool warnIfInhibitor = true,
}) => SwitchListTile.adaptive(
key: key,
value: isActive,
activeColor: PharMeTheme.primaryColor,
inactiveThumbColor: PharMeTheme.surfaceColor,
inactiveTrackColor: PharMeTheme.borderColor,
trackOutlineColor: WidgetStatePropertyAll(Colors.transparent),
title: Text(title),
subtitle: subtitle.isNotNullOrBlank ? Text(subtitle!, style: PharMeTheme.textTheme.bodyMedium): null,
contentPadding: contentPadding,
onChanged: disabled ? null : (newValue) {
if (isInhibitor(drug.name)) {
if (warnIfInhibitor && isInhibitor(drug.name)) {
showAdaptiveDialog(
context: context,
builder: (context) => DialogWrapper(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ List<SwitchListTile> _buildSelectionList(
subtitle: (drug.annotations.brandNames.isNotEmpty) ?
formatBrandNames(context, drug) :
null,
warnIfInhibitor: showDrugInteractionIndicator,
)
).toList();
}
81 changes: 49 additions & 32 deletions app/lib/common/widgets/page_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,45 +29,58 @@ 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,
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)),
),
]),
),
);
}

Scaffold unscrollablePageScaffold({
void _maybeRemoveFocus(BuildContext? contextToDismissFocusOnTap) =>
contextToDismissFocusOnTap != null
? FocusScope.of(contextToDismissFocusOnTap).unfocus()
: null;

Widget unscrollablePageScaffold({
required Widget body,
String? title,
String? titleTooltip,
List<Widget>? actions,
bool canNavigateBack = true,
BuildContext? contextToDismissFocusOnTap,
bool resizeToAvoidBottomInset = false,
Key? key,
}) {
final appBar = title == null
Expand All @@ -84,13 +97,17 @@ 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: () => _maybeRemoveFocus(contextToDismissFocusOnTap),
child: Scaffold(
key: key,
appBar: appBar,
resizeToAvoidBottomInset: resizeToAvoidBottomInset,
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
32 changes: 25 additions & 7 deletions app/lib/drug_selection/pages/drug_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,14 @@ class DrugSelectionPage extends HookWidget {
return unscrollablePageScaffold(
title: context.l10n.drug_selection_header,
canNavigateBack: !concludesOnboarding,
contextToDismissFocusOnTap: context,
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.symmetric(vertical: PharMeTheme.smallSpace),
child: PageDescription.fromText(
concludesOnboarding
? context.l10n.drug_selection_onboarding_description
: context.l10n.drug_selection_settings_description,
context.l10n.drug_selection_settings_description,
),
),
Expanded(child: _buildDrugList(context, state)),
Expand All @@ -67,10 +66,29 @@ class DrugSelectionPage extends HookWidget {
child: FullWidthButton(
context.l10n.action_continue,
() async {
MetaData.instance.initialDrugSelectionDone = true;
await MetaData.save();
// ignore: use_build_context_synchronously
await overwriteRoutes(context, nextPage: MainRoute());
await showAdaptiveDialog(
context: context,
builder: (context) => DialogWrapper(
title: context.l10n.drug_selection_continue_warning_title,
content: Text(context.l10n.drug_selection_continue_warning),
actions: [
DialogAction(
onPressed: context.router.root.maybePop,
text: context.l10n.action_cancel,
),
DialogAction(
onPressed: () async {
MetaData.instance.initialDrugSelectionDone = true;
await MetaData.save();
// ignore: use_build_context_synchronously
await overwriteRoutes(context, nextPage: MainRoute());
},
text: context.l10n.action_understood,
isDefault: true,
),
],
),
);
},
enabled: _isEditable(state),
)
Expand Down
Loading

0 comments on commit 8746a9c

Please sign in to comment.