From a7c8713efa61d97ce570d2aca42ba3d3c5d0c1bc Mon Sep 17 00:00:00 2001 From: Harry Sild <46851868+Kypsis@users.noreply.github.com> Date: Fri, 2 Aug 2024 10:14:05 +0300 Subject: [PATCH] feat!: [MDS-1264] Release v1.0.0 (#432) Co-authored-by: Hub <79840500+GittHub-d@users.noreply.github.com> Co-authored-by: Birgitt Majas Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- README.md | 12 +- example/assets/code_snippets/breadcrumb.md | 44 +-- .../stories/primitives/bottom_sheet.dart | 6 +- .../stories/primitives/breadcrumb.dart | 178 +++++------- .../storybook/stories/primitives/drawer.dart | 11 +- .../stories/primitives/linear_progress.dart | 9 +- .../storybook/stories/primitives/tab_bar.dart | 1 + example/lib/src/storybook/storybook.dart | 28 +- lib/moon_design.dart | 1 - .../theme/breadcrumb/breadcrumb_theme.dart | 10 +- lib/src/theme/checkbox/checkbox_colors.dart | 13 +- .../theme/checkbox/checkbox_properties.dart | 31 +- lib/src/theme/checkbox/checkbox_theme.dart | 13 +- lib/src/theme/drawer/drawer_colors.dart | 16 +- lib/src/theme/drawer/drawer_properties.dart | 15 +- lib/src/theme/drawer/drawer_theme.dart | 1 - .../linear_progress_sizes.dart | 18 +- .../progress_pin/progress_pin_theme.dart | 17 +- lib/src/theme/radio/radio_colors.dart | 13 +- lib/src/theme/radio/radio_properties.dart | 38 --- lib/src/theme/radio/radio_theme.dart | 21 +- lib/src/theme/switch/switch_sizes.dart | 12 +- lib/src/theme/tag/tag_size_properties.dart | 19 +- lib/src/theme/tag/tag_sizes.dart | 6 +- .../theme/tokens/typography/text_styles.dart | 129 +-------- .../theme/tokens/typography/typography.dart | 22 +- lib/src/widgets/breadcrumb/breadcrumb.dart | 185 +++++++----- .../widgets/breadcrumb/breadcrumb_item.dart | 6 +- lib/src/widgets/checkbox/checkbox.dart | 166 ++++------- lib/src/widgets/common/moon_icon.dart | 269 ------------------ lib/src/widgets/drawer/drawer.dart | 36 ++- lib/src/widgets/progress/linear_progress.dart | 73 +++-- lib/src/widgets/progress_pin/pin_style.dart | 8 - .../widgets/progress_pin/progress_pin.dart | 55 ++-- lib/src/widgets/radio/radio.dart | 140 +++------ lib/src/widgets/tag/tag.dart | 24 +- release-please-config.json | 2 - 37 files changed, 547 insertions(+), 1101 deletions(-) delete mode 100644 lib/src/theme/radio/radio_properties.dart delete mode 100644 lib/src/widgets/common/moon_icon.dart diff --git a/README.md b/README.md index e3263481..4a3ce5f9 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,10 @@ _Note: This project uses **[Release Please](https://github.com/googleapis/release-please)** and **[Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)** spec, please follow the conventions or consider using **[Commitizen](https://github.com/commitizen/cz-cli)** to write commit messages._ +## Disclaimer + +The current major release, v1.0.0, will be maintained as-is and will not receive further updates, except for patches. The v1 theming is based on the soon-to-be deprecated Moon Design Figma v1 and lacks flexibility. For greater control over theming with v1 of moon_flutter, it is recommended to create custom wrapper widgets around the moon_flutter widgets that align with your project's specific theming requirements. + ## Resources - 📱 [Playground](https://flutter.moon.io) @@ -22,7 +26,13 @@ final lightTokens = MoonTokens.light.copyWith( textPrimary: Colors.amber, ), typography: MoonTypography.typography.copyWith( - heading: MoonTypography.typography.heading.apply(fontFamily: "DMSans"), + heading: MoonTypography.typography.heading.apply( + // Using variable font and bumping down the font weight compared to the + // baseline 600 for heading. + fontFamily: "DMSans", + fontWeightDelta: -1, + fontVariations: [const FontVariation('wght', 500)], + ), ), ); diff --git a/example/assets/code_snippets/breadcrumb.md b/example/assets/code_snippets/breadcrumb.md index 95ec0136..988494e9 100644 --- a/example/assets/code_snippets/breadcrumb.md +++ b/example/assets/code_snippets/breadcrumb.md @@ -11,7 +11,6 @@ class BreadcrumbStory extends StatefulWidget { class _BreadcrumbStoryState extends State { bool _showDropdown = false; - Color? _dropdownIconColor; @override Widget build(BuildContext context) { @@ -50,38 +49,21 @@ class _BreadcrumbStoryState extends State { ? MoonIcons.controls_chevron_right_small_16_light : MoonIcons.controls_chevron_left_small_16_light, ), - showMoreWidget: MoonDropdown( - show: _showDropdown, - onTapOutside: () => setState(() { - _showDropdown = false; - _dropdownIconColor = context.moonColors!.iconSecondary; - }), - content: Column( - children: List.generate( - 3, - (int index) => MoonMenuItem( - onTap: () {}, - label: Text('Page ${index + 1}'), - ), - ), - ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 8), - child: MouseRegion( - onHover: (PointerHoverEvent _) { - setState(() => _dropdownIconColor = context.moonColors!.iconPrimary); - }, - onExit: (PointerExitEvent _) { - if (!_showDropdown) setState(() => _dropdownIconColor = context.moonColors!.iconSecondary); - }, - child: MoonButton.icon( - buttonSize: MoonButtonSize.xs, - hoverEffectColor: Colors.transparent, - iconColor: _dropdownIconColor ?? context.moonColors!.iconSecondary, - onTap: () => setState(() => _showDropdown = !_showDropdown), - icon: const Icon(MoonIcons.generic_burger_regular_16_light), + showMoreWidget: MoonBreadcrumbItem( + onTap: () => setState(() => _showDropdown = !_showDropdown), + label: MoonDropdown( + show: _showDropdown, + onTapOutside: () => setState(() => _showDropdown = false), + content: Column( + children: List.generate( + 3, + (int index) => MoonMenuItem( + onTap: () {}, + label: Text('Page ${index + 1}'), + ), ), ), + child: const Icon(MoonIcons.generic_burger_regular_16_light), ), ), items: List.generate( diff --git a/example/lib/src/storybook/stories/primitives/bottom_sheet.dart b/example/lib/src/storybook/stories/primitives/bottom_sheet.dart index 0d7e23f1..eabc16f1 100644 --- a/example/lib/src/storybook/stories/primitives/bottom_sheet.dart +++ b/example/lib/src/storybook/stories/primitives/bottom_sheet.dart @@ -65,7 +65,9 @@ class BottomSheetStory extends StatelessWidget { ? MediaQuery.of(context).size.height * heightKnob : MediaQuery.of(context).size.height * 0.7, closeProgressThreshold: closeProgressThresholdKnob, - borderRadius: borderRadiusKnob != null ? BorderRadius.circular(borderRadiusKnob.toDouble()) : null, + borderRadius: borderRadiusKnob != null + ? BorderRadius.circular(borderRadiusKnob.toDouble()) + : null, builder: (BuildContext context) => Column( children: [ Container( @@ -84,7 +86,7 @@ class BottomSheetStory extends StatelessWidget { child: Center( child: Text( 'Pick your choice!', - style: MoonTypography.typography.heading.text16, + style: MoonTypography.typography.body.text16, ), ), ), diff --git a/example/lib/src/storybook/stories/primitives/breadcrumb.dart b/example/lib/src/storybook/stories/primitives/breadcrumb.dart index 8482320c..55766852 100644 --- a/example/lib/src/storybook/stories/primitives/breadcrumb.dart +++ b/example/lib/src/storybook/stories/primitives/breadcrumb.dart @@ -1,6 +1,7 @@ +import 'dart:math'; + import 'package:example/src/storybook/common/color_options.dart'; import 'package:example/src/storybook/common/widgets/text_divider.dart'; -import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:moon_design/moon_design.dart'; import 'package:storybook_flutter/storybook_flutter.dart'; @@ -16,7 +17,6 @@ class BreadcrumbStory extends StatefulWidget { class _BreadcrumbStoryState extends State { bool _showDropdown = false; - Color? _dropdownIconColor; @override Widget build(BuildContext context) { @@ -98,6 +98,35 @@ class _BreadcrumbStoryState extends State { description: "Show widget in MoonBreadcrumb item trailing slot.", ); + final List breadcrumbItems = List.generate( + itemCountKnob ?? 7, + (int index) { + final bool isHomePage = index == 0; + + return MoonBreadcrumbItem( + semanticLabel: index.toString(), + onTap: () => MoonToast.show( + context, + displayDuration: const Duration(seconds: 1), + label: Text(isHomePage ? 'Home Page' : 'Page $index'), + ), + leading: showLeadingKnob && isHomePage + ? const Icon( + MoonIcons.generic_home_16_light, + size: 16, + ) + : null, + label: Text(isHomePage ? 'Home' : 'Page $index'), + trailing: showTrailingKnob && isHomePage + ? const Icon( + MoonIcons.generic_home_16_light, + size: 16, + ) + : null, + ); + }, + ); + return Center( child: SingleChildScrollView( padding: const EdgeInsets.symmetric(vertical: 64.0, horizontal: 16.0), @@ -108,50 +137,28 @@ class _BreadcrumbStoryState extends State { text: "MoonBreadcrumb", paddingTop: 0, ), - Column( - children: [ - MoonBreadcrumb( - visibleItemCount: visibleItemCountKnob ?? 3, - gap: gapKnob?.toDouble(), - padding: const EdgeInsets.symmetric(horizontal: 16), - hoverEffectColor: hoverEffectColor, - dividerColor: dividerColor, - itemTextStyle: TextStyle(color: itemColor), - currentItemTextStyle: TextStyle(color: currentItemColor), - items: List.generate( - itemCountKnob ?? 7, - (int index) { - final bool isHomePage = index == 0; - - return MoonBreadcrumbItem( - onTap: () => MoonToast.show( - context, - displayDuration: const Duration(seconds: 1), - label: Text(isHomePage ? 'Home Page' : 'Page $index'), - ), - leading: - showLeadingKnob && isHomePage ? const Icon(MoonIcons.generic_home_16_light, size: 16) : null, - label: Text(isHomePage ? 'Home' : 'Page $index'), - trailing: - showTrailingKnob && isHomePage ? const Icon(MoonIcons.generic_home_16_light, size: 16) : null, - ); - }, - ), - ), - const SizedBox(height: 16), - MoonButton( - backgroundColor: context.moonColors!.piccolo, - onTap: () => setState(() => {}), - label: Text( - 'Reset', - style: TextStyle(color: context.moonColors!.goten), - ), - ), - ], + MoonBreadcrumb( + visibleItemCount: visibleItemCountKnob ?? 3, + gap: gapKnob?.toDouble(), + padding: const EdgeInsets.symmetric(horizontal: 16), + hoverEffectColor: hoverEffectColor, + dividerColor: dividerColor, + itemTextStyle: TextStyle(color: itemColor), + currentItemTextStyle: TextStyle(color: currentItemColor), + items: breadcrumbItems, + ), + const SizedBox(height: 32), + MoonButton( + backgroundColor: context.moonColors!.piccolo, + onTap: () => setState(() => {}), + label: Text( + 'Reset', + style: TextStyle(color: context.moonColors!.goten), + ), ), const TextDivider(text: "Custom MoonBreadcrumb with MoonDropdown"), StatefulBuilder( - builder: (context, setState) { + builder: (BuildContext context, StateSetter setState) { return MoonBreadcrumb( visibleItemCount: visibleItemCountKnob ?? 3, gap: gapKnob?.toDouble(), @@ -168,74 +175,37 @@ class _BreadcrumbStoryState extends State { ? MoonIcons.controls_chevron_right_small_16_light : MoonIcons.controls_chevron_left_small_16_light, ), - showMoreWidget: MoonDropdown( - show: _showDropdown, - onTapOutside: () => setState(() { - _showDropdown = false; - _dropdownIconColor = context.moonColors!.iconSecondary; - }), - content: Column( - children: List.generate( - 4, - (int index) => MoonMenuItem( - width: 120, - onTap: () => MoonToast.show( - context, - displayDuration: const Duration(seconds: 1), + showMoreWidget: MoonBreadcrumbItem( + onTap: () => setState(() => _showDropdown = !_showDropdown), + label: MoonDropdown( + maxHeight: 250, + maxWidth: 150, + show: _showDropdown, + onTapOutside: () => setState(() => _showDropdown = false), + content: ListView( + shrinkWrap: true, + padding: EdgeInsets.zero, + children: List.generate( + max( + (itemCountKnob ?? 7) - (visibleItemCountKnob ?? 3), + 0, + ), + (int index) => MoonMenuItem( + onTap: () => MoonToast.show( + context, + displayDuration: const Duration(seconds: 1), + label: Text('Page ${index + 1}'), + ), label: Text('Page ${index + 1}'), ), - label: Text('Page ${index + 1}'), ), ), - ), - child: Padding( - padding: EdgeInsets.symmetric(horizontal: gapKnob?.toDouble() ?? 8), - child: MouseRegion( - onHover: (PointerHoverEvent event) { - setState(() => _dropdownIconColor = hoverEffectColor ?? context.moonColors!.iconPrimary); - }, - onExit: (PointerExitEvent event) { - if (!_showDropdown) { - setState(() => _dropdownIconColor = itemColor ?? context.moonColors!.iconSecondary); - } - }, - child: MoonButton.icon( - buttonSize: MoonButtonSize.xs, - hoverEffectColor: Colors.transparent, - iconColor: _dropdownIconColor ?? context.moonColors!.iconSecondary, - icon: const Icon(MoonIcons.generic_burger_regular_16_light), - onTap: () => setState(() => _showDropdown = !_showDropdown), - ), + child: const Icon( + MoonIcons.generic_burger_regular_16_light, ), ), ), - items: List.generate( - itemCountKnob ?? 7, - (int index) { - final bool isHomePage = index == 0; - - return MoonBreadcrumbItem( - onTap: () => MoonToast.show( - context, - displayDuration: const Duration(seconds: 1), - label: Text(isHomePage ? 'Home Page' : 'Page $index'), - ), - leading: showLeadingKnob && isHomePage - ? const Icon( - MoonIcons.generic_home_16_light, - size: 16, - ) - : null, - label: Text(isHomePage ? 'Home' : 'Page $index'), - trailing: showTrailingKnob && isHomePage - ? const Icon( - MoonIcons.generic_home_16_light, - size: 16, - ) - : null, - ); - }, - ), + items: breadcrumbItems, ); }, ), diff --git a/example/lib/src/storybook/stories/primitives/drawer.dart b/example/lib/src/storybook/stories/primitives/drawer.dart index d2c7b7aa..01dae701 100644 --- a/example/lib/src/storybook/stories/primitives/drawer.dart +++ b/example/lib/src/storybook/stories/primitives/drawer.dart @@ -55,13 +55,11 @@ class DrawerStory extends StatelessWidget { drawerScrimColor: barrierColor, drawer: MoonDrawer( backgroundColor: backgroundColor, - barrierColor: barrierColorKnob != null - ? barrierColor - : context.moonTheme?.drawerTheme.colors.barrierColor ?? MoonColors.light.zeno, borderRadius: BorderRadiusDirectional.horizontal( end: Radius.circular(borderRadiusKnob?.toDouble() ?? 0), ), - width: drawerWidthKnob?.toDouble() ?? MediaQuery.of(context).size.width, + width: drawerWidthKnob?.toDouble() ?? + MediaQuery.of(context).size.width * 0.8, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -82,7 +80,10 @@ class DrawerStory extends StatelessWidget { child: Builder( builder: (BuildContext context) { return Padding( - padding: const EdgeInsets.symmetric(vertical: 64.0, horizontal: 16.0), + padding: const EdgeInsets.symmetric( + vertical: 64.0, + horizontal: 16.0, + ), child: MoonFilledButton( label: const Text("Tap me"), onTap: () => Scaffold.of(context).openDrawer(), diff --git a/example/lib/src/storybook/stories/primitives/linear_progress.dart b/example/lib/src/storybook/stories/primitives/linear_progress.dart index 115e17be..9880a5a1 100644 --- a/example/lib/src/storybook/stories/primitives/linear_progress.dart +++ b/example/lib/src/storybook/stories/primitives/linear_progress.dart @@ -44,7 +44,8 @@ class LinearProgressStory extends StatelessWidget { options: colorOptions, ); - final backgroundColor = colorTable(context)[progressBackgroundColorKnob ?? 40]; + final backgroundColor = + colorTable(context)[progressBackgroundColorKnob ?? 40]; final pinColorKnob = context.knobs.nullable.options( label: "pinColor", @@ -116,13 +117,15 @@ class LinearProgressStory extends StatelessWidget { return Center( child: Padding( - padding: const EdgeInsets.symmetric(vertical: 64, horizontal: 16), + padding: const EdgeInsets.symmetric(vertical: 64, horizontal: 20), child: MoonLinearProgress( linearProgressSize: progressSizeKnob, value: linearProgressValueKnob, color: color, backgroundColor: backgroundColor, - borderRadius: borderRadiusKnob != null ? BorderRadius.circular(borderRadiusKnob.toDouble()) : null, + borderRadius: borderRadiusKnob != null + ? BorderRadius.circular(borderRadiusKnob.toDouble()) + : null, showMinLabel: showMinLabelKnob, showMaxLabel: showMaxLabelKnob, showPin: showPinKnob, diff --git a/example/lib/src/storybook/stories/primitives/tab_bar.dart b/example/lib/src/storybook/stories/primitives/tab_bar.dart index 7d3df702..71dfe600 100644 --- a/example/lib/src/storybook/stories/primitives/tab_bar.dart +++ b/example/lib/src/storybook/stories/primitives/tab_bar.dart @@ -186,6 +186,7 @@ class _TabBarStoryState extends State tabs: List.generate( 4, (int index) => MoonTab( + disabled: index == 1, trailing: const Icon(MoonIcons.other_frame_24_light), tabStyle: tabStyle, ), diff --git a/example/lib/src/storybook/storybook.dart b/example/lib/src/storybook/storybook.dart index bd2daf1b..0880280f 100644 --- a/example/lib/src/storybook/storybook.dart +++ b/example/lib/src/storybook/storybook.dart @@ -37,12 +37,14 @@ class StorybookPage extends StatelessWidget { tokens: MoonTokens.light.copyWith( colors: mdsLightColors, typography: MoonTypography.typography.copyWith( - heading: MoonTypography.typography.heading - .apply(fontFamily: "DMSans"), - body: MoonTypography.typography.body - .apply(fontFamily: "DMSans"), - caption: MoonTypography.typography.caption - .apply(fontFamily: "DMSans"), + heading: MoonTypography.typography.heading.apply( + fontFamily: "DMSans", + fontWeightDelta: -1, + fontVariations: [const FontVariation('wght', 500)], + ), + body: MoonTypography.typography.body.apply( + fontFamily: "DMSans", + ), ), ), ), @@ -55,12 +57,14 @@ class StorybookPage extends StatelessWidget { tokens: MoonTokens.dark.copyWith( colors: mdsDarkColors, typography: MoonTypography.typography.copyWith( - heading: MoonTypography.typography.heading - .apply(fontFamily: "DMSans"), - body: MoonTypography.typography.body - .apply(fontFamily: "DMSans"), - caption: MoonTypography.typography.caption - .apply(fontFamily: "DMSans"), + heading: MoonTypography.typography.heading.apply( + fontFamily: "DMSans", + fontWeightDelta: -1, + fontVariations: [const FontVariation('wght', 500)], + ), + body: MoonTypography.typography.body.apply( + fontFamily: "DMSans", + ), ), ), ), diff --git a/lib/moon_design.dart b/lib/moon_design.dart index c77bb2dc..1933cef2 100644 --- a/lib/moon_design.dart +++ b/lib/moon_design.dart @@ -67,7 +67,6 @@ export 'package:moon_design/src/widgets/common/base_segmented_tab_bar.dart'; export 'package:moon_design/src/widgets/common/effects/focus_effect.dart'; export 'package:moon_design/src/widgets/common/effects/pulse_effect.dart'; export 'package:moon_design/src/widgets/common/error_message_widgets.dart'; -export 'package:moon_design/src/widgets/common/moon_icon.dart'; export 'package:moon_design/src/widgets/common/progress_indicators/circular_progress_indicator.dart'; export 'package:moon_design/src/widgets/common/progress_indicators/linear_progress_indicator.dart'; export 'package:moon_design/src/widgets/dot_indicator/dot_indicator.dart'; diff --git a/lib/src/theme/breadcrumb/breadcrumb_theme.dart b/lib/src/theme/breadcrumb/breadcrumb_theme.dart index 25eea95f..1cbb71e6 100644 --- a/lib/src/theme/breadcrumb/breadcrumb_theme.dart +++ b/lib/src/theme/breadcrumb/breadcrumb_theme.dart @@ -5,7 +5,8 @@ import 'package:moon_design/src/theme/breadcrumb/breadcrumb_colors.dart'; import 'package:moon_design/src/theme/breadcrumb/breadcrumb_properties.dart'; @immutable -class MoonBreadcrumbTheme extends ThemeExtension with DiagnosticableTreeMixin { +class MoonBreadcrumbTheme extends ThemeExtension + with DiagnosticableTreeMixin { /// The tokens of the Moon Design System. final MoonTokens tokens; @@ -33,7 +34,7 @@ class MoonBreadcrumbTheme extends ThemeExtension with Diagn transitionCurve: tokens.transitions.defaultTransitionCurve, itemTextStyle: tokens.typography.body.textDefault, currentItemTextStyle: tokens.typography.body.textDefault, - showMoreItemTextStyle: tokens.typography.caption.textDefault, + showMoreItemTextStyle: tokens.typography.body.textDefault, ); @override @@ -50,7 +51,10 @@ class MoonBreadcrumbTheme extends ThemeExtension with Diagn } @override - MoonBreadcrumbTheme lerp(ThemeExtension? other, double t) { + MoonBreadcrumbTheme lerp( + ThemeExtension? other, + double t, + ) { if (other is! MoonBreadcrumbTheme) return this; return MoonBreadcrumbTheme( diff --git a/lib/src/theme/checkbox/checkbox_colors.dart b/lib/src/theme/checkbox/checkbox_colors.dart index 7581f1d5..8ab21377 100644 --- a/lib/src/theme/checkbox/checkbox_colors.dart +++ b/lib/src/theme/checkbox/checkbox_colors.dart @@ -4,7 +4,8 @@ import 'package:flutter/material.dart'; import 'package:moon_design/src/utils/color_premul_lerp.dart'; @immutable -class MoonCheckboxColors extends ThemeExtension with DiagnosticableTreeMixin { +class MoonCheckboxColors extends ThemeExtension + with DiagnosticableTreeMixin { /// The background color of the checked MoonCheckbox. final Color activeColor; @@ -17,15 +18,11 @@ class MoonCheckboxColors extends ThemeExtension with Diagnos /// The background color of the unchecked MoonCheckbox. final Color inactiveColor; - /// The text color of the MoonCheckbox with label. - final Color textColor; - const MoonCheckboxColors({ required this.activeColor, required this.borderColor, required this.checkColor, required this.inactiveColor, - required this.textColor, }); @override @@ -34,14 +31,12 @@ class MoonCheckboxColors extends ThemeExtension with Diagnos Color? borderColor, Color? checkColor, Color? inactiveColor, - Color? textColor, }) { return MoonCheckboxColors( activeColor: activeColor ?? this.activeColor, borderColor: borderColor ?? this.borderColor, checkColor: checkColor ?? this.checkColor, inactiveColor: inactiveColor ?? this.inactiveColor, - textColor: textColor ?? this.textColor, ); } @@ -54,7 +49,6 @@ class MoonCheckboxColors extends ThemeExtension with Diagnos borderColor: colorPremulLerp(borderColor, other.borderColor, t)!, checkColor: colorPremulLerp(checkColor, other.checkColor, t)!, inactiveColor: colorPremulLerp(inactiveColor, other.inactiveColor, t)!, - textColor: colorPremulLerp(textColor, other.textColor, t)!, ); } @@ -66,7 +60,6 @@ class MoonCheckboxColors extends ThemeExtension with Diagnos ..add(ColorProperty("activeColor", activeColor)) ..add(ColorProperty("borderColor", borderColor)) ..add(ColorProperty("checkColor", checkColor)) - ..add(ColorProperty("inactiveColor", inactiveColor)) - ..add(ColorProperty("textColor", textColor)); + ..add(ColorProperty("inactiveColor", inactiveColor)); } } diff --git a/lib/src/theme/checkbox/checkbox_properties.dart b/lib/src/theme/checkbox/checkbox_properties.dart index 1217b970..9418d870 100644 --- a/lib/src/theme/checkbox/checkbox_properties.dart +++ b/lib/src/theme/checkbox/checkbox_properties.dart @@ -2,36 +2,30 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @immutable -class MoonCheckboxProperties extends ThemeExtension with DiagnosticableTreeMixin { +class MoonCheckboxProperties extends ThemeExtension + with DiagnosticableTreeMixin { /// The border radius of the MoonCheckbox. final BorderRadiusGeometry borderRadius; - /// The text style of the MoonCheckbox. - final TextStyle textStyle; - - const MoonCheckboxProperties({ - required this.borderRadius, - required this.textStyle, - }); + const MoonCheckboxProperties({required this.borderRadius}); @override - MoonCheckboxProperties copyWith({ - BorderRadiusGeometry? borderRadius, - TextStyle? textStyle, - }) { + MoonCheckboxProperties copyWith({BorderRadiusGeometry? borderRadius}) { return MoonCheckboxProperties( borderRadius: borderRadius ?? this.borderRadius, - textStyle: textStyle ?? this.textStyle, ); } @override - MoonCheckboxProperties lerp(ThemeExtension? other, double t) { + MoonCheckboxProperties lerp( + ThemeExtension? other, + double t, + ) { if (other is! MoonCheckboxProperties) return this; return MoonCheckboxProperties( - borderRadius: BorderRadiusGeometry.lerp(borderRadius, other.borderRadius, t)!, - textStyle: TextStyle.lerp(textStyle, other.textStyle, t)!, + borderRadius: + BorderRadiusGeometry.lerp(borderRadius, other.borderRadius, t)!, ); } @@ -40,7 +34,8 @@ class MoonCheckboxProperties extends ThemeExtension with super.debugFillProperties(properties); properties ..add(DiagnosticsProperty("type", "MoonCheckboxProperties")) - ..add(DiagnosticsProperty("borderRadius", borderRadius)) - ..add(DiagnosticsProperty("textStyle", textStyle)); + ..add( + DiagnosticsProperty("borderRadius", borderRadius), + ); } } diff --git a/lib/src/theme/checkbox/checkbox_theme.dart b/lib/src/theme/checkbox/checkbox_theme.dart index 5e6fe0c0..6c7c80f6 100644 --- a/lib/src/theme/checkbox/checkbox_theme.dart +++ b/lib/src/theme/checkbox/checkbox_theme.dart @@ -6,7 +6,8 @@ import 'package:moon_design/src/theme/checkbox/checkbox_properties.dart'; import 'package:moon_design/src/theme/tokens/tokens.dart'; @immutable -class MoonCheckboxTheme extends ThemeExtension with DiagnosticableTreeMixin { +class MoonCheckboxTheme extends ThemeExtension + with DiagnosticableTreeMixin { /// The tokens of the Moon Design System. final MoonTokens tokens; @@ -26,13 +27,9 @@ class MoonCheckboxTheme extends ThemeExtension with Diagnosti borderColor: tokens.colors.trunks, checkColor: tokens.colors.goten, inactiveColor: Colors.transparent, - textColor: tokens.colors.textPrimary, ), properties = properties ?? - MoonCheckboxProperties( - borderRadius: tokens.borders.interactiveXs, - textStyle: tokens.typography.body.textDefault, - ); + MoonCheckboxProperties(borderRadius: tokens.borders.interactiveXs); @override MoonCheckboxTheme copyWith({ @@ -65,6 +62,8 @@ class MoonCheckboxTheme extends ThemeExtension with Diagnosti ..add(DiagnosticsProperty("type", "MoonCheckboxTheme")) ..add(DiagnosticsProperty("tokens", tokens)) ..add(DiagnosticsProperty("colors", colors)) - ..add(DiagnosticsProperty("properties", properties)); + ..add( + DiagnosticsProperty("properties", properties), + ); } } diff --git a/lib/src/theme/drawer/drawer_colors.dart b/lib/src/theme/drawer/drawer_colors.dart index e2d27b10..9aceb3e3 100644 --- a/lib/src/theme/drawer/drawer_colors.dart +++ b/lib/src/theme/drawer/drawer_colors.dart @@ -4,7 +4,8 @@ import 'package:flutter/material.dart'; import 'package:moon_design/src/utils/color_premul_lerp.dart'; @immutable -class MoonDrawerColors extends ThemeExtension with DiagnosticableTreeMixin { +class MoonDrawerColors extends ThemeExtension + with DiagnosticableTreeMixin { /// The text color of the MoonDrawer. final Color textColor; @@ -14,14 +15,10 @@ class MoonDrawerColors extends ThemeExtension with Diagnostica /// The background color of the MoonDrawer. final Color backgroundColor; - /// The color of the MoonDrawer barrier. - final Color barrierColor; - const MoonDrawerColors({ required this.textColor, required this.iconColor, required this.backgroundColor, - required this.barrierColor, }); @override @@ -29,13 +26,11 @@ class MoonDrawerColors extends ThemeExtension with Diagnostica Color? textColor, Color? iconColor, Color? backgroundColor, - Color? barrierColor, }) { return MoonDrawerColors( textColor: textColor ?? this.textColor, iconColor: iconColor ?? this.iconColor, backgroundColor: backgroundColor ?? this.backgroundColor, - barrierColor: barrierColor ?? this.barrierColor, ); } @@ -46,8 +41,8 @@ class MoonDrawerColors extends ThemeExtension with Diagnostica return MoonDrawerColors( textColor: colorPremulLerp(textColor, other.textColor, t)!, iconColor: colorPremulLerp(iconColor, other.iconColor, t)!, - backgroundColor: colorPremulLerp(backgroundColor, other.backgroundColor, t)!, - barrierColor: colorPremulLerp(barrierColor, other.barrierColor, t)!, + backgroundColor: + colorPremulLerp(backgroundColor, other.backgroundColor, t)!, ); } @@ -58,7 +53,6 @@ class MoonDrawerColors extends ThemeExtension with Diagnostica ..add(DiagnosticsProperty("type", "MoonDrawerColors")) ..add(ColorProperty("textColor", textColor)) ..add(ColorProperty("iconColor", iconColor)) - ..add(ColorProperty("backgroundColor", backgroundColor)) - ..add(ColorProperty("barrierColor", barrierColor)); + ..add(ColorProperty("backgroundColor", backgroundColor)); } } diff --git a/lib/src/theme/drawer/drawer_properties.dart b/lib/src/theme/drawer/drawer_properties.dart index 22e61aa9..c83f9b9f 100644 --- a/lib/src/theme/drawer/drawer_properties.dart +++ b/lib/src/theme/drawer/drawer_properties.dart @@ -4,7 +4,8 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @immutable -class MoonDrawerProperties extends ThemeExtension with DiagnosticableTreeMixin { +class MoonDrawerProperties extends ThemeExtension + with DiagnosticableTreeMixin { /// The border radius of the MoonDrawer. final BorderRadiusGeometry borderRadius; @@ -34,11 +35,15 @@ class MoonDrawerProperties extends ThemeExtension with Dia } @override - MoonDrawerProperties lerp(ThemeExtension? other, double t) { + MoonDrawerProperties lerp( + ThemeExtension? other, + double t, + ) { if (other is! MoonDrawerProperties) return this; return MoonDrawerProperties( - borderRadius: BorderRadiusGeometry.lerp(borderRadius, other.borderRadius, t)!, + borderRadius: + BorderRadiusGeometry.lerp(borderRadius, other.borderRadius, t)!, width: lerpDouble(width, other.width, t)!, textStyle: TextStyle.lerp(textStyle, other.textStyle, t)!, ); @@ -49,7 +54,9 @@ class MoonDrawerProperties extends ThemeExtension with Dia super.debugFillProperties(properties); properties ..add(DiagnosticsProperty("type", "MoonDrawerProperties")) - ..add(DiagnosticsProperty("borderRadius", borderRadius)) + ..add( + DiagnosticsProperty("borderRadius", borderRadius), + ) ..add(DoubleProperty("width", width)) ..add(DiagnosticsProperty("textStyle", textStyle)); } diff --git a/lib/src/theme/drawer/drawer_theme.dart b/lib/src/theme/drawer/drawer_theme.dart index 482f5f35..63fe3de2 100644 --- a/lib/src/theme/drawer/drawer_theme.dart +++ b/lib/src/theme/drawer/drawer_theme.dart @@ -30,7 +30,6 @@ class MoonDrawerTheme extends ThemeExtension with Diagnosticabl textColor: tokens.colors.textPrimary, iconColor: tokens.colors.iconPrimary, backgroundColor: tokens.colors.goku, - barrierColor: tokens.colors.zeno, ), properties = properties ?? MoonDrawerProperties( diff --git a/lib/src/theme/progress/linear_progress/linear_progress_sizes.dart b/lib/src/theme/progress/linear_progress/linear_progress_sizes.dart index d41d3f4b..c387a884 100644 --- a/lib/src/theme/progress/linear_progress/linear_progress_sizes.dart +++ b/lib/src/theme/progress/linear_progress/linear_progress_sizes.dart @@ -5,7 +5,8 @@ import 'package:moon_design/src/theme/progress/linear_progress/linear_progress_s import 'package:moon_design/src/theme/tokens/tokens.dart'; @immutable -class MoonLinearProgressSizes extends ThemeExtension with DiagnosticableTreeMixin { +class MoonLinearProgressSizes extends ThemeExtension + with DiagnosticableTreeMixin { /// The tokens of the Moon Design System. final MoonTokens tokens; @@ -37,7 +38,7 @@ class MoonLinearProgressSizes extends ThemeExtension wi progressHeight: tokens.sizes.x6s, thumbSizeValue: tokens.sizes.x3s, verticalGap: tokens.sizes.x4s, - textStyle: tokens.typography.caption.text10, + textStyle: tokens.typography.body.text10, ), x5s = x5s ?? MoonLinearProgressSizeProperties( @@ -45,7 +46,7 @@ class MoonLinearProgressSizes extends ThemeExtension wi progressHeight: tokens.sizes.x5s, thumbSizeValue: tokens.sizes.x3s, verticalGap: tokens.sizes.x4s, - textStyle: tokens.typography.caption.text10, + textStyle: tokens.typography.body.text10, ), x4s = x4s ?? MoonLinearProgressSizeProperties( @@ -53,7 +54,7 @@ class MoonLinearProgressSizes extends ThemeExtension wi progressHeight: tokens.sizes.x4s, thumbSizeValue: tokens.sizes.x3s, verticalGap: 6, - textStyle: tokens.typography.caption.text10, + textStyle: tokens.typography.body.text10, ), x3s = x3s ?? MoonLinearProgressSizeProperties( @@ -61,7 +62,7 @@ class MoonLinearProgressSizes extends ThemeExtension wi progressHeight: tokens.sizes.x3s, thumbSizeValue: tokens.sizes.x2s, verticalGap: 6, - textStyle: tokens.typography.caption.text10, + textStyle: tokens.typography.body.text10, ), x2s = x2s ?? MoonLinearProgressSizeProperties( @@ -69,7 +70,7 @@ class MoonLinearProgressSizes extends ThemeExtension wi progressHeight: tokens.sizes.x2s, thumbSizeValue: tokens.sizes.x2s, verticalGap: tokens.sizes.x5s, - textStyle: tokens.typography.caption.text10, + textStyle: tokens.typography.body.text10, ); @override @@ -92,7 +93,10 @@ class MoonLinearProgressSizes extends ThemeExtension wi } @override - MoonLinearProgressSizes lerp(ThemeExtension? other, double t) { + MoonLinearProgressSizes lerp( + ThemeExtension? other, + double t, + ) { if (other is! MoonLinearProgressSizes) return this; return MoonLinearProgressSizes( diff --git a/lib/src/theme/progress_pin/progress_pin_theme.dart b/lib/src/theme/progress_pin/progress_pin_theme.dart index c428efdf..fff56798 100644 --- a/lib/src/theme/progress_pin/progress_pin_theme.dart +++ b/lib/src/theme/progress_pin/progress_pin_theme.dart @@ -6,7 +6,8 @@ import 'package:moon_design/src/theme/progress_pin/progress_pin_properties.dart' import 'package:moon_design/src/theme/tokens/tokens.dart'; @immutable -class MoonProgressPinTheme extends ThemeExtension with DiagnosticableTreeMixin { +class MoonProgressPinTheme extends ThemeExtension + with DiagnosticableTreeMixin { /// The tokens of the Moon Design System. final MoonTokens tokens; @@ -36,7 +37,7 @@ class MoonProgressPinTheme extends ThemeExtension with Dia pinWidth: 36, pinBorderWidth: tokens.sizes.x6s, shadowElevation: 6, - textStyle: tokens.typography.caption.text10, + textStyle: tokens.typography.body.text10, ); @override @@ -53,7 +54,10 @@ class MoonProgressPinTheme extends ThemeExtension with Dia } @override - MoonProgressPinTheme lerp(ThemeExtension? other, double t) { + MoonProgressPinTheme lerp( + ThemeExtension? other, + double t, + ) { if (other is! MoonProgressPinTheme) return this; return MoonProgressPinTheme( @@ -70,6 +74,11 @@ class MoonProgressPinTheme extends ThemeExtension with Dia ..add(DiagnosticsProperty("type", "MoonProgressPinTheme")) ..add(DiagnosticsProperty("tokens", tokens)) ..add(DiagnosticsProperty("colors", colors)) - ..add(DiagnosticsProperty("properties", properties)); + ..add( + DiagnosticsProperty( + "properties", + properties, + ), + ); } } diff --git a/lib/src/theme/radio/radio_colors.dart b/lib/src/theme/radio/radio_colors.dart index 1411bf61..0f7f5a20 100644 --- a/lib/src/theme/radio/radio_colors.dart +++ b/lib/src/theme/radio/radio_colors.dart @@ -4,32 +4,27 @@ import 'package:flutter/material.dart'; import 'package:moon_design/src/utils/color_premul_lerp.dart'; @immutable -class MoonRadioColors extends ThemeExtension with DiagnosticableTreeMixin { +class MoonRadioColors extends ThemeExtension + with DiagnosticableTreeMixin { /// The color of the selected MoonRadio button. final Color activeColor; /// The background color of the unselected MoonRadio button. final Color inactiveColor; - /// The text color of the MoonRadio with label button. - final Color textColor; - const MoonRadioColors({ required this.activeColor, required this.inactiveColor, - required this.textColor, }); @override MoonRadioColors copyWith({ Color? activeColor, Color? inactiveColor, - Color? textColor, }) { return MoonRadioColors( activeColor: activeColor ?? this.activeColor, inactiveColor: inactiveColor ?? this.inactiveColor, - textColor: textColor ?? this.textColor, ); } @@ -40,7 +35,6 @@ class MoonRadioColors extends ThemeExtension with Diagnosticabl return MoonRadioColors( activeColor: colorPremulLerp(activeColor, other.activeColor, t)!, inactiveColor: colorPremulLerp(inactiveColor, other.inactiveColor, t)!, - textColor: colorPremulLerp(textColor, other.textColor, t)!, ); } @@ -50,7 +44,6 @@ class MoonRadioColors extends ThemeExtension with Diagnosticabl properties ..add(DiagnosticsProperty("type", "MoonRadioColors")) ..add(ColorProperty("activeColor", activeColor)) - ..add(ColorProperty("inactiveColor", inactiveColor)) - ..add(ColorProperty("textColor", textColor)); + ..add(ColorProperty("inactiveColor", inactiveColor)); } } diff --git a/lib/src/theme/radio/radio_properties.dart b/lib/src/theme/radio/radio_properties.dart deleted file mode 100644 index 439801c4..00000000 --- a/lib/src/theme/radio/radio_properties.dart +++ /dev/null @@ -1,38 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; - -@immutable -class MoonRadioProperties extends ThemeExtension with DiagnosticableTreeMixin { - /// The text style of the MoonRadio with label button. - final TextStyle textStyle; - - const MoonRadioProperties({ - required this.textStyle, - }); - - @override - MoonRadioProperties copyWith({ - TextStyle? textStyle, - }) { - return MoonRadioProperties( - textStyle: textStyle ?? this.textStyle, - ); - } - - @override - MoonRadioProperties lerp(ThemeExtension? other, double t) { - if (other is! MoonRadioProperties) return this; - - return MoonRadioProperties( - textStyle: TextStyle.lerp(textStyle, other.textStyle, t)!, - ); - } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties - ..add(DiagnosticsProperty("type", "MoonRadioProperties")) - ..add(DiagnosticsProperty("textStyle", textStyle)); - } -} diff --git a/lib/src/theme/radio/radio_theme.dart b/lib/src/theme/radio/radio_theme.dart index 459e2f6b..9cbd7457 100644 --- a/lib/src/theme/radio/radio_theme.dart +++ b/lib/src/theme/radio/radio_theme.dart @@ -2,45 +2,34 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:moon_design/src/theme/radio/radio_colors.dart'; -import 'package:moon_design/src/theme/radio/radio_properties.dart'; import 'package:moon_design/src/theme/tokens/tokens.dart'; @immutable -class MoonRadioTheme extends ThemeExtension with DiagnosticableTreeMixin { +class MoonRadioTheme extends ThemeExtension + with DiagnosticableTreeMixin { /// The tokens of the Moon Design System. final MoonTokens tokens; /// The colors of the MoonRadio. final MoonRadioColors colors; - /// The properties of the MoonRadio. - final MoonRadioProperties properties; - MoonRadioTheme({ required this.tokens, MoonRadioColors? colors, - MoonRadioProperties? properties, - }) : colors = colors ?? + }) : colors = colors ?? MoonRadioColors( activeColor: tokens.colors.piccolo, inactiveColor: tokens.colors.trunks, - textColor: tokens.colors.textPrimary, - ), - properties = properties ?? - MoonRadioProperties( - textStyle: tokens.typography.body.textDefault, ); @override MoonRadioTheme copyWith({ MoonTokens? tokens, MoonRadioColors? colors, - MoonRadioProperties? properties, }) { return MoonRadioTheme( tokens: tokens ?? this.tokens, colors: colors ?? this.colors, - properties: properties ?? this.properties, ); } @@ -51,7 +40,6 @@ class MoonRadioTheme extends ThemeExtension with DiagnosticableT return MoonRadioTheme( tokens: tokens.lerp(other.tokens, t), colors: colors.lerp(other.colors, t), - properties: properties.lerp(other.properties, t), ); } @@ -61,7 +49,6 @@ class MoonRadioTheme extends ThemeExtension with DiagnosticableT diagnosticProperties ..add(DiagnosticsProperty("type", "MoonRadioTheme")) ..add(DiagnosticsProperty("tokens", tokens)) - ..add(DiagnosticsProperty("colors", colors)) - ..add(DiagnosticsProperty("properties", properties)); + ..add(DiagnosticsProperty("colors", colors)); } } diff --git a/lib/src/theme/switch/switch_sizes.dart b/lib/src/theme/switch/switch_sizes.dart index ccd788ba..75948779 100644 --- a/lib/src/theme/switch/switch_sizes.dart +++ b/lib/src/theme/switch/switch_sizes.dart @@ -5,7 +5,8 @@ import 'package:moon_design/src/theme/switch/switch_size_properties.dart'; import 'package:moon_design/src/theme/tokens/tokens.dart'; @immutable -class MoonSwitchSizes extends ThemeExtension with DiagnosticableTreeMixin { +class MoonSwitchSizes extends ThemeExtension + with DiagnosticableTreeMixin { /// The tokens of the Moon Design System. final MoonTokens tokens; @@ -30,7 +31,8 @@ class MoonSwitchSizes extends ThemeExtension with Diagnosticabl thumbSizeValue: tokens.sizes.x3s, iconSizeValue: tokens.sizes.x3s, padding: EdgeInsets.all(tokens.sizes.x6s), - textStyle: tokens.typography.caption.text6.copyWith(letterSpacing: 0), + textStyle: + tokens.typography.body.text6.copyWith(letterSpacing: 0), ), xs = xs ?? MoonSwitchSizeProperties( @@ -39,7 +41,8 @@ class MoonSwitchSizes extends ThemeExtension with Diagnosticabl thumbSizeValue: tokens.sizes.x2s, iconSizeValue: tokens.sizes.x2s, padding: EdgeInsets.all(tokens.sizes.x5s), - textStyle: tokens.typography.caption.text8.copyWith(letterSpacing: 0.1), + textStyle: + tokens.typography.body.text8.copyWith(letterSpacing: 0.1), ), sm = sm ?? MoonSwitchSizeProperties( @@ -48,7 +51,8 @@ class MoonSwitchSizes extends ThemeExtension with Diagnosticabl thumbSizeValue: tokens.sizes.xs, iconSizeValue: tokens.sizes.xs, padding: EdgeInsets.all(tokens.sizes.x5s), - textStyle: tokens.typography.caption.text10.copyWith(letterSpacing: 0.1), + textStyle: + tokens.typography.body.text10.copyWith(letterSpacing: 0.1), ); @override diff --git a/lib/src/theme/tag/tag_size_properties.dart b/lib/src/theme/tag/tag_size_properties.dart index 298d3203..e4f5c50d 100644 --- a/lib/src/theme/tag/tag_size_properties.dart +++ b/lib/src/theme/tag/tag_size_properties.dart @@ -23,12 +23,6 @@ class MoonTagSizeProperties extends ThemeExtension with D /// The text style of the MoonTag. final TextStyle textStyle; - /// The upper case text style of the MoonTag. - @Deprecated( - "Handle upper case text style properly at place of usage. This property will be removed in 1.0.0 release.", - ) - final TextStyle upperCaseTextStyle; - const MoonTagSizeProperties({ required this.borderRadius, required this.gap, @@ -36,10 +30,6 @@ class MoonTagSizeProperties extends ThemeExtension with D required this.iconSizeValue, required this.padding, required this.textStyle, - @Deprecated( - "Handle upper case text style properly at place of usage. This property will be removed in 1.0.0 release.", - ) - required this.upperCaseTextStyle, }); @override @@ -50,7 +40,6 @@ class MoonTagSizeProperties extends ThemeExtension with D double? iconSizeValue, EdgeInsetsGeometry? padding, TextStyle? textStyle, - TextStyle? upperCaseTextStyle, }) { return MoonTagSizeProperties( borderRadius: borderRadius ?? this.borderRadius, @@ -59,8 +48,6 @@ class MoonTagSizeProperties extends ThemeExtension with D iconSizeValue: iconSizeValue ?? this.iconSizeValue, padding: padding ?? this.padding, textStyle: textStyle ?? this.textStyle, - // ignore: deprecated_member_use_from_same_package - upperCaseTextStyle: upperCaseTextStyle ?? this.upperCaseTextStyle, ); } @@ -75,8 +62,6 @@ class MoonTagSizeProperties extends ThemeExtension with D iconSizeValue: lerpDouble(iconSizeValue, other.iconSizeValue, t)!, padding: EdgeInsetsGeometry.lerp(padding, other.padding, t)!, textStyle: TextStyle.lerp(textStyle, other.textStyle, t)!, - // ignore: deprecated_member_use_from_same_package - upperCaseTextStyle: TextStyle.lerp(upperCaseTextStyle, other.upperCaseTextStyle, t)!, ); } @@ -90,8 +75,6 @@ class MoonTagSizeProperties extends ThemeExtension with D ..add(DoubleProperty("height", height)) ..add(DoubleProperty("iconSizeValue", iconSizeValue)) ..add(DiagnosticsProperty("padding", padding)) - ..add(DiagnosticsProperty("textStyle", textStyle)) - // ignore: deprecated_member_use_from_same_package - ..add(DiagnosticsProperty("upperCaseTextStyle", upperCaseTextStyle)); + ..add(DiagnosticsProperty("textStyle", textStyle)); } } diff --git a/lib/src/theme/tag/tag_sizes.dart b/lib/src/theme/tag/tag_sizes.dart index d64ca6b8..f1577053 100644 --- a/lib/src/theme/tag/tag_sizes.dart +++ b/lib/src/theme/tag/tag_sizes.dart @@ -5,7 +5,8 @@ import 'package:moon_design/src/theme/tag/tag_size_properties.dart'; import 'package:moon_design/src/theme/tokens/tokens.dart'; @immutable -class MoonTagSizes extends ThemeExtension with DiagnosticableTreeMixin { +class MoonTagSizes extends ThemeExtension + with DiagnosticableTreeMixin { /// The tokens of the Moon Design System. final MoonTokens tokens; @@ -31,7 +32,6 @@ class MoonTagSizes extends ThemeExtension with DiagnosticableTreeM iconSizeValue: tokens.sizes.x3s, padding: EdgeInsets.symmetric(horizontal: tokens.sizes.x4s), textStyle: tokens.typography.body.text9, - upperCaseTextStyle: tokens.typography.caption.text9.copyWith(height: 1.4), ), xs = xs ?? MoonTagSizeProperties( @@ -41,7 +41,6 @@ class MoonTagSizes extends ThemeExtension with DiagnosticableTreeM iconSizeValue: tokens.sizes.x2s, padding: EdgeInsets.symmetric(horizontal: tokens.sizes.x4s), textStyle: tokens.typography.body.text12, - upperCaseTextStyle: tokens.typography.caption.text10.copyWith(height: 1.4), ), sm = sm ?? MoonTagSizeProperties( @@ -51,7 +50,6 @@ class MoonTagSizes extends ThemeExtension with DiagnosticableTreeM iconSizeValue: tokens.sizes.x2s, padding: EdgeInsets.symmetric(horizontal: tokens.sizes.x2s), textStyle: tokens.typography.body.text12, - upperCaseTextStyle: tokens.typography.caption.text10.copyWith(height: 1.4), ); @override diff --git a/lib/src/theme/tokens/typography/text_styles.dart b/lib/src/theme/tokens/typography/text_styles.dart index 8c64d77b..0e2857e6 100644 --- a/lib/src/theme/tokens/typography/text_styles.dart +++ b/lib/src/theme/tokens/typography/text_styles.dart @@ -2,9 +2,10 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @immutable -class MoonTextStyles extends ThemeExtension with DiagnosticableTreeMixin { - static const _semiBold = FontWeight.w500; - static const _semiBoldVariation = [FontVariation('wght', 500)]; +class MoonTextStyles extends ThemeExtension + with DiagnosticableTreeMixin { + static const _semiBold = FontWeight.w600; + static const _semiBoldVariation = [FontVariation('wght', 600)]; static const body = MoonTextStyles( textDefault: TextStyle( @@ -148,128 +149,6 @@ class MoonTextStyles extends ThemeExtension with DiagnosticableT ), ); - static const caption = MoonTextStyles( - textDefault: TextStyle( - fontSize: 14, - height: 1.2, - letterSpacing: 1, - fontVariations: _semiBoldVariation, - fontWeight: _semiBold, - ), - text6: TextStyle( - fontSize: 6, - height: 1.1, - letterSpacing: 1, - fontVariations: _semiBoldVariation, - fontWeight: _semiBold, - ), - text8: TextStyle( - fontSize: 8, - height: 1.1, - letterSpacing: 1, - fontVariations: _semiBoldVariation, - fontWeight: _semiBold, - ), - text9: TextStyle( - fontSize: 9, - height: 1.2, - letterSpacing: 1, - fontVariations: _semiBoldVariation, - fontWeight: _semiBold, - ), - text10: TextStyle( - fontSize: 10, - height: 1.2, - letterSpacing: 1, - fontVariations: _semiBoldVariation, - fontWeight: _semiBold, - ), - text12: TextStyle( - fontSize: 12, - height: 1.2, - letterSpacing: 1, - fontVariations: _semiBoldVariation, - fontWeight: _semiBold, - ), - text14: TextStyle( - fontSize: 14, - height: 1.2, - letterSpacing: 1, - fontVariations: _semiBoldVariation, - fontWeight: _semiBold, - ), - text16: TextStyle( - fontSize: 16, - height: 1.2, - letterSpacing: 1, - fontVariations: _semiBoldVariation, - fontWeight: _semiBold, - ), - text18: TextStyle( - fontSize: 18, - height: 1.2, - letterSpacing: 1, - fontVariations: _semiBoldVariation, - fontWeight: _semiBold, - ), - text20: TextStyle( - fontSize: 20, - height: 1.2, - letterSpacing: 1, - fontVariations: _semiBoldVariation, - fontWeight: _semiBold, - ), - text24: TextStyle( - fontSize: 24, - height: 1.2, - letterSpacing: 1, - fontVariations: _semiBoldVariation, - fontWeight: _semiBold, - ), - text32: TextStyle( - fontSize: 32, - height: 1.2, - letterSpacing: 1, - fontVariations: _semiBoldVariation, - fontWeight: _semiBold, - ), - text40: TextStyle( - fontSize: 40, - height: 1.2, - letterSpacing: 1, - fontVariations: _semiBoldVariation, - fontWeight: _semiBold, - ), - text48: TextStyle( - fontSize: 48, - height: 1.2, - letterSpacing: 1, - fontVariations: _semiBoldVariation, - fontWeight: _semiBold, - ), - text56: TextStyle( - fontSize: 56, - height: 1.2, - letterSpacing: 1, - fontVariations: _semiBoldVariation, - fontWeight: _semiBold, - ), - text64: TextStyle( - fontSize: 64, - height: 1.2, - letterSpacing: 1, - fontVariations: _semiBoldVariation, - fontWeight: _semiBold, - ), - text72: TextStyle( - fontSize: 72, - height: 1.2, - letterSpacing: 1, - fontVariations: _semiBoldVariation, - fontWeight: _semiBold, - ), - ); - /// The default text size. final TextStyle textDefault; diff --git a/lib/src/theme/tokens/typography/typography.dart b/lib/src/theme/tokens/typography/typography.dart index 64df6980..b6c3b53b 100644 --- a/lib/src/theme/tokens/typography/typography.dart +++ b/lib/src/theme/tokens/typography/typography.dart @@ -4,37 +4,25 @@ import 'package:flutter/material.dart'; import 'package:moon_design/src/theme/tokens/typography/text_styles.dart'; @immutable -class MoonTypography extends ThemeExtension with DiagnosticableTreeMixin { +class MoonTypography extends ThemeExtension + with DiagnosticableTreeMixin { static const typography = MoonTypography( body: MoonTextStyles.body, - caption: MoonTextStyles.caption, heading: MoonTextStyles.heading, ); /// The text styles for the body. final MoonTextStyles body; - /// The text styles for the caption. - final MoonTextStyles caption; - /// The text styles for the heading. final MoonTextStyles heading; - const MoonTypography({ - required this.body, - required this.caption, - required this.heading, - }); + const MoonTypography({required this.body, required this.heading}); @override - MoonTypography copyWith({ - MoonTextStyles? body, - MoonTextStyles? caption, - MoonTextStyles? heading, - }) { + MoonTypography copyWith({MoonTextStyles? body, MoonTextStyles? heading}) { return MoonTypography( body: body ?? this.body, - caption: caption ?? this.caption, heading: heading ?? this.heading, ); } @@ -45,7 +33,6 @@ class MoonTypography extends ThemeExtension with DiagnosticableT return MoonTypography( body: body.lerp(other.body, t), - caption: caption.lerp(other.caption, t), heading: heading.lerp(other.heading, t), ); } @@ -56,7 +43,6 @@ class MoonTypography extends ThemeExtension with DiagnosticableT properties ..add(DiagnosticsProperty("type", "MoonTypography")) ..add(DiagnosticsProperty("body", body)) - ..add(DiagnosticsProperty("caption", caption)) ..add(DiagnosticsProperty("heading", heading)); } } diff --git a/lib/src/widgets/breadcrumb/breadcrumb.dart b/lib/src/widgets/breadcrumb/breadcrumb.dart index 274956e2..4ae649b9 100644 --- a/lib/src/widgets/breadcrumb/breadcrumb.dart +++ b/lib/src/widgets/breadcrumb/breadcrumb.dart @@ -45,7 +45,7 @@ class MoonBreadcrumb extends StatefulWidget { final Widget? divider; /// The single custom widget to replace all the breadcrumb collapsed items with. - final Widget? showMoreWidget; + final MoonBreadcrumbItem? showMoreWidget; /// Creates a Moon Design breadcrumb. const MoonBreadcrumb({ @@ -69,48 +69,89 @@ class MoonBreadcrumb extends StatefulWidget { } class _MoonBreadcrumbState extends State { - bool showFullPath = false; + bool _showFullPath = false; List _buildItems() { final MoonBreadcrumbTheme? theme = context.moonTheme?.breadcrumbTheme; - final double effectiveGap = widget.gap ?? theme?.properties.gap ?? MoonSizes.sizes.x4s; + final double effectiveGap = + widget.gap ?? theme?.properties.gap ?? MoonSizes.sizes.x4s; - final Color effectiveItemTextColor = - widget.itemTextStyle?.color ?? theme?.colors.itemColor ?? MoonColors.light.textSecondary; + final Color effectiveItemTextColor = widget.itemTextStyle?.color ?? + theme?.colors.itemColor ?? + MoonColors.light.textSecondary; final Color effectiveCurrentItemTextColor = - widget.currentItemTextStyle?.color ?? theme?.colors.currentItemColor ?? MoonColors.light.textPrimary; + widget.currentItemTextStyle?.color ?? + theme?.colors.currentItemColor ?? + MoonColors.light.textPrimary; - final Color effectiveHoverEffectColor = - widget.hoverEffectColor ?? theme?.colors.hoverEffectColor ?? MoonColors.light.textPrimary; + final Color effectiveHoverEffectColor = widget.hoverEffectColor ?? + theme?.colors.hoverEffectColor ?? + MoonColors.light.textPrimary; - final TextStyle effectiveItemTextStyle = - widget.itemTextStyle ?? theme?.properties.itemTextStyle ?? MoonTextStyles.body.textDefault; + final TextStyle effectiveItemTextStyle = widget.itemTextStyle ?? + theme?.properties.itemTextStyle ?? + MoonTextStyles.body.textDefault; final TextStyle effectiveCurrentItemTextStyle = - widget.currentItemTextStyle ?? theme?.properties.currentItemTextStyle ?? MoonTextStyles.body.textDefault; + widget.currentItemTextStyle ?? + theme?.properties.currentItemTextStyle ?? + MoonTextStyles.body.textDefault; final TextStyle effectiveShowMoreItemTextStyle = - theme?.properties.showMoreItemTextStyle ?? MoonTextStyles.caption.textDefault; + theme?.properties.showMoreItemTextStyle ?? + MoonTextStyles.body.textDefault; final Duration effectiveTransitionDuration = - theme?.properties.transitionDuration ?? MoonTransitions.transitions.defaultTransitionDuration; + theme?.properties.transitionDuration ?? + MoonTransitions.transitions.defaultTransitionDuration; - final Curve effectiveTransitionCurve = - theme?.properties.transitionCurve ?? MoonTransitions.transitions.defaultTransitionCurve; + final Curve effectiveTransitionCurve = theme?.properties.transitionCurve ?? + MoonTransitions.transitions.defaultTransitionCurve; - final int resolvedItemCountToShow = showFullPath ? widget.items.length : widget.visibleItemCount; + final int resolvedItemCountToShow = + _showFullPath ? widget.items.length : widget.visibleItemCount; final List visibleItemsList = _getVisibleItems(); - final List customizedVisibleItemsList = visibleItemsList - .map( - (MoonBreadcrumbItem item) => Row( - children: [ - if (item != visibleItemsList.first) SizedBox(width: effectiveGap), - _BreadcrumbItemBuilder( - isCurrent: item == visibleItemsList.last, + final List customizedVisibleItemsList = visibleItemsList.map( + (MoonBreadcrumbItem item) { + return Row( + children: [ + if (item != visibleItemsList.first) SizedBox(width: effectiveGap), + _BreadcrumbItemBuilder( + isCurrent: item == visibleItemsList.last, + itemColor: effectiveItemTextColor, + currentItemColor: effectiveCurrentItemTextColor, + hoverEffectColor: effectiveHoverEffectColor, + decoration: widget.itemDecoration, + itemTextStyle: effectiveItemTextStyle, + currentItemTextStyle: effectiveCurrentItemTextStyle, + transitionDuration: effectiveTransitionDuration, + transitionCurve: effectiveTransitionCurve, + onTap: item.onTap, + item: item, + ), + if (item != visibleItemsList.last) ...[ + SizedBox(width: effectiveGap), + _buildDivider(), + ], + ], + ); + }, + ).toList(); + + if (widget.items.length > resolvedItemCountToShow && + resolvedItemCountToShow > 1) { + customizedVisibleItemsList.insert( + 1, + Row( + children: [ + Padding( + padding: EdgeInsets.symmetric(horizontal: effectiveGap), + child: _BreadcrumbItemBuilder( + isCurrent: false, itemColor: effectiveItemTextColor, currentItemColor: effectiveCurrentItemTextColor, hoverEffectColor: effectiveHoverEffectColor, @@ -119,38 +160,10 @@ class _MoonBreadcrumbState extends State { currentItemTextStyle: effectiveCurrentItemTextStyle, transitionDuration: effectiveTransitionDuration, transitionCurve: effectiveTransitionCurve, - onTap: item.onTap, - item: item, - ), - if (item != visibleItemsList.last) ...[ - SizedBox(width: effectiveGap), - _buildDivider(), - ], - ], - ), - ) - .toList(); - - if (widget.items.length > resolvedItemCountToShow && resolvedItemCountToShow > 1) { - customizedVisibleItemsList.insert( - 1, - Row( - children: [ - widget.showMoreWidget ?? - Padding( - padding: EdgeInsets.symmetric(horizontal: effectiveGap), - child: _BreadcrumbItemBuilder( - isCurrent: false, - itemColor: effectiveItemTextColor, - currentItemColor: effectiveCurrentItemTextColor, - hoverEffectColor: effectiveHoverEffectColor, - decoration: widget.itemDecoration, - itemTextStyle: effectiveItemTextStyle, - currentItemTextStyle: effectiveCurrentItemTextStyle, - transitionDuration: effectiveTransitionDuration, - transitionCurve: effectiveTransitionCurve, - onTap: () => setState(() => showFullPath = true), - item: MoonBreadcrumbItem( + onTap: widget.showMoreWidget?.onTap ?? + () => setState(() => _showFullPath = true), + item: widget.showMoreWidget ?? + MoonBreadcrumbItem( semanticLabel: widget.semanticLabel, label: SizedBox( width: 24, @@ -161,8 +174,8 @@ class _MoonBreadcrumbState extends State { ), ), ), - ), - ), + ), + ), _buildDivider(), ], ), @@ -170,22 +183,24 @@ class _MoonBreadcrumbState extends State { } // Restores the breadcrumb's initial collapsed state during every rebuild. - showFullPath = false; + _showFullPath = false; return customizedVisibleItemsList; } List _getVisibleItems() { - final int resolvedItemCountToShow = showFullPath ? widget.items.length : widget.visibleItemCount; + final int resolvedItemCountToShow = + _showFullPath ? widget.items.length : widget.visibleItemCount; final List visibleItems = resolvedItemCountToShow == 0 ? [] : widget.items.length > resolvedItemCountToShow ? [ widget.items[0], - ...List.generate(resolvedItemCountToShow - 1, (index) => widget.items.length - index) - .reversed - .map((int index) => widget.items[index - 1]), + ...List.generate( + resolvedItemCountToShow - 1, + (index) => widget.items.length - index, + ).reversed.map((int index) => widget.items[index - 1]), ] : widget.items; @@ -254,24 +269,28 @@ class _BreadcrumbItemBuilder extends StatefulWidget { State<_BreadcrumbItemBuilder> createState() => _BreadCrumbItemBuilderState(); } -class _BreadCrumbItemBuilderState extends State<_BreadcrumbItemBuilder> with SingleTickerProviderStateMixin { - final ColorTweenWithPremultipliedAlpha _itemColorTween = ColorTweenWithPremultipliedAlpha(); +class _BreadCrumbItemBuilderState extends State<_BreadcrumbItemBuilder> + with SingleTickerProviderStateMixin { + final ColorTweenWithPremultipliedAlpha _itemColorTween = + ColorTweenWithPremultipliedAlpha(); Animation? _itemColor; AnimationController? _animationController; - void _handleActiveEffect(bool isActive) { - isActive ? _animationController?.forward() : _animationController?.reverse(); - } + void _handleActiveEffect(bool isActive) => isActive + ? _animationController?.forward() + : _animationController?.reverse(); @override void initState() { super.initState(); - _animationController = AnimationController(duration: widget.transitionDuration, vsync: this); - - if (widget.isCurrent) _animationController?.value = 1; + _animationController = AnimationController( + duration: widget.transitionDuration, + vsync: this, + value: widget.isCurrent ? 1 : 0, + ); } @override @@ -283,14 +302,18 @@ class _BreadCrumbItemBuilderState extends State<_BreadcrumbItemBuilder> with Sin @override Widget build(BuildContext context) { - final double effectiveGap = - widget.item.gap ?? context.moonTheme?.breadcrumbTheme.properties.itemGap ?? MoonSizes.sizes.x6s; + final double effectiveGap = widget.item.gap ?? + context.moonTheme?.breadcrumbTheme.properties.itemGap ?? + MoonSizes.sizes.x6s; - final Color resolvedItemColor = widget.isCurrent ? widget.currentItemColor : widget.itemColor; + final Color resolvedItemColor = + widget.isCurrent ? widget.currentItemColor : widget.itemColor; - final Color resolvedHoverEffectColor = widget.isCurrent ? widget.currentItemColor : widget.hoverEffectColor; + final Color resolvedHoverEffectColor = + widget.isCurrent ? widget.currentItemColor : widget.hoverEffectColor; - final TextStyle resolvedTextStyle = widget.isCurrent ? widget.currentItemTextStyle : widget.itemTextStyle; + final TextStyle resolvedTextStyle = + widget.isCurrent ? widget.currentItemTextStyle : widget.itemTextStyle; _itemColor ??= _animationController!.drive( _itemColorTween.chain(CurveTween(curve: widget.transitionCurve)), @@ -304,9 +327,17 @@ class _BreadCrumbItemBuilderState extends State<_BreadcrumbItemBuilder> with Sin semanticLabel: widget.item.semanticLabel, backgroundColor: widget.decoration?.color, borderRadius: widget.decoration?.borderRadius, + propagateGesturesToChild: true, onTap: widget.onTap, - builder: (BuildContext context, bool isEnabled, bool isHovered, bool isFocused, bool isPressed) { - final bool isActive = isEnabled && (widget.isCurrent || isHovered || isPressed); + builder: ( + BuildContext context, + bool isEnabled, + bool isHovered, + bool isFocused, + bool isPressed, + ) { + final bool isActive = + isEnabled && (widget.isCurrent || isHovered || isPressed); _handleActiveEffect(isActive); diff --git a/lib/src/widgets/breadcrumb/breadcrumb_item.dart b/lib/src/widgets/breadcrumb/breadcrumb_item.dart index 5ad8b14b..2f733f6f 100644 --- a/lib/src/widgets/breadcrumb/breadcrumb_item.dart +++ b/lib/src/widgets/breadcrumb/breadcrumb_item.dart @@ -1,7 +1,8 @@ import 'package:flutter/material.dart'; class MoonBreadcrumbItem { - /// The gap between the [leading], [label] and [trailing] widgets of the breadcrumb item. + /// The gap between the [leading], [label] and [trailing] widgets of the + /// breadcrumb item. final double? gap; /// The semantic label for the breadcrumb item. @@ -9,6 +10,9 @@ class MoonBreadcrumbItem { /// The callback that is called when the breadcrumb item is tapped or pressed. /// If null, the breadcrumb item is disabled. + /// + /// For [MoonBreadcrumb.showMoreWidget], when [onTap] is null, default behavior + /// is to display all collapsed breadcrumb items. final VoidCallback? onTap; /// The widget to display before the [label] widget of the breadcrumb item. diff --git a/lib/src/widgets/checkbox/checkbox.dart b/lib/src/widgets/checkbox/checkbox.dart index 2cb0a621..678b6da0 100644 --- a/lib/src/widgets/checkbox/checkbox.dart +++ b/lib/src/widgets/checkbox/checkbox.dart @@ -5,7 +5,6 @@ import 'package:moon_design/src/theme/theme.dart'; import 'package:moon_design/src/theme/tokens/borders.dart'; import 'package:moon_design/src/theme/tokens/opacities.dart'; import 'package:moon_design/src/theme/tokens/tokens.dart'; -import 'package:moon_design/src/theme/tokens/typography/typography.dart'; import 'package:moon_design/src/utils/extensions.dart'; import 'package:moon_design/src/utils/squircle/squircle_border.dart'; import 'package:moon_design/src/utils/touch_target_padding.dart'; @@ -81,81 +80,12 @@ class MoonCheckbox extends StatefulWidget { required this.onChanged, }); - /// Creates a Moon Design checkbox with label. - @Deprecated("Use MoonMenuItem with MoonCheckbox as a trailing widget instead.") - static Widget withLabel( - BuildContext context, { - Key? key, - bool autofocus = false, - bool tristate = false, - required bool? value, - Color? activeColor, - Color? borderColor, - Color? checkColor, - Color? inactiveColor, - double tapAreaSizeValue = 40, - FocusNode? focusNode, - TextStyle? textStyle, - required String label, - required ValueChanged? onChanged, - }) { - final bool isInteractive = onChanged != null; - - final Color effectiveTextColor = context.moonTheme?.checkboxTheme.colors.textColor ?? MoonColors.light.textPrimary; - - final TextStyle effectiveTextStyle = - context.moonTheme?.checkboxTheme.properties.textStyle ?? MoonTypography.typography.body.textDefault; - - final TextStyle resolvedTextStyle = effectiveTextStyle.copyWith(color: effectiveTextColor).merge(textStyle); - - final double effectiveDisabledOpacityValue = context.moonOpacities?.disabled ?? MoonOpacities.opacities.disabled; - - final Duration effectiveFocusEffectDuration = context.moonEffects?.controlFocusEffect.effectDuration ?? - MoonEffectsTheme(tokens: MoonTokens.light).controlFocusEffect.effectDuration; - - return GestureDetector( - onTap: () => onChanged?.call(!value!), - child: MouseRegion( - cursor: isInteractive ? SystemMouseCursors.click : SystemMouseCursors.basic, - child: ConstrainedBox( - constraints: BoxConstraints(minHeight: tapAreaSizeValue), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - AnimatedOpacity( - opacity: isInteractive ? 1 : effectiveDisabledOpacityValue, - duration: effectiveFocusEffectDuration, - child: DefaultTextStyle( - style: resolvedTextStyle, - child: Text(label), - ), - ), - const SizedBox(width: 12), - MoonCheckbox( - key: key, - autofocus: autofocus, - tristate: tristate, - value: value, - activeColor: activeColor, - borderColor: borderColor, - checkColor: checkColor, - inactiveColor: inactiveColor, - tapAreaSizeValue: 0, - focusNode: focusNode, - onChanged: onChanged, - ), - ], - ), - ), - ), - ); - } - @override State createState() => _MoonCheckboxState(); } -class _MoonCheckboxState extends State with TickerProviderStateMixin, ToggleableStateMixin { +class _MoonCheckboxState extends State + with TickerProviderStateMixin, ToggleableStateMixin { final MoonCheckboxPainter _painter = MoonCheckboxPainter(); bool? _previousValue; @@ -170,7 +100,9 @@ class _MoonCheckboxState extends State with TickerProviderStateMix bool? get value => widget.value; BorderSide? _resolveSide(BorderSide? side) { - if (side is MaterialStateBorderSide) return MaterialStateProperty.resolveAs(side, states); + if (side is MaterialStateBorderSide) { + return MaterialStateProperty.resolveAs(side, states); + } if (!states.contains(MaterialState.selected)) return side; @@ -206,36 +138,55 @@ class _MoonCheckboxState extends State with TickerProviderStateMix const Size size = Size(16, 16); final BorderRadiusGeometry effectiveBorderRadius = - context.moonTheme?.checkboxTheme.properties.borderRadius ?? MoonBorders.borders.interactiveXs; - - final Color effectiveActiveColor = - widget.activeColor ?? context.moonTheme?.checkboxTheme.colors.activeColor ?? MoonColors.light.piccolo; - - final Color effectiveInactiveColor = - widget.inactiveColor ?? context.moonTheme?.checkboxTheme.colors.inactiveColor ?? Colors.transparent; - - final Color effectiveCheckColor = - widget.checkColor ?? context.moonTheme?.checkboxTheme.colors.checkColor ?? MoonColors.light.goten; - - final Color effectiveBorderColor = - widget.borderColor ?? context.moonTheme?.checkboxTheme.colors.borderColor ?? MoonColors.light.trunks; - - final Color effectiveFocusEffectColor = context.moonEffects?.controlFocusEffect.effectColor ?? - MoonEffectsTheme(tokens: MoonTokens.light).controlFocusEffect.effectColor; - - final Duration effectiveFocusEffectDuration = context.moonEffects?.controlFocusEffect.effectDuration ?? - MoonEffectsTheme(tokens: MoonTokens.light).controlFocusEffect.effectDuration; - - final Curve effectiveFocusEffectCurve = context.moonEffects?.controlFocusEffect.effectCurve ?? - MoonEffectsTheme(tokens: MoonTokens.light).controlFocusEffect.effectCurve; - - final double effectiveFocusEffectExtent = context.moonEffects?.controlFocusEffect.effectExtent ?? - MoonEffectsTheme(tokens: MoonTokens.light).controlFocusEffect.effectExtent; - - final double effectiveDisabledOpacityValue = context.moonOpacities?.disabled ?? MoonOpacities.opacities.disabled; + context.moonTheme?.checkboxTheme.properties.borderRadius ?? + MoonBorders.borders.interactiveXs; + + final Color effectiveActiveColor = widget.activeColor ?? + context.moonTheme?.checkboxTheme.colors.activeColor ?? + MoonColors.light.piccolo; + + final Color effectiveInactiveColor = widget.inactiveColor ?? + context.moonTheme?.checkboxTheme.colors.inactiveColor ?? + Colors.transparent; + + final Color effectiveCheckColor = widget.checkColor ?? + context.moonTheme?.checkboxTheme.colors.checkColor ?? + MoonColors.light.goten; + + final Color effectiveBorderColor = widget.borderColor ?? + context.moonTheme?.checkboxTheme.colors.borderColor ?? + MoonColors.light.trunks; + + final Color effectiveFocusEffectColor = + context.moonEffects?.controlFocusEffect.effectColor ?? + MoonEffectsTheme(tokens: MoonTokens.light) + .controlFocusEffect + .effectColor; + + final Duration effectiveFocusEffectDuration = + context.moonEffects?.controlFocusEffect.effectDuration ?? + MoonEffectsTheme(tokens: MoonTokens.light) + .controlFocusEffect + .effectDuration; + + final Curve effectiveFocusEffectCurve = + context.moonEffects?.controlFocusEffect.effectCurve ?? + MoonEffectsTheme(tokens: MoonTokens.light) + .controlFocusEffect + .effectCurve; + + final double effectiveFocusEffectExtent = + context.moonEffects?.controlFocusEffect.effectExtent ?? + MoonEffectsTheme(tokens: MoonTokens.light) + .controlFocusEffect + .effectExtent; + + final double effectiveDisabledOpacityValue = + context.moonOpacities?.disabled ?? MoonOpacities.opacities.disabled; final MaterialStateProperty effectiveMouseCursor = - MaterialStateProperty.resolveWith((Set states) { + MaterialStateProperty.resolveWith( + (Set states) { return MaterialStateMouseCursor.clickable.resolve(states); }); @@ -254,7 +205,9 @@ class _MoonCheckboxState extends State with TickerProviderStateMix effectDuration: effectiveFocusEffectDuration, effectExtent: effectiveFocusEffectExtent, child: AnimatedOpacity( - opacity: states.contains(MaterialState.disabled) ? effectiveDisabledOpacityValue : 1, + opacity: states.contains(MaterialState.disabled) + ? effectiveDisabledOpacityValue + : 1, duration: effectiveFocusEffectDuration, child: buildToggleable( mouseCursor: effectiveMouseCursor, @@ -268,8 +221,13 @@ class _MoonCheckboxState extends State with TickerProviderStateMix ..checkColor = effectiveCheckColor ..value = value ..previousValue = _previousValue - ..shape = MoonSquircleBorder(borderRadius: effectiveBorderRadius.squircleBorderRadius(context)) - ..side = _resolveSide(BorderSide(color: effectiveBorderColor)), + ..shape = MoonSquircleBorder( + borderRadius: + effectiveBorderRadius.squircleBorderRadius(context), + ) + ..side = _resolveSide( + BorderSide(color: effectiveBorderColor), + ), ), ), ), diff --git a/lib/src/widgets/common/moon_icon.dart b/lib/src/widgets/common/moon_icon.dart deleted file mode 100644 index c6c4ce29..00000000 --- a/lib/src/widgets/common/moon_icon.dart +++ /dev/null @@ -1,269 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; - -class MoonIcon extends StatelessWidget { - /// Creates a Moon Design icon. - /// - /// This is necessary to ensure that custom icons are rendered correctly in mobile Safari. - @Deprecated("Unnecessary with current moon_icons icon font. Use regular Icon widget instead.") - const MoonIcon( - this.icon, { - super.key, - this.size, - this.fill, - this.weight, - this.grade, - this.opticalSize, - this.color, - this.shadows, - this.semanticLabel, - this.textDirection, - }) : assert(fill == null || (0.0 <= fill && fill <= 1.0)), - assert(weight == null || (0.0 < weight)), - assert(opticalSize == null || (0.0 < opticalSize)); - - /// The icon to display. - /// - /// The available icons are described in [Icons]. - /// - /// If the icon is null, the widget will render as an empty space of the specified [size]. - final IconData? icon; - - /// The size of the icon in logical pixels. - /// - /// Icons occupy a square with width and height equal to the specified size. - /// - /// Defaults to the nearest [IconTheme]'s [IconThemeData.size]. - /// - /// When the [MoonIcon] is used within an [IconButton], it is recommended to - /// utilize the [IconButton.iconSize] property to manage both the icon's size and - /// the splash area's size. The [IconButton] uses an [IconTheme] to - /// pass down the size to the [MoonIcon]. - final double? size; - - /// The fill for drawing the icon. - /// - /// Requires the underlying icon font to support the `FILL` [FontVariation] - /// axis, otherwise has no effect. Variable font filenames often indicate - /// the supported axes. Must be between 0.0 (unfilled) and 1.0 (filled), - /// inclusive. - /// - /// Can be used to convey a state transition for animation or interaction. - /// - /// Defaults to nearest [IconTheme]'s [IconThemeData.fill]. - /// - /// See also: - /// * [weight], for controlling stroke weight. - /// * [grade], for controlling stroke weight in a more granular way. - /// * [opticalSize], for controlling optical size. - final double? fill; - - /// The stroke weight for drawing the icon. - /// - /// Requires the underlying icon font to support the `wght` [FontVariation] - /// axis, otherwise has no effect. Variable font filenames often indicate - /// the supported axes. Must be greater than 0. - /// - /// Defaults to nearest [IconTheme]'s [IconThemeData.weight]. - /// - /// See also: - /// * [fill], for controlling fill. - /// * [grade], for controlling stroke weight in a more granular way. - /// * [opticalSize], for controlling optical size. - /// * https://fonts.google.com/knowledge/glossary/weight_axis - final double? weight; - - /// The grade (granular stroke weight) for drawing the icon. - /// - /// Requires the underlying icon font to support the `GRAD` [FontVariation] - /// axis, otherwise has no effect. Variable font filenames often indicate - /// the supported axes. Can be negative. - /// - /// Grade and [weight] both affect a symbol's stroke weight (thickness), but - /// grade has a smaller impact on the size of the symbol. - /// - /// Grade is also available in some text fonts. One can match grade levels - /// between text and symbols for a harmonious visual effect. For example, if - /// the text font has a -25 grade value, the symbols can match it with a - /// suitable value, say -25. - /// - /// Defaults to nearest [IconTheme]'s [IconThemeData.grade]. - /// - /// See also: - /// * [fill], for controlling fill. - /// * [weight], for controlling stroke weight in a less granular way. - /// * [opticalSize], for controlling optical size. - /// * https://fonts.google.com/knowledge/glossary/grade_axis - final double? grade; - - /// The optical size for drawing the icon. - /// - /// Requires the underlying icon font to support the `opsz` [FontVariation] - /// axis, otherwise has no effect. Variable font filenames often indicate - /// the supported axes. Must be greater than 0. - /// - /// For an icon to look the same at different sizes, the stroke weight - /// (thickness) must change as the icon size scales. Optical size offers a way - /// to automatically adjust the stroke weight as icon size changes. - /// - /// Defaults to nearest [IconTheme]'s [IconThemeData.opticalSize]. - /// - /// See also: - /// * [fill], for controlling fill. - /// * [weight], for controlling stroke weight. - /// * [grade], for controlling stroke weight in a more granular way. - /// * https://fonts.google.com/knowledge/glossary/optical_size_axis - final double? opticalSize; - - /// The color to use when drawing the icon. - /// - /// Defaults to the nearest [IconTheme]'s [IconThemeData.color]. - /// - /// The color (whether specified explicitly here or obtained from the - /// [IconTheme]) will be further adjusted by the nearest [IconTheme]'s - /// [IconThemeData.opacity]. - /// - /// {@tool snippet} - /// Typically, a Material Design color will be used, as follows: - /// - /// ```dart - /// Icon( - /// Icons.widgets, - /// color: Colors.blue.shade400, - /// ) - /// ``` - /// {@end-tool} - final Color? color; - - /// The list of shadows that will be painted underneath the icon. - /// - /// Multiple shadows are supported to replicate lighting from multiple light - /// sources. - /// - /// Shadows must be in the same order for [MoonIcon] to be considered as - /// equivalent as order produces differing transparency. - /// - /// Defaults to the nearest [IconTheme]'s [IconThemeData.shadows]. - final List? shadows; - - /// Semantic label for the icon. - /// - /// Announced in accessibility modes (e.g TalkBack/VoiceOver). - /// This label does not show in the UI. - /// - /// * [SemanticsProperties.label], which is set to [semanticLabel] in the - /// underlying [Semantics] widget. - final String? semanticLabel; - - /// The text direction to use for rendering the icon. - /// - /// If this is null, the ambient [Directionality] is used instead. - /// - /// Some icons follow the reading direction. For example, "back" buttons point - /// left in left-to-right environments and right in right-to-left - /// environments. Such icons have their [IconData.matchTextDirection] field - /// set to true, and the [MoonIcon] widget uses the [textDirection] to determine - /// the orientation in which to draw the icon. - /// - /// This property has no effect if the [icon]'s [IconData.matchTextDirection] - /// field is false, but for consistency a text direction value must always be - /// specified, either directly using this property or using [Directionality]. - final TextDirection? textDirection; - - @override - Widget build(BuildContext context) { - assert(this.textDirection != null || debugCheckHasDirectionality(context)); - final TextDirection textDirection = this.textDirection ?? Directionality.of(context); - - final IconThemeData iconTheme = IconTheme.of(context); - - final double? iconSize = size ?? iconTheme.size; - - final double? iconFill = fill ?? iconTheme.fill; - - final double? iconWeight = weight ?? iconTheme.weight; - - final double? iconGrade = grade ?? iconTheme.grade; - - final double? iconOpticalSize = opticalSize ?? iconTheme.opticalSize; - - final List? iconShadows = shadows ?? iconTheme.shadows; - - if (icon == null) { - return Semantics( - label: semanticLabel, - child: SizedBox(width: iconSize, height: iconSize), - ); - } - - final double iconOpacity = iconTheme.opacity ?? 1.0; - Color iconColor = color ?? iconTheme.color!; - if (iconOpacity != 1.0) { - iconColor = iconColor.withOpacity(iconColor.opacity * iconOpacity); - } - - Widget iconWidget = RichText( - overflow: TextOverflow.visible, // Never clip. - textDirection: textDirection, // Since we already fetched it for the assert... - text: TextSpan( - text: String.fromCharCode(icon!.codePoint), - style: TextStyle( - fontVariations: [ - if (iconFill != null) FontVariation('FILL', iconFill), - if (iconWeight != null) FontVariation('wght', iconWeight), - if (iconGrade != null) FontVariation('GRAD', iconGrade), - if (iconOpticalSize != null) FontVariation('opsz', iconOpticalSize), - ], - inherit: false, - color: iconColor, - fontSize: iconSize, - height: 1, - fontFamily: icon!.fontFamily, - package: icon!.fontPackage, - shadows: iconShadows, - ), - ), - ); - - if (icon!.matchTextDirection) { - switch (textDirection) { - case TextDirection.rtl: - iconWidget = Transform( - transform: Matrix4.identity()..scale(-1.0, 1.0, 1.0), - alignment: Alignment.center, - transformHitTests: false, - child: iconWidget, - ); - case TextDirection.ltr: - break; - } - } - - return Semantics( - label: semanticLabel, - child: ExcludeSemantics( - child: SizedBox.square( - dimension: iconSize, - child: Center( - child: iconWidget, - ), - ), - ), - ); - } - - @override - void debugFillProperties(DiagnosticPropertiesBuilder properties) { - super.debugFillProperties(properties); - properties.add(IconDataProperty('icon', icon, ifNull: '', showName: false)); - properties.add(DoubleProperty('size', size, defaultValue: null)); - properties.add(DoubleProperty('fill', fill, defaultValue: null)); - properties.add(DoubleProperty('weight', weight, defaultValue: null)); - properties.add(DoubleProperty('grade', grade, defaultValue: null)); - properties.add(DoubleProperty('opticalSize', opticalSize, defaultValue: null)); - properties.add(ColorProperty('color', color, defaultValue: null)); - properties.add(IterableProperty('shadows', shadows, defaultValue: null)); - properties.add(StringProperty('semanticLabel', semanticLabel, defaultValue: null)); - properties.add(EnumProperty('textDirection', textDirection, defaultValue: null)); - } -} diff --git a/lib/src/widgets/drawer/drawer.dart b/lib/src/widgets/drawer/drawer.dart index 00d83cfd..4f375f1f 100644 --- a/lib/src/widgets/drawer/drawer.dart +++ b/lib/src/widgets/drawer/drawer.dart @@ -15,9 +15,6 @@ class MoonDrawer extends StatelessWidget { /// The background color of the drawer. final Color? backgroundColor; - /// The color of the drawer barrier. - final Color? barrierColor; - /// The custom decoration of the drawer. final Decoration? decoration; @@ -38,7 +35,6 @@ class MoonDrawer extends StatelessWidget { super.key, this.borderRadius, this.backgroundColor, - this.barrierColor, this.decoration, this.width, this.drawerShadows, @@ -48,28 +44,37 @@ class MoonDrawer extends StatelessWidget { @override Widget build(BuildContext context) { - final BorderRadiusGeometry effectiveBorderRadius = - borderRadius ?? context.moonTheme?.drawerTheme.properties.borderRadius ?? BorderRadius.zero; + final BorderRadiusGeometry effectiveBorderRadius = borderRadius ?? + context.moonTheme?.drawerTheme.properties.borderRadius ?? + BorderRadius.zero; - final Color effectiveBackgroundColor = - backgroundColor ?? context.moonTheme?.drawerTheme.colors.backgroundColor ?? MoonColors.light.goku; + final Color effectiveBackgroundColor = backgroundColor ?? + context.moonTheme?.drawerTheme.colors.backgroundColor ?? + MoonColors.light.goku; - final Color effectiveTextColor = context.moonTheme?.drawerTheme.colors.textColor ?? MoonColors.light.textPrimary; + final Color effectiveTextColor = + context.moonTheme?.drawerTheme.colors.textColor ?? + MoonColors.light.textPrimary; - final Color effectiveIconColor = context.moonTheme?.drawerTheme.colors.iconColor ?? MoonColors.light.iconPrimary; + final Color effectiveIconColor = + context.moonTheme?.drawerTheme.colors.iconColor ?? + MoonColors.light.iconPrimary; - final double effectiveWidthFromTheme = context.moonTheme?.drawerTheme.properties.width ?? 448; + final double effectiveWidthFromTheme = + context.moonTheme?.drawerTheme.properties.width ?? 448; final double effectiveWidth = width ?? (MediaQuery.of(context).size.width < effectiveWidthFromTheme ? MediaQuery.of(context).size.width : effectiveWidthFromTheme); - final List effectiveDrawerShadows = - drawerShadows ?? context.moonTheme?.drawerTheme.shadows.drawerShadows ?? MoonShadows.light.lg; + final List effectiveDrawerShadows = drawerShadows ?? + context.moonTheme?.drawerTheme.shadows.drawerShadows ?? + MoonShadows.light.lg; final TextStyle effectiveTextStyle = - context.moonTheme?.drawerTheme.properties.textStyle ?? MoonTypography.typography.body.textDefault; + context.moonTheme?.drawerTheme.properties.textStyle ?? + MoonTypography.typography.body.textDefault; return Semantics( explicitChildNodes: true, @@ -87,7 +92,8 @@ class MoonDrawer extends StatelessWidget { color: effectiveBackgroundColor, shadows: effectiveDrawerShadows, shape: MoonSquircleBorder( - borderRadius: effectiveBorderRadius.squircleBorderRadius(context), + borderRadius: + effectiveBorderRadius.squircleBorderRadius(context), ), ), child: child, diff --git a/lib/src/widgets/progress/linear_progress.dart b/lib/src/widgets/progress/linear_progress.dart index 0717801b..174eef1e 100644 --- a/lib/src/widgets/progress/linear_progress.dart +++ b/lib/src/widgets/progress/linear_progress.dart @@ -30,7 +30,8 @@ class MoonLinearProgress extends StatelessWidget { /// Whether the pin height is added to the linear progress height. /// Applies only when both this and [showPin] are true. - /// Otherwise, the pin acts as an overlay without affecting the linear progress height. + /// Otherwise, the pin acts as an overlay without affecting the linear + /// progress height. final bool pinAffectsHeight; /// The border radius of the linear progress. @@ -48,7 +49,8 @@ class MoonLinearProgress extends StatelessWidget { /// The height of the linear progress. final double? height; - /// The vertical gap between the linear progress and the [minLabel] and [maxLabel] widgets. + /// The vertical gap between the linear progress and the [minLabel] and + /// [maxLabel] widgets. /// /// Has effect only if [showMinLabel] and [showMaxLabel] are true. final double? verticalGap; @@ -120,13 +122,17 @@ class MoonLinearProgress extends StatelessWidget { @override Widget build(BuildContext context) { - final MoonLinearProgressSizeProperties effectiveProgressSize = _getMoonProgressSize(context, linearProgressSize); + final MoonLinearProgressSizeProperties effectiveProgressSize = + _getMoonProgressSize(context, linearProgressSize); - final BorderRadiusGeometry effectiveBorderRadius = borderRadius ?? effectiveProgressSize.borderRadius; + final BorderRadiusGeometry effectiveBorderRadius = + borderRadius ?? effectiveProgressSize.borderRadius; - // This is used to ensure that the corners of the progress bar properly touch the thumb with bigger bar variants. + // This is used to ensure that the corners of the progress bar properly + // touch the thumb with bigger bar variants. final BorderRadiusGeometry progressRadius = switch (effectiveBorderRadius) { - BorderRadiusDirectional() when showPin == true => BorderRadiusDirectional.only( + BorderRadiusDirectional() when showPin == true => + BorderRadiusDirectional.only( topStart: effectiveBorderRadius.topStart, bottomStart: effectiveBorderRadius.bottomStart, ), @@ -137,39 +143,50 @@ class MoonLinearProgress extends StatelessWidget { _ => effectiveBorderRadius, }; - final Color effectiveColor = - color ?? context.moonTheme?.linearProgressTheme.colors.color ?? MoonColors.light.piccolo; + final Color effectiveColor = color ?? + context.moonTheme?.linearProgressTheme.colors.color ?? + MoonColors.light.piccolo; - final Color effectiveBackgroundColor = - backgroundColor ?? context.moonTheme?.linearProgressTheme.colors.backgroundColor ?? MoonColors.light.beerus; + final Color effectiveBackgroundColor = backgroundColor ?? + context.moonTheme?.linearProgressTheme.colors.backgroundColor ?? + MoonColors.light.beerus; - final Color effectiveTextColor = - textColor ?? context.moonTheme?.linearProgressTheme.colors.textColor ?? MoonColors.light.textPrimary; + final Color effectiveTextColor = textColor ?? + context.moonTheme?.linearProgressTheme.colors.textColor ?? + MoonColors.light.textPrimary; - final double effectiveHeight = height ?? effectiveProgressSize.progressHeight; + final double effectiveHeight = + height ?? effectiveProgressSize.progressHeight; - final double effectiveVerticalGap = verticalGap ?? effectiveProgressSize.verticalGap; + final double effectiveVerticalGap = + verticalGap ?? effectiveProgressSize.verticalGap; final double effectiveThumbSizeValue = - // ignore: deprecated_member_use_from_same_package - (pinStyle?.thumbSizeValue ?? pinStyle?.thumbWidth) ?? effectiveProgressSize.thumbSizeValue; + pinStyle?.thumbSizeValue ?? effectiveProgressSize.thumbSizeValue; - final double effectivePinWidth = - pinStyle?.pinWidth ?? context.moonTheme?.progressPinTheme.properties.pinWidth ?? 36; + final double effectivePinWidth = pinStyle?.pinWidth ?? + context.moonTheme?.progressPinTheme.properties.pinWidth ?? + 36; - final double effectivePinDistance = - pinStyle?.pinDistance ?? context.moonTheme?.progressPinTheme.properties.pinDistance ?? MoonSizes.sizes.x5s; + final double effectivePinDistance = pinStyle?.pinDistance ?? + context.moonTheme?.progressPinTheme.properties.pinDistance ?? + MoonSizes.sizes.x5s; - final double effectivePinArrowHeight = - pinStyle?.arrowHeight ?? context.moonTheme?.progressPinTheme.properties.arrowHeight ?? 6; + final double effectivePinArrowHeight = pinStyle?.arrowHeight ?? + context.moonTheme?.progressPinTheme.properties.arrowHeight ?? + 6; final TextStyle effectiveTextStyle = effectiveProgressSize.textStyle; final double resolvedPaddingValue = - effectiveThumbSizeValue - effectiveHeight > 0 ? effectiveThumbSizeValue / 2 - effectiveHeight / 2 : 0; + effectiveThumbSizeValue - effectiveHeight > 0 + ? effectiveThumbSizeValue / 2 - effectiveHeight / 2 + : 0; - final double heightWithPin = - effectivePinWidth + effectivePinArrowHeight + effectivePinDistance + effectiveThumbSizeValue; + final double heightWithPin = effectivePinWidth + + effectivePinArrowHeight + + effectivePinDistance + + effectiveThumbSizeValue; Widget child = MoonLinearProgressIndicator( value: value, @@ -200,7 +217,8 @@ class MoonLinearProgress extends StatelessWidget { if (showMinLabel) Expanded( child: DefaultTextStyle( - style: effectiveTextStyle.copyWith(color: effectiveTextColor), + style: + effectiveTextStyle.copyWith(color: effectiveTextColor), child: Align( alignment: AlignmentDirectional.centerStart, child: minLabel ?? const Text("0%"), @@ -210,7 +228,8 @@ class MoonLinearProgress extends StatelessWidget { if (showMaxLabel) Expanded( child: DefaultTextStyle( - style: effectiveTextStyle.copyWith(color: effectiveTextColor), + style: + effectiveTextStyle.copyWith(color: effectiveTextColor), child: Align( alignment: AlignmentDirectional.centerEnd, child: maxLabel ?? const Text("100%"), diff --git a/lib/src/widgets/progress_pin/pin_style.dart b/lib/src/widgets/progress_pin/pin_style.dart index 71e8e208..7bc47d47 100644 --- a/lib/src/widgets/progress_pin/pin_style.dart +++ b/lib/src/widgets/progress_pin/pin_style.dart @@ -22,10 +22,6 @@ class PinStyle { /// The width of the progress pin arrow. final double? arrowWidth; - /// The width of the progress thumb. - @Deprecated("Use thumbSizeValue instead") - final double? thumbWidth; - /// The size value of the progress thumb. final double? thumbSizeValue; @@ -53,7 +49,6 @@ class PinStyle { this.shadowColor, this.arrowHeight, this.arrowWidth, - @Deprecated("Use thumbSizeValue instead") this.thumbWidth, this.thumbSizeValue, this.pinWidth, this.pinBorderWidth, @@ -70,7 +65,6 @@ class PinStyle { Color? shadowColor, double? arrowHeight, double? arrowWidth, - double? thumbWidth, double? thumbSizeValue, double? pinWidth, double? pinBorderWidth, @@ -86,8 +80,6 @@ class PinStyle { shadowColor: shadowColor ?? this.shadowColor, arrowHeight: arrowHeight ?? this.arrowHeight, arrowWidth: arrowWidth ?? this.arrowWidth, - // ignore: deprecated_member_use_from_same_package - thumbWidth: thumbWidth ?? this.thumbWidth, thumbSizeValue: thumbSizeValue ?? this.thumbSizeValue, pinWidth: pinWidth ?? this.pinWidth, pinBorderWidth: pinBorderWidth ?? this.pinBorderWidth, diff --git a/lib/src/widgets/progress_pin/progress_pin.dart b/lib/src/widgets/progress_pin/progress_pin.dart index 15c74402..8a3537ed 100644 --- a/lib/src/widgets/progress_pin/progress_pin.dart +++ b/lib/src/widgets/progress_pin/progress_pin.dart @@ -24,43 +24,53 @@ class MoonProgressPin extends StatelessWidget { @override Widget build(BuildContext context) { - final Color effectivePinColor = - pinStyle?.pinColor ?? context.moonTheme?.progressPinTheme.colors.pinColor ?? MoonColors.light.popo; + final Color effectivePinColor = pinStyle?.pinColor ?? + context.moonTheme?.progressPinTheme.colors.pinColor ?? + MoonColors.light.popo; - final Color effectivePinBorderColor = - pinStyle?.pinBorderColor ?? context.moonTheme?.progressPinTheme.colors.pinBorderColor ?? MoonColors.light.goten; + final Color effectivePinBorderColor = pinStyle?.pinBorderColor ?? + context.moonTheme?.progressPinTheme.colors.pinBorderColor ?? + MoonColors.light.goten; - final Color effectiveThumbColor = - pinStyle?.thumbColor ?? context.moonTheme?.progressPinTheme.colors.thumbColor ?? MoonColors.light.goten; + final Color effectiveThumbColor = pinStyle?.thumbColor ?? + context.moonTheme?.progressPinTheme.colors.thumbColor ?? + MoonColors.light.goten; - final Color effectiveShadowColor = - pinStyle?.shadowColor ?? context.moonTheme?.progressPinTheme.colors.shadowColor ?? MoonColors.light.popo; + final Color effectiveShadowColor = pinStyle?.shadowColor ?? + context.moonTheme?.progressPinTheme.colors.shadowColor ?? + MoonColors.light.popo; - final Color effectiveTextColor = - pinStyle?.textStyle?.color ?? context.moonTheme?.progressPinTheme.colors.textColor ?? MoonColors.light.goten; + final Color effectiveTextColor = pinStyle?.textStyle?.color ?? + context.moonTheme?.progressPinTheme.colors.textColor ?? + MoonColors.light.goten; final TextStyle effectiveTextStyle = pinStyle?.textStyle ?? context.moonTheme?.progressPinTheme.properties.textStyle ?? - MoonTypography.typography.caption.text10; + MoonTypography.typography.body.text10; - final double effectivePinWidth = - pinStyle?.pinWidth ?? context.moonTheme?.progressPinTheme.properties.pinWidth ?? 36; + final double effectivePinWidth = pinStyle?.pinWidth ?? + context.moonTheme?.progressPinTheme.properties.pinWidth ?? + 36; final double effectivePinBorderWidth = pinStyle?.pinBorderWidth ?? context.moonTheme?.progressPinTheme.properties.pinBorderWidth ?? MoonSizes.sizes.x6s; - final double effectivePinDistance = - pinStyle?.pinDistance ?? context.moonTheme?.progressPinTheme.properties.pinDistance ?? MoonSizes.sizes.x5s; + final double effectivePinDistance = pinStyle?.pinDistance ?? + context.moonTheme?.progressPinTheme.properties.pinDistance ?? + MoonSizes.sizes.x5s; - final double effectiveArrowHeight = - pinStyle?.arrowHeight ?? context.moonTheme?.progressPinTheme.properties.arrowHeight ?? 6; + final double effectiveArrowHeight = pinStyle?.arrowHeight ?? + context.moonTheme?.progressPinTheme.properties.arrowHeight ?? + 6; - final double effectiveArrowWidth = - pinStyle?.arrowWidth ?? context.moonTheme?.progressPinTheme.properties.arrowWidth ?? MoonSizes.sizes.x4s; + final double effectiveArrowWidth = pinStyle?.arrowWidth ?? + context.moonTheme?.progressPinTheme.properties.arrowWidth ?? + MoonSizes.sizes.x4s; - final double effectiveShadowElevation = - pinStyle?.shadowElevation ?? context.moonTheme?.progressPinTheme.properties.shadowElevation ?? 6; + final double effectiveShadowElevation = pinStyle?.shadowElevation ?? + context.moonTheme?.progressPinTheme.properties.shadowElevation ?? + 6; final TextDirection effectiveTextDirection = Directionality.of(context); @@ -76,8 +86,7 @@ class MoonProgressPin extends StatelessWidget { arrowWidth: effectiveArrowWidth, pinDistance: effectivePinDistance, pinWidth: effectivePinWidth, - // ignore: deprecated_member_use_from_same_package - thumbSizeValue: pinStyle?.thumbSizeValue ?? pinStyle?.thumbWidth, + thumbSizeValue: pinStyle?.thumbSizeValue, progressValue: progressValue, shadowElevation: effectiveShadowElevation, pinText: pinText, diff --git a/lib/src/widgets/radio/radio.dart b/lib/src/widgets/radio/radio.dart index a123aaff..942cd414 100644 --- a/lib/src/widgets/radio/radio.dart +++ b/lib/src/widgets/radio/radio.dart @@ -4,7 +4,6 @@ import 'package:moon_design/src/theme/effects/effects_theme.dart'; import 'package:moon_design/src/theme/theme.dart'; import 'package:moon_design/src/theme/tokens/opacities.dart'; import 'package:moon_design/src/theme/tokens/tokens.dart'; -import 'package:moon_design/src/theme/tokens/typography/typography.dart'; import 'package:moon_design/src/utils/touch_target_padding.dart'; import 'package:moon_design/src/widgets/common/effects/focus_effect.dart'; import 'package:moon_design/src/widgets/radio/radio_painter.dart'; @@ -81,82 +80,14 @@ class MoonRadio extends StatefulWidget { required this.onChanged, }); - /// Creates a Moon Design radio button with label. - @Deprecated("Use MoonMenuItem with MoonRadio as a trailing widget instead.") - static Widget withLabel( - BuildContext context, { - Key? key, - bool autofocus = false, - bool toggleable = false, - Color? activeColor, - Color? inactiveColor, - double tapAreaSizeValue = 40, - FocusNode? focusNode, - TextStyle? textStyle, - required String label, - required T value, - required T? groupValue, - required ValueChanged? onChanged, - }) { - final bool isInteractive = onChanged != null; - - final Color effectiveTextColor = context.moonTheme?.radioTheme.colors.textColor ?? MoonColors.light.textPrimary; - - final TextStyle effectiveTextStyle = - context.moonTheme?.radioTheme.properties.textStyle ?? MoonTypography.typography.body.textDefault; - - final TextStyle resolvedTextStyle = effectiveTextStyle.copyWith(color: effectiveTextColor).merge(textStyle); - - final double effectiveDisabledOpacityValue = context.moonOpacities?.disabled ?? MoonOpacities.opacities.disabled; - - final Duration effectiveFocusEffectDuration = context.moonEffects?.controlFocusEffect.effectDuration ?? - MoonEffectsTheme(tokens: MoonTokens.light).controlFocusEffect.effectDuration; - - return GestureDetector( - onTap: () => onChanged?.call(value), - behavior: HitTestBehavior.opaque, - child: MouseRegion( - cursor: isInteractive ? SystemMouseCursors.click : SystemMouseCursors.basic, - child: ConstrainedBox( - constraints: BoxConstraints(minHeight: tapAreaSizeValue), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - AnimatedOpacity( - opacity: isInteractive ? 1 : effectiveDisabledOpacityValue, - duration: effectiveFocusEffectDuration, - child: DefaultTextStyle( - style: resolvedTextStyle, - child: Text(label), - ), - ), - const SizedBox(width: 12), - MoonRadio( - key: key, - value: value, - groupValue: groupValue, - onChanged: onChanged, - toggleable: toggleable, - tapAreaSizeValue: 0, - activeColor: activeColor, - inactiveColor: inactiveColor, - focusNode: focusNode, - autofocus: autofocus, - ), - ], - ), - ), - ), - ); - } - bool get _selected => value == groupValue; @override State> createState() => _RadioState(); } -class _RadioState extends State> with TickerProviderStateMixin, ToggleableStateMixin { +class _RadioState extends State> + with TickerProviderStateMixin, ToggleableStateMixin { final MoonRadioPainter _painter = MoonRadioPainter(); void _handleChanged(bool? selected) { @@ -174,9 +105,7 @@ class _RadioState extends State> with TickerProviderStateMixin, void didUpdateWidget(MoonRadio oldWidget) { super.didUpdateWidget(oldWidget); - if (widget._selected != oldWidget._selected) { - animateToValue(); - } + if (widget._selected != oldWidget._selected) animateToValue(); } @override @@ -187,7 +116,8 @@ class _RadioState extends State> with TickerProviderStateMixin, } @override - ValueChanged? get onChanged => widget.onChanged != null ? _handleChanged : null; + ValueChanged? get onChanged => + widget.onChanged != null ? _handleChanged : null; @override bool get tristate => widget.toggleable; @@ -199,28 +129,44 @@ class _RadioState extends State> with TickerProviderStateMixin, Widget build(BuildContext context) { const Size size = Size(16, 16); - final Color effectiveActiveColor = - widget.activeColor ?? context.moonTheme?.radioTheme.colors.activeColor ?? MoonColors.light.piccolo; - - final Color effectiveInactiveColor = - widget.inactiveColor ?? context.moonTheme?.radioTheme.colors.inactiveColor ?? MoonColors.light.trunks; - - final Color effectiveFocusEffectColor = context.moonEffects?.controlFocusEffect.effectColor ?? - MoonEffectsTheme(tokens: MoonTokens.light).controlFocusEffect.effectColor; - - final double effectiveFocusEffectExtent = context.moonEffects?.controlFocusEffect.effectExtent ?? - MoonEffectsTheme(tokens: MoonTokens.light).controlFocusEffect.effectExtent; - - final Duration effectiveFocusEffectDuration = context.moonEffects?.controlFocusEffect.effectDuration ?? - MoonEffectsTheme(tokens: MoonTokens.light).controlFocusEffect.effectDuration; - - final Curve effectiveFocusEffectCurve = context.moonEffects?.controlFocusEffect.effectCurve ?? - MoonEffectsTheme(tokens: MoonTokens.light).controlFocusEffect.effectCurve; - - final double effectiveDisabledOpacityValue = context.moonOpacities?.disabled ?? MoonOpacities.opacities.disabled; + final Color effectiveActiveColor = widget.activeColor ?? + context.moonTheme?.radioTheme.colors.activeColor ?? + MoonColors.light.piccolo; + + final Color effectiveInactiveColor = widget.inactiveColor ?? + context.moonTheme?.radioTheme.colors.inactiveColor ?? + MoonColors.light.trunks; + + final Color effectiveFocusEffectColor = + context.moonEffects?.controlFocusEffect.effectColor ?? + MoonEffectsTheme(tokens: MoonTokens.light) + .controlFocusEffect + .effectColor; + + final double effectiveFocusEffectExtent = + context.moonEffects?.controlFocusEffect.effectExtent ?? + MoonEffectsTheme(tokens: MoonTokens.light) + .controlFocusEffect + .effectExtent; + + final Duration effectiveFocusEffectDuration = + context.moonEffects?.controlFocusEffect.effectDuration ?? + MoonEffectsTheme(tokens: MoonTokens.light) + .controlFocusEffect + .effectDuration; + + final Curve effectiveFocusEffectCurve = + context.moonEffects?.controlFocusEffect.effectCurve ?? + MoonEffectsTheme(tokens: MoonTokens.light) + .controlFocusEffect + .effectCurve; + + final double effectiveDisabledOpacityValue = + context.moonOpacities?.disabled ?? MoonOpacities.opacities.disabled; final MaterialStateProperty effectiveMouseCursor = - MaterialStateProperty.resolveWith((Set states) { + MaterialStateProperty.resolveWith( + (Set states) { return MaterialStateMouseCursor.clickable.resolve(states); }); @@ -239,7 +185,9 @@ class _RadioState extends State> with TickerProviderStateMixin, effectDuration: effectiveFocusEffectDuration, child: RepaintBoundary( child: AnimatedOpacity( - opacity: states.contains(MaterialState.disabled) ? effectiveDisabledOpacityValue : 1, + opacity: states.contains(MaterialState.disabled) + ? effectiveDisabledOpacityValue + : 1, duration: effectiveFocusEffectDuration, child: buildToggleable( focusNode: widget.focusNode, diff --git a/lib/src/widgets/tag/tag.dart b/lib/src/widgets/tag/tag.dart index ebb5e6b8..9895cf4a 100644 --- a/lib/src/widgets/tag/tag.dart +++ b/lib/src/widgets/tag/tag.dart @@ -16,13 +16,6 @@ enum MoonTagSize { } class MoonTag extends StatelessWidget { - /// Whether to use the upper case text style for the tag. - @Deprecated( - "Handle upper case text style properly at place of usage. " - "This property will be removed in 1.0.0 release.", - ) - final bool isUpperCase; - /// The border radius of the tag. final BorderRadiusGeometry? borderRadius; @@ -68,11 +61,6 @@ class MoonTag extends StatelessWidget { /// Creates a Moon Design tag. const MoonTag({ super.key, - @Deprecated( - "Handle upper case text style properly at place of usage. " - "This property will be removed in 1.0.0 release.", - ) - this.isUpperCase = false, this.borderRadius, this.backgroundColor, this.height, @@ -179,15 +167,9 @@ class MoonTag extends StatelessWidget { size: effectiveMoonTagSize.iconSizeValue, ), child: DefaultTextStyle( - // ignore: deprecated_member_use_from_same_package - style: isUpperCase - // ignore: deprecated_member_use_from_same_package - ? effectiveMoonTagSize.upperCaseTextStyle.copyWith( - color: effectiveTextColor, - ) - : effectiveMoonTagSize.textStyle.copyWith( - color: effectiveTextColor, - ), + style: effectiveMoonTagSize.textStyle.copyWith( + color: effectiveTextColor, + ), child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, diff --git a/release-please-config.json b/release-please-config.json index 915f5f2e..4aafd32c 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -3,8 +3,6 @@ "packages": { ".": { "release-type": "dart", - "bump-minor-pre-major": true, - "bump-patch-for-minor-pre-major": false, "draft": false, "prerelease": false, "extra-files": [