Added the ability to set the enabled of textfields

This commit is contained in:
Jacques 2023-10-26 14:08:21 +02:00
parent 2f0ceff64e
commit cfc051531a
3 changed files with 42 additions and 26 deletions

View file

@ -29,6 +29,7 @@ class DateTimeInputField extends StatefulWidget {
this.validator,
required this.timePickerEntryMode,
required this.style,
this.enabled = true,
}) : super(
key: key,
);
@ -50,6 +51,7 @@ class DateTimeInputField extends StatefulWidget {
final void Function(String?)? onSaved;
final void Function(String?)? onChanged;
final TimePickerEntryMode timePickerEntryMode;
final bool enabled;
@override
State<DateTimeInputField> createState() => _DateInputFieldState();
@ -128,6 +130,7 @@ class _DateInputFieldState extends State<DateTimeInputField> {
});
break;
case FlutterFormDateTimeType.range:
if (context.mounted) {
userInput = (await showDateRangePicker(
context: context,
firstDate: firstDate,
@ -139,8 +142,10 @@ class _DateInputFieldState extends State<DateTimeInputField> {
: '';
}))
.toString();
}
break;
case FlutterFormDateTimeType.time:
if (context.mounted) {
userInput = await showTimePicker(
initialEntryMode: widget.timePickerEntryMode,
builder: (BuildContext context, Widget? child) {
@ -157,6 +162,7 @@ class _DateInputFieldState extends State<DateTimeInputField> {
: MaterialLocalizations.of(context)
.formatTimeOfDay(value, alwaysUse24HourFormat: true));
}
}
return userInput;
}
@ -185,6 +191,7 @@ class _DateInputFieldState extends State<DateTimeInputField> {
focusColor: Theme.of(context).primaryColor,
label: widget.label ?? const Text("Date"),
),
enabled: widget.enabled,
);
}
}

View file

@ -14,6 +14,7 @@ class FlutterFormInputPassword extends StatefulWidget {
final String? Function(String?)? validator;
final Function(String?)? onChanged;
final Function(String?)? onFieldSubmitted;
final bool enabled;
const FlutterFormInputPassword({
Key? key,
@ -24,6 +25,7 @@ class FlutterFormInputPassword extends StatefulWidget {
this.validator,
this.onChanged,
this.onFieldSubmitted,
this.enabled = true,
}) : super(key: key);
@override
@ -54,6 +56,7 @@ class _PasswordTextFieldState extends State<FlutterFormInputPassword> {
icon: Icon(obscured ? Icons.visibility_off : Icons.visibility),
),
),
enabled: widget.enabled,
);
}
}

View file

@ -22,6 +22,7 @@ class FlutterFormInputPlainText extends StatelessWidget {
this.validator,
this.onFieldSubmitted,
this.style,
this.enabled = true,
}) : super(
key: key,
);
@ -41,6 +42,7 @@ class FlutterFormInputPlainText extends StatelessWidget {
final Function(String?)? onChanged;
final Function(String?)? onFieldSubmitted;
final TextStyle? style;
final bool enabled;
@override
Widget build(BuildContext context) {
@ -64,6 +66,7 @@ class FlutterFormInputPlainText extends StatelessWidget {
maxLines: maxLines,
maxLength: maxLength,
keyboardType: keyboardType,
enabled: enabled,
);
}
}
@ -75,6 +78,7 @@ class FlutterFormInputMultiLine extends StatelessWidget {
this.focusNode,
this.hint,
this.maxCharacters,
this.enabled = true,
this.scrollPadding,
this.keyboardType,
this.initialValue,
@ -89,6 +93,7 @@ class FlutterFormInputMultiLine extends StatelessWidget {
final FocusNode? focusNode;
final String? hint;
final int? maxCharacters;
final bool enabled;
final InputDecoration? decoration;
final EdgeInsets? scrollPadding;
@ -131,6 +136,7 @@ class FlutterFormInputMultiLine extends StatelessWidget {
),
filled: true,
),
enabled: enabled,
),
),
],