From 63bbde8213ad18741ed22fbdd545ce0624c7a023 Mon Sep 17 00:00:00 2001 From: Hugo Pointcheval Date: Thu, 16 Feb 2023 15:12:18 +0100 Subject: [PATCH] refactor(ui_component): remove CopyWith extension --- .../buttons/file_selection_button_style.dart | 28 +++- .../file_selection_button_style.g.dart | 152 ------------------ .../entities/buttons/flat_button_style.dart | 26 ++- .../entities/buttons/flat_button_style.g.dart | 137 ---------------- .../buttons/simple_icon_button_style.dart | 26 ++- .../buttons/simple_icon_button_style.g.dart | 141 ---------------- .../entities/buttons/symbol_button_style.dart | 28 +++- .../buttons/symbol_button_style.g.dart | 150 ----------------- .../lib/src/domain/entities/theme_style.dart | 3 + packages/wyatt_ui_components/pubspec.yaml | 2 - 10 files changed, 95 insertions(+), 598 deletions(-) delete mode 100644 packages/wyatt_ui_components/lib/src/domain/entities/buttons/file_selection_button_style.g.dart delete mode 100644 packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_style.g.dart delete mode 100644 packages/wyatt_ui_components/lib/src/domain/entities/buttons/simple_icon_button_style.g.dart delete mode 100644 packages/wyatt_ui_components/lib/src/domain/entities/buttons/symbol_button_style.g.dart 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 4bf83810..75fc9a42 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,14 +16,10 @@ 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, @@ -117,4 +113,28 @@ class FileSelectionButtonStyle extends ButtonStyle { 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 deleted file mode 100644 index 6576a261..00000000 --- a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/file_selection_button_style.g.dart +++ /dev/null @@ -1,152 +0,0 @@ -// 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 980b83d7..f5476e31 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,14 +16,10 @@ 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, @@ -106,4 +102,26 @@ class FlatButtonStyle extends ButtonStyle { @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 deleted file mode 100644 index 939a48e1..00000000 --- a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_style.g.dart +++ /dev/null @@ -1,137 +0,0 @@ -// 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 70be77bc..e31acee7 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,14 +16,10 @@ 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, @@ -106,4 +102,26 @@ class SimpleIconButtonStyle extends ButtonStyle { @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 deleted file mode 100644 index f0ee5153..00000000 --- a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/simple_icon_button_style.g.dart +++ /dev/null @@ -1,141 +0,0 @@ -// 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 7f8e7b6d..a0815b3c 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,14 +16,10 @@ 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, @@ -114,4 +110,28 @@ class SymbolButtonStyle extends ButtonStyle { @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 deleted file mode 100644 index a3233cec..00000000 --- a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/symbol_button_style.g.dart +++ /dev/null @@ -1,150 +0,0 @@ -// 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/theme_style.dart b/packages/wyatt_ui_components/lib/src/domain/entities/theme_style.dart index 7c923ac0..0f637eed 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 @@ -22,4 +22,7 @@ abstract class ThemeStyle { /// Used for interpolation. T? lerpWith(T? other, double t); + + /// 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 8be94829..80e5e707 100644 --- a/packages/wyatt_ui_components/pubspec.yaml +++ b/packages/wyatt_ui_components/pubspec.yaml @@ -9,7 +9,6 @@ environment: sdk: ">=2.17.0 <3.0.0" dependencies: - copy_with_extension: ^5.0.0 flutter: { sdk: flutter } wyatt_component_copy_with_extension: git: @@ -18,7 +17,6 @@ dependencies: dev_dependencies: build_runner: ^2.3.3 - copy_with_extension_gen: ^5.0.0 flutter_test: { sdk: flutter } wyatt_analysis: hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub