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
b184dc65bd
commit
0525e9d3b6
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 canSave = _breakViewModel.canSave;
|
||||||
|
|
||||||
var onSaveButtonPress = canSave
|
var onSaveButtonPress = canSave ? onSave : null;
|
||||||
? () {
|
|
||||||
if (_breakViewModel.isValid) {
|
|
||||||
Navigator.of(context).pop(_breakViewModel);
|
|
||||||
} else {
|
|
||||||
debugPrint("Break is not valid");
|
|
||||||
// TODO(freek): show error message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
: null;
|
|
||||||
|
|
||||||
var saveButton = options.primaryButtonBuilder(
|
var saveButton = options.primaryButtonBuilder(
|
||||||
context,
|
context,
|
||||||
|
|
Loading…
Reference in a new issue