From 1b1a0656dc2efec336fc1825b4c0971e80d81a94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Tue, 21 Feb 2023 09:54:19 +0100 Subject: [PATCH] fix(ui_components-ui_kit): fix, clean and unify logic and code after rebase --- .../lib/src/core/utils/theme_resolver.dart | 22 ++- .../buttons/file_selection_button_style.dart | 34 +--- .../file_selection_button_style.g.dart | 152 ++++++++++++++++++ .../entities/buttons/flat_button_style.dart | 29 +--- .../entities/buttons/flat_button_style.g.dart | 137 ++++++++++++++++ .../buttons/simple_icon_button_style.dart | 29 +--- .../buttons/simple_icon_button_style.g.dart | 141 ++++++++++++++++ .../entities/buttons/symbol_button_style.dart | 31 +--- .../buttons/symbol_button_style.g.dart | 150 +++++++++++++++++ .../lib/src/domain/entities/loader_style.dart | 17 +- .../src/domain/entities/loader_style.g.dart | 67 ++++++++ .../rich_text_builder_style.dart | 17 +- .../rich_text_builder_style.g.dart | 71 ++++++++ .../text_inputs/text_input_style.dart | 6 +- .../lib/src/domain/entities/theme_style.dart | 8 +- .../file_selection_button_screen.dart | 2 +- .../file_selection_button_theme_resolver.dart | 6 +- .../flat_button/flat_button_screen.dart | 2 +- .../flat_button_theme_resolver.dart | 4 +- .../simple_icon_button_theme_resolver.dart | 4 +- .../simple_icon_screen.dart | 2 +- .../symbol_button/symbol_button_screen.dart | 2 +- .../symbol_button_theme_resolver.dart | 6 +- .../lib/src/components/loader/loader.dart | 10 -- .../loader/loader_theme_resolver.dart | 17 +- .../rich_text_builder/rich_text_builder.dart | 10 -- .../rich_text_builder_theme_resolver.dart | 18 ++- .../text_inputs/text_input_screen.dart | 7 +- .../text_input_theme_resolver.dart | 9 +- 29 files changed, 787 insertions(+), 223 deletions(-) create mode 100644 packages/wyatt_ui_components/lib/src/domain/entities/buttons/file_selection_button_style.g.dart create mode 100644 packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_style.g.dart create mode 100644 packages/wyatt_ui_components/lib/src/domain/entities/buttons/simple_icon_button_style.g.dart create mode 100644 packages/wyatt_ui_components/lib/src/domain/entities/buttons/symbol_button_style.g.dart create mode 100644 packages/wyatt_ui_components/lib/src/domain/entities/loader_style.g.dart create mode 100644 packages/wyatt_ui_components/lib/src/domain/entities/rich_text_builder/rich_text_builder_style.g.dart diff --git a/packages/wyatt_ui_components/lib/src/core/utils/theme_resolver.dart b/packages/wyatt_ui_components/lib/src/core/utils/theme_resolver.dart index c77e588b..4626fb50 100644 --- a/packages/wyatt_ui_components/lib/src/core/utils/theme_resolver.dart +++ b/packages/wyatt_ui_components/lib/src/core/utils/theme_resolver.dart @@ -35,59 +35,55 @@ abstract class ThemeResolver, T, E> { /// {@macro theme_resolver} const ThemeResolver(); - S? Function(BuildContext context, S extensionValue, {E? extra}) - get customStyleFn; + S? Function(BuildContext context, {E? extra}) get customStyleFn; /// Compute default value from Flutter Theme or with hardcoded values. S computeDefaultValue(BuildContext context, {E? extra}); S? computeExtensionValueFn( BuildContext context, - S defaultValue, T themeExtension, { E? extra, }); /// Compute values from the extension if found S? _computeExtensionValue( - BuildContext context, - S defaultValue, { + BuildContext context, { E? extra, }) { final themeExtension = Theme.of(context).extension(); if (themeExtension != null) { return computeExtensionValueFn( context, - defaultValue, themeExtension, extra: extra, ); } - return defaultValue; + return null; } /// Compute custom value S? _computeCustomValue( - BuildContext context, - S previousPhaseValue, { + BuildContext context, { E? extra, }) { final customStyle = customStyleFn( context, - previousPhaseValue, extra: extra, ); if (customStyle != null) { return customStyle; } - return previousPhaseValue; + return null; } /// Choose most suitable style for a given context. S negotiate(BuildContext context, {E? extra}) { S style = computeDefaultValue(context, extra: extra); - style = _computeExtensionValue(context, style, extra: extra) ?? style; - style = _computeCustomValue(context, style, extra: extra) ?? style; + style = + style.mergeWith(_computeExtensionValue(context, extra: extra)) ?? style; + style = + style.mergeWith(_computeCustomValue(context, extra: extra)) ?? style; return style; } } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/file_selection_button_style.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/file_selection_button_style.dart index 75fc9a42..8585273e 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/file_selection_button_style.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/file_selection_button_style.dart @@ -16,10 +16,13 @@ import 'dart:ui'; +import 'package:copy_with_extension/copy_with_extension.dart'; import 'package:flutter/widgets.dart'; import 'package:wyatt_ui_components/src/core/utils/multi_color.dart'; import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart'; +part 'file_selection_button_style.g.dart'; +@CopyWith() class FileSelectionButtonStyle extends ButtonStyle { const FileSelectionButtonStyle({ this.title, @@ -106,35 +109,4 @@ class FileSelectionButtonStyle extends ButtonStyle { @override FileSelectionButtonStyle mergeWith(FileSelectionButtonStyle? other) => FileSelectionButtonStyle.merge(this, other)!; - - @override - FileSelectionButtonStyle? lerpWith( - FileSelectionButtonStyle? other, - double t, - ) => - FileSelectionButtonStyle.lerp(this, other, t); - - @override - FileSelectionButtonStyle copyWith({ - TextStyle? title, - TextStyle? subTitle, - BorderRadiusGeometry? radius, - EdgeInsetsGeometry? padding, - MultiColor? foregroundColors, - MultiColor? backgroundColors, - MultiColor? borderColors, - double? stroke, - BoxShadow? shadow, - }) => - FileSelectionButtonStyle( - title: title ?? this.title, - subTitle: subTitle ?? this.subTitle, - radius: radius ?? this.radius, - padding: padding ?? this.padding, - foregroundColors: foregroundColors ?? this.foregroundColors, - backgroundColors: backgroundColors ?? this.backgroundColors, - borderColors: borderColors ?? this.borderColors, - stroke: stroke ?? this.stroke, - shadow: shadow ?? this.shadow, - ); } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/file_selection_button_style.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/file_selection_button_style.g.dart new file mode 100644 index 00000000..6576a261 --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/file_selection_button_style.g.dart @@ -0,0 +1,152 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'file_selection_button_style.dart'; + +// ************************************************************************** +// CopyWithGenerator +// ************************************************************************** + +abstract class _$FileSelectionButtonStyleCWProxy { + FileSelectionButtonStyle title(TextStyle? title); + + FileSelectionButtonStyle subTitle(TextStyle? subTitle); + + FileSelectionButtonStyle radius(BorderRadiusGeometry? radius); + + FileSelectionButtonStyle padding(EdgeInsetsGeometry? padding); + + FileSelectionButtonStyle foregroundColors(MultiColor? foregroundColors); + + FileSelectionButtonStyle backgroundColors(MultiColor? backgroundColors); + + FileSelectionButtonStyle borderColors(MultiColor? borderColors); + + FileSelectionButtonStyle stroke(double? stroke); + + FileSelectionButtonStyle shadow(BoxShadow? shadow); + + /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `FileSelectionButtonStyle(...).copyWith.fieldName(...)` to override fields one at a time with nullification support. + /// + /// Usage + /// ```dart + /// FileSelectionButtonStyle(...).copyWith(id: 12, name: "My name") + /// ```` + FileSelectionButtonStyle call({ + TextStyle? title, + TextStyle? subTitle, + BorderRadiusGeometry? radius, + EdgeInsetsGeometry? padding, + MultiColor? foregroundColors, + MultiColor? backgroundColors, + MultiColor? borderColors, + double? stroke, + BoxShadow? shadow, + }); +} + +/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfFileSelectionButtonStyle.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfFileSelectionButtonStyle.copyWith.fieldName(...)` +class _$FileSelectionButtonStyleCWProxyImpl + implements _$FileSelectionButtonStyleCWProxy { + const _$FileSelectionButtonStyleCWProxyImpl(this._value); + + final FileSelectionButtonStyle _value; + + @override + FileSelectionButtonStyle title(TextStyle? title) => this(title: title); + + @override + FileSelectionButtonStyle subTitle(TextStyle? subTitle) => + this(subTitle: subTitle); + + @override + FileSelectionButtonStyle radius(BorderRadiusGeometry? radius) => + this(radius: radius); + + @override + FileSelectionButtonStyle padding(EdgeInsetsGeometry? padding) => + this(padding: padding); + + @override + FileSelectionButtonStyle foregroundColors(MultiColor? foregroundColors) => + this(foregroundColors: foregroundColors); + + @override + FileSelectionButtonStyle backgroundColors(MultiColor? backgroundColors) => + this(backgroundColors: backgroundColors); + + @override + FileSelectionButtonStyle borderColors(MultiColor? borderColors) => + this(borderColors: borderColors); + + @override + FileSelectionButtonStyle stroke(double? stroke) => this(stroke: stroke); + + @override + FileSelectionButtonStyle shadow(BoxShadow? shadow) => this(shadow: shadow); + + @override + + /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `FileSelectionButtonStyle(...).copyWith.fieldName(...)` to override fields one at a time with nullification support. + /// + /// Usage + /// ```dart + /// FileSelectionButtonStyle(...).copyWith(id: 12, name: "My name") + /// ```` + FileSelectionButtonStyle call({ + Object? title = const $CopyWithPlaceholder(), + Object? subTitle = const $CopyWithPlaceholder(), + Object? radius = const $CopyWithPlaceholder(), + Object? padding = const $CopyWithPlaceholder(), + Object? foregroundColors = const $CopyWithPlaceholder(), + Object? backgroundColors = const $CopyWithPlaceholder(), + Object? borderColors = const $CopyWithPlaceholder(), + Object? stroke = const $CopyWithPlaceholder(), + Object? shadow = const $CopyWithPlaceholder(), + }) { + return FileSelectionButtonStyle( + title: title == const $CopyWithPlaceholder() + ? _value.title + // ignore: cast_nullable_to_non_nullable + : title as TextStyle?, + subTitle: subTitle == const $CopyWithPlaceholder() + ? _value.subTitle + // ignore: cast_nullable_to_non_nullable + : subTitle as TextStyle?, + radius: radius == const $CopyWithPlaceholder() + ? _value.radius + // ignore: cast_nullable_to_non_nullable + : radius as BorderRadiusGeometry?, + padding: padding == const $CopyWithPlaceholder() + ? _value.padding + // ignore: cast_nullable_to_non_nullable + : padding as EdgeInsetsGeometry?, + foregroundColors: foregroundColors == const $CopyWithPlaceholder() + ? _value.foregroundColors + // ignore: cast_nullable_to_non_nullable + : foregroundColors as MultiColor?, + backgroundColors: backgroundColors == const $CopyWithPlaceholder() + ? _value.backgroundColors + // ignore: cast_nullable_to_non_nullable + : backgroundColors as MultiColor?, + borderColors: borderColors == const $CopyWithPlaceholder() + ? _value.borderColors + // ignore: cast_nullable_to_non_nullable + : borderColors as MultiColor?, + stroke: stroke == const $CopyWithPlaceholder() + ? _value.stroke + // ignore: cast_nullable_to_non_nullable + : stroke as double?, + shadow: shadow == const $CopyWithPlaceholder() + ? _value.shadow + // ignore: cast_nullable_to_non_nullable + : shadow as BoxShadow?, + ); + } +} + +extension $FileSelectionButtonStyleCopyWith on FileSelectionButtonStyle { + /// Returns a callable class that can be used as follows: `instanceOfFileSelectionButtonStyle.copyWith(...)` or like so:`instanceOfFileSelectionButtonStyle.copyWith.fieldName(...)`. + // ignore: library_private_types_in_public_api + _$FileSelectionButtonStyleCWProxy get copyWith => + _$FileSelectionButtonStyleCWProxyImpl(this); +} diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_style.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_style.dart index f5476e31..676d510c 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_style.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_style.dart @@ -16,10 +16,13 @@ import 'dart:ui'; +import 'package:copy_with_extension/copy_with_extension.dart'; import 'package:flutter/widgets.dart'; import 'package:wyatt_ui_components/src/core/utils/multi_color.dart'; import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart'; +part 'flat_button_style.g.dart'; +@CopyWith() class FlatButtonStyle extends ButtonStyle { const FlatButtonStyle({ this.label, @@ -98,30 +101,4 @@ class FlatButtonStyle extends ButtonStyle { @override FlatButtonStyle mergeWith(FlatButtonStyle? other) => FlatButtonStyle.merge(this, other)!; - - @override - FlatButtonStyle? lerpWith(FlatButtonStyle? other, double t) => - FlatButtonStyle.lerp(this, other, t); - - @override - FlatButtonStyle copyWith({ - TextStyle? label, - BorderRadiusGeometry? radius, - EdgeInsetsGeometry? padding, - MultiColor? foregroundColors, - MultiColor? backgroundColors, - MultiColor? borderColors, - double? stroke, - BoxShadow? shadow, - }) => - FlatButtonStyle( - label: label ?? this.label, - radius: radius ?? this.radius, - padding: padding ?? this.padding, - foregroundColors: foregroundColors ?? this.foregroundColors, - backgroundColors: backgroundColors ?? this.backgroundColors, - borderColors: borderColors ?? this.borderColors, - stroke: stroke ?? this.stroke, - shadow: shadow ?? this.shadow, - ); } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_style.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_style.g.dart new file mode 100644 index 00000000..939a48e1 --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_style.g.dart @@ -0,0 +1,137 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'flat_button_style.dart'; + +// ************************************************************************** +// CopyWithGenerator +// ************************************************************************** + +abstract class _$FlatButtonStyleCWProxy { + FlatButtonStyle label(TextStyle? label); + + FlatButtonStyle radius(BorderRadiusGeometry? radius); + + FlatButtonStyle padding(EdgeInsetsGeometry? padding); + + FlatButtonStyle foregroundColors(MultiColor? foregroundColors); + + FlatButtonStyle backgroundColors(MultiColor? backgroundColors); + + FlatButtonStyle borderColors(MultiColor? borderColors); + + FlatButtonStyle stroke(double? stroke); + + FlatButtonStyle shadow(BoxShadow? shadow); + + /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `FlatButtonStyle(...).copyWith.fieldName(...)` to override fields one at a time with nullification support. + /// + /// Usage + /// ```dart + /// FlatButtonStyle(...).copyWith(id: 12, name: "My name") + /// ```` + FlatButtonStyle call({ + TextStyle? label, + BorderRadiusGeometry? radius, + EdgeInsetsGeometry? padding, + MultiColor? foregroundColors, + MultiColor? backgroundColors, + MultiColor? borderColors, + double? stroke, + BoxShadow? shadow, + }); +} + +/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfFlatButtonStyle.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfFlatButtonStyle.copyWith.fieldName(...)` +class _$FlatButtonStyleCWProxyImpl implements _$FlatButtonStyleCWProxy { + const _$FlatButtonStyleCWProxyImpl(this._value); + + final FlatButtonStyle _value; + + @override + FlatButtonStyle label(TextStyle? label) => this(label: label); + + @override + FlatButtonStyle radius(BorderRadiusGeometry? radius) => this(radius: radius); + + @override + FlatButtonStyle padding(EdgeInsetsGeometry? padding) => + this(padding: padding); + + @override + FlatButtonStyle foregroundColors(MultiColor? foregroundColors) => + this(foregroundColors: foregroundColors); + + @override + FlatButtonStyle backgroundColors(MultiColor? backgroundColors) => + this(backgroundColors: backgroundColors); + + @override + FlatButtonStyle borderColors(MultiColor? borderColors) => + this(borderColors: borderColors); + + @override + FlatButtonStyle stroke(double? stroke) => this(stroke: stroke); + + @override + FlatButtonStyle shadow(BoxShadow? shadow) => this(shadow: shadow); + + @override + + /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `FlatButtonStyle(...).copyWith.fieldName(...)` to override fields one at a time with nullification support. + /// + /// Usage + /// ```dart + /// FlatButtonStyle(...).copyWith(id: 12, name: "My name") + /// ```` + FlatButtonStyle call({ + Object? label = const $CopyWithPlaceholder(), + Object? radius = const $CopyWithPlaceholder(), + Object? padding = const $CopyWithPlaceholder(), + Object? foregroundColors = const $CopyWithPlaceholder(), + Object? backgroundColors = const $CopyWithPlaceholder(), + Object? borderColors = const $CopyWithPlaceholder(), + Object? stroke = const $CopyWithPlaceholder(), + Object? shadow = const $CopyWithPlaceholder(), + }) { + return FlatButtonStyle( + label: label == const $CopyWithPlaceholder() + ? _value.label + // ignore: cast_nullable_to_non_nullable + : label as TextStyle?, + radius: radius == const $CopyWithPlaceholder() + ? _value.radius + // ignore: cast_nullable_to_non_nullable + : radius as BorderRadiusGeometry?, + padding: padding == const $CopyWithPlaceholder() + ? _value.padding + // ignore: cast_nullable_to_non_nullable + : padding as EdgeInsetsGeometry?, + foregroundColors: foregroundColors == const $CopyWithPlaceholder() + ? _value.foregroundColors + // ignore: cast_nullable_to_non_nullable + : foregroundColors as MultiColor?, + backgroundColors: backgroundColors == const $CopyWithPlaceholder() + ? _value.backgroundColors + // ignore: cast_nullable_to_non_nullable + : backgroundColors as MultiColor?, + borderColors: borderColors == const $CopyWithPlaceholder() + ? _value.borderColors + // ignore: cast_nullable_to_non_nullable + : borderColors as MultiColor?, + stroke: stroke == const $CopyWithPlaceholder() + ? _value.stroke + // ignore: cast_nullable_to_non_nullable + : stroke as double?, + shadow: shadow == const $CopyWithPlaceholder() + ? _value.shadow + // ignore: cast_nullable_to_non_nullable + : shadow as BoxShadow?, + ); + } +} + +extension $FlatButtonStyleCopyWith on FlatButtonStyle { + /// Returns a callable class that can be used as follows: `instanceOfFlatButtonStyle.copyWith(...)` or like so:`instanceOfFlatButtonStyle.copyWith.fieldName(...)`. + // ignore: library_private_types_in_public_api + _$FlatButtonStyleCWProxy get copyWith => _$FlatButtonStyleCWProxyImpl(this); +} diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/simple_icon_button_style.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/simple_icon_button_style.dart index e31acee7..2168895e 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/simple_icon_button_style.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/simple_icon_button_style.dart @@ -16,10 +16,13 @@ import 'dart:ui'; +import 'package:copy_with_extension/copy_with_extension.dart'; import 'package:flutter/widgets.dart'; import 'package:wyatt_ui_components/src/core/utils/multi_color.dart'; import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart'; +part 'simple_icon_button_style.g.dart'; +@CopyWith() class SimpleIconButtonStyle extends ButtonStyle { const SimpleIconButtonStyle({ this.dimension, @@ -98,30 +101,4 @@ class SimpleIconButtonStyle extends ButtonStyle { @override SimpleIconButtonStyle mergeWith(SimpleIconButtonStyle? other) => SimpleIconButtonStyle.merge(this, other)!; - - @override - SimpleIconButtonStyle? lerpWith(SimpleIconButtonStyle? other, double t) => - SimpleIconButtonStyle.lerp(this, other, t); - - @override - SimpleIconButtonStyle copyWith({ - double? dimension, - BorderRadiusGeometry? radius, - EdgeInsetsGeometry? padding, - MultiColor? foregroundColors, - MultiColor? backgroundColors, - MultiColor? borderColors, - double? stroke, - BoxShadow? shadow, - }) => - SimpleIconButtonStyle( - dimension: dimension ?? this.dimension, - radius: radius ?? this.radius, - padding: padding ?? this.padding, - foregroundColors: foregroundColors ?? this.foregroundColors, - backgroundColors: backgroundColors ?? this.backgroundColors, - borderColors: borderColors ?? this.borderColors, - stroke: stroke ?? this.stroke, - shadow: shadow ?? this.shadow, - ); } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/simple_icon_button_style.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/simple_icon_button_style.g.dart new file mode 100644 index 00000000..f0ee5153 --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/simple_icon_button_style.g.dart @@ -0,0 +1,141 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'simple_icon_button_style.dart'; + +// ************************************************************************** +// CopyWithGenerator +// ************************************************************************** + +abstract class _$SimpleIconButtonStyleCWProxy { + SimpleIconButtonStyle dimension(double? dimension); + + SimpleIconButtonStyle radius(BorderRadiusGeometry? radius); + + SimpleIconButtonStyle padding(EdgeInsetsGeometry? padding); + + SimpleIconButtonStyle foregroundColors(MultiColor? foregroundColors); + + SimpleIconButtonStyle backgroundColors(MultiColor? backgroundColors); + + SimpleIconButtonStyle borderColors(MultiColor? borderColors); + + SimpleIconButtonStyle stroke(double? stroke); + + SimpleIconButtonStyle shadow(BoxShadow? shadow); + + /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `SimpleIconButtonStyle(...).copyWith.fieldName(...)` to override fields one at a time with nullification support. + /// + /// Usage + /// ```dart + /// SimpleIconButtonStyle(...).copyWith(id: 12, name: "My name") + /// ```` + SimpleIconButtonStyle call({ + double? dimension, + BorderRadiusGeometry? radius, + EdgeInsetsGeometry? padding, + MultiColor? foregroundColors, + MultiColor? backgroundColors, + MultiColor? borderColors, + double? stroke, + BoxShadow? shadow, + }); +} + +/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfSimpleIconButtonStyle.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfSimpleIconButtonStyle.copyWith.fieldName(...)` +class _$SimpleIconButtonStyleCWProxyImpl + implements _$SimpleIconButtonStyleCWProxy { + const _$SimpleIconButtonStyleCWProxyImpl(this._value); + + final SimpleIconButtonStyle _value; + + @override + SimpleIconButtonStyle dimension(double? dimension) => + this(dimension: dimension); + + @override + SimpleIconButtonStyle radius(BorderRadiusGeometry? radius) => + this(radius: radius); + + @override + SimpleIconButtonStyle padding(EdgeInsetsGeometry? padding) => + this(padding: padding); + + @override + SimpleIconButtonStyle foregroundColors(MultiColor? foregroundColors) => + this(foregroundColors: foregroundColors); + + @override + SimpleIconButtonStyle backgroundColors(MultiColor? backgroundColors) => + this(backgroundColors: backgroundColors); + + @override + SimpleIconButtonStyle borderColors(MultiColor? borderColors) => + this(borderColors: borderColors); + + @override + SimpleIconButtonStyle stroke(double? stroke) => this(stroke: stroke); + + @override + SimpleIconButtonStyle shadow(BoxShadow? shadow) => this(shadow: shadow); + + @override + + /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `SimpleIconButtonStyle(...).copyWith.fieldName(...)` to override fields one at a time with nullification support. + /// + /// Usage + /// ```dart + /// SimpleIconButtonStyle(...).copyWith(id: 12, name: "My name") + /// ```` + SimpleIconButtonStyle call({ + Object? dimension = const $CopyWithPlaceholder(), + Object? radius = const $CopyWithPlaceholder(), + Object? padding = const $CopyWithPlaceholder(), + Object? foregroundColors = const $CopyWithPlaceholder(), + Object? backgroundColors = const $CopyWithPlaceholder(), + Object? borderColors = const $CopyWithPlaceholder(), + Object? stroke = const $CopyWithPlaceholder(), + Object? shadow = const $CopyWithPlaceholder(), + }) { + return SimpleIconButtonStyle( + dimension: dimension == const $CopyWithPlaceholder() + ? _value.dimension + // ignore: cast_nullable_to_non_nullable + : dimension as double?, + radius: radius == const $CopyWithPlaceholder() + ? _value.radius + // ignore: cast_nullable_to_non_nullable + : radius as BorderRadiusGeometry?, + padding: padding == const $CopyWithPlaceholder() + ? _value.padding + // ignore: cast_nullable_to_non_nullable + : padding as EdgeInsetsGeometry?, + foregroundColors: foregroundColors == const $CopyWithPlaceholder() + ? _value.foregroundColors + // ignore: cast_nullable_to_non_nullable + : foregroundColors as MultiColor?, + backgroundColors: backgroundColors == const $CopyWithPlaceholder() + ? _value.backgroundColors + // ignore: cast_nullable_to_non_nullable + : backgroundColors as MultiColor?, + borderColors: borderColors == const $CopyWithPlaceholder() + ? _value.borderColors + // ignore: cast_nullable_to_non_nullable + : borderColors as MultiColor?, + stroke: stroke == const $CopyWithPlaceholder() + ? _value.stroke + // ignore: cast_nullable_to_non_nullable + : stroke as double?, + shadow: shadow == const $CopyWithPlaceholder() + ? _value.shadow + // ignore: cast_nullable_to_non_nullable + : shadow as BoxShadow?, + ); + } +} + +extension $SimpleIconButtonStyleCopyWith on SimpleIconButtonStyle { + /// Returns a callable class that can be used as follows: `instanceOfSimpleIconButtonStyle.copyWith(...)` or like so:`instanceOfSimpleIconButtonStyle.copyWith.fieldName(...)`. + // ignore: library_private_types_in_public_api + _$SimpleIconButtonStyleCWProxy get copyWith => + _$SimpleIconButtonStyleCWProxyImpl(this); +} diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/symbol_button_style.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/symbol_button_style.dart index a0815b3c..46bbcb35 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/symbol_button_style.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/symbol_button_style.dart @@ -16,10 +16,13 @@ import 'dart:ui'; +import 'package:copy_with_extension/copy_with_extension.dart'; import 'package:flutter/widgets.dart'; import 'package:wyatt_ui_components/src/core/utils/multi_color.dart'; import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart'; +part 'symbol_button_style.g.dart'; +@CopyWith() class SymbolButtonStyle extends ButtonStyle { const SymbolButtonStyle({ this.label, @@ -106,32 +109,4 @@ class SymbolButtonStyle extends ButtonStyle { @override SymbolButtonStyle mergeWith(SymbolButtonStyle? other) => SymbolButtonStyle.merge(this, other)!; - - @override - SymbolButtonStyle? lerpWith(SymbolButtonStyle? other, double t) => - SymbolButtonStyle.lerp(this, other, t); - - @override - SymbolButtonStyle copyWith({ - TextStyle? label, - double? dimension, - BorderRadiusGeometry? radius, - EdgeInsetsGeometry? padding, - MultiColor? foregroundColors, - MultiColor? backgroundColors, - MultiColor? borderColors, - double? stroke, - BoxShadow? shadow, - }) => - SymbolButtonStyle( - label: label ?? this.label, - dimension: dimension ?? this.dimension, - radius: radius ?? this.radius, - padding: padding ?? this.padding, - foregroundColors: foregroundColors ?? this.foregroundColors, - backgroundColors: backgroundColors ?? this.backgroundColors, - borderColors: borderColors ?? this.borderColors, - stroke: stroke ?? this.stroke, - shadow: shadow ?? this.shadow, - ); } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/symbol_button_style.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/symbol_button_style.g.dart new file mode 100644 index 00000000..a3233cec --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/symbol_button_style.g.dart @@ -0,0 +1,150 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'symbol_button_style.dart'; + +// ************************************************************************** +// CopyWithGenerator +// ************************************************************************** + +abstract class _$SymbolButtonStyleCWProxy { + SymbolButtonStyle label(TextStyle? label); + + SymbolButtonStyle dimension(double? dimension); + + SymbolButtonStyle radius(BorderRadiusGeometry? radius); + + SymbolButtonStyle padding(EdgeInsetsGeometry? padding); + + SymbolButtonStyle foregroundColors(MultiColor? foregroundColors); + + SymbolButtonStyle backgroundColors(MultiColor? backgroundColors); + + SymbolButtonStyle borderColors(MultiColor? borderColors); + + SymbolButtonStyle stroke(double? stroke); + + SymbolButtonStyle shadow(BoxShadow? shadow); + + /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `SymbolButtonStyle(...).copyWith.fieldName(...)` to override fields one at a time with nullification support. + /// + /// Usage + /// ```dart + /// SymbolButtonStyle(...).copyWith(id: 12, name: "My name") + /// ```` + SymbolButtonStyle call({ + TextStyle? label, + double? dimension, + BorderRadiusGeometry? radius, + EdgeInsetsGeometry? padding, + MultiColor? foregroundColors, + MultiColor? backgroundColors, + MultiColor? borderColors, + double? stroke, + BoxShadow? shadow, + }); +} + +/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfSymbolButtonStyle.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfSymbolButtonStyle.copyWith.fieldName(...)` +class _$SymbolButtonStyleCWProxyImpl implements _$SymbolButtonStyleCWProxy { + const _$SymbolButtonStyleCWProxyImpl(this._value); + + final SymbolButtonStyle _value; + + @override + SymbolButtonStyle label(TextStyle? label) => this(label: label); + + @override + SymbolButtonStyle dimension(double? dimension) => this(dimension: dimension); + + @override + SymbolButtonStyle radius(BorderRadiusGeometry? radius) => + this(radius: radius); + + @override + SymbolButtonStyle padding(EdgeInsetsGeometry? padding) => + this(padding: padding); + + @override + SymbolButtonStyle foregroundColors(MultiColor? foregroundColors) => + this(foregroundColors: foregroundColors); + + @override + SymbolButtonStyle backgroundColors(MultiColor? backgroundColors) => + this(backgroundColors: backgroundColors); + + @override + SymbolButtonStyle borderColors(MultiColor? borderColors) => + this(borderColors: borderColors); + + @override + SymbolButtonStyle stroke(double? stroke) => this(stroke: stroke); + + @override + SymbolButtonStyle shadow(BoxShadow? shadow) => this(shadow: shadow); + + @override + + /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `SymbolButtonStyle(...).copyWith.fieldName(...)` to override fields one at a time with nullification support. + /// + /// Usage + /// ```dart + /// SymbolButtonStyle(...).copyWith(id: 12, name: "My name") + /// ```` + SymbolButtonStyle call({ + Object? label = const $CopyWithPlaceholder(), + Object? dimension = const $CopyWithPlaceholder(), + Object? radius = const $CopyWithPlaceholder(), + Object? padding = const $CopyWithPlaceholder(), + Object? foregroundColors = const $CopyWithPlaceholder(), + Object? backgroundColors = const $CopyWithPlaceholder(), + Object? borderColors = const $CopyWithPlaceholder(), + Object? stroke = const $CopyWithPlaceholder(), + Object? shadow = const $CopyWithPlaceholder(), + }) { + return SymbolButtonStyle( + label: label == const $CopyWithPlaceholder() + ? _value.label + // ignore: cast_nullable_to_non_nullable + : label as TextStyle?, + dimension: dimension == const $CopyWithPlaceholder() + ? _value.dimension + // ignore: cast_nullable_to_non_nullable + : dimension as double?, + radius: radius == const $CopyWithPlaceholder() + ? _value.radius + // ignore: cast_nullable_to_non_nullable + : radius as BorderRadiusGeometry?, + padding: padding == const $CopyWithPlaceholder() + ? _value.padding + // ignore: cast_nullable_to_non_nullable + : padding as EdgeInsetsGeometry?, + foregroundColors: foregroundColors == const $CopyWithPlaceholder() + ? _value.foregroundColors + // ignore: cast_nullable_to_non_nullable + : foregroundColors as MultiColor?, + backgroundColors: backgroundColors == const $CopyWithPlaceholder() + ? _value.backgroundColors + // ignore: cast_nullable_to_non_nullable + : backgroundColors as MultiColor?, + borderColors: borderColors == const $CopyWithPlaceholder() + ? _value.borderColors + // ignore: cast_nullable_to_non_nullable + : borderColors as MultiColor?, + stroke: stroke == const $CopyWithPlaceholder() + ? _value.stroke + // ignore: cast_nullable_to_non_nullable + : stroke as double?, + shadow: shadow == const $CopyWithPlaceholder() + ? _value.shadow + // ignore: cast_nullable_to_non_nullable + : shadow as BoxShadow?, + ); + } +} + +extension $SymbolButtonStyleCopyWith on SymbolButtonStyle { + /// Returns a callable class that can be used as follows: `instanceOfSymbolButtonStyle.copyWith(...)` or like so:`instanceOfSymbolButtonStyle.copyWith.fieldName(...)`. + // ignore: library_private_types_in_public_api + _$SymbolButtonStyleCWProxy get copyWith => + _$SymbolButtonStyleCWProxyImpl(this); +} diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/loader_style.dart b/packages/wyatt_ui_components/lib/src/domain/entities/loader_style.dart index 43c3253c..3a8be8e2 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/loader_style.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/loader_style.dart @@ -16,8 +16,11 @@ import 'dart:ui'; +import 'package:copy_with_extension/copy_with_extension.dart'; import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart'; +part 'loader_style.g.dart'; +@CopyWith() class LoaderStyle extends ThemeStyle { const LoaderStyle({ this.colors, @@ -67,20 +70,6 @@ class LoaderStyle extends ThemeStyle { @override LoaderStyle mergeWith(LoaderStyle? other) => LoaderStyle.merge(this, other)!; - @override - LoaderStyle? lerpWith(LoaderStyle? other, double t) => - LoaderStyle.lerp(this, other, t); - - @override - LoaderStyle copyWith({ - MultiColor? colors, - double? stroke, - }) => - LoaderStyle( - colors: colors ?? this.colors, - stroke: stroke ?? this.stroke, - ); - @override String toString() => 'LoaderStyle($colors, $stroke)'; } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/loader_style.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/loader_style.g.dart new file mode 100644 index 00000000..86ec75c5 --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/loader_style.g.dart @@ -0,0 +1,67 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'loader_style.dart'; + +// ************************************************************************** +// CopyWithGenerator +// ************************************************************************** + +abstract class _$LoaderStyleCWProxy { + LoaderStyle colors(MultiColor? colors); + + LoaderStyle stroke(double? stroke); + + /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `LoaderStyle(...).copyWith.fieldName(...)` to override fields one at a time with nullification support. + /// + /// Usage + /// ```dart + /// LoaderStyle(...).copyWith(id: 12, name: "My name") + /// ```` + LoaderStyle call({ + MultiColor? colors, + double? stroke, + }); +} + +/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfLoaderStyle.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfLoaderStyle.copyWith.fieldName(...)` +class _$LoaderStyleCWProxyImpl implements _$LoaderStyleCWProxy { + const _$LoaderStyleCWProxyImpl(this._value); + + final LoaderStyle _value; + + @override + LoaderStyle colors(MultiColor? colors) => this(colors: colors); + + @override + LoaderStyle stroke(double? stroke) => this(stroke: stroke); + + @override + + /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `LoaderStyle(...).copyWith.fieldName(...)` to override fields one at a time with nullification support. + /// + /// Usage + /// ```dart + /// LoaderStyle(...).copyWith(id: 12, name: "My name") + /// ```` + LoaderStyle call({ + Object? colors = const $CopyWithPlaceholder(), + Object? stroke = const $CopyWithPlaceholder(), + }) { + return LoaderStyle( + colors: colors == const $CopyWithPlaceholder() + ? _value.colors + // ignore: cast_nullable_to_non_nullable + : colors as MultiColor?, + stroke: stroke == const $CopyWithPlaceholder() + ? _value.stroke + // ignore: cast_nullable_to_non_nullable + : stroke as double?, + ); + } +} + +extension $LoaderStyleCopyWith on LoaderStyle { + /// Returns a callable class that can be used as follows: `instanceOfLoaderStyle.copyWith(...)` or like so:`instanceOfLoaderStyle.copyWith.fieldName(...)`. + // ignore: library_private_types_in_public_api + _$LoaderStyleCWProxy get copyWith => _$LoaderStyleCWProxyImpl(this); +} diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/rich_text_builder/rich_text_builder_style.dart b/packages/wyatt_ui_components/lib/src/domain/entities/rich_text_builder/rich_text_builder_style.dart index 43a03ff5..43ea1a9b 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/rich_text_builder/rich_text_builder_style.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/rich_text_builder/rich_text_builder_style.dart @@ -14,9 +14,12 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +import 'package:copy_with_extension/copy_with_extension.dart'; import 'package:flutter/widgets.dart'; import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart'; +part 'rich_text_builder_style.g.dart'; +@CopyWith() class RichTextBuilderStyle extends ThemeStyle { const RichTextBuilderStyle({ this.defaultStyle, @@ -66,18 +69,4 @@ class RichTextBuilderStyle extends ThemeStyle { @override RichTextBuilderStyle mergeWith(RichTextBuilderStyle? other) => RichTextBuilderStyle.merge(this, other)!; - - @override - RichTextBuilderStyle? lerpWith(RichTextBuilderStyle? other, double t) => - RichTextBuilderStyle.lerp(this, other, t); - - @override - RichTextBuilderStyle copyWith({ - TextStyle? defaultStyle, - Map? styles, - }) => - RichTextBuilderStyle( - defaultStyle: defaultStyle ?? this.defaultStyle, - styles: styles ?? this.styles, - ); } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/rich_text_builder/rich_text_builder_style.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/rich_text_builder/rich_text_builder_style.g.dart new file mode 100644 index 00000000..8f74d5da --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/rich_text_builder/rich_text_builder_style.g.dart @@ -0,0 +1,71 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'rich_text_builder_style.dart'; + +// ************************************************************************** +// CopyWithGenerator +// ************************************************************************** + +abstract class _$RichTextBuilderStyleCWProxy { + RichTextBuilderStyle defaultStyle(TextStyle? defaultStyle); + + RichTextBuilderStyle styles(Map? styles); + + /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `RichTextBuilderStyle(...).copyWith.fieldName(...)` to override fields one at a time with nullification support. + /// + /// Usage + /// ```dart + /// RichTextBuilderStyle(...).copyWith(id: 12, name: "My name") + /// ```` + RichTextBuilderStyle call({ + TextStyle? defaultStyle, + Map? styles, + }); +} + +/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfRichTextBuilderStyle.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfRichTextBuilderStyle.copyWith.fieldName(...)` +class _$RichTextBuilderStyleCWProxyImpl + implements _$RichTextBuilderStyleCWProxy { + const _$RichTextBuilderStyleCWProxyImpl(this._value); + + final RichTextBuilderStyle _value; + + @override + RichTextBuilderStyle defaultStyle(TextStyle? defaultStyle) => + this(defaultStyle: defaultStyle); + + @override + RichTextBuilderStyle styles(Map? styles) => + this(styles: styles); + + @override + + /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `RichTextBuilderStyle(...).copyWith.fieldName(...)` to override fields one at a time with nullification support. + /// + /// Usage + /// ```dart + /// RichTextBuilderStyle(...).copyWith(id: 12, name: "My name") + /// ```` + RichTextBuilderStyle call({ + Object? defaultStyle = const $CopyWithPlaceholder(), + Object? styles = const $CopyWithPlaceholder(), + }) { + return RichTextBuilderStyle( + defaultStyle: defaultStyle == const $CopyWithPlaceholder() + ? _value.defaultStyle + // ignore: cast_nullable_to_non_nullable + : defaultStyle as TextStyle?, + styles: styles == const $CopyWithPlaceholder() + ? _value.styles + // ignore: cast_nullable_to_non_nullable + : styles as Map?, + ); + } +} + +extension $RichTextBuilderStyleCopyWith on RichTextBuilderStyle { + /// Returns a callable class that can be used as follows: `instanceOfRichTextBuilderStyle.copyWith(...)` or like so:`instanceOfRichTextBuilderStyle.copyWith.fieldName(...)`. + // ignore: library_private_types_in_public_api + _$RichTextBuilderStyleCWProxy get copyWith => + _$RichTextBuilderStyleCWProxyImpl(this); +} diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/text_inputs/text_input_style.dart b/packages/wyatt_ui_components/lib/src/domain/entities/text_inputs/text_input_style.dart index a456647e..1c19d260 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/text_inputs/text_input_style.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/text_inputs/text_input_style.dart @@ -20,7 +20,7 @@ import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart'; part 'text_input_style.g.dart'; @CopyWith() -class TextInputStyle { +class TextInputStyle extends ThemeStyle { TextInputStyle({ this.labelStyle, this.hintStyle, @@ -99,4 +99,8 @@ class TextInputStyle { iconColor: Color.lerp(a.iconColor, b.iconColor, t), ); } + + @override + TextInputStyle? mergeWith(TextInputStyle? other) => + TextInputStyle.merge(this, other); } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/theme_style.dart b/packages/wyatt_ui_components/lib/src/domain/entities/theme_style.dart index 0f637eed..591b6fee 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/theme_style.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/theme_style.dart @@ -18,11 +18,5 @@ abstract class ThemeStyle { const ThemeStyle(); /// Merges non-null `other` attributes in `this` and returns a copy. - T mergeWith(T? other); - - /// Used for interpolation. - T? lerpWith(T? other, double t); - - /// Copy with (mandatory for mergeWith, needs to be simple and ignore `null`) - T copyWith(); + T? mergeWith(T? other); } diff --git a/packages/wyatt_ui_kit/lib/src/components/buttons/file_selection_button/file_selection_button_screen.dart b/packages/wyatt_ui_kit/lib/src/components/buttons/file_selection_button/file_selection_button_screen.dart index 18a2cf0b..d707014c 100644 --- a/packages/wyatt_ui_kit/lib/src/components/buttons/file_selection_button/file_selection_button_screen.dart +++ b/packages/wyatt_ui_kit/lib/src/components/buttons/file_selection_button/file_selection_button_screen.dart @@ -67,7 +67,7 @@ class FileSelectionButtonScreen FileSelectionButtonStyle _resolve(BuildContext context, ButtonState state) { final FileSelectionButtonThemeResolver resolver = themeResolver ?? FileSelectionButtonThemeResolver( - customStyleFn: (context, extensionValue, {extra}) { + customStyleFn: (context, {extra}) { FileSelectionButtonStyle? style; switch (extra?.state) { case ControlState.disabled: diff --git a/packages/wyatt_ui_kit/lib/src/components/buttons/file_selection_button/file_selection_button_theme_resolver.dart b/packages/wyatt_ui_kit/lib/src/components/buttons/file_selection_button/file_selection_button_theme_resolver.dart index 92399773..505e9e37 100644 --- a/packages/wyatt_ui_kit/lib/src/components/buttons/file_selection_button/file_selection_button_theme_resolver.dart +++ b/packages/wyatt_ui_kit/lib/src/components/buttons/file_selection_button/file_selection_button_theme_resolver.dart @@ -73,19 +73,17 @@ class FileSelectionButtonThemeResolver extends ThemeResolver< @override final FileSelectionButtonStyle? Function( - BuildContext context, - FileSelectionButtonStyle? extensionValue, { + BuildContext context, { ButtonState? extra, }) customStyleFn; @override FileSelectionButtonStyle? computeExtensionValueFn( BuildContext context, - FileSelectionButtonStyle defaultValue, FileSelectionButtonThemeExtension themeExtension, { ButtonState? extra, }) { - FileSelectionButtonStyle? style = defaultValue; + FileSelectionButtonStyle? style; switch (extra?.state) { case ControlState.disabled: style = themeExtension.disabledStyle; diff --git a/packages/wyatt_ui_kit/lib/src/components/buttons/flat_button/flat_button_screen.dart b/packages/wyatt_ui_kit/lib/src/components/buttons/flat_button/flat_button_screen.dart index 88ff27f5..14b739fa 100644 --- a/packages/wyatt_ui_kit/lib/src/components/buttons/flat_button/flat_button_screen.dart +++ b/packages/wyatt_ui_kit/lib/src/components/buttons/flat_button/flat_button_screen.dart @@ -61,7 +61,7 @@ class FlatButtonScreen extends CubitScreen { FlatButtonStyle _resolve(BuildContext context, ControlState state) { final FlatButtonThemeResolver resolver = themeResolver ?? FlatButtonThemeResolver( - customStyleFn: (context, extensionValue, {extra}) { + customStyleFn: (context, {extra}) { switch (extra) { case ControlState.disabled: return disabledStyle; diff --git a/packages/wyatt_ui_kit/lib/src/components/buttons/flat_button/flat_button_theme_resolver.dart b/packages/wyatt_ui_kit/lib/src/components/buttons/flat_button/flat_button_theme_resolver.dart index cef92e2f..dfbe1349 100644 --- a/packages/wyatt_ui_kit/lib/src/components/buttons/flat_button/flat_button_theme_resolver.dart +++ b/packages/wyatt_ui_kit/lib/src/components/buttons/flat_button/flat_button_theme_resolver.dart @@ -69,15 +69,13 @@ class FlatButtonThemeResolver extends ThemeResolver { SimpleIconButtonStyle _resolve(BuildContext context, ControlState state) { final SimpleIconButtonThemeResolver resolver = themeResolver ?? SimpleIconButtonThemeResolver( - customStyleFn: (context, extensionValue, {extra}) { + customStyleFn: (context, {extra}) { switch (extra) { case ControlState.disabled: return disabledStyle; diff --git a/packages/wyatt_ui_kit/lib/src/components/buttons/symbol_button/symbol_button_screen.dart b/packages/wyatt_ui_kit/lib/src/components/buttons/symbol_button/symbol_button_screen.dart index e2e427fd..6b586d82 100644 --- a/packages/wyatt_ui_kit/lib/src/components/buttons/symbol_button/symbol_button_screen.dart +++ b/packages/wyatt_ui_kit/lib/src/components/buttons/symbol_button/symbol_button_screen.dart @@ -63,7 +63,7 @@ class SymbolButtonScreen SymbolButtonStyle _resolve(BuildContext context, ButtonState state) { final SymbolButtonThemeResolver resolver = themeResolver ?? SymbolButtonThemeResolver( - customStyleFn: (context, extensionValue, {extra}) { + customStyleFn: (context, {extra}) { SymbolButtonStyle? style; switch (extra?.state) { case ControlState.disabled: diff --git a/packages/wyatt_ui_kit/lib/src/components/buttons/symbol_button/symbol_button_theme_resolver.dart b/packages/wyatt_ui_kit/lib/src/components/buttons/symbol_button/symbol_button_theme_resolver.dart index bed01568..4628bd87 100644 --- a/packages/wyatt_ui_kit/lib/src/components/buttons/symbol_button/symbol_button_theme_resolver.dart +++ b/packages/wyatt_ui_kit/lib/src/components/buttons/symbol_button/symbol_button_theme_resolver.dart @@ -69,19 +69,17 @@ class SymbolButtonThemeResolver extends ThemeResolver - LoaderStyle( - colors: themeExtension.colors, - stroke: themeExtension.stroke, - ), customStyleFn: (context, {extra}) => LoaderStyle( colors: colors, stroke: stroke, diff --git a/packages/wyatt_ui_kit/lib/src/components/loader/loader_theme_resolver.dart b/packages/wyatt_ui_kit/lib/src/components/loader/loader_theme_resolver.dart index 60047759..1b45ddaf 100644 --- a/packages/wyatt_ui_kit/lib/src/components/loader/loader_theme_resolver.dart +++ b/packages/wyatt_ui_kit/lib/src/components/loader/loader_theme_resolver.dart @@ -21,7 +21,6 @@ import 'package:wyatt_ui_kit/wyatt_ui_kit.dart'; class LoaderThemeResolver extends ThemeResolver { const LoaderThemeResolver({ - required this.computeExtensionValueFn, required this.customStyleFn, }); @@ -42,12 +41,18 @@ class LoaderThemeResolver @override final LoaderStyle? Function( - BuildContext context, - LoaderStyle defaultValue, - LoaderThemeExtension themeExtension, { + BuildContext context, { void extra, - }) computeExtensionValueFn; + }) customStyleFn; @override - final LoaderStyle? Function(BuildContext context, {void extra}) customStyleFn; + LoaderStyle? computeExtensionValueFn( + BuildContext context, + LoaderThemeExtension themeExtension, { + void extra, + }) => + LoaderStyle( + colors: themeExtension.colors, + stroke: themeExtension.stroke, + ); } diff --git a/packages/wyatt_ui_kit/lib/src/components/rich_text_builder/rich_text_builder.dart b/packages/wyatt_ui_kit/lib/src/components/rich_text_builder/rich_text_builder.dart index 745d3462..0ca1798a 100644 --- a/packages/wyatt_ui_kit/lib/src/components/rich_text_builder/rich_text_builder.dart +++ b/packages/wyatt_ui_kit/lib/src/components/rich_text_builder/rich_text_builder.dart @@ -42,16 +42,6 @@ class RichTextBuilder extends RichTextBuilderComponent RichTextBuilderStyle _resolve(BuildContext context) { final RichTextBuilderThemeResolver resolver = themeResolver ?? RichTextBuilderThemeResolver( - computeExtensionValueFn: ( - context, - defaultValue, - themeExtension, { - extra, - }) => - RichTextBuilderStyle( - defaultStyle: themeExtension.defaultStyle, - styles: themeExtension.styles, - ), customStyleFn: (context, {extra}) => RichTextBuilderStyle( defaultStyle: defaultStyle, styles: styles, diff --git a/packages/wyatt_ui_kit/lib/src/components/rich_text_builder/rich_text_builder_theme_resolver.dart b/packages/wyatt_ui_kit/lib/src/components/rich_text_builder/rich_text_builder_theme_resolver.dart index f619d0a0..4661a264 100644 --- a/packages/wyatt_ui_kit/lib/src/components/rich_text_builder/rich_text_builder_theme_resolver.dart +++ b/packages/wyatt_ui_kit/lib/src/components/rich_text_builder/rich_text_builder_theme_resolver.dart @@ -21,7 +21,6 @@ import 'package:wyatt_ui_kit/wyatt_ui_kit.dart'; class RichTextBuilderThemeResolver extends ThemeResolver { const RichTextBuilderThemeResolver({ - required this.computeExtensionValueFn, required this.customStyleFn, }); @@ -37,13 +36,18 @@ class RichTextBuilderThemeResolver extends ThemeResolver + RichTextBuilderStyle( + defaultStyle: themeExtension.defaultStyle, + styles: themeExtension.styles, + ); } diff --git a/packages/wyatt_ui_kit/lib/src/components/text_inputs/text_input_screen.dart b/packages/wyatt_ui_kit/lib/src/components/text_inputs/text_input_screen.dart index 51a9d291..0766f8c0 100644 --- a/packages/wyatt_ui_kit/lib/src/components/text_inputs/text_input_screen.dart +++ b/packages/wyatt_ui_kit/lib/src/components/text_inputs/text_input_screen.dart @@ -195,7 +195,7 @@ class TextInputScreen extends CubitScreen { TextInputStyle _resolve(BuildContext context, TextInputState state) { final resolver = TextInputThemeResolver( - customStyleFn: (context, extensionValue, {extra}) { + customStyleFn: (context, {extra}) { TextInputStyle? textInputStyle; switch (extra?.controlState) { case ControlState.focused: @@ -230,10 +230,7 @@ class TextInputScreen extends CubitScreen { break; } - return TextInputStyle.merge( - extensionValue, - TextInputStyle.merge(textInputStyle, style), - ); + return TextInputStyle.merge(textInputStyle, style); }, ); diff --git a/packages/wyatt_ui_kit/lib/src/components/text_inputs/text_input_theme_resolver.dart b/packages/wyatt_ui_kit/lib/src/components/text_inputs/text_input_theme_resolver.dart index b774c720..f421b762 100644 --- a/packages/wyatt_ui_kit/lib/src/components/text_inputs/text_input_theme_resolver.dart +++ b/packages/wyatt_ui_kit/lib/src/components/text_inputs/text_input_theme_resolver.dart @@ -28,8 +28,7 @@ class TextInputThemeResolver extends ThemeResolver