Skip to content

Commit

Permalink
feat: add household leave confirmation dialog (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomBursch authored May 15, 2023
1 parent 130e6c8 commit d6cbb37
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
6 changes: 6 additions & 0 deletions lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
23 changes: 18 additions & 5 deletions lib/pages/settings_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,25 @@ class _SettingsPageState extends State<SettingsPage> {
ListTile(
title: Text(AppLocalizations.of(context)!.householdLeave),
leading: const Icon(Icons.person_remove_rounded),
onTap: () {
ApiService.getInstance().removeHouseholdMember(
widget.household!,
BlocProvider.of<AuthCubit>(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<AuthCubit>(context).getUser()!,
);
context.go("/household");
}
},
),
ListTile(
Expand Down

0 comments on commit d6cbb37

Please sign in to comment.