From 837ab2e52b0141291de6b1cfbeb7bdfc47f04346 Mon Sep 17 00:00:00 2001 From: Matthias Ngeo Date: Fri, 6 Dec 2024 11:34:26 +0800 Subject: [PATCH 1/3] Tidy up themes --- forui/lib/src/theme/breakpoints.dart | 10 +++++----- forui/lib/src/theme/color_scheme.dart | 4 ++-- forui/lib/src/theme/theme_data.dart | 15 +++++++++++---- forui/lib/src/theme/themes.dart | 18 ++++++++++++++++++ forui/lib/src/theme/typography.dart | 26 +++++++++++++------------- 5 files changed, 49 insertions(+), 24 deletions(-) diff --git a/forui/lib/src/theme/breakpoints.dart b/forui/lib/src/theme/breakpoints.dart index 3ca5dd573..245eca999 100644 --- a/forui/lib/src/theme/breakpoints.dart +++ b/forui/lib/src/theme/breakpoints.dart @@ -89,10 +89,10 @@ final class FBreakpoints with Diagnosticable { void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); properties - ..add(DoubleProperty('sm', sm)) - ..add(DoubleProperty('md', md)) - ..add(DoubleProperty('lg', lg)) - ..add(DoubleProperty('xl', xl)) - ..add(DoubleProperty('xl2', xl2)); + ..add(DoubleProperty('sm', sm, defaultValue: 640)) + ..add(DoubleProperty('md', md, defaultValue: 768)) + ..add(DoubleProperty('lg', lg, defaultValue: 1024)) + ..add(DoubleProperty('xl', xl, defaultValue: 1280)) + ..add(DoubleProperty('xl2', xl2, defaultValue: 1536)); } } diff --git a/forui/lib/src/theme/color_scheme.dart b/forui/lib/src/theme/color_scheme.dart index be3fa58ac..aeec1e91d 100644 --- a/forui/lib/src/theme/color_scheme.dart +++ b/forui/lib/src/theme/color_scheme.dart @@ -226,8 +226,8 @@ final class FColorScheme with Diagnosticable { ..add(ColorProperty('error', error)) ..add(ColorProperty('errorForeground', errorForeground)) ..add(ColorProperty('border', border)) - ..add(DoubleProperty('enabledHoveredOpacity', enabledHoveredOpacity)) - ..add(DoubleProperty('disabledOpacity', disabledOpacity)); + ..add(PercentProperty('enabledHoveredOpacity', enabledHoveredOpacity)) + ..add(PercentProperty('disabledOpacity', disabledOpacity)); } @override diff --git a/forui/lib/src/theme/theme_data.dart b/forui/lib/src/theme/theme_data.dart index c389064e4..52b43bd89 100644 --- a/forui/lib/src/theme/theme_data.dart +++ b/forui/lib/src/theme/theme_data.dart @@ -15,6 +15,9 @@ import 'package:meta/meta.dart'; /// [FThemeData] and widget styles provide an `inherit(...)` constructor. The constructor configures the theme data/ /// widget style using the defaults provided by the [colorScheme], [typography], and [style]. final class FThemeData with Diagnosticable { + /// A label that is used in the [toString] output. Intended to aid with identifying themes in debug output. + final String? debugLabel; + /// The responsive breakpoints. final FBreakpoints breakpoints; @@ -152,6 +155,7 @@ final class FThemeData with Diagnosticable { required this.textFieldStyle, required this.tooltipStyle, required this.tileGroupStyle, + this.debugLabel, this.breakpoints = const FBreakpoints(), this.typography = const FTypography(), }); @@ -159,12 +163,14 @@ final class FThemeData with Diagnosticable { /// Creates a [FThemeData] that configures the widget styles using the given properties. factory FThemeData.inherit({ required FColorScheme colorScheme, + String? debugLabel, FStyle? style, FTypography? typography, }) { typography ??= FTypography.inherit(colorScheme: colorScheme); style ??= FStyle.inherit(colorScheme: colorScheme, typography: typography); return FThemeData( + debugLabel: debugLabel, colorScheme: colorScheme, typography: typography, style: style, @@ -320,10 +326,11 @@ final class FThemeData with Diagnosticable { void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); properties - ..add(DiagnosticsProperty('breakpoints', breakpoints, level: DiagnosticLevel.debug)) - ..add(DiagnosticsProperty('colorScheme', colorScheme, level: DiagnosticLevel.debug)) - ..add(DiagnosticsProperty('typography', typography, level: DiagnosticLevel.debug)) - ..add(DiagnosticsProperty('style', style, level: DiagnosticLevel.debug)) + ..add(StringProperty('debugLabel', debugLabel, showName: false)) + ..add(DiagnosticsProperty('breakpoints', breakpoints)) + ..add(DiagnosticsProperty('colorScheme', colorScheme)) + ..add(DiagnosticsProperty('typography', typography)) + ..add(DiagnosticsProperty('style', style)) ..add(DiagnosticsProperty('accordionStyle', accordionStyle)) ..add(DiagnosticsProperty('alertStyles', alertStyles, level: DiagnosticLevel.debug)) ..add(DiagnosticsProperty('avatarStyle', avatarStyle, level: DiagnosticLevel.debug)) diff --git a/forui/lib/src/theme/themes.dart b/forui/lib/src/theme/themes.dart index ce196fa88..8a079f88d 100644 --- a/forui/lib/src/theme/themes.dart +++ b/forui/lib/src/theme/themes.dart @@ -8,6 +8,7 @@ extension FThemes on Never { /// The light and dark variants of the [Zinc](https://ui.shadcn.com/themes) theme. static final zinc = ( light: FThemeData.inherit( + debugLabel: 'Zinc Light ThemeData', colorScheme: const FColorScheme( brightness: Brightness.light, barrier: Color(0x33000000), @@ -27,6 +28,7 @@ extension FThemes on Never { ), ), dark: FThemeData.inherit( + debugLabel: 'Zinc Dark ThemeData', colorScheme: const FColorScheme( brightness: Brightness.dark, barrier: Color(0x7A000000), @@ -50,6 +52,7 @@ extension FThemes on Never { /// The light and dark variants of the [Slate](https://ui.shadcn.com/themes) theme. static final slate = ( light: FThemeData.inherit( + debugLabel: 'Slate Light ThemeData', colorScheme: const FColorScheme( brightness: Brightness.light, barrier: Color(0x33000000), @@ -69,6 +72,7 @@ extension FThemes on Never { ), ), dark: FThemeData.inherit( + debugLabel: 'Slate Dark ThemeData', colorScheme: const FColorScheme( brightness: Brightness.dark, barrier: Color(0x7A000000), @@ -92,6 +96,7 @@ extension FThemes on Never { /// The light and dark variants of the [Red](https://ui.shadcn.com/themes) theme. static final red = ( light: FThemeData.inherit( + debugLabel: 'Red Light ThemeData', colorScheme: const FColorScheme( brightness: Brightness.light, barrier: Color(0x33000000), @@ -111,6 +116,7 @@ extension FThemes on Never { ), ), dark: FThemeData.inherit( + debugLabel: 'Red Dark ThemeData', colorScheme: const FColorScheme( brightness: Brightness.dark, barrier: Color(0x7A000000), @@ -134,6 +140,7 @@ extension FThemes on Never { /// The light and dark variants of the [Rose](https://ui.shadcn.com/themes) theme. static final rose = ( light: FThemeData.inherit( + debugLabel: 'Rose Light ThemeData', colorScheme: const FColorScheme( brightness: Brightness.light, barrier: Color(0x33000000), @@ -153,6 +160,7 @@ extension FThemes on Never { ), ), dark: FThemeData.inherit( + debugLabel: 'Rose Dark ThemeData', colorScheme: const FColorScheme( brightness: Brightness.dark, barrier: Color(0x7A000000), @@ -176,6 +184,7 @@ extension FThemes on Never { /// The light and dark variants of the [Orange](https://ui.shadcn.com/themes) theme. static final orange = ( light: FThemeData.inherit( + debugLabel: 'Orange Light ThemeData', colorScheme: const FColorScheme( brightness: Brightness.light, barrier: Color(0x33000000), @@ -195,6 +204,7 @@ extension FThemes on Never { ), ), dark: FThemeData.inherit( + debugLabel: 'Orange Dark ThemeData', colorScheme: const FColorScheme( brightness: Brightness.dark, barrier: Color(0x7A000000), @@ -218,6 +228,7 @@ extension FThemes on Never { /// The light and dark variants of the [Green](https://ui.shadcn.com/themes) theme. static final green = ( light: FThemeData.inherit( + debugLabel: 'Green Light ThemeData', colorScheme: const FColorScheme( brightness: Brightness.light, barrier: Color(0x33000000), @@ -237,6 +248,7 @@ extension FThemes on Never { ), ), dark: FThemeData.inherit( + debugLabel: 'Green Dark ThemeData', colorScheme: const FColorScheme( brightness: Brightness.dark, barrier: Color(0x7A000000), @@ -260,6 +272,7 @@ extension FThemes on Never { /// The light and dark variants of the [Blue](https://ui.shadcn.com/themes) theme. static final blue = ( light: FThemeData.inherit( + debugLabel: 'Blue Light ThemeData', colorScheme: const FColorScheme( brightness: Brightness.light, barrier: Color(0x33000000), @@ -279,6 +292,7 @@ extension FThemes on Never { ), ), dark: FThemeData.inherit( + debugLabel: 'Blue Dark ThemeData', colorScheme: const FColorScheme( brightness: Brightness.dark, barrier: Color(0x7A000000), @@ -302,6 +316,7 @@ extension FThemes on Never { /// The light and dark variants of the [Yellow](https://ui.shadcn.com/themes) theme. static final yellow = ( light: FThemeData.inherit( + debugLabel: 'Yellow Light ThemeData', colorScheme: const FColorScheme( brightness: Brightness.light, barrier: Color(0x33000000), @@ -321,6 +336,7 @@ extension FThemes on Never { ), ), dark: FThemeData.inherit( + debugLabel: 'Yellow Dark ThemeData', colorScheme: const FColorScheme( brightness: Brightness.dark, barrier: Color(0x7A000000), @@ -344,6 +360,7 @@ extension FThemes on Never { /// The light and dark variants of the [Violet](https://ui.shadcn.com/themes) theme. static final violet = ( light: FThemeData.inherit( + debugLabel: 'Violet Light ThemeData', colorScheme: const FColorScheme( brightness: Brightness.light, barrier: Color(0x33000000), @@ -363,6 +380,7 @@ extension FThemes on Never { ), ), dark: FThemeData.inherit( + debugLabel: 'Violet Dark ThemeData', colorScheme: const FColorScheme( brightness: Brightness.dark, barrier: Color(0x7A000000), diff --git a/forui/lib/src/theme/typography.dart b/forui/lib/src/theme/typography.dart index ac62bf15f..659508eb6 100644 --- a/forui/lib/src/theme/typography.dart +++ b/forui/lib/src/theme/typography.dart @@ -228,19 +228,19 @@ final class FTypography with Diagnosticable { void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); properties - ..add(StringProperty('family', defaultFontFamily, defaultValue: 'packages/forui/Inter')) - ..add(DiagnosticsProperty('xs', xs, defaultValue: 12)) - ..add(DiagnosticsProperty('sm', sm, defaultValue: 14)) - ..add(DiagnosticsProperty('base', base, defaultValue: 16)) - ..add(DiagnosticsProperty('lg', lg, defaultValue: 18)) - ..add(DiagnosticsProperty('xl', xl, defaultValue: 20)) - ..add(DiagnosticsProperty('xl2', xl2, defaultValue: 22)) - ..add(DiagnosticsProperty('xl3', xl3, defaultValue: 30)) - ..add(DiagnosticsProperty('xl4', xl4, defaultValue: 36)) - ..add(DiagnosticsProperty('xl5', xl5, defaultValue: 48)) - ..add(DiagnosticsProperty('xl6', xl6, defaultValue: 60)) - ..add(DiagnosticsProperty('xl7', xl7, defaultValue: 72)) - ..add(DiagnosticsProperty('xl8', xl8, defaultValue: 96)); + ..add(StringProperty('defaultFontFamily', defaultFontFamily, defaultValue: 'packages/forui/Inter')) + ..add(DiagnosticsProperty('xs', xs)) + ..add(DiagnosticsProperty('sm', sm)) + ..add(DiagnosticsProperty('base', base)) + ..add(DiagnosticsProperty('lg', lg)) + ..add(DiagnosticsProperty('xl', xl)) + ..add(DiagnosticsProperty('xl2', xl2)) + ..add(DiagnosticsProperty('xl3', xl3)) + ..add(DiagnosticsProperty('xl4', xl4)) + ..add(DiagnosticsProperty('xl5', xl5)) + ..add(DiagnosticsProperty('xl6', xl6)) + ..add(DiagnosticsProperty('xl7', xl7)) + ..add(DiagnosticsProperty('xl8', xl8)); } @override From 2f90649ea4c94f1252a258bd409d5cdf1d793386 Mon Sep 17 00:00:00 2001 From: Matthias Ngeo Date: Tue, 17 Dec 2024 13:07:22 +0800 Subject: [PATCH 2/3] Replace DoubleProperty with PercentageProperty --- .../src/widgets/accordion/accordion_item.dart | 4 +- .../widgets/calendar/calendar_controller.dart | 30 +++++----- forui/lib/src/widgets/progress.dart | 2 +- forui/lib/src/widgets/resizable/divider.dart | 2 +- .../lib/src/widgets/resizable/resizable.dart | 2 +- .../resizable/resizable_region_data.dart | 11 +--- .../src/widgets/slider/slider_selection.dart | 13 ++-- forui/test/src/theme/color_scheme_test.dart | 4 +- forui/test/src/theme/typography_test.dart | 2 +- .../lib/src/calendar_controller_hook.dart | 59 ++++++++++--------- .../lib/src/slider_controller_hook.dart | 2 +- 11 files changed, 61 insertions(+), 70 deletions(-) diff --git a/forui/lib/src/widgets/accordion/accordion_item.dart b/forui/lib/src/widgets/accordion/accordion_item.dart index cc3c399ce..686ebe030 100644 --- a/forui/lib/src/widgets/accordion/accordion_item.dart +++ b/forui/lib/src/widgets/accordion/accordion_item.dart @@ -193,7 +193,7 @@ class _Expandable extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(DoubleProperty('value', value)); + properties.add(PercentProperty('value', value)); } } @@ -243,7 +243,7 @@ class _RenderExpandable extends RenderBox with RenderObjectWithChildMixin true; -DateTime _stripTimezone(DateTime date) => DateTime.utc(date.year, date.month, date.day); +DateTime _truncateAndStripTimezone(DateTime date) => DateTime.utc(date.year, date.month, date.day); /// A controller that controls date selection in a calendar. /// @@ -124,22 +124,22 @@ class _AutoDateController extends FCalendarController { DateTime? initialSelection, Predicate? selectable, }) : _selectable = selectable ?? _true, - super(initialSelection = initialSelection == null ? null : _stripTimezone(initialSelection)); + super(initialSelection = initialSelection == null ? null : _truncateAndStripTimezone(initialSelection)); @override - bool selectable(DateTime date) => _selectable(_stripTimezone(date)); + bool selectable(DateTime date) => _selectable(_truncateAndStripTimezone(date)); @override - bool selected(DateTime date) => value == _stripTimezone(date); + bool selected(DateTime date) => value == _truncateAndStripTimezone(date); @override void select(DateTime date) { - date = _stripTimezone(date); + date = _truncateAndStripTimezone(date); super.value = value == date ? null : date; } @override - set value(DateTime? value) => super.value = value == null ? null : _stripTimezone(value); + set value(DateTime? value) => super.value = value == null ? null : _truncateAndStripTimezone(value); } class _DateController extends FCalendarController { @@ -170,22 +170,22 @@ final class _AutoDatesController extends FCalendarController> { Set initialSelections = const {}, Predicate? selectable, }) : _selectable = selectable ?? _true, - super(initialSelections.map(_stripTimezone).toSet()); + super(initialSelections.map(_truncateAndStripTimezone).toSet()); @override - bool selectable(DateTime date) => _selectable(_stripTimezone(date)); + bool selectable(DateTime date) => _selectable(_truncateAndStripTimezone(date)); @override - bool selected(DateTime date) => value.contains(_stripTimezone(date)); + bool selected(DateTime date) => value.contains(_truncateAndStripTimezone(date)); @override void select(DateTime date) { final copy = {...value}; - super.value = copy..toggle(_stripTimezone(date)); + super.value = copy..toggle(_truncateAndStripTimezone(date)); } @override - set value(Set value) => super.value = value.map(_stripTimezone).toSet(); + set value(Set value) => super.value = value.map(_truncateAndStripTimezone).toSet(); } final class _DatesController extends FCalendarController> { @@ -219,7 +219,7 @@ final class _AutoRangeController extends FCalendarController<(DateTime, DateTime super( initialSelection = initialSelection == null ? null - : (_stripTimezone(initialSelection.$1), _stripTimezone(initialSelection.$2)), + : (_truncateAndStripTimezone(initialSelection.$1), _truncateAndStripTimezone(initialSelection.$2)), ) { final range = value; assert( @@ -229,7 +229,7 @@ final class _AutoRangeController extends FCalendarController<(DateTime, DateTime } @override - bool selectable(DateTime date) => _selectable(_stripTimezone(date)); + bool selectable(DateTime date) => _selectable(_truncateAndStripTimezone(date)); @override bool selected(DateTime date) { @@ -243,7 +243,7 @@ final class _AutoRangeController extends FCalendarController<(DateTime, DateTime @override void select(DateTime date) { - date = _stripTimezone(date); + date = _truncateAndStripTimezone(date); if (value == null) { super.value = (date, date); return; @@ -265,7 +265,7 @@ final class _AutoRangeController extends FCalendarController<(DateTime, DateTime @override set value((DateTime, DateTime)? value) => - super.value = value == null ? null : (_stripTimezone(value.$1), _stripTimezone(value.$2)); + super.value = value == null ? null : (_truncateAndStripTimezone(value.$1), _truncateAndStripTimezone(value.$2)); } final class _RangeController extends FCalendarController<(DateTime, DateTime)?> { diff --git a/forui/lib/src/widgets/progress.dart b/forui/lib/src/widgets/progress.dart index f7c097737..27e94c06a 100644 --- a/forui/lib/src/widgets/progress.dart +++ b/forui/lib/src/widgets/progress.dart @@ -67,7 +67,7 @@ class FProgress extends StatelessWidget { super.debugFillProperties(properties); properties ..add(DiagnosticsProperty('style', style)) - ..add(DoubleProperty('value', value)); + ..add(PercentProperty('value', value)); } } diff --git a/forui/lib/src/widgets/resizable/divider.dart b/forui/lib/src/widgets/resizable/divider.dart index 5cdaac11c..6f23c349d 100644 --- a/forui/lib/src/widgets/resizable/divider.dart +++ b/forui/lib/src/widgets/resizable/divider.dart @@ -84,7 +84,7 @@ sealed class Divider extends StatefulWidget { ..add(IntProperty('right', right)) ..add(DoubleProperty('crossAxisExtent', crossAxisExtent)) ..add(DoubleProperty('hitRegionExtent', hitRegionExtent)) - ..add(DoubleProperty('resizePercentage', resizePercentage)) + ..add(PercentProperty('resizePercentage', resizePercentage)) ..add(DiagnosticsProperty('cursor', cursor)) ..add(ObjectFlagProperty.has('semanticFormatterCallback', semanticFormatterCallback)); } diff --git a/forui/lib/src/widgets/resizable/resizable.dart b/forui/lib/src/widgets/resizable/resizable.dart index 8fe83f11f..34cfee0c2 100644 --- a/forui/lib/src/widgets/resizable/resizable.dart +++ b/forui/lib/src/widgets/resizable/resizable.dart @@ -99,7 +99,7 @@ class FResizable extends StatefulWidget { ..add(EnumProperty('divider', divider)) ..add(DoubleProperty('crossAxisExtent', crossAxisExtent)) ..add(DoubleProperty('hitRegionExtent', hitRegionExtent)) - ..add(DoubleProperty('resizePercentage', resizePercentage)) + ..add(PercentProperty('resizePercentage', resizePercentage)) ..add(ObjectFlagProperty.has('semanticFormatterCallback', semanticFormatterCallback)) ..add(IterableProperty('children', children)); } diff --git a/forui/lib/src/widgets/resizable/resizable_region_data.dart b/forui/lib/src/widgets/resizable/resizable_region_data.dart index 64ef60431..67a3db5dc 100644 --- a/forui/lib/src/widgets/resizable/resizable_region_data.dart +++ b/forui/lib/src/widgets/resizable/resizable_region_data.dart @@ -98,14 +98,9 @@ final class FResizableRegionData with Diagnosticable { super.debugFillProperties(properties); properties ..add(IntProperty('index', index)) - ..add(DoubleProperty('extent.min', extent.min)) - ..add(DoubleProperty('extent.current', extent.current)) - ..add(DoubleProperty('extent.max', extent.max)) - ..add(DoubleProperty('extent.total', extent.total)) - ..add(DoubleProperty('offset.min', offset.min)) - ..add(DoubleProperty('offset.max', offset.max)) - ..add(DoubleProperty('offsetPercentage.min', offsetPercentage.min)) - ..add(DoubleProperty('offsetPercentage.max', offsetPercentage.max)); + ..add(StringProperty('extent', extent.toString())) + ..add(StringProperty('offset', offset.toString())) + ..add(StringProperty('offsetPercentage', offsetPercentage.toString())); } } diff --git a/forui/lib/src/widgets/slider/slider_selection.dart b/forui/lib/src/widgets/slider/slider_selection.dart index da86cb033..d0233ab02 100644 --- a/forui/lib/src/widgets/slider/slider_selection.dart +++ b/forui/lib/src/widgets/slider/slider_selection.dart @@ -75,15 +75,10 @@ sealed class FSliderSelection with Diagnosticable { void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); properties - ..add(DoubleProperty('extent.min', extent.min)) - ..add(DoubleProperty('extent.max', extent.max)) - ..add(DoubleProperty('offset.min', offset.min)) - ..add(DoubleProperty('offset.max', offset.max)) - ..add(DoubleProperty('rawExtent.min', rawExtent.min)) - ..add(DoubleProperty('rawExtent.max', rawExtent.max)) - ..add(DoubleProperty('rawExtent.total', rawExtent.total)) - ..add(DoubleProperty('rawOffset.min', rawOffset.min)) - ..add(DoubleProperty('rawOffset.max', rawOffset.max)); + ..add(StringProperty('extent', extent.toString())) + ..add(StringProperty('offset', offset.toString())) + ..add(StringProperty('rawExtent', rawExtent.toString())) + ..add(StringProperty('rawOffset', rawOffset.toString())); } @override diff --git a/forui/test/src/theme/color_scheme_test.dart b/forui/test/src/theme/color_scheme_test.dart index 1c8d52462..32b7b6a2d 100644 --- a/forui/test/src/theme/color_scheme_test.dart +++ b/forui/test/src/theme/color_scheme_test.dart @@ -90,8 +90,8 @@ void main() { ColorProperty('error', Colors.red), ColorProperty('errorForeground', Colors.redAccent), ColorProperty('border', Colors.lightBlue), - DoubleProperty('enabledHoveredOpacity', 0.9), - DoubleProperty('disabledOpacity', 0.5), + PercentProperty('enabledHoveredOpacity', 0.9), + PercentProperty('disabledOpacity', 0.5), ].map((p) => p.toString()), ); }); diff --git a/forui/test/src/theme/typography_test.dart b/forui/test/src/theme/typography_test.dart index c051eef08..f02cc28f4 100644 --- a/forui/test/src/theme/typography_test.dart +++ b/forui/test/src/theme/typography_test.dart @@ -291,7 +291,7 @@ void main() { expect( builder.properties.map((p) => p.toString()), [ - StringProperty('family', 'Roboto'), + StringProperty('defaultFontFamily', 'Roboto'), DiagnosticsProperty('xs', const TextStyle(fontSize: 1)), DiagnosticsProperty('sm', const TextStyle(fontSize: 2)), DiagnosticsProperty('base', const TextStyle(fontSize: 3)), diff --git a/forui_hooks/lib/src/calendar_controller_hook.dart b/forui_hooks/lib/src/calendar_controller_hook.dart index e94ed0483..70a827ff3 100644 --- a/forui_hooks/lib/src/calendar_controller_hook.dart +++ b/forui_hooks/lib/src/calendar_controller_hook.dart @@ -10,23 +10,23 @@ typedef _Create = FCalendarController Function(_CalendarControllerHook) /// /// [selectable] will always return true if not given. /// -/// [autoConvert] determines whether the controller should truncate and convert all given [DateTime]s to dates in -/// UTC timezone. Defaults to true. +/// [truncateAndStripTimezone] determines whether the controller should truncate and convert all given [DateTime]s to +/// dates in UTC timezone. Defaults to true. /// /// ```dart -/// DateTime convert(DateTime date) => DateTime.utc(date.year, date.month, date.day); +/// DateTime truncateAndStripTimezone(DateTime date) => DateTime.utc(date.year, date.month, date.day); /// ``` /// -/// [autoConvert] should be set to false if you can guarantee that all dates are in UTC timezone (with the help of an -/// 3rd party library), which will improve performance. **Warning:** Giving a [DateTime] in local timezone or with a -/// time component when [autoConvert] is false is undefined behavior. +/// [truncateAndStripTimezone] should be set to false if you can guarantee that all dates are in UTC timezone (with +/// the help of a 3rd party library), which will improve performance. **Warning:** Giving a [DateTime] in local +/// timezone or with a time component when [truncateAndStripTimezone] is false is undefined behavior. /// /// ## Contract -/// Throws [AssertionError] if [initialSelection] is not in UTC timezone and [autoConvert] is false. +/// Throws [AssertionError] if [initialSelection] is not in UTC timezone and [truncateAndStripTimezone] is false. FCalendarController useFDateCalendarController({ DateTime? initialSelection, bool Function(DateTime)? selectable, - bool autoConvert = true, + bool truncateAndStripTimezone = true, List? keys, }) => use(_CalendarControllerHook( @@ -36,7 +36,7 @@ FCalendarController useFDateCalendarController({ create: (hook) => FCalendarController.date( initialSelection: hook.value, selectable: hook.selectable, - truncateAndStripTimezone: autoConvert, + truncateAndStripTimezone: truncateAndStripTimezone, ), )); @@ -44,23 +44,24 @@ FCalendarController useFDateCalendarController({ /// /// [selectable] will always return true if not given. /// -/// [autoConvert] determines whether the controller should truncate and convert all given [DateTime]s to dates in -/// UTC timezone. Defaults to true. +/// [truncateAndStripTimezone] determines whether the controller should truncate and convert all given [DateTime]s to +/// dates in UTC timezone. Defaults to true. /// /// ```dart -/// DateTime convert(DateTime date) => DateTime.utc(date.year, date.month, date.day); +/// DateTime truncateAndStripTimezone(DateTime date) => DateTime.utc(date.year, date.month, date.day); /// ``` /// -/// [autoConvert] should be set to false if you can guarantee that all dates are in UTC timezone (with the help of an -/// 3rd party library), which will improve performance. **Warning:** Giving a [DateTime] in local timezone or with a -/// time component when [autoConvert] is false is undefined behavior. +/// [truncateAndStripTimezone] should be set to false if you can guarantee that all dates are in UTC timezone (with +/// the help of an 3rd party library), which will improve performance. **Warning:** Giving a [DateTime] in local +/// timezone or with a time component when [truncateAndStripTimezone] is false is undefined behavior. /// /// ## Contract -/// Throws [AssertionError] if the dates in [initialSelections] are not in UTC timezone and [autoConvert] is false. +/// Throws [AssertionError] if the dates in [initialSelections] are not in UTC timezone and [truncateAndStripTimezone] +/// is false. FCalendarController> useFDatesCalendarController({ Set initialSelections = const {}, bool Function(DateTime)? selectable, - bool autoConvert = true, + bool truncateAndStripTimezone = true, List? keys, }) => use(_CalendarControllerHook>( @@ -70,7 +71,7 @@ FCalendarController> useFDatesCalendarController({ create: (hook) => FCalendarController.dates( initialSelections: hook.value, selectable: hook.selectable, - truncateAndStripTimezone: autoConvert, + truncateAndStripTimezone: truncateAndStripTimezone, ), )); @@ -79,28 +80,28 @@ FCalendarController> useFDatesCalendarController({ /// /// [selectable] will always return true if not given. /// -/// [autoConvert] determines whether the controller should truncate and convert all given [DateTime]s to dates in -/// UTC timezone. Defaults to true. +/// [truncateAndStripTimezone] determines whether the controller should truncate and convert all given [DateTime]s to +/// dates in UTC timezone. Defaults to true. /// /// ```dart -/// DateTime convert(DateTime date) => DateTime.utc(date.year, date.month, date.day); +/// DateTime truncateAndStripTimezone(DateTime date) => DateTime.utc(date.year, date.month, date.day); /// ``` /// -/// [autoConvert] should be set to false if you can guarantee that all dates are in UTC timezone (with the help of an -/// 3rd party library), which will improve performance. **Warning:** Giving a [DateTime] in local timezone or with a -/// time component when [autoConvert] is false is undefined behavior. +/// [truncateAndStripTimezone] should be set to false if you can guarantee that all dates are in UTC timezone (with +/// the help of an 3rd party library), which will improve performance. **Warning:** Giving a [DateTime] in local +/// timezone or with a time component when [truncateAndStripTimezone] is false is undefined behavior. /// -/// Both the start and end dates of the range is inclusive. Unselectable dates within the selected range are -/// selected regardless. +/// Both the start and end dates of the range is inclusive. Unselectable dates within the selected range are selected +/// regardless. /// /// ## Contract /// Throws [AssertionError] if: -/// * the given dates in [initialSelection] is not in UTC timezone and [autoConvert] is false. +/// * the given dates in [initialSelection] is not in UTC timezone and [truncateAndStripTimezone] is false. /// * the end date is less than start date. FCalendarController<(DateTime, DateTime)?> useFRangeCalendarController({ (DateTime, DateTime)? initialSelection, bool Function(DateTime)? selectable, - bool autoConvert = true, + bool truncateAndStripTimezone = true, List? keys, }) => use(_CalendarControllerHook<(DateTime, DateTime)?>( @@ -110,7 +111,7 @@ FCalendarController<(DateTime, DateTime)?> useFRangeCalendarController({ create: (hook) => FCalendarController.range( initialSelection: hook.value, selectable: hook.selectable, - truncateAndStripTimezone: autoConvert, + truncateAndStripTimezone: truncateAndStripTimezone, ), )); diff --git a/forui_hooks/lib/src/slider_controller_hook.dart b/forui_hooks/lib/src/slider_controller_hook.dart index 0904c8bf3..bae487dd0 100644 --- a/forui_hooks/lib/src/slider_controller_hook.dart +++ b/forui_hooks/lib/src/slider_controller_hook.dart @@ -46,7 +46,7 @@ class _ContinuousControllerHook extends Hook { super.debugFillProperties(properties); properties ..add(DiagnosticsProperty('selection', selection)) - ..add(DoubleProperty('stepPercentage', stepPercentage)) + ..add(PercentProperty('stepPercentage', stepPercentage)) ..add(FlagProperty('tooltips', value: tooltips, ifTrue: 'enabled', ifFalse: 'disabled')) ..add(EnumProperty('allowedInteraction', allowedInteraction)) ..add(FlagProperty('minExtendable', value: minExtendable, ifTrue: 'min extendable', ifFalse: 'max extendable')); From a4149be549c36c0d98fe73dbcb8d6847a93d5491 Mon Sep 17 00:00:00 2001 From: Matthias Ngeo Date: Tue, 17 Dec 2024 15:07:58 +0800 Subject: [PATCH 3/3] More tweaks --- forui/CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/forui/CHANGELOG.md b/forui/CHANGELOG.md index 7171d8d92..5ae0eba57 100644 --- a/forui/CHANGELOG.md +++ b/forui/CHANGELOG.md @@ -30,7 +30,9 @@ Bump minimum Flutter version to 3.27.0. * Add `FSelectMenuTile.builder`. -* Add `resizeToAvoidBottomInset` to `FScaffold(...)`. +* Add `FScaffold.resizeToAvoidBottomInset`. + +* Add `FThemeData.debugLabel`. ### Changes