mirror of
https://github.com/Iconica-Development/flutter_availability.git
synced 2025-05-19 13:13:44 +02:00
feat: add confirmation dialog for saving availabilities
This commit is contained in:
parent
01e1794754
commit
440b1e7caa
3 changed files with 26 additions and 1 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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),
|
||||
);
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ class DefaultConfirmationDialog extends StatelessWidget {
|
|||
Text(
|
||||
title,
|
||||
style: textTheme.titleMedium,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
|
|
Loading…
Reference in a new issue