mirror of
https://github.com/Iconica-Development/flutter_availability.git
synced 2025-05-19 05:03:44 +02:00
fix: add pause validation directly in the pause dialog when saving
This commit is contained in:
parent
16b7a7190b
commit
6eef54570b
1 changed files with 20 additions and 10 deletions
|
@ -277,18 +277,28 @@ class _AvailabilityBreakSelectionDialogState
|
|||
});
|
||||
}
|
||||
|
||||
Future<void> onSave() async {
|
||||
AvailabilityError? error;
|
||||
try {
|
||||
_breakViewModel.toBreak().validate();
|
||||
Navigator.of(context).pop(_breakViewModel);
|
||||
} on BreakEndBeforeStartException {
|
||||
error = AvailabilityError.breakEndBeforeStart;
|
||||
} on BreakSubmittedDurationTooLongException {
|
||||
error = AvailabilityError.breakSubmittedDurationTooLong;
|
||||
}
|
||||
|
||||
if (error != null && context.mounted) {
|
||||
await options.errorDisplayBuilder(
|
||||
context,
|
||||
error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
var canSave = _breakViewModel.canSave;
|
||||
|
||||
var onSaveButtonPress = canSave
|
||||
? () {
|
||||
if (_breakViewModel.isValid) {
|
||||
Navigator.of(context).pop(_breakViewModel);
|
||||
} else {
|
||||
debugPrint("Break is not valid");
|
||||
// TODO(freek): show error message
|
||||
}
|
||||
}
|
||||
: null;
|
||||
var onSaveButtonPress = canSave ? onSave : null;
|
||||
|
||||
var saveButton = options.primaryButtonBuilder(
|
||||
context,
|
||||
|
|
Loading…
Reference in a new issue