From c4a48d32337b3f0b4a92cf4734867c03634d9bde Mon Sep 17 00:00:00 2001 From: Tom Bursch Date: Mon, 15 May 2023 11:00:03 +0200 Subject: [PATCH] feat: add household leave confirmation dialog --- lib/l10n/app_de.arb | 6 ++++++ lib/l10n/app_en.arb | 6 ++++++ lib/pages/settings_page.dart | 23 ++++++++++++++++++----- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/lib/l10n/app_de.arb b/lib/l10n/app_de.arb index ecd3e9d2..cd557756 100644 --- a/lib/l10n/app_de.arb +++ b/lib/l10n/app_de.arb @@ -385,6 +385,12 @@ "@householdEmpty": {}, "householdLeave": "Haushalt verlassen", "@householdLeave": {}, + "householdLeaveConfirmation": "Bist du sicher, dass du {household} verlassen möchtest?", + "@householdLeaveConfirmation": { + "placeholders": { + "household": {} + } + }, "householdNew": "Neuer Haushalt", "@householdNew": {}, "households": "Haushalte", diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index aa077a08..33d16877 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -167,6 +167,12 @@ "@householdEmpty": {}, "householdLeave": "Leave Household", "@householdLeave": {}, + "householdLeaveConfirmation": "Are you sure you want to leave {household}?", + "@householdLeaveConfirmation": { + "placeholders": { + "household": {} + } + }, "householdNew": "New Household", "@householdNew": {}, "households": "Households", diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart index 4030e462..bf5484e1 100644 --- a/lib/pages/settings_page.dart +++ b/lib/pages/settings_page.dart @@ -195,12 +195,25 @@ class _SettingsPageState extends State { ListTile( title: Text(AppLocalizations.of(context)!.householdLeave), leading: const Icon(Icons.person_remove_rounded), - onTap: () { - ApiService.getInstance().removeHouseholdMember( - widget.household!, - BlocProvider.of(context).getUser()!, + onTap: () async { + final confirm = await askForConfirmation( + context: context, + title: Text( + AppLocalizations.of(context)!.householdLeave, + ), + content: Text( + AppLocalizations.of(context)! + .householdLeaveConfirmation(widget.household!.name), + ), + confirmText: AppLocalizations.of(context)!.yes, ); - context.go("/household"); + if (confirm) { + ApiService.getInstance().removeHouseholdMember( + widget.household!, + BlocProvider.of(context).getUser()!, + ); + context.go("/household"); + } }, ), ListTile(