Skip to content

Commit

Permalink
Merge pull request #37 from udos86/v11.1.0
Browse files Browse the repository at this point in the history
v11.1.0
  • Loading branch information
udos86 authored Jun 24, 2023
2 parents 68edcf8 + 236dedf commit 9778946
Show file tree
Hide file tree
Showing 13 changed files with 145 additions and 23 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## [11.1.0] - 06/25/2023

* `text` property on `FastRadioOption` is now deprecated
* adds `isThreeLine`, `secondary`, `selected`. `subtitle`, `title` and `visualDensity` properties to `FastRadioOption`
* adds `activeColor`, `controlAffinity`, `fillColor`, `hoverColor`, `materialTapTargetSize`, `mouseCursor`,
`overlayColor`, `selectedTileColor`, `shapeBorder`, `splashRadius`, `tileColor` and `toggleable` properties to `FastRadioGroup`

* adds `isError` and `onFocus` properties to `FastCheckbox`
* adds `onActiveThumbImageError`, `onFocusChange` and `onInactiveThumbImageError` properties to `FastSwitch`
* adds `showDayOfWeek` property to `FastDatePicker`
* adds `keyboardType` property to `FastDateRangePicker`
* adds `orientation` property to `FastTimePicker`
* adds `onChangeEnd`, `onChangeStart` and `semanticFormatterCallback` properties to `FastRangeSlider`
* adds `onChanged` property to `FastSlider`
* adds `magnifierConfiguration`, `onTapOutside` and `spellCheckConfiguration` properties to `FastTextField`

## [11.0.0] - 05/16/2023

* upgrades to Flutter `3.10.0`
Expand Down
6 changes: 3 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ class FormPage extends StatelessWidget {
name: 'radio_group',
labelText: 'Radio Group Model',
options: const [
FastRadioOption(text: 'Option 1', value: 'option-1'),
FastRadioOption(text: 'Option 2', value: 'option-2'),
FastRadioOption(text: 'Option 3', value: 'option-3'),
FastRadioOption(title: Text('Option 1'), value: 'option-1'),
FastRadioOption(title: Text('Option 2'), value: 'option-2'),
FastRadioOption(title: Text('Option 3'), value: 'option-3'),
],
),
FastSlider(
Expand Down
6 changes: 6 additions & 0 deletions lib/src/check/checkbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ class FastCheckbox extends FastFormField<bool> {
this.helperBuilder,
this.hoverColor,
this.inactiveColor,
this.isError = false,
this.isThreeLine = false,
this.materialTapTargetSize,
this.mouseCursor,
this.onFocusChange,
this.overlayColor,
this.secondary,
this.selectedTileColor,
Expand Down Expand Up @@ -71,9 +73,11 @@ class FastCheckbox extends FastFormField<bool> {
final FastHelperBuilder<bool>? helperBuilder;
final Color? hoverColor;
final Color? inactiveColor;
final bool isError;
final bool isThreeLine;
final MaterialTapTargetSize? materialTapTargetSize;
final MouseCursor? mouseCursor;
final void Function(bool)? onFocusChange;
final MaterialStateProperty<Color?>? overlayColor;
final Widget? secondary;
final Color? selectedTileColor;
Expand Down Expand Up @@ -128,10 +132,12 @@ Widget materialCheckboxBuilder(FormFieldState<bool> field) {
fillColor: widget.fillColor,
focusNode: widget.focusNode,
hoverColor: widget.hoverColor,
isError: widget.isError,
isThreeLine: widget.isThreeLine,
materialTapTargetSize: widget.materialTapTargetSize,
mouseCursor: widget.mouseCursor,
onChanged: widget.enabled ? field.didChange : null,
onFocusChange: widget.onFocusChange,
overlayColor: widget.overlayColor,
secondary: widget.secondary,
selected: field.value ?? false,
Expand Down
9 changes: 9 additions & 0 deletions lib/src/check/switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class FastSwitch extends FastFormField<bool> {
this.isThreeLine = false,
this.materialTapTargetSize,
this.mouseCursor,
this.onActiveThumbImageError,
this.onFocusChange,
this.onInactiveThumbImageError,
this.overlayColor,
this.secondary,
this.selectedTileColor,
Expand Down Expand Up @@ -82,6 +85,9 @@ class FastSwitch extends FastFormField<bool> {
final bool isThreeLine;
final MaterialTapTargetSize? materialTapTargetSize;
final MouseCursor? mouseCursor;
final void Function(Object, StackTrace?)? onActiveThumbImageError;
final void Function(bool)? onFocusChange;
final void Function(Object, StackTrace?)? onInactiveThumbImageError;
final MaterialStateProperty<Color?>? overlayColor;
final Widget? secondary;
final Color? selectedTileColor;
Expand Down Expand Up @@ -144,7 +150,10 @@ Widget materialSwitchBuilder(FormFieldState<bool> field) {
isThreeLine: widget.isThreeLine,
materialTapTargetSize: widget.materialTapTargetSize,
mouseCursor: widget.mouseCursor,
onActiveThumbImageError: widget.onActiveThumbImageError,
onChanged: widget.enabled ? field.didChange : null,
onFocusChange: widget.onFocusChange,
onInactiveThumbImageError: widget.onInactiveThumbImageError,
overlayColor: widget.overlayColor,
secondary: widget.secondary,
selected: field.value!,
Expand Down
3 changes: 3 additions & 0 deletions lib/src/date_time/date_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class FastDatePicker extends FastFormField<DateTime> {
this.onDatePickerModeChange,
this.routeSettings,
this.selectableDayPredicate,
this.showDayOfWeek,
this.showModalPopup = false,
this.textBuilder,
this.textDirection,
Expand Down Expand Up @@ -109,6 +110,7 @@ class FastDatePicker extends FastFormField<DateTime> {
final void Function(DatePickerEntryMode)? onDatePickerModeChange;
final RouteSettings? routeSettings;
final SelectableDayPredicate? selectableDayPredicate;
final bool? showDayOfWeek;
final bool showModalPopup;
final FastDatePickerTextBuilder? textBuilder;
final TextDirection? textDirection;
Expand Down Expand Up @@ -343,6 +345,7 @@ Widget cupertinoDatePickerBuilder(FormFieldState<DateTime> field) {
minuteInterval: widget.minuteInterval,
mode: widget.mode,
onDateTimeChanged: field.didChange,
showDayOfWeek: widget.showDayOfWeek ?? false,
use24hFormat: widget.use24hFormat,
),
),
Expand Down
3 changes: 3 additions & 0 deletions lib/src/date_time/date_range_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class FastDateRangePicker extends FastFormField<DateTimeRange> {
this.icon,
this.iconButtonBuilder,
this.initialEntryMode = DatePickerEntryMode.calendar,
this.keyboardType = TextInputType.datetime,
this.locale,
required this.lastDate,
this.routeSettings,
Expand Down Expand Up @@ -76,6 +77,7 @@ class FastDateRangePicker extends FastFormField<DateTimeRange> {
final Icon? icon;
final FastDateRangePickerIconButtonBuilder? iconButtonBuilder;
final DatePickerEntryMode initialEntryMode;
final TextInputType keyboardType;
final DateTime lastDate;
final Locale? locale;
final RouteSettings? routeSettings;
Expand Down Expand Up @@ -140,6 +142,7 @@ Widget dateRangePickerBuilder(FormFieldState<DateTimeRange> field) {
helpText: widget.helpText,
initialEntryMode: entryMode,
initialDateRange: field.value,
keyboardType: widget.keyboardType,
lastDate: widget.lastDate,
locale: widget.locale,
routeSettings: widget.routeSettings,
Expand Down
3 changes: 3 additions & 0 deletions lib/src/date_time/time_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class FastTimePicker extends FastFormField<TimeOfDay> {
this.initialEntryMode = TimePickerEntryMode.dial,
this.minuteLabelText,
this.onEntryModeChanged,
this.orientation,
this.routeSettings,
this.textBuilder,
this.textStyle,
Expand All @@ -58,6 +59,7 @@ class FastTimePicker extends FastFormField<TimeOfDay> {
final TimePickerEntryMode initialEntryMode;
final String? minuteLabelText;
final EntryModeChangeCallback? onEntryModeChanged;
final Orientation? orientation;
final RouteSettings? routeSettings;
final FastTimePickerTextBuilder? textBuilder;
final TextStyle? textStyle;
Expand Down Expand Up @@ -114,6 +116,7 @@ Widget timePickerBuilder(FormFieldState<TimeOfDay> field) {
initialTime: field.value ?? TimeOfDay.now(),
minuteLabelText: widget.minuteLabelText,
onEntryModeChanged: widget.onEntryModeChanged,
orientation: widget.orientation,
routeSettings: widget.routeSettings,
useRootNavigator: widget.useRootNavigator,
).then((value) {
Expand Down
84 changes: 74 additions & 10 deletions lib/src/options/radio_group.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,27 @@ import '../form.dart';

@immutable
class FastRadioOption<T> {
const FastRadioOption({required this.text, required this.value});

final String text;
const FastRadioOption({
this.isThreeLine = false,
this.secondary,
this.selected = false,
this.subtitle,
@Deprecated('Use title instead') this.text,
this.title,
required this.value,
this.visualDensity,
}) : assert(!(text == null && title == null),
'Either text or title must be set');

final bool isThreeLine;
final Widget? secondary;
final bool selected;
final Widget? subtitle;
@Deprecated('Use title instead')
final String? text;
final Widget? title;
final T value;
final VisualDensity? visualDensity;
}

typedef FastRadioOptionBuilder<T> = Widget Function(
Expand Down Expand Up @@ -37,19 +54,48 @@ class FastRadioGroup<T> extends FastFormField<T> {
super.onSaved,
super.restorationId,
super.validator,
this.activeColor,
this.controlAffinity = ListTileControlAffinity.platform,
this.fillColor,
this.hoverColor,
this.materialTapTargetSize,
this.mouseCursor,
this.orientation = FastRadioGroupOrientation.vertical,
required this.options,
this.optionBuilder,
this.optionsBuilder,
this.overlayColor,
this.selectedTileColor,
this.shapeBorder,
this.splashRadius,
this.tileColor,
this.toggleable = false,
}) : super(
builder: builder ?? radioGroupBuilder<T>,
initialValue: initialValue ?? options.first.value,
);

builder: builder ?? radioGroupBuilder<T>,
initialValue: initialValue ??
options
.lastWhere(
(option) => option.selected,
orElse: () => options.first,
)
.value);

final Color? activeColor;
final ListTileControlAffinity controlAffinity;
final MaterialStateProperty<Color?>? fillColor;
final Color? hoverColor;
final MaterialTapTargetSize? materialTapTargetSize;
final MouseCursor? mouseCursor;
final List<FastRadioOption<T>> options;
final FastRadioOptionBuilder<T>? optionBuilder;
final FastRadioOptionsBuilder<T>? optionsBuilder;
final FastRadioGroupOrientation orientation;
final MaterialStateProperty<Color?>? overlayColor;
final Color? selectedTileColor;
final ShapeBorder? shapeBorder;
final double? splashRadius;
final Color? tileColor;
final bool toggleable;

@override
FastRadioGroupState<T> createState() => FastRadioGroupState<T>();
Expand All @@ -62,13 +108,31 @@ class FastRadioGroupState<T> extends FastFormFieldState<T> {

Widget radioOptionBuilder<T>(
FastRadioOption<T> option, FastRadioGroupState<T> field) {
final vertical =
field.widget.orientation == FastRadioGroupOrientation.vertical;
final widget = field.widget;
final vertical = widget.orientation == FastRadioGroupOrientation.vertical;
final tile = RadioListTile<T>(
activeColor: widget.activeColor,
controlAffinity: widget.controlAffinity,
fillColor: widget.fillColor,
hoverColor: widget.hoverColor,
groupValue: field.value,
isThreeLine: option.isThreeLine,
materialTapTargetSize: widget.materialTapTargetSize,
mouseCursor: widget.mouseCursor,
onChanged: field.widget.enabled ? field.didChange : null,
title: Text(option.text),
overlayColor: widget.overlayColor,
secondary: option.secondary,
selected: option.selected,
selectedTileColor: widget.selectedTileColor,
shape: widget.shapeBorder,
splashRadius: widget.splashRadius,
subtitle: option.subtitle,
tileColor: widget.tileColor,
// ignore: deprecated_member_use_from_same_package
title: option.title ?? Text(option.text!),
toggleable: widget.toggleable,
value: option.value,
visualDensity: option.visualDensity,
);

return vertical ? tile : Expanded(child: tile);
Expand Down
9 changes: 9 additions & 0 deletions lib/src/slider/range_slider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ class FastRangeSlider extends FastFormField<RangeValues> {
this.max = 1.0,
this.min = 0.0,
this.mouseCursor,
this.onChangeEnd,
this.onChangeStart,
this.overlayColor,
this.prefixBuilder,
this.semanticFormatterCallback,
this.suffixBuilder,
}) : super(initialValue: initialValue ?? RangeValues(min, max));

Expand All @@ -44,8 +47,11 @@ class FastRangeSlider extends FastFormField<RangeValues> {
final double max;
final double min;
final MaterialStateProperty<MouseCursor?>? mouseCursor;
final void Function(RangeValues)? onChangeEnd;
final void Function(RangeValues)? onChangeStart;
final MaterialStateProperty<Color?>? overlayColor;
final FastRangeSliderFixBuilder? prefixBuilder;
final String Function(double)? semanticFormatterCallback;
final FastRangeSliderFixBuilder? suffixBuilder;

@override
Expand Down Expand Up @@ -109,7 +115,10 @@ Widget rangeSliderBuilder(FormFieldState<RangeValues> field) {
min: widget.min,
mouseCursor: widget.mouseCursor,
onChanged: widget.enabled ? field.didChange : null,
onChangeEnd: widget.onChangeEnd,
onChangeStart: widget.onChangeStart,
overlayColor: widget.overlayColor,
semanticFormatterCallback: widget.semanticFormatterCallback,
values: field.value!,
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/slider/slider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ Widget materialSliderBuilder(FormFieldState<double> field) {
min: widget.min,
mouseCursor: widget.mouseCursor,
onChangeEnd: widget.onChangeEnd,
onChanged: widget.enabled ? field.didChange : null,
onChangeStart: widget.onChangeStart,
overlayColor: widget.overlayColor,
secondaryActiveColor: widget.secondaryActiveColor,
secondaryTrackValue: widget.secondaryTrackValue,
semanticFormatterCallback: widget.semanticFormatterCallback,
thumbColor: widget.thumbColor,
value: field.value!,
onChanged: widget.enabled ? field.didChange : null,
),
),
if (widget.suffixBuilder != null) widget.suffixBuilder!(field),
Expand Down
Loading

0 comments on commit 9778946

Please sign in to comment.