Skip to content

Commit

Permalink
feat(app): show dialog instead of different explanation text when con…
Browse files Browse the repository at this point in the history
…tinuing from first medication selection
  • Loading branch information
tamslo committed Nov 20, 2024
1 parent 36155a5 commit fbd3099
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
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
30 changes: 23 additions & 7 deletions app/lib/drug_selection/pages/drug_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ class DrugSelectionPage extends HookWidget {
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 +65,28 @@ 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(
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
2 changes: 1 addition & 1 deletion app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"drug_item_brand_names": "Brand names",

"drug_selection_header": "Current medications",
"drug_selection_onboarding_description": "Please review the medications you are currently taking below and update them if needed. You can always change the status for a medication later on a medication page or in the settings.",
"drug_selection_continue_warning": "If you continue, you will complete the initial setup and will not be able to come back to this page. You can always change the status for a medication later in the app.",
"drug_selection_settings_description": "Review the medications you are currently taking below.",
"drug_selection_no_drugs_loaded": "No medications loaded",

Expand Down

0 comments on commit fbd3099

Please sign in to comment.