feat: add template deletion confirmation dialog

This commit is contained in:
Freek van de Ven 2024-07-25 11:46:04 +02:00
parent e7a1a8abfa
commit 6b6bb2171b
2 changed files with 18 additions and 0 deletions

View file

@ -45,6 +45,8 @@ class AvailabilityTranslations {
required this.templateTitleLabel, required this.templateTitleLabel,
required this.templateColorLabel, required this.templateColorLabel,
required this.weekTemplateOverviewTitle, required this.weekTemplateOverviewTitle,
required this.templateDeleteDialogConfirmTitle,
required this.templateDeleteDialogConfirmDescription,
required this.pause, required this.pause,
required this.unavailable, required this.unavailable,
required this.time, required this.time,
@ -113,6 +115,9 @@ class AvailabilityTranslations {
this.templateTitleLabel = "Template Title", this.templateTitleLabel = "Template Title",
this.templateColorLabel = "Colorlabel", this.templateColorLabel = "Colorlabel",
this.weekTemplateOverviewTitle = "Overview availability", this.weekTemplateOverviewTitle = "Overview availability",
this.templateDeleteDialogConfirmTitle = "Are you sure you want to delete?",
this.templateDeleteDialogConfirmDescription =
"You can't undo this deletion",
this.pause = "Pause", this.pause = "Pause",
this.unavailable = "Unavailable", this.unavailable = "Unavailable",
this.time = "Time", this.time = "Time",
@ -247,6 +252,12 @@ class AvailabilityTranslations {
/// The title for the week overview section /// The title for the week overview section
final String weekTemplateOverviewTitle; final String weekTemplateOverviewTitle;
/// The title on the dialog for confirming the template delete
final String templateDeleteDialogConfirmTitle;
/// The description on the dialog for confirming the template delete
final String templateDeleteDialogConfirmDescription;
/// The label used for pause /// The label used for pause
final String pause; final String pause;

View file

@ -51,6 +51,13 @@ class _DayTemplateModificationScreenState
var translations = options.translations; var translations = options.translations;
Future<void> onDeletePressed() async { Future<void> onDeletePressed() async {
var isConfirmed = await options.confirmationDialogBuilder(
context,
title: translations.templateDeleteDialogConfirmTitle,
description: translations.templateDeleteDialogConfirmDescription,
);
if (!isConfirmed) return;
await service.deleteTemplate(widget.template!); await service.deleteTemplate(widget.template!);
widget.onExit(); widget.onExit();
} }