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 8585273e..1e61e3a5 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 @@ -107,6 +107,30 @@ class FileSelectionButtonStyle extends ButtonStyle { final TextStyle? subTitle; @override - FileSelectionButtonStyle mergeWith(FileSelectionButtonStyle? other) => - FileSelectionButtonStyle.merge(this, other)!; + FileSelectionButtonStyle? mergeWith(FileSelectionButtonStyle? other) => + FileSelectionButtonStyle.merge(this, other); + + @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/flat_button_style.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_style.dart index 676d510c..50ac5fb2 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 @@ -99,6 +99,28 @@ class FlatButtonStyle extends ButtonStyle { final TextStyle? label; @override - FlatButtonStyle mergeWith(FlatButtonStyle? other) => - FlatButtonStyle.merge(this, other)!; + FlatButtonStyle? mergeWith(FlatButtonStyle? other) => + FlatButtonStyle.merge(this, other); + + @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/simple_icon_button_style.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/simple_icon_button_style.dart index 2168895e..298d32d2 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 @@ -99,6 +99,28 @@ class SimpleIconButtonStyle extends ButtonStyle { final double? dimension; @override - SimpleIconButtonStyle mergeWith(SimpleIconButtonStyle? other) => - SimpleIconButtonStyle.merge(this, other)!; + SimpleIconButtonStyle? mergeWith(SimpleIconButtonStyle? other) => + SimpleIconButtonStyle.merge(this, other); + + @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/symbol_button_style.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/symbol_button_style.dart index 46bbcb35..9dcc9640 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 @@ -107,6 +107,30 @@ class SymbolButtonStyle extends ButtonStyle { final double? dimension; @override - SymbolButtonStyle mergeWith(SymbolButtonStyle? other) => - SymbolButtonStyle.merge(this, other)!; + SymbolButtonStyle? mergeWith(SymbolButtonStyle? other) => + SymbolButtonStyle.merge(this, other); + + @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/loader_style.dart b/packages/wyatt_ui_components/lib/src/domain/entities/loader_style.dart index 3a8be8e2..0f46cbba 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 @@ -68,7 +68,17 @@ class LoaderStyle extends ThemeStyle { final double? stroke; @override - LoaderStyle mergeWith(LoaderStyle? other) => LoaderStyle.merge(this, other)!; + LoaderStyle? mergeWith(LoaderStyle? other) => LoaderStyle.merge(this, other); + + @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/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 43ea1a9b..48a21b3d 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 @@ -67,6 +67,16 @@ class RichTextBuilderStyle extends ThemeStyle { final Map? styles; @override - RichTextBuilderStyle mergeWith(RichTextBuilderStyle? other) => - RichTextBuilderStyle.merge(this, other)!; + RichTextBuilderStyle? mergeWith(RichTextBuilderStyle? other) => + RichTextBuilderStyle.merge(this, other); + + @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/text_inputs/text_input_style.dart b/packages/wyatt_ui_components/lib/src/domain/entities/text_inputs/text_input_style.dart index 1c19d260..61640bcd 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 @@ -58,19 +58,19 @@ class TextInputStyle extends ThemeStyle { if (a == null) { return b.copyWith(); } - return a.copyWith( - labelStyle: b.labelStyle, - hintStyle: b.hintStyle, - backgroundColors: b.backgroundColors, - borderColors: b.borderColors, - boxShadow: b.boxShadow, - radius: b.radius, - inputStyle: b.inputStyle, - iconColor: b.iconColor, - prefixStyle: b.prefixStyle, - prefixIconColor: b.prefixIconColor, - suffixIconColor: b.suffixIconColor, - suffixStyle: b.suffixStyle, + return b.copyWith( + labelStyle: a.labelStyle, + hintStyle: a.hintStyle, + backgroundColors: a.backgroundColors, + borderColors: a.borderColors, + boxShadow: a.boxShadow, + radius: a.radius, + inputStyle: a.inputStyle, + iconColor: a.iconColor, + prefixStyle: a.prefixStyle, + prefixIconColor: a.prefixIconColor, + suffixIconColor: a.suffixIconColor, + suffixStyle: a.suffixStyle, ); } @@ -103,4 +103,34 @@ class TextInputStyle extends ThemeStyle { @override TextInputStyle? mergeWith(TextInputStyle? other) => TextInputStyle.merge(this, other); + + @override + TextInputStyle copyWith({ + TextStyle? labelStyle, + TextStyle? hintStyle, + MultiColor? backgroundColors, + MultiColor? borderColors, + BoxShadow? boxShadow, + BorderRadiusGeometry? radius, + TextStyle? inputStyle, + Color? iconColor, + TextStyle? prefixStyle, + Color? prefixIconColor, + TextStyle? suffixStyle, + Color? suffixIconColor, + }) => + TextInputStyle( + labelStyle: labelStyle ?? this.labelStyle, + hintStyle: hintStyle ?? this.hintStyle, + backgroundColors: backgroundColors ?? this.backgroundColors, + radius: radius ?? this.radius, + borderColors: borderColors ?? this.borderColors, + boxShadow: boxShadow ?? this.boxShadow, + inputStyle: inputStyle ?? this.inputStyle, + prefixStyle: prefixStyle ?? this.prefixStyle, + suffixStyle: suffixStyle ?? this.suffixStyle, + prefixIconColor: prefixIconColor ?? this.prefixIconColor, + suffixIconColor: suffixIconColor ?? this.suffixIconColor, + iconColor: iconColor ?? this.iconColor, + ); } 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 591b6fee..a0a69ffb 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 @@ -19,4 +19,7 @@ abstract class ThemeStyle { /// Merges non-null `other` attributes in `this` and returns a copy. T? mergeWith(T? other); + + /// Copy with (mandatory for mergeWith, needs to be simple and ignore `null`) + T? copyWith(); } diff --git a/packages/wyatt_ui_components/pubspec.yaml b/packages/wyatt_ui_components/pubspec.yaml index 395554ea..865b67f9 100644 --- a/packages/wyatt_ui_components/pubspec.yaml +++ b/packages/wyatt_ui_components/pubspec.yaml @@ -15,11 +15,13 @@ dependencies: git: url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git path: packages/wyatt_component_copy_with_extension + freezed_annotation: ^2.2.0 dev_dependencies: build_runner: ^2.3.3 copy_with_extension_gen: ^5.0.0 flutter_test: { sdk: flutter } + freezed: ^2.3.2 wyatt_analysis: hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub version: ^2.4.0