feat(ui_component): add copyWith gen and make button style lerping
This commit is contained in:
parent
ed29f39673
commit
2806ac5923
@ -30,25 +30,25 @@ abstract class ButtonComponent extends Component {
|
||||
});
|
||||
|
||||
/// Style of this button in disabled state
|
||||
final ButtonStyle? disabledStyle;
|
||||
final ButtonStyle<dynamic>? disabledStyle;
|
||||
|
||||
/// Style of this button in normal state
|
||||
final ButtonStyle? normalStyle;
|
||||
final ButtonStyle<dynamic>? normalStyle;
|
||||
|
||||
/// Style of this button in hovered state
|
||||
final ButtonStyle? hoveredStyle;
|
||||
final ButtonStyle<dynamic>? hoveredStyle;
|
||||
|
||||
/// Style of this button in focused state
|
||||
final ButtonStyle? focusedStyle;
|
||||
final ButtonStyle<dynamic>? focusedStyle;
|
||||
|
||||
/// Style of this button in tapped state
|
||||
final ButtonStyle? tappedStyle;
|
||||
final ButtonStyle<dynamic>? tappedStyle;
|
||||
|
||||
/// Style of this button in selected state
|
||||
final ButtonStyle? selectedStyle;
|
||||
final ButtonStyle<dynamic>? selectedStyle;
|
||||
|
||||
/// Style of this button in invalid state
|
||||
final ButtonStyle? invalidStyle;
|
||||
final ButtonStyle<dynamic>? invalidStyle;
|
||||
|
||||
/// Callback on button press
|
||||
final void Function(ControlState state)? onPressed;
|
||||
|
@ -17,41 +17,49 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:wyatt_ui_components/src/core/utils/multi_color.dart';
|
||||
|
||||
abstract class ButtonStyle {
|
||||
abstract class ButtonStyle<T> {
|
||||
const ButtonStyle({
|
||||
this.radius = 15,
|
||||
this.padding = 10,
|
||||
this.radius,
|
||||
this.padding,
|
||||
this.foregroundColors,
|
||||
this.backgroundColors,
|
||||
this.borderColors,
|
||||
this.stroke = 2,
|
||||
this.shadow = const BoxShadow(
|
||||
blurRadius: 30,
|
||||
offset: Offset(0, 5),
|
||||
color: Color.fromRGBO(0, 0, 0, 0.05),
|
||||
),
|
||||
this.stroke,
|
||||
this.shadow,
|
||||
});
|
||||
|
||||
/// Button radius
|
||||
final double? radius;
|
||||
///
|
||||
/// Default to `BorderRadius.all(Radius.circular(4.0))`
|
||||
final BorderRadiusGeometry? radius;
|
||||
|
||||
/// Padding and gaps of this card
|
||||
final double? padding;
|
||||
/// Padding and gaps of this button
|
||||
///
|
||||
/// Default to `ButtonTheme.padding`
|
||||
final EdgeInsetsGeometry? padding;
|
||||
|
||||
/// Button foreground gradient colors (from left to right)
|
||||
///
|
||||
/// Default to `Theme.colorScheme.onPrimary`
|
||||
final MultiColor? foregroundColors;
|
||||
|
||||
|
||||
/// Button background gradient colors (from left to right)
|
||||
///
|
||||
/// Default to `Theme.colorScheme.primary`
|
||||
final MultiColor? backgroundColors;
|
||||
|
||||
/// Border colors (from left to right).
|
||||
///
|
||||
/// Default to `null`
|
||||
final MultiColor? borderColors;
|
||||
|
||||
/// Stroke of the border
|
||||
///
|
||||
/// Default to `null`
|
||||
final double? stroke;
|
||||
|
||||
/// Drop shadow
|
||||
///
|
||||
/// Default to `null`
|
||||
final BoxShadow? shadow;
|
||||
|
||||
ButtonStyle copyWith();
|
||||
}
|
||||
|
@ -11,13 +11,15 @@ abstract class $FileSelectionButtonComponentCWProxy {
|
||||
FileSelectionButtonComponent leading(Widget? leading);
|
||||
FileSelectionButtonComponent title(TextWrapper? title);
|
||||
FileSelectionButtonComponent subTitle(TextWrapper? subTitle);
|
||||
FileSelectionButtonComponent disabledStyle(ButtonStyle? disabledStyle);
|
||||
FileSelectionButtonComponent normalStyle(ButtonStyle? normalStyle);
|
||||
FileSelectionButtonComponent hoveredStyle(ButtonStyle? hoveredStyle);
|
||||
FileSelectionButtonComponent focusedStyle(ButtonStyle? focusedStyle);
|
||||
FileSelectionButtonComponent tappedStyle(ButtonStyle? tappedStyle);
|
||||
FileSelectionButtonComponent selectedStyle(ButtonStyle? selectedStyle);
|
||||
FileSelectionButtonComponent invalidStyle(ButtonStyle? invalidStyle);
|
||||
FileSelectionButtonComponent disabledStyle(
|
||||
ButtonStyle<dynamic>? disabledStyle);
|
||||
FileSelectionButtonComponent normalStyle(ButtonStyle<dynamic>? normalStyle);
|
||||
FileSelectionButtonComponent hoveredStyle(ButtonStyle<dynamic>? hoveredStyle);
|
||||
FileSelectionButtonComponent focusedStyle(ButtonStyle<dynamic>? focusedStyle);
|
||||
FileSelectionButtonComponent tappedStyle(ButtonStyle<dynamic>? tappedStyle);
|
||||
FileSelectionButtonComponent selectedStyle(
|
||||
ButtonStyle<dynamic>? selectedStyle);
|
||||
FileSelectionButtonComponent invalidStyle(ButtonStyle<dynamic>? invalidStyle);
|
||||
FileSelectionButtonComponent onPressed(
|
||||
void Function(ControlState)? onPressed);
|
||||
FileSelectionButtonComponent key(Key? key);
|
||||
@ -26,13 +28,13 @@ abstract class $FileSelectionButtonComponentCWProxy {
|
||||
Widget? leading,
|
||||
TextWrapper? title,
|
||||
TextWrapper? subTitle,
|
||||
ButtonStyle? disabledStyle,
|
||||
ButtonStyle? normalStyle,
|
||||
ButtonStyle? hoveredStyle,
|
||||
ButtonStyle? focusedStyle,
|
||||
ButtonStyle? tappedStyle,
|
||||
ButtonStyle? selectedStyle,
|
||||
ButtonStyle? invalidStyle,
|
||||
ButtonStyle<dynamic>? disabledStyle,
|
||||
ButtonStyle<dynamic>? normalStyle,
|
||||
ButtonStyle<dynamic>? hoveredStyle,
|
||||
ButtonStyle<dynamic>? focusedStyle,
|
||||
ButtonStyle<dynamic>? tappedStyle,
|
||||
ButtonStyle<dynamic>? selectedStyle,
|
||||
ButtonStyle<dynamic>? invalidStyle,
|
||||
void Function(ControlState)? onPressed,
|
||||
Key? key,
|
||||
});
|
||||
|
@ -14,42 +14,85 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:wyatt_ui_components/src/core/extensions/build_context_extensions.dart';
|
||||
import 'package:wyatt_ui_components/src/core/utils/multi_color.dart';
|
||||
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
|
||||
|
||||
class FileSelectionButtonStyle extends ButtonStyle {
|
||||
part 'file_selection_button_style.g.dart';
|
||||
|
||||
@CopyWith()
|
||||
class FileSelectionButtonStyle extends ButtonStyle<FileSelectionButtonStyle> {
|
||||
const FileSelectionButtonStyle({
|
||||
super.radius = 12,
|
||||
super.padding = 13,
|
||||
this.title,
|
||||
this.subTitle,
|
||||
super.radius,
|
||||
super.padding,
|
||||
super.foregroundColors,
|
||||
super.backgroundColors,
|
||||
super.borderColors,
|
||||
super.stroke = 2,
|
||||
super.shadow = const BoxShadow(
|
||||
blurRadius: 30,
|
||||
offset: Offset(0, 5),
|
||||
color: Color.fromRGBO(0, 0, 0, 0.05),
|
||||
),
|
||||
super.stroke,
|
||||
super.shadow,
|
||||
});
|
||||
|
||||
@override
|
||||
FileSelectionButtonStyle copyWith({
|
||||
double? radius,
|
||||
double? padding,
|
||||
MultiColor? foregroundColors,
|
||||
MultiColor? backgroundColors,
|
||||
MultiColor? borderColors,
|
||||
double? stroke,
|
||||
BoxShadow? shadow,
|
||||
}) =>
|
||||
/// Used in negociation to build a style from Flutter default values.
|
||||
factory FileSelectionButtonStyle.fromFlutter(BuildContext context) =>
|
||||
FileSelectionButtonStyle(
|
||||
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,
|
||||
title: context.textTheme.labelLarge,
|
||||
subTitle: context.textTheme.labelSmall,
|
||||
radius: (context.buttonTheme.shape is RoundedRectangleBorder)
|
||||
? (context.buttonTheme.shape as RoundedRectangleBorder).borderRadius
|
||||
: null,
|
||||
padding: context.buttonTheme.padding,
|
||||
foregroundColors: MultiColor.single(context.colorScheme.onPrimary),
|
||||
backgroundColors: MultiColor.single(context.colorScheme.primary),
|
||||
);
|
||||
|
||||
/// Used for interpolation.
|
||||
static FileSelectionButtonStyle? lerp(
|
||||
FileSelectionButtonStyle? a,
|
||||
FileSelectionButtonStyle? b,
|
||||
double t,
|
||||
) {
|
||||
if (a == null || b == null) {
|
||||
return null;
|
||||
}
|
||||
// b.copyWith to return b attributes even if they are not lerped
|
||||
return b.copyWith(
|
||||
title: TextStyle.lerp(a.title, b.title, t),
|
||||
subTitle: TextStyle.lerp(a.title, b.title, t),
|
||||
foregroundColors: MultiColor.lerp(
|
||||
a.foregroundColors,
|
||||
b.foregroundColors,
|
||||
t,
|
||||
),
|
||||
backgroundColors: MultiColor.lerp(
|
||||
a.backgroundColors,
|
||||
b.backgroundColors,
|
||||
t,
|
||||
),
|
||||
borderColors: MultiColor.lerp(
|
||||
a.borderColors,
|
||||
b.borderColors,
|
||||
t,
|
||||
),
|
||||
radius: BorderRadiusGeometry.lerp(a.radius, b.radius, t),
|
||||
padding: EdgeInsetsGeometry.lerp(a.padding, b.padding, t),
|
||||
stroke: lerpDouble(a.stroke, b.stroke, t),
|
||||
shadow: BoxShadow.lerp(a.shadow, b.shadow, t),
|
||||
);
|
||||
}
|
||||
|
||||
/// Title text style
|
||||
///
|
||||
/// Default to `TextTheme.labelLarge`
|
||||
final TextStyle? title;
|
||||
|
||||
/// Sub title text style
|
||||
///
|
||||
/// Default to `TextTheme.labelSmall`
|
||||
final TextStyle? subTitle;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
@ -24,7 +24,7 @@ part 'flat_button_component.g.dart';
|
||||
abstract class FlatButtonComponent extends ButtonComponent
|
||||
with CopyWithMixin<$FlatButtonComponentCWProxy> {
|
||||
const FlatButtonComponent({
|
||||
this.mainAxisSize = MainAxisSize.min,
|
||||
this.mainAxisSize,
|
||||
this.prefix,
|
||||
this.suffix,
|
||||
this.label,
|
||||
|
@ -11,11 +11,11 @@ abstract class $FlatButtonComponentCWProxy {
|
||||
FlatButtonComponent prefix(Widget? prefix);
|
||||
FlatButtonComponent suffix(Widget? suffix);
|
||||
FlatButtonComponent label(TextWrapper? label);
|
||||
FlatButtonComponent disabledStyle(ButtonStyle? disabledStyle);
|
||||
FlatButtonComponent normalStyle(ButtonStyle? normalStyle);
|
||||
FlatButtonComponent hoveredStyle(ButtonStyle? hoveredStyle);
|
||||
FlatButtonComponent focusedStyle(ButtonStyle? focusedStyle);
|
||||
FlatButtonComponent tappedStyle(ButtonStyle? tappedStyle);
|
||||
FlatButtonComponent disabledStyle(ButtonStyle<dynamic>? disabledStyle);
|
||||
FlatButtonComponent normalStyle(ButtonStyle<dynamic>? normalStyle);
|
||||
FlatButtonComponent hoveredStyle(ButtonStyle<dynamic>? hoveredStyle);
|
||||
FlatButtonComponent focusedStyle(ButtonStyle<dynamic>? focusedStyle);
|
||||
FlatButtonComponent tappedStyle(ButtonStyle<dynamic>? tappedStyle);
|
||||
FlatButtonComponent onPressed(void Function(ControlState)? onPressed);
|
||||
FlatButtonComponent key(Key? key);
|
||||
FlatButtonComponent call({
|
||||
@ -23,11 +23,11 @@ abstract class $FlatButtonComponentCWProxy {
|
||||
Widget? prefix,
|
||||
Widget? suffix,
|
||||
TextWrapper? label,
|
||||
ButtonStyle? disabledStyle,
|
||||
ButtonStyle? normalStyle,
|
||||
ButtonStyle? hoveredStyle,
|
||||
ButtonStyle? focusedStyle,
|
||||
ButtonStyle? tappedStyle,
|
||||
ButtonStyle<dynamic>? disabledStyle,
|
||||
ButtonStyle<dynamic>? normalStyle,
|
||||
ButtonStyle<dynamic>? hoveredStyle,
|
||||
ButtonStyle<dynamic>? focusedStyle,
|
||||
ButtonStyle<dynamic>? tappedStyle,
|
||||
void Function(ControlState)? onPressed,
|
||||
Key? key,
|
||||
});
|
||||
|
@ -14,42 +14,76 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:wyatt_ui_components/src/core/extensions/build_context_extensions.dart';
|
||||
import 'package:wyatt_ui_components/src/core/utils/multi_color.dart';
|
||||
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
|
||||
|
||||
class FlatButtonStyle extends ButtonStyle {
|
||||
part 'flat_button_style.g.dart';
|
||||
|
||||
@CopyWith()
|
||||
class FlatButtonStyle extends ButtonStyle<FlatButtonStyle> {
|
||||
const FlatButtonStyle({
|
||||
super.radius = 15,
|
||||
super.padding = 10,
|
||||
this.label,
|
||||
super.radius,
|
||||
super.padding,
|
||||
super.foregroundColors,
|
||||
super.backgroundColors,
|
||||
super.borderColors,
|
||||
super.stroke = 2,
|
||||
super.shadow = const BoxShadow(
|
||||
blurRadius: 30,
|
||||
offset: Offset(0, 5),
|
||||
color: Color.fromRGBO(0, 0, 0, 0.05),
|
||||
),
|
||||
super.stroke,
|
||||
super.shadow,
|
||||
});
|
||||
|
||||
@override
|
||||
FlatButtonStyle copyWith({
|
||||
double? radius,
|
||||
double? padding,
|
||||
MultiColor? foregroundColors,
|
||||
MultiColor? backgroundColors,
|
||||
MultiColor? borderColors,
|
||||
double? stroke,
|
||||
BoxShadow? shadow,
|
||||
}) =>
|
||||
FlatButtonStyle(
|
||||
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,
|
||||
/// Used in negociation to build a style from Flutter default values.
|
||||
factory FlatButtonStyle.fromFlutter(BuildContext context) => FlatButtonStyle(
|
||||
label: context.textTheme.labelLarge,
|
||||
radius: (context.buttonTheme.shape is RoundedRectangleBorder)
|
||||
? (context.buttonTheme.shape as RoundedRectangleBorder).borderRadius
|
||||
: null,
|
||||
padding: context.buttonTheme.padding,
|
||||
foregroundColors: MultiColor.single(context.colorScheme.onPrimary),
|
||||
backgroundColors: MultiColor.single(context.colorScheme.primary),
|
||||
);
|
||||
|
||||
/// Used for interpolation.
|
||||
static FlatButtonStyle? lerp(
|
||||
FlatButtonStyle? a,
|
||||
FlatButtonStyle? b,
|
||||
double t,
|
||||
) {
|
||||
if (a == null || b == null) {
|
||||
return null;
|
||||
}
|
||||
// b.copyWith to return b attributes even if they are not lerped
|
||||
return b.copyWith(
|
||||
label: TextStyle.lerp(a.label, b.label, t),
|
||||
foregroundColors: MultiColor.lerp(
|
||||
a.foregroundColors,
|
||||
b.foregroundColors,
|
||||
t,
|
||||
),
|
||||
backgroundColors: MultiColor.lerp(
|
||||
a.backgroundColors,
|
||||
b.backgroundColors,
|
||||
t,
|
||||
),
|
||||
borderColors: MultiColor.lerp(
|
||||
a.borderColors,
|
||||
b.borderColors,
|
||||
t,
|
||||
),
|
||||
radius: BorderRadiusGeometry.lerp(a.radius, b.radius, t),
|
||||
padding: EdgeInsetsGeometry.lerp(a.padding, b.padding, t),
|
||||
stroke: lerpDouble(a.stroke, b.stroke, t),
|
||||
shadow: BoxShadow.lerp(a.shadow, b.shadow, t),
|
||||
);
|
||||
}
|
||||
|
||||
/// Label text style
|
||||
///
|
||||
/// Default to `TextTheme.labelLarge`
|
||||
final TextStyle? label;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
@ -16,7 +16,6 @@
|
||||
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart';
|
||||
import 'package:wyatt_ui_components/src/domain/entities/buttons/simple_icon_button_style.dart';
|
||||
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
|
||||
|
||||
part 'simple_icon_button_component.g.dart';
|
||||
@ -31,7 +30,6 @@ abstract class SimpleIconButtonComponent extends ButtonComponent
|
||||
super.hoveredStyle,
|
||||
super.focusedStyle,
|
||||
super.tappedStyle,
|
||||
super.selectedStyle,
|
||||
super.onPressed,
|
||||
super.key,
|
||||
});
|
||||
@ -51,8 +49,5 @@ abstract class SimpleIconButtonComponent extends ButtonComponent
|
||||
@override
|
||||
SimpleIconButtonStyle? get tappedStyle;
|
||||
|
||||
@override
|
||||
SimpleIconButtonStyle? get selectedStyle;
|
||||
|
||||
final Icon? icon;
|
||||
}
|
||||
|
@ -8,22 +8,20 @@ part of 'simple_icon_button_component.dart';
|
||||
|
||||
abstract class $SimpleIconButtonComponentCWProxy {
|
||||
SimpleIconButtonComponent icon(Icon? icon);
|
||||
SimpleIconButtonComponent disabledStyle(ButtonStyle? disabledStyle);
|
||||
SimpleIconButtonComponent normalStyle(ButtonStyle? normalStyle);
|
||||
SimpleIconButtonComponent hoveredStyle(ButtonStyle? hoveredStyle);
|
||||
SimpleIconButtonComponent focusedStyle(ButtonStyle? focusedStyle);
|
||||
SimpleIconButtonComponent tappedStyle(ButtonStyle? tappedStyle);
|
||||
SimpleIconButtonComponent selectedStyle(ButtonStyle? selectedStyle);
|
||||
SimpleIconButtonComponent disabledStyle(ButtonStyle<dynamic>? disabledStyle);
|
||||
SimpleIconButtonComponent normalStyle(ButtonStyle<dynamic>? normalStyle);
|
||||
SimpleIconButtonComponent hoveredStyle(ButtonStyle<dynamic>? hoveredStyle);
|
||||
SimpleIconButtonComponent focusedStyle(ButtonStyle<dynamic>? focusedStyle);
|
||||
SimpleIconButtonComponent tappedStyle(ButtonStyle<dynamic>? tappedStyle);
|
||||
SimpleIconButtonComponent onPressed(void Function(ControlState)? onPressed);
|
||||
SimpleIconButtonComponent key(Key? key);
|
||||
SimpleIconButtonComponent call({
|
||||
Icon? icon,
|
||||
ButtonStyle? disabledStyle,
|
||||
ButtonStyle? normalStyle,
|
||||
ButtonStyle? hoveredStyle,
|
||||
ButtonStyle? focusedStyle,
|
||||
ButtonStyle? tappedStyle,
|
||||
ButtonStyle? selectedStyle,
|
||||
ButtonStyle<dynamic>? disabledStyle,
|
||||
ButtonStyle<dynamic>? normalStyle,
|
||||
ButtonStyle<dynamic>? hoveredStyle,
|
||||
ButtonStyle<dynamic>? focusedStyle,
|
||||
ButtonStyle<dynamic>? tappedStyle,
|
||||
void Function(ControlState)? onPressed,
|
||||
Key? key,
|
||||
});
|
||||
|
@ -14,47 +14,77 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:wyatt_ui_components/src/core/extensions/build_context_extensions.dart';
|
||||
import 'package:wyatt_ui_components/src/core/utils/multi_color.dart';
|
||||
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
|
||||
|
||||
class SimpleIconButtonStyle extends ButtonStyle {
|
||||
part 'simple_icon_button_style.g.dart';
|
||||
|
||||
@CopyWith()
|
||||
class SimpleIconButtonStyle extends ButtonStyle<SimpleIconButtonStyle> {
|
||||
const SimpleIconButtonStyle({
|
||||
this.dimension = 30,
|
||||
super.radius = 5,
|
||||
super.padding = 5,
|
||||
this.dimension,
|
||||
super.radius,
|
||||
super.padding,
|
||||
super.foregroundColors,
|
||||
super.backgroundColors,
|
||||
super.borderColors,
|
||||
super.stroke = 2,
|
||||
super.shadow = const BoxShadow(
|
||||
blurRadius: 30,
|
||||
offset: Offset(0, 5),
|
||||
color: Color.fromRGBO(0, 0, 0, 0.05),
|
||||
),
|
||||
super.stroke,
|
||||
super.shadow,
|
||||
});
|
||||
|
||||
final double? dimension;
|
||||
|
||||
@override
|
||||
SimpleIconButtonStyle copyWith({
|
||||
double? dimension,
|
||||
double? radius,
|
||||
double? padding,
|
||||
MultiColor? foregroundColors,
|
||||
MultiColor? backgroundColors,
|
||||
MultiColor? borderColors,
|
||||
double? stroke,
|
||||
BoxShadow? shadow,
|
||||
}) =>
|
||||
/// Used in negociation to build a style from Flutter default values.
|
||||
factory SimpleIconButtonStyle.fromFlutter(BuildContext context) =>
|
||||
SimpleIconButtonStyle(
|
||||
dimension: dimension ?? this.dimension,
|
||||
radius: radius ?? radius,
|
||||
padding: padding ?? padding,
|
||||
foregroundColors: foregroundColors ?? foregroundColors,
|
||||
backgroundColors: backgroundColors ?? backgroundColors,
|
||||
borderColors: borderColors ?? borderColors,
|
||||
stroke: stroke ?? stroke,
|
||||
shadow: shadow ?? shadow,
|
||||
dimension: context.buttonTheme.height,
|
||||
radius: (context.buttonTheme.shape is RoundedRectangleBorder)
|
||||
? (context.buttonTheme.shape as RoundedRectangleBorder).borderRadius
|
||||
: null,
|
||||
padding: context.buttonTheme.padding,
|
||||
foregroundColors: MultiColor.single(context.colorScheme.onPrimary),
|
||||
backgroundColors: MultiColor.single(context.colorScheme.primary),
|
||||
);
|
||||
|
||||
/// Used for interpolation.
|
||||
static SimpleIconButtonStyle? lerp(
|
||||
SimpleIconButtonStyle? a,
|
||||
SimpleIconButtonStyle? b,
|
||||
double t,
|
||||
) {
|
||||
if (a == null || b == null) {
|
||||
return null;
|
||||
}
|
||||
// b.copyWith to return b attributes even if they are not lerped
|
||||
return b.copyWith(
|
||||
dimension: lerpDouble(a.dimension, b.dimension, t),
|
||||
foregroundColors: MultiColor.lerp(
|
||||
a.foregroundColors,
|
||||
b.foregroundColors,
|
||||
t,
|
||||
),
|
||||
backgroundColors: MultiColor.lerp(
|
||||
a.backgroundColors,
|
||||
b.backgroundColors,
|
||||
t,
|
||||
),
|
||||
borderColors: MultiColor.lerp(
|
||||
a.borderColors,
|
||||
b.borderColors,
|
||||
t,
|
||||
),
|
||||
radius: BorderRadiusGeometry.lerp(a.radius, b.radius, t),
|
||||
padding: EdgeInsetsGeometry.lerp(a.padding, b.padding, t),
|
||||
stroke: lerpDouble(a.stroke, b.stroke, t),
|
||||
shadow: BoxShadow.lerp(a.shadow, b.shadow, t),
|
||||
);
|
||||
}
|
||||
|
||||
/// Dimension of this button (as a square)
|
||||
///
|
||||
/// Default to `context.buttonTheme.height`
|
||||
final double? dimension;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
@ -10,24 +10,24 @@ abstract class $SymbolButtonComponentCWProxy {
|
||||
SymbolButtonComponent mainAxisSize(MainAxisSize? mainAxisSize);
|
||||
SymbolButtonComponent label(TextWrapper? label);
|
||||
SymbolButtonComponent icon(Widget? icon);
|
||||
SymbolButtonComponent disabledStyle(ButtonStyle? disabledStyle);
|
||||
SymbolButtonComponent normalStyle(ButtonStyle? normalStyle);
|
||||
SymbolButtonComponent hoveredStyle(ButtonStyle? hoveredStyle);
|
||||
SymbolButtonComponent focusedStyle(ButtonStyle? focusedStyle);
|
||||
SymbolButtonComponent tappedStyle(ButtonStyle? tappedStyle);
|
||||
SymbolButtonComponent selectedStyle(ButtonStyle? selectedStyle);
|
||||
SymbolButtonComponent disabledStyle(ButtonStyle<dynamic>? disabledStyle);
|
||||
SymbolButtonComponent normalStyle(ButtonStyle<dynamic>? normalStyle);
|
||||
SymbolButtonComponent hoveredStyle(ButtonStyle<dynamic>? hoveredStyle);
|
||||
SymbolButtonComponent focusedStyle(ButtonStyle<dynamic>? focusedStyle);
|
||||
SymbolButtonComponent tappedStyle(ButtonStyle<dynamic>? tappedStyle);
|
||||
SymbolButtonComponent selectedStyle(ButtonStyle<dynamic>? selectedStyle);
|
||||
SymbolButtonComponent onPressed(void Function(ControlState)? onPressed);
|
||||
SymbolButtonComponent key(Key? key);
|
||||
SymbolButtonComponent call({
|
||||
MainAxisSize? mainAxisSize,
|
||||
TextWrapper? label,
|
||||
Widget? icon,
|
||||
ButtonStyle? disabledStyle,
|
||||
ButtonStyle? normalStyle,
|
||||
ButtonStyle? hoveredStyle,
|
||||
ButtonStyle? focusedStyle,
|
||||
ButtonStyle? tappedStyle,
|
||||
ButtonStyle? selectedStyle,
|
||||
ButtonStyle<dynamic>? disabledStyle,
|
||||
ButtonStyle<dynamic>? normalStyle,
|
||||
ButtonStyle<dynamic>? hoveredStyle,
|
||||
ButtonStyle<dynamic>? focusedStyle,
|
||||
ButtonStyle<dynamic>? tappedStyle,
|
||||
ButtonStyle<dynamic>? selectedStyle,
|
||||
void Function(ControlState)? onPressed,
|
||||
Key? key,
|
||||
});
|
||||
|
@ -14,47 +14,85 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:copy_with_extension/copy_with_extension.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:wyatt_ui_components/src/core/extensions/build_context_extensions.dart';
|
||||
import 'package:wyatt_ui_components/src/core/utils/multi_color.dart';
|
||||
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
|
||||
|
||||
class SymbolButtonStyle extends ButtonStyle {
|
||||
part 'symbol_button_style.g.dart';
|
||||
|
||||
@CopyWith()
|
||||
class SymbolButtonStyle extends ButtonStyle<SymbolButtonStyle> {
|
||||
const SymbolButtonStyle({
|
||||
this.dimension = 60,
|
||||
super.radius = 15,
|
||||
super.padding = 10,
|
||||
this.label,
|
||||
this.dimension,
|
||||
super.radius,
|
||||
super.padding,
|
||||
super.foregroundColors,
|
||||
super.backgroundColors,
|
||||
super.borderColors,
|
||||
super.stroke = 2,
|
||||
super.shadow = const BoxShadow(
|
||||
blurRadius: 30,
|
||||
offset: Offset(0, 5),
|
||||
color: Color.fromRGBO(0, 0, 0, 0.05),
|
||||
),
|
||||
super.stroke,
|
||||
super.shadow,
|
||||
});
|
||||
|
||||
final double? dimension;
|
||||
|
||||
@override
|
||||
SymbolButtonStyle copyWith({
|
||||
double? dimension,
|
||||
double? radius,
|
||||
double? padding,
|
||||
MultiColor? foregroundColors,
|
||||
MultiColor? backgroundColors,
|
||||
MultiColor? borderColors,
|
||||
double? stroke,
|
||||
BoxShadow? shadow,
|
||||
}) =>
|
||||
/// Used in negociation to build a style from Flutter default values.
|
||||
factory SymbolButtonStyle.fromFlutter(BuildContext context) =>
|
||||
SymbolButtonStyle(
|
||||
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,
|
||||
label: context.textTheme.labelLarge,
|
||||
dimension: context.buttonTheme.height,
|
||||
radius: (context.buttonTheme.shape is RoundedRectangleBorder)
|
||||
? (context.buttonTheme.shape as RoundedRectangleBorder).borderRadius
|
||||
: null,
|
||||
padding: context.buttonTheme.padding,
|
||||
foregroundColors: MultiColor.single(context.colorScheme.onPrimary),
|
||||
backgroundColors: MultiColor.single(context.colorScheme.primary),
|
||||
);
|
||||
|
||||
/// Used for interpolation.
|
||||
static SymbolButtonStyle? lerp(
|
||||
SymbolButtonStyle? a,
|
||||
SymbolButtonStyle? b,
|
||||
double t,
|
||||
) {
|
||||
if (a == null || b == null) {
|
||||
return null;
|
||||
}
|
||||
// b.copyWith to return b attributes even if they are not lerped
|
||||
return b.copyWith(
|
||||
label: TextStyle.lerp(a.label, b.label, t),
|
||||
dimension: lerpDouble(a.dimension, b.dimension, t),
|
||||
foregroundColors: MultiColor.lerp(
|
||||
a.foregroundColors,
|
||||
b.foregroundColors,
|
||||
t,
|
||||
),
|
||||
backgroundColors: MultiColor.lerp(
|
||||
a.backgroundColors,
|
||||
b.backgroundColors,
|
||||
t,
|
||||
),
|
||||
borderColors: MultiColor.lerp(
|
||||
a.borderColors,
|
||||
b.borderColors,
|
||||
t,
|
||||
),
|
||||
radius: BorderRadiusGeometry.lerp(a.radius, b.radius, t),
|
||||
padding: EdgeInsetsGeometry.lerp(a.padding, b.padding, t),
|
||||
stroke: lerpDouble(a.stroke, b.stroke, t),
|
||||
shadow: BoxShadow.lerp(a.shadow, b.shadow, t),
|
||||
);
|
||||
}
|
||||
|
||||
/// Label text style
|
||||
///
|
||||
/// Default to `TextTheme.labelLarge`
|
||||
final TextStyle? label;
|
||||
|
||||
/// Dimension of this button (as a square)
|
||||
///
|
||||
/// Default to `context.buttonTheme.height`
|
||||
final double? dimension;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
@ -13,6 +13,8 @@ abstract class $SkillCardComponentCWProxy {
|
||||
SkillCardComponent description(TextWrapper? description);
|
||||
SkillCardComponent skills(List<TextWrapper>? skills);
|
||||
SkillCardComponent leadingIcon(IconData? leadingIcon);
|
||||
SkillCardComponent secondaryBackgroundColors(
|
||||
Color? secondaryBackgroundColors);
|
||||
SkillCardComponent radius(double? radius);
|
||||
SkillCardComponent padding(double? padding);
|
||||
SkillCardComponent borderColors(List<Color>? borderColors);
|
||||
@ -21,8 +23,6 @@ abstract class $SkillCardComponentCWProxy {
|
||||
SkillCardComponent maxSize(Size? maxSize);
|
||||
SkillCardComponent shadow(BoxShadow? shadow);
|
||||
SkillCardComponent background(Widget? background);
|
||||
SkillCardComponent secondaryBackgroundColors(
|
||||
Color? secondaryBackgroundColors);
|
||||
SkillCardComponent key(Key? key);
|
||||
SkillCardComponent call({
|
||||
IconData? icon,
|
||||
@ -31,6 +31,7 @@ abstract class $SkillCardComponentCWProxy {
|
||||
TextWrapper? description,
|
||||
List<TextWrapper>? skills,
|
||||
IconData? leadingIcon,
|
||||
Color? secondaryBackgroundColors,
|
||||
double? radius,
|
||||
double? padding,
|
||||
List<Color>? borderColors,
|
||||
@ -39,7 +40,6 @@ abstract class $SkillCardComponentCWProxy {
|
||||
Size? maxSize,
|
||||
BoxShadow? shadow,
|
||||
Widget? background,
|
||||
Color? secondaryBackgroundColors,
|
||||
Key? key,
|
||||
});
|
||||
}
|
||||
|
@ -9,25 +9,21 @@ environment:
|
||||
sdk: ">=2.17.0 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
copy_with_extension: ^5.0.0
|
||||
flutter: { sdk: flutter }
|
||||
wyatt_component_copy_with_extension:
|
||||
git:
|
||||
url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git
|
||||
path: packages/wyatt_component_copy_with_extension
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
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
|
||||
version: ^2.4.0
|
||||
wyatt_component_copy_with_gen:
|
||||
git:
|
||||
url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git
|
||||
path: packages/wyatt_component_copy_with_gen
|
||||
|
||||
wyatt_analysis:
|
||||
git:
|
||||
url: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages
|
||||
ref: wyatt_analysis-v2.4.0
|
||||
path: packages/wyatt_analysis
|
||||
|
Loading…
x
Reference in New Issue
Block a user