diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ee9cba..f8a22a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -137,3 +137,8 @@ ## 6.3.2 - May 15th 2024 - Loosened the dependency on intl to be more compatible with several Flutter versions + + +## 6.4.0 - June 28th 2024 +- Added `FlutterFormInputDropdown` for dropdown selection +- Added style property to `FlutterFormInputEmail` diff --git a/lib/src/widgets/input/input_types/input_dropdown.dart b/lib/src/widgets/input/input_types/input_dropdown.dart new file mode 100644 index 0000000..8f890a8 --- /dev/null +++ b/lib/src/widgets/input/input_types/input_dropdown.dart @@ -0,0 +1,164 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_form_wizard/flutter_form.dart'; +import 'package:flutter_input_library/flutter_input_library.dart' as input; + +class FlutterFormInputDropdown extends FlutterFormInputWidget { + const FlutterFormInputDropdown({ + required super.controller, + required this.validationMessage, + this.items, + this.selectedItemBuilder, + this.value, + this.hint, + this.disabledHint, + this.onChanged, + this.onTap, + this.elevation = 8, + this.style, + this.icon, + this.iconDisabledColor, + this.iconEnabledColor, + this.iconSize = 24.0, + this.isDense = false, + this.isExpanded = false, + this.itemHeight, + this.focusColor, + this.autofocus = false, + this.dropdownColor, + this.decoration, + this.onSaved, + this.validator, + this.autovalidateMode, + this.menuMaxHeight, + this.enableFeedback, + this.alignment = Alignment.centerLeft, + this.borderRadius, + this.padding, + super.key, + super.focusNode, + super.label, + }); + + final List>? items; + final List Function(BuildContext)? selectedItemBuilder; + final Object? value; + final Widget? hint; + final Widget? disabledHint; + final void Function(Object?)? onChanged; + final void Function()? onTap; + final int elevation; + final TextStyle? style; + final Widget? icon; + final Color? iconDisabledColor; + final Color? iconEnabledColor; + final double iconSize; + final bool isDense; + final bool isExpanded; + final double? itemHeight; + final Color? focusColor; + final bool autofocus; + final Color? dropdownColor; + final InputDecoration? decoration; + final void Function(Object?)? onSaved; + final String? Function(Object?)? validator; + final AutovalidateMode? autovalidateMode; + final double? menuMaxHeight; + final bool? enableFeedback; + final AlignmentGeometry alignment; + final BorderRadius? borderRadius; + final EdgeInsetsGeometry? padding; + final String validationMessage; + + @override + Widget build(BuildContext context) { + super.registerController(context); + return input.FlutterFormInputDropdown( + items: items, + selectedItemBuilder: selectedItemBuilder, + value: value, + hint: hint, + disabledHint: disabledHint, + onChanged: controller.onChanged, + onTap: () => onTap?.call(), + elevation: elevation, + style: style, + icon: icon, + iconDisabledColor: iconDisabledColor, + iconEnabledColor: iconEnabledColor, + iconSize: iconSize, + isDense: isDense, + isExpanded: isExpanded, + itemHeight: itemHeight, + focusColor: focusColor, + focusNode: focusNode, + autofocus: autofocus, + dropdownColor: dropdownColor, + decoration: decoration, + onSaved: controller.onSaved, + validator: validator ?? + (value) => controller.onValidate( + value, + validationMessage, + ), + autovalidateMode: autovalidateMode, + menuMaxHeight: menuMaxHeight, + enableFeedback: enableFeedback, + alignment: alignment, + borderRadius: borderRadius, + padding: padding, + ); + } +} + +class FlutterFormInputDropdownController + implements FlutterFormInputController { + FlutterFormInputDropdownController({ + required this.id, + this.mandatory = false, + this.value, + this.checkPageTitle, + this.checkPageDescription, + this.onChanged, + this.onSubmit, + }); + + @override + String? id; + + @override + Object? value; + + @override + bool mandatory; + + @override + String Function(Object? value)? checkPageTitle; + + @override + String Function(Object? value)? checkPageDescription; + + @override + void Function(Object? value)? onChanged; + + @override + void Function(Object? value)? onSubmit; + + @override + void onSaved(Object? value) { + this.value = value; + } + + @override + String? onValidate( + Object? value, + String validationMessage, + ) { + if (mandatory) { + if (value == null) { + return validationMessage; + } + } + + return null; + } +} diff --git a/lib/src/widgets/input/input_types/input_email.dart b/lib/src/widgets/input/input_types/input_email.dart index 87a6e11..99bb6cb 100644 --- a/lib/src/widgets/input/input_types/input_email.dart +++ b/lib/src/widgets/input/input_types/input_email.dart @@ -23,6 +23,7 @@ class FlutterFormInputEmail extends FlutterFormInputWidget { bool? enabled, this.validator, this.decoration, + this.style, }) : super( enabled: enabled ?? true, ); @@ -30,12 +31,14 @@ class FlutterFormInputEmail extends FlutterFormInputWidget { final InputDecoration? decoration; final String validationMessage; final String? Function(String?)? validator; + final TextStyle? style; @override Widget build(BuildContext context) { super.registerController(context); return input.FlutterFormInputPlainText( + style: style, enabled: enabled, initialValue: controller.value, onSaved: (value) { diff --git a/lib/src/widgets/input/input_types/input_types.dart b/lib/src/widgets/input/input_types/input_types.dart index 2ba6335..bd1b4b1 100644 --- a/lib/src/widgets/input/input_types/input_types.dart +++ b/lib/src/widgets/input/input_types/input_types.dart @@ -7,6 +7,7 @@ export 'package:flutter_input_library/flutter_input_library.dart' export 'input_carousel/input_carousel.dart'; export 'input_date_picker/input_date_picker.dart'; +export 'input_dropdown.dart'; export 'input_email.dart'; export 'input_number_picker/input_number_picker.dart'; export 'input_password/input_password.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index 2463e63..8b07a01 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_form_wizard description: A new Flutter package project. -version: 6.3.2 +version: 6.4.0 homepage: https://github.com/Iconica-Development/flutter_form_wizard publish_to: none @@ -18,7 +18,7 @@ dependencies: flutter_input_library: git: url: https://github.com/Iconica-Development/flutter_input_library - ref: 3.3.1 + ref: 3.4.0 dev_dependencies: flutter_test: