mirror of
https://github.com/Iconica-Development/flutter_input_library.git
synced 2025-05-18 17:03:45 +02:00
Merge pull request #22 from Iconica-Development/feature/date_picker_disable_on_tap
Added the ability to disable onTap of DateTimePicker
This commit is contained in:
commit
6f9fbccfbd
4 changed files with 27 additions and 12 deletions
|
@ -37,3 +37,7 @@
|
|||
|
||||
## 2.3.0
|
||||
* The ability to set the enabled parameter of TextFormFields
|
||||
|
||||
## 2.4.0
|
||||
* The ability to disable the onTap paramater of the DatePicker
|
||||
* FlutterFormInputDateTime now also had the enabled parameter to provide to DateTimeInputField
|
|
@ -34,6 +34,8 @@ class FlutterFormInputDateTime extends StatelessWidget {
|
|||
this.validator,
|
||||
this.autovalidateMode = AutovalidateMode.disabled,
|
||||
this.timePickerEntryMode = TimePickerEntryMode.dial,
|
||||
this.enabled = true,
|
||||
this.onTapEnabled = true,
|
||||
}) : super(
|
||||
key: key,
|
||||
);
|
||||
|
@ -55,6 +57,8 @@ class FlutterFormInputDateTime extends StatelessWidget {
|
|||
final void Function(String?)? onChanged;
|
||||
final AutovalidateMode autovalidateMode;
|
||||
final TimePickerEntryMode timePickerEntryMode;
|
||||
final bool enabled;
|
||||
final bool onTapEnabled;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -77,6 +81,8 @@ class FlutterFormInputDateTime extends StatelessWidget {
|
|||
onSaved: (value) => onSaved?.call(value),
|
||||
showIcon: showIcon,
|
||||
timePickerEntryMode: timePickerEntryMode,
|
||||
enabled: enabled,
|
||||
onTapEnabled: onTapEnabled,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ class DateTimeInputField extends StatefulWidget {
|
|||
required this.timePickerEntryMode,
|
||||
required this.style,
|
||||
this.enabled = true,
|
||||
this.onTapEnabled = true,
|
||||
}) : super(
|
||||
key: key,
|
||||
);
|
||||
|
@ -52,6 +53,7 @@ class DateTimeInputField extends StatefulWidget {
|
|||
final void Function(String?)? onChanged;
|
||||
final TimePickerEntryMode timePickerEntryMode;
|
||||
final bool enabled;
|
||||
final bool onTapEnabled;
|
||||
|
||||
@override
|
||||
State<DateTimeInputField> createState() => _DateInputFieldState();
|
||||
|
@ -174,16 +176,19 @@ class _DateInputFieldState extends State<DateTimeInputField> {
|
|||
key: UniqueKey(),
|
||||
initialValue: currentValue.isEmpty ? widget.initialValue : currentValue,
|
||||
onSaved: (value) => widget.onSaved?.call(value),
|
||||
onTap: () async {
|
||||
onTap: widget.onTapEnabled
|
||||
? () async {
|
||||
String userInput = await getInputFromUser(
|
||||
widget.inputType,
|
||||
DateFormat('dd MM yyyy HH:mm'),
|
||||
);
|
||||
setState(() {
|
||||
currentValue = userInput != '' ? userInput : currentValue;
|
||||
widget.onChanged?.call(userInput != '' ? userInput : currentValue);
|
||||
widget.onChanged
|
||||
?.call(userInput != '' ? userInput : currentValue);
|
||||
});
|
||||
},
|
||||
}
|
||||
: null,
|
||||
validator: (value) => widget.validator?.call(value),
|
||||
decoration: widget.decoration ??
|
||||
InputDecoration(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: flutter_input_library
|
||||
description: A new Flutter package project.
|
||||
version: 2.3.0
|
||||
version: 2.4.0
|
||||
repository: https://github.com/Iconica-Development/flutter_input_library
|
||||
|
||||
environment:
|
||||
|
|
Loading…
Reference in a new issue