feat: add confirmation dialog for saving availabilities

This commit is contained in:
Freek van de Ven 2024-07-11 11:47:27 +02:00
parent e308152b75
commit 04691461d8
3 changed files with 26 additions and 1 deletions

View file

@ -26,6 +26,8 @@ class AvailabilityTranslations {
required this.availabilityAddTemplateTitle,
required this.availabilityTimeTitle,
required this.availabilitiesTimeTitle,
required this.availabilityDialogConfirmTitle,
required this.availabilityDialogConfirmDescription,
required this.templateScreenTitle,
required this.dayTemplates,
required this.weekTemplates,
@ -75,6 +77,11 @@ class AvailabilityTranslations {
this.availabilityAddTemplateTitle = "Add template to availability",
this.availabilityTimeTitle = "Start and end time workday",
this.availabilitiesTimeTitle = "Start and end time workdays",
this.availabilityDialogConfirmTitle =
"Are you sure you want to save the changes?",
this.availabilityDialogConfirmDescription =
"This will update your availabilities but you can always "
"change them later",
this.overviewScreenTitle = "Availability",
this.templateScreenTitle = "Templates",
this.dayTemplates = "Day templates",
@ -155,6 +162,12 @@ class AvailabilityTranslations {
/// The title on the time selection section for adding multiple availabilities
final String availabilitiesTimeTitle;
/// The title on the dialog for confirming the availability update
final String availabilityDialogConfirmTitle;
/// The description on the dialog for confirming the availability update
final String availabilityDialogConfirmDescription;
/// The title on the template screen
final String templateScreenTitle;

View file

@ -92,11 +92,22 @@ class _AvailabilitiesModificationScreenState
widget.onExit();
}
Future<void> onClickSave() async {
var confirmed = await options.confirmationDialogBuilder(
context,
title: translations.availabilityDialogConfirmTitle,
description: translations.availabilityDialogConfirmDescription,
);
if (confirmed ?? false) {
await onSave();
}
}
var canSave =
_clearAvailability || (_startTime != null && _endTime != null);
var saveButton = options.primaryButtonBuilder(
context,
canSave ? onSave : null,
canSave ? onClickSave : null,
Text(translations.saveButton),
);

View file

@ -58,6 +58,7 @@ class DefaultConfirmationDialog extends StatelessWidget {
Text(
title,
style: textTheme.titleMedium,
textAlign: TextAlign.center,
),
const SizedBox(height: 16),
Text(