diff --git a/packages/wyatt_ui_components/lib/src/core/core.dart b/packages/wyatt_ui_components/lib/src/core/core.dart index a18f1e81..50874264 100644 --- a/packages/wyatt_ui_components/lib/src/core/core.dart +++ b/packages/wyatt_ui_components/lib/src/core/core.dart @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -export 'enums/control_state.dart'; +export 'enums/enums.dart'; export 'extensions/build_context_extensions.dart'; export 'extensions/string_extension.dart'; export 'mixins/copy_with_mixin.dart'; diff --git a/packages/wyatt_ui_components/lib/src/core/enums/enums.dart b/packages/wyatt_ui_components/lib/src/core/enums/enums.dart new file mode 100644 index 00000000..9b4b1438 --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/core/enums/enums.dart @@ -0,0 +1,18 @@ +// Copyright (C) 2023 WYATT GROUP +// Please see the AUTHORS file for details. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +export './control_state.dart'; +export './status_state.dart'; diff --git a/packages/wyatt_ui_components/lib/src/core/enums/status_state.dart b/packages/wyatt_ui_components/lib/src/core/enums/status_state.dart new file mode 100644 index 00000000..878899f6 --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/core/enums/status_state.dart @@ -0,0 +1,22 @@ +// Copyright (C) 2023 WYATT GROUP +// Please see the AUTHORS file for details. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +enum StatusState { + initial, + success, + loading, + error; +} diff --git a/packages/wyatt_ui_components/lib/src/core/utils/multi_color.dart b/packages/wyatt_ui_components/lib/src/core/utils/multi_color.dart index aa37be5b..9e9b7222 100644 --- a/packages/wyatt_ui_components/lib/src/core/utils/multi_color.dart +++ b/packages/wyatt_ui_components/lib/src/core/utils/multi_color.dart @@ -41,10 +41,36 @@ class MultiColor { static MultiColor? lerp(MultiColor? a, MultiColor? b, double t) { if (a == null && b == null) { return null; - } - if (b == null) { + } else if (a == null) { + return b; + } else if (b == null) { return a; } + if (a.isColor && b.isColor) { + return MultiColor.single(Color.lerp(a.color, b.color, t)); + } else if (a.isColor && b.isGradient) { + return MultiColor( + b.colors + .map((e) => Color.lerp(a.color, e, t)) + .whereType() + .toList(), + ); + } else if (a.isGradient && b.isColor) { + return MultiColor( + a.colors + .map((e) => Color.lerp(b.color, e, t)) + .whereType() + .toList(), + ); + } else if (a.isGradient && b.isGradient) { + final colors = List.empty(growable: true); + for (int i = 0; i < a.colors.length; i++) { + final lerpColor = Color.lerp(a.colors[i], b.colors[i], t); + if (lerpColor != null) { + colors.add(lerpColor); + } + } + } return b; } 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 cc14f747..dbf5fcfc 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 @@ -34,24 +34,26 @@ abstract class ThemeResolver { /// {@macro theme_resolver} const ThemeResolver(); - S? Function( - BuildContext context, - S defaultValue, - T themeExtension, { - E? extra, - }) get computeExtensionValueFn; - S? Function(BuildContext context, {E? extra}) get customStyleFn; + S? Function(BuildContext context, S extensionValue, {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( + S? _computeExtensionValue( BuildContext context, S defaultValue, { E? extra, }) { - final themeExtension = findExtension(context); + final themeExtension = Theme.of(context).extension(); if (themeExtension != null) { return computeExtensionValueFn( context, @@ -64,25 +66,27 @@ abstract class ThemeResolver { } /// Compute custom value - S? computeCustomValue( + S? _computeCustomValue( BuildContext context, S previousPhaseValue, { E? extra, }) { - final customStyle = customStyleFn(context, extra: extra); + final customStyle = customStyleFn( + context, + previousPhaseValue, + extra: extra, + ); if (customStyle != null) { return customStyle; } return previousPhaseValue; } - T? findExtension(BuildContext context) => Theme.of(context).extension(); - /// 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 = _computeExtensionValue(context, style, extra: extra) ?? style; + style = _computeCustomValue(context, style, extra: extra) ?? style; return style; } } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/file_selection_button_component.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/file_selection_button_component.g.dart index 1c9f5b2d..aa5816fe 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/file_selection_button_component.g.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/file_selection_button_component.g.dart @@ -22,6 +22,8 @@ abstract class $FileSelectionButtonComponentCWProxy { FileSelectionButtonComponent invalidStyle(ButtonStyle? invalidStyle); FileSelectionButtonComponent onPressed( void Function(ControlState)? onPressed); + FileSelectionButtonComponent themeResolver( + ThemeResolver? themeResolver); FileSelectionButtonComponent key(Key? key); FileSelectionButtonComponent call({ MainAxisSize? mainAxisSize, @@ -36,6 +38,7 @@ abstract class $FileSelectionButtonComponentCWProxy { ButtonStyle? selectedStyle, ButtonStyle? invalidStyle, void Function(ControlState)? onPressed, + ThemeResolver? themeResolver, Key? key, }); } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_component.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_component.g.dart index e234fa3d..fb87d810 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_component.g.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_component.g.dart @@ -17,6 +17,8 @@ abstract class $FlatButtonComponentCWProxy { FlatButtonComponent focusedStyle(ButtonStyle? focusedStyle); FlatButtonComponent tappedStyle(ButtonStyle? tappedStyle); FlatButtonComponent onPressed(void Function(ControlState)? onPressed); + FlatButtonComponent themeResolver( + ThemeResolver? themeResolver); FlatButtonComponent key(Key? key); FlatButtonComponent call({ MainAxisSize? mainAxisSize, @@ -29,6 +31,7 @@ abstract class $FlatButtonComponentCWProxy { ButtonStyle? focusedStyle, ButtonStyle? tappedStyle, void Function(ControlState)? onPressed, + ThemeResolver? themeResolver, Key? key, }); } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/simple_icon_button_component.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/simple_icon_button_component.g.dart index b6c02777..9a4b83ac 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/simple_icon_button_component.g.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/simple_icon_button_component.g.dart @@ -14,6 +14,8 @@ abstract class $SimpleIconButtonComponentCWProxy { SimpleIconButtonComponent focusedStyle(ButtonStyle? focusedStyle); SimpleIconButtonComponent tappedStyle(ButtonStyle? tappedStyle); SimpleIconButtonComponent onPressed(void Function(ControlState)? onPressed); + SimpleIconButtonComponent themeResolver( + ThemeResolver? themeResolver); SimpleIconButtonComponent key(Key? key); SimpleIconButtonComponent call({ Icon? icon, @@ -23,6 +25,7 @@ abstract class $SimpleIconButtonComponentCWProxy { ButtonStyle? focusedStyle, ButtonStyle? tappedStyle, void Function(ControlState)? onPressed, + ThemeResolver? themeResolver, Key? key, }); } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/symbol_button_component.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/symbol_button_component.g.dart index 08422d60..a97dced0 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/symbol_button_component.g.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/symbol_button_component.g.dart @@ -17,6 +17,8 @@ abstract class $SymbolButtonComponentCWProxy { SymbolButtonComponent tappedStyle(ButtonStyle? tappedStyle); SymbolButtonComponent selectedStyle(ButtonStyle? selectedStyle); SymbolButtonComponent onPressed(void Function(ControlState)? onPressed); + SymbolButtonComponent themeResolver( + ThemeResolver? themeResolver); SymbolButtonComponent key(Key? key); SymbolButtonComponent call({ MainAxisSize? mainAxisSize, @@ -29,6 +31,7 @@ abstract class $SymbolButtonComponentCWProxy { ButtonStyle? tappedStyle, ButtonStyle? selectedStyle, void Function(ControlState)? onPressed, + ThemeResolver? themeResolver, Key? key, }); } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/entities.dart b/packages/wyatt_ui_components/lib/src/domain/entities/entities.dart index fe9edb39..ee7477a3 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/entities.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/entities.dart @@ -21,4 +21,4 @@ export './cards/cards.dart'; export './component.dart'; export './error_widget_component.dart'; export './loading_widget_component.dart'; -export './text_input_component.dart'; +export './text_inputs/text_inputs.dart'; diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/text_input_component.dart b/packages/wyatt_ui_components/lib/src/domain/entities/text_inputs/text_input_component.dart similarity index 86% rename from packages/wyatt_ui_components/lib/src/domain/entities/text_input_component.dart rename to packages/wyatt_ui_components/lib/src/domain/entities/text_inputs/text_input_component.dart index f89985e6..2963da6a 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/text_input_component.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/text_inputs/text_input_component.dart @@ -28,12 +28,21 @@ part 'text_input_component.g.dart'; abstract class TextInputComponent extends Component with CopyWithMixin<$TextInputComponentCWProxy> { const TextInputComponent({ - this.backgroundColors, - this.borderColors, - this.radius, + this.expand, + this.onError, + this.validator, + this.suffixText, + this.prefixText, + this.prefixIcon, + this.suffixIcon, + this.label, + this.hint, + this.normalStyle, + this.focusedStyle, + this.errorStyle, + this.disableStyle, this.controller, this.focusNode, - this.decoration, this.keyboardType, this.smartDashesType, this.smartQuotesType, @@ -92,7 +101,6 @@ abstract class TextInputComponent extends Component final TextMagnifierConfiguration? magnifierConfiguration; final TextEditingController? controller; final FocusNode? focusNode; - final InputDecoration? decoration; final TextInputType? keyboardType; final TextInputAction? textInputAction; final TextCapitalization? textCapitalization; @@ -120,7 +128,7 @@ abstract class TextInputComponent extends Component final ValueChanged? onSubmitted; final AppPrivateCommandCallback? onAppPrivateCommand; final List? inputFormatters; - final bool? enabled; + final ValueNotifier? enabled; final double? cursorWidth; final double? cursorHeight; final Radius? cursorRadius; @@ -145,7 +153,21 @@ abstract class TextInputComponent extends Component final EditableTextContextMenuBuilder? contextMenuBuilder; final SpellCheckConfiguration? spellCheckConfiguration; - final MultiColor? backgroundColors; - final MultiColor? borderColors; - final double? radius; + final bool Function(String)? validator; + final String? Function(String)? onError; + + final TextInputStyle? normalStyle; + final TextInputStyle? focusedStyle; + final TextInputStyle? errorStyle; + final TextInputStyle? disableStyle; + + final bool? expand; + + final TextWrapper? label; + final TextWrapper? hint; + + final TextWrapper? prefixText; + final TextWrapper? suffixText; + final Icon? prefixIcon; + final Icon? suffixIcon; } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/text_input_component.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/text_inputs/text_input_component.g.dart similarity index 82% rename from packages/wyatt_ui_components/lib/src/domain/entities/text_input_component.g.dart rename to packages/wyatt_ui_components/lib/src/domain/entities/text_inputs/text_input_component.g.dart index 0bb149e2..59083bd6 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/text_input_component.g.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/text_inputs/text_input_component.g.dart @@ -7,12 +7,21 @@ part of 'text_input_component.dart'; // ************************************************************************** abstract class $TextInputComponentCWProxy { - TextInputComponent backgroundColors(MultiColor? backgroundColors); - TextInputComponent borderColors(MultiColor? borderColors); - TextInputComponent radius(double? radius); + TextInputComponent expand(bool? expand); + TextInputComponent onError(String Function(String)? onError); + TextInputComponent validator(bool Function(String)? validator); + TextInputComponent suffixText(TextWrapper? suffixText); + TextInputComponent prefixText(TextWrapper? prefixText); + TextInputComponent prefixIcon(Icon? prefixIcon); + TextInputComponent suffixIcon(Icon? suffixIcon); + TextInputComponent label(TextWrapper? label); + TextInputComponent hint(TextWrapper? hint); + TextInputComponent normalStyle(TextInputStyle? normalStyle); + TextInputComponent focusedStyle(TextInputStyle? focusedStyle); + TextInputComponent errorStyle(TextInputStyle? errorStyle); + TextInputComponent disableStyle(TextInputStyle? disableStyle); TextInputComponent controller(TextEditingController? controller); TextInputComponent focusNode(FocusNode? focusNode); - TextInputComponent decoration(InputDecoration? decoration); TextInputComponent keyboardType(TextInputType? keyboardType); TextInputComponent smartDashesType(SmartDashesType? smartDashesType); TextInputComponent smartQuotesType(SmartQuotesType? smartQuotesType); @@ -44,7 +53,7 @@ abstract class $TextInputComponentCWProxy { TextInputComponent onAppPrivateCommand( void Function(String, Map)? onAppPrivateCommand); TextInputComponent inputFormatters(List? inputFormatters); - TextInputComponent enabled(bool? enabled); + TextInputComponent enabled(ValueNotifier? enabled); TextInputComponent cursorWidth(double? cursorWidth); TextInputComponent cursorHeight(double? cursorHeight); TextInputComponent cursorRadius(Radius? cursorRadius); @@ -76,12 +85,21 @@ abstract class $TextInputComponentCWProxy { TextMagnifierConfiguration? magnifierConfiguration); TextInputComponent key(Key? key); TextInputComponent call({ - MultiColor? backgroundColors, - MultiColor? borderColors, - double? radius, + bool? expand, + String Function(String)? onError, + bool Function(String)? validator, + TextWrapper? suffixText, + TextWrapper? prefixText, + Icon? prefixIcon, + Icon? suffixIcon, + TextWrapper? label, + TextWrapper? hint, + TextInputStyle? normalStyle, + TextInputStyle? focusedStyle, + TextInputStyle? errorStyle, + TextInputStyle? disableStyle, TextEditingController? controller, FocusNode? focusNode, - InputDecoration? decoration, TextInputType? keyboardType, SmartDashesType? smartDashesType, SmartQuotesType? smartQuotesType, @@ -110,7 +128,7 @@ abstract class $TextInputComponentCWProxy { void Function(String)? onSubmitted, void Function(String, Map)? onAppPrivateCommand, List? inputFormatters, - bool? enabled, + ValueNotifier? enabled, double? cursorWidth, double? cursorHeight, Radius? cursorRadius, 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 new file mode 100644 index 00000000..a456647e --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/text_inputs/text_input_style.dart @@ -0,0 +1,102 @@ +// Copyright (C) 2023 WYATT GROUP +// Please see the AUTHORS file for details. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// 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/material.dart'; +import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart'; +part 'text_input_style.g.dart'; + +@CopyWith() +class TextInputStyle { + TextInputStyle({ + this.labelStyle, + this.hintStyle, + this.backgroundColors, + this.borderColors, + this.boxShadow, + this.radius, + this.inputStyle, + this.iconColor, + this.prefixStyle, + this.prefixIconColor, + this.suffixStyle, + this.suffixIconColor, + }); + + final TextStyle? labelStyle; + final TextStyle? hintStyle; + + final Color? iconColor; + final TextStyle? prefixStyle; + final Color? prefixIconColor; + final TextStyle? suffixStyle; + final Color? suffixIconColor; + + final MultiColor? backgroundColors; + final MultiColor? borderColors; + final BoxShadow? boxShadow; + final BorderRadiusGeometry? radius; + final TextStyle? inputStyle; + + static TextInputStyle? merge(TextInputStyle? a, TextInputStyle? b) { + if (b == null) { + return a?.copyWith(); + } + 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, + ); + } + + static TextInputStyle? lerp( + TextInputStyle? a, + TextInputStyle? b, + double t, + ) { + if (a == null || b == null) { + return null; + } + + return b.copyWith( + labelStyle: TextStyle.lerp(a.labelStyle, b.labelStyle, t), + hintStyle: TextStyle.lerp(a.hintStyle, b.hintStyle, t), + backgroundColors: + MultiColor.lerp(a.backgroundColors, b.backgroundColors, t), + radius: BorderRadiusGeometry.lerp(a.radius, b.radius, t), + borderColors: MultiColor.lerp(a.borderColors, b.borderColors, t), + boxShadow: BoxShadow.lerp(a.boxShadow, b.boxShadow, t), + inputStyle: TextStyle.lerp(a.inputStyle, b.inputStyle, t), + prefixStyle: TextStyle.lerp(a.prefixStyle, b.prefixStyle, t), + suffixStyle: TextStyle.lerp(a.suffixStyle, b.suffixStyle, t), + prefixIconColor: Color.lerp(a.prefixIconColor, b.prefixIconColor, t), + suffixIconColor: Color.lerp(a.suffixIconColor, b.suffixIconColor, t), + iconColor: Color.lerp(a.iconColor, b.iconColor, t), + ); + } +} diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/text_inputs/text_input_style.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/text_inputs/text_input_style.g.dart new file mode 100644 index 00000000..972c2b88 --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/text_inputs/text_input_style.g.dart @@ -0,0 +1,185 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'text_input_style.dart'; + +// ************************************************************************** +// CopyWithGenerator +// ************************************************************************** + +abstract class _$TextInputStyleCWProxy { + TextInputStyle labelStyle(TextStyle? labelStyle); + + TextInputStyle hintStyle(TextStyle? hintStyle); + + TextInputStyle backgroundColors(MultiColor? backgroundColors); + + TextInputStyle borderColors(MultiColor? borderColors); + + TextInputStyle boxShadow(BoxShadow? boxShadow); + + TextInputStyle radius(BorderRadiusGeometry? radius); + + TextInputStyle inputStyle(TextStyle? inputStyle); + + TextInputStyle iconColor(Color? iconColor); + + TextInputStyle prefixStyle(TextStyle? prefixStyle); + + TextInputStyle prefixIconColor(Color? prefixIconColor); + + TextInputStyle suffixStyle(TextStyle? suffixStyle); + + TextInputStyle suffixIconColor(Color? suffixIconColor); + + /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `TextInputStyle(...).copyWith.fieldName(...)` to override fields one at a time with nullification support. + /// + /// Usage + /// ```dart + /// TextInputStyle(...).copyWith(id: 12, name: "My name") + /// ```` + TextInputStyle call({ + TextStyle? labelStyle, + TextStyle? hintStyle, + MultiColor? backgroundColors, + MultiColor? borderColors, + BoxShadow? boxShadow, + BorderRadiusGeometry? radius, + TextStyle? inputStyle, + Color? iconColor, + TextStyle? prefixStyle, + Color? prefixIconColor, + TextStyle? suffixStyle, + Color? suffixIconColor, + }); +} + +/// Proxy class for `copyWith` functionality. This is a callable class and can be used as follows: `instanceOfTextInputStyle.copyWith(...)`. Additionally contains functions for specific fields e.g. `instanceOfTextInputStyle.copyWith.fieldName(...)` +class _$TextInputStyleCWProxyImpl implements _$TextInputStyleCWProxy { + const _$TextInputStyleCWProxyImpl(this._value); + + final TextInputStyle _value; + + @override + TextInputStyle labelStyle(TextStyle? labelStyle) => + this(labelStyle: labelStyle); + + @override + TextInputStyle hintStyle(TextStyle? hintStyle) => this(hintStyle: hintStyle); + + @override + TextInputStyle backgroundColors(MultiColor? backgroundColors) => + this(backgroundColors: backgroundColors); + + @override + TextInputStyle borderColors(MultiColor? borderColors) => + this(borderColors: borderColors); + + @override + TextInputStyle boxShadow(BoxShadow? boxShadow) => this(boxShadow: boxShadow); + + @override + TextInputStyle radius(BorderRadiusGeometry? radius) => this(radius: radius); + + @override + TextInputStyle inputStyle(TextStyle? inputStyle) => + this(inputStyle: inputStyle); + + @override + TextInputStyle iconColor(Color? iconColor) => this(iconColor: iconColor); + + @override + TextInputStyle prefixStyle(TextStyle? prefixStyle) => + this(prefixStyle: prefixStyle); + + @override + TextInputStyle prefixIconColor(Color? prefixIconColor) => + this(prefixIconColor: prefixIconColor); + + @override + TextInputStyle suffixStyle(TextStyle? suffixStyle) => + this(suffixStyle: suffixStyle); + + @override + TextInputStyle suffixIconColor(Color? suffixIconColor) => + this(suffixIconColor: suffixIconColor); + + @override + + /// This function **does support** nullification of nullable fields. All `null` values passed to `non-nullable` fields will be ignored. You can also use `TextInputStyle(...).copyWith.fieldName(...)` to override fields one at a time with nullification support. + /// + /// Usage + /// ```dart + /// TextInputStyle(...).copyWith(id: 12, name: "My name") + /// ```` + TextInputStyle call({ + Object? labelStyle = const $CopyWithPlaceholder(), + Object? hintStyle = const $CopyWithPlaceholder(), + Object? backgroundColors = const $CopyWithPlaceholder(), + Object? borderColors = const $CopyWithPlaceholder(), + Object? boxShadow = const $CopyWithPlaceholder(), + Object? radius = const $CopyWithPlaceholder(), + Object? inputStyle = const $CopyWithPlaceholder(), + Object? iconColor = const $CopyWithPlaceholder(), + Object? prefixStyle = const $CopyWithPlaceholder(), + Object? prefixIconColor = const $CopyWithPlaceholder(), + Object? suffixStyle = const $CopyWithPlaceholder(), + Object? suffixIconColor = const $CopyWithPlaceholder(), + }) { + return TextInputStyle( + labelStyle: labelStyle == const $CopyWithPlaceholder() + ? _value.labelStyle + // ignore: cast_nullable_to_non_nullable + : labelStyle as TextStyle?, + hintStyle: hintStyle == const $CopyWithPlaceholder() + ? _value.hintStyle + // ignore: cast_nullable_to_non_nullable + : hintStyle as TextStyle?, + 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?, + boxShadow: boxShadow == const $CopyWithPlaceholder() + ? _value.boxShadow + // ignore: cast_nullable_to_non_nullable + : boxShadow as BoxShadow?, + radius: radius == const $CopyWithPlaceholder() + ? _value.radius + // ignore: cast_nullable_to_non_nullable + : radius as BorderRadiusGeometry?, + inputStyle: inputStyle == const $CopyWithPlaceholder() + ? _value.inputStyle + // ignore: cast_nullable_to_non_nullable + : inputStyle as TextStyle?, + iconColor: iconColor == const $CopyWithPlaceholder() + ? _value.iconColor + // ignore: cast_nullable_to_non_nullable + : iconColor as Color?, + prefixStyle: prefixStyle == const $CopyWithPlaceholder() + ? _value.prefixStyle + // ignore: cast_nullable_to_non_nullable + : prefixStyle as TextStyle?, + prefixIconColor: prefixIconColor == const $CopyWithPlaceholder() + ? _value.prefixIconColor + // ignore: cast_nullable_to_non_nullable + : prefixIconColor as Color?, + suffixStyle: suffixStyle == const $CopyWithPlaceholder() + ? _value.suffixStyle + // ignore: cast_nullable_to_non_nullable + : suffixStyle as TextStyle?, + suffixIconColor: suffixIconColor == const $CopyWithPlaceholder() + ? _value.suffixIconColor + // ignore: cast_nullable_to_non_nullable + : suffixIconColor as Color?, + ); + } +} + +extension $TextInputStyleCopyWith on TextInputStyle { + /// Returns a callable class that can be used as follows: `instanceOfTextInputStyle.copyWith(...)` or like so:`instanceOfTextInputStyle.copyWith.fieldName(...)`. + // ignore: library_private_types_in_public_api + _$TextInputStyleCWProxy get copyWith => _$TextInputStyleCWProxyImpl(this); +} diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/text_inputs/text_inputs.dart b/packages/wyatt_ui_components/lib/src/domain/entities/text_inputs/text_inputs.dart new file mode 100644 index 00000000..26b4e465 --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/text_inputs/text_inputs.dart @@ -0,0 +1,18 @@ +// Copyright (C) 2023 WYATT GROUP +// Please see the AUTHORS file for details. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +export './text_input_component.dart'; +export './text_input_style.dart';