mirror of
https://github.com/Iconica-Development/flutter_availability.git
synced 2025-05-19 13:13:44 +02:00
feat: add custom timepicker option for overriding the default
This commit is contained in:
parent
239eb92609
commit
ff7ab2bc42
2 changed files with 17 additions and 4 deletions
|
@ -18,6 +18,7 @@ class AvailabilityOptions {
|
||||||
this.spacing = const AvailabilitySpacing(),
|
this.spacing = const AvailabilitySpacing(),
|
||||||
this.textStyles = const AvailabilityTextStyles(),
|
this.textStyles = const AvailabilityTextStyles(),
|
||||||
this.colors = const AvailabilityColors(),
|
this.colors = const AvailabilityColors(),
|
||||||
|
this.timePickerBuilder,
|
||||||
AvailabilityDataInterface? dataInterface,
|
AvailabilityDataInterface? dataInterface,
|
||||||
}) : dataInterface = dataInterface ?? LocalAvailabilityDataInterface();
|
}) : dataInterface = dataInterface ?? LocalAvailabilityDataInterface();
|
||||||
|
|
||||||
|
@ -48,6 +49,10 @@ class AvailabilityOptions {
|
||||||
|
|
||||||
/// The colors used in the userstory
|
/// The colors used in the userstory
|
||||||
final AvailabilityColors colors;
|
final AvailabilityColors colors;
|
||||||
|
|
||||||
|
/// A way to provide your own time picker implementation or customize
|
||||||
|
/// the default time picker
|
||||||
|
final TimePickerBuilder? timePickerBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// All configurable paddings and whitespaces withing the userstory
|
/// All configurable paddings and whitespaces withing the userstory
|
||||||
|
@ -137,3 +142,9 @@ typedef ButtonBuilder = Widget Function(
|
||||||
FutureOr<void>? Function()? onPressed,
|
FutureOr<void>? Function()? onPressed,
|
||||||
Widget child,
|
Widget child,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// Builder definition for providing a time picker implementation
|
||||||
|
typedef TimePickerBuilder = Future<TimeOfDay?> Function(
|
||||||
|
BuildContext context,
|
||||||
|
TimeOfDay? initialTime,
|
||||||
|
);
|
||||||
|
|
|
@ -24,10 +24,12 @@ class TimeInputField extends StatelessWidget {
|
||||||
var translations = options.translations;
|
var translations = options.translations;
|
||||||
|
|
||||||
Future<void> onFieldtap() async {
|
Future<void> onFieldtap() async {
|
||||||
var time = await showTimePicker(
|
var initialTime = TimeOfDay.fromDateTime(initialValue ?? DateTime.now());
|
||||||
|
var time = await (options.timePickerBuilder?.call(context, initialTime) ??
|
||||||
|
showTimePicker(
|
||||||
context: context,
|
context: context,
|
||||||
initialTime: TimeOfDay.fromDateTime(initialValue ?? DateTime.now()),
|
initialTime: TimeOfDay.fromDateTime(initialValue ?? DateTime.now()),
|
||||||
);
|
));
|
||||||
if (time != null) {
|
if (time != null) {
|
||||||
onTimeChanged(
|
onTimeChanged(
|
||||||
DateTime(
|
DateTime(
|
||||||
|
|
Loading…
Reference in a new issue