Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add household leave confirmation dialog #164

Merged
merged 1 commit into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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