Compare commits
No commits in common. "c331bc6056427fe71e0d342a1e0b77f417d2f997" and "5c34528b3d778ce0ed49eab6e688986a1d53f436" have entirely different histories.
c331bc6056
...
5c34528b3d
@ -19,7 +19,4 @@ import 'package:wyatt_ui_components/src/features/features.dart';
|
|||||||
|
|
||||||
extension ThemeComponentBuildContext on BuildContext {
|
extension ThemeComponentBuildContext on BuildContext {
|
||||||
ComponentThemeData get components => ComponentTheme.of(this);
|
ComponentThemeData get components => ComponentTheme.of(this);
|
||||||
TextTheme get textTheme => Theme.of(this).textTheme;
|
|
||||||
ColorScheme get colorScheme => Theme.of(this).colorScheme;
|
|
||||||
ButtonThemeData get buttonTheme => Theme.of(this).buttonTheme;
|
|
||||||
}
|
}
|
||||||
|
@ -42,14 +42,4 @@ class MultiColor {
|
|||||||
|
|
||||||
bool get isGradient =>
|
bool get isGradient =>
|
||||||
(_colors?.isNotEmpty ?? false) && (_colors?.length ?? 0) > 1;
|
(_colors?.isNotEmpty ?? false) && (_colors?.length ?? 0) > 1;
|
||||||
|
|
||||||
static MultiColor? lerp(MultiColor? a, MultiColor? b, double t) {
|
|
||||||
if (a == null && b == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (b == null) {
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -30,25 +30,25 @@ abstract class ButtonComponent extends Component {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/// Style of this button in disabled state
|
/// Style of this button in disabled state
|
||||||
final ButtonStyle<dynamic>? disabledStyle;
|
final ButtonStyle? disabledStyle;
|
||||||
|
|
||||||
/// Style of this button in normal state
|
/// Style of this button in normal state
|
||||||
final ButtonStyle<dynamic>? normalStyle;
|
final ButtonStyle? normalStyle;
|
||||||
|
|
||||||
/// Style of this button in hovered state
|
/// Style of this button in hovered state
|
||||||
final ButtonStyle<dynamic>? hoveredStyle;
|
final ButtonStyle? hoveredStyle;
|
||||||
|
|
||||||
/// Style of this button in focused state
|
/// Style of this button in focused state
|
||||||
final ButtonStyle<dynamic>? focusedStyle;
|
final ButtonStyle? focusedStyle;
|
||||||
|
|
||||||
/// Style of this button in tapped state
|
/// Style of this button in tapped state
|
||||||
final ButtonStyle<dynamic>? tappedStyle;
|
final ButtonStyle? tappedStyle;
|
||||||
|
|
||||||
/// Style of this button in selected state
|
/// Style of this button in selected state
|
||||||
final ButtonStyle<dynamic>? selectedStyle;
|
final ButtonStyle? selectedStyle;
|
||||||
|
|
||||||
/// Style of this button in invalid state
|
/// Style of this button in invalid state
|
||||||
final ButtonStyle<dynamic>? invalidStyle;
|
final ButtonStyle? invalidStyle;
|
||||||
|
|
||||||
/// Callback on button press
|
/// Callback on button press
|
||||||
final void Function(ControlState state)? onPressed;
|
final void Function(ControlState state)? onPressed;
|
||||||
|
@ -17,49 +17,41 @@
|
|||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:wyatt_ui_components/src/core/utils/multi_color.dart';
|
import 'package:wyatt_ui_components/src/core/utils/multi_color.dart';
|
||||||
|
|
||||||
abstract class ButtonStyle<T> {
|
abstract class ButtonStyle {
|
||||||
const ButtonStyle({
|
const ButtonStyle({
|
||||||
this.radius,
|
this.radius = 15,
|
||||||
this.padding,
|
this.padding = 10,
|
||||||
this.foregroundColors,
|
this.foregroundColors,
|
||||||
this.backgroundColors,
|
this.backgroundColors,
|
||||||
this.borderColors,
|
this.borderColors,
|
||||||
this.stroke,
|
this.stroke = 2,
|
||||||
this.shadow,
|
this.shadow = const BoxShadow(
|
||||||
|
blurRadius: 30,
|
||||||
|
offset: Offset(0, 5),
|
||||||
|
color: Color.fromRGBO(0, 0, 0, 0.05),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Button radius
|
/// Button radius
|
||||||
///
|
final double? radius;
|
||||||
/// Default to `BorderRadius.all(Radius.circular(4.0))`
|
|
||||||
final BorderRadiusGeometry? radius;
|
|
||||||
|
|
||||||
/// Padding and gaps of this button
|
/// Padding and gaps of this card
|
||||||
///
|
final double? padding;
|
||||||
/// Default to `ButtonTheme.padding`
|
|
||||||
final EdgeInsetsGeometry? padding;
|
|
||||||
|
|
||||||
/// Button foreground gradient colors (from left to right)
|
/// Button foreground gradient colors (from left to right)
|
||||||
///
|
|
||||||
/// Default to `Theme.colorScheme.onPrimary`
|
|
||||||
final MultiColor? foregroundColors;
|
final MultiColor? foregroundColors;
|
||||||
|
|
||||||
/// Button background gradient colors (from left to right)
|
/// Button background gradient colors (from left to right)
|
||||||
///
|
|
||||||
/// Default to `Theme.colorScheme.primary`
|
|
||||||
final MultiColor? backgroundColors;
|
final MultiColor? backgroundColors;
|
||||||
|
|
||||||
/// Border colors (from left to right).
|
/// Border colors (from left to right).
|
||||||
///
|
|
||||||
/// Default to `null`
|
|
||||||
final MultiColor? borderColors;
|
final MultiColor? borderColors;
|
||||||
|
|
||||||
/// Stroke of the border
|
/// Stroke of the border
|
||||||
///
|
|
||||||
/// Default to `null`
|
|
||||||
final double? stroke;
|
final double? stroke;
|
||||||
|
|
||||||
/// Drop shadow
|
/// Drop shadow
|
||||||
///
|
|
||||||
/// Default to `null`
|
|
||||||
final BoxShadow? shadow;
|
final BoxShadow? shadow;
|
||||||
|
|
||||||
|
ButtonStyle copyWith();
|
||||||
}
|
}
|
||||||
|
@ -11,15 +11,13 @@ abstract class $FileSelectionButtonComponentCWProxy {
|
|||||||
FileSelectionButtonComponent leading(Widget? leading);
|
FileSelectionButtonComponent leading(Widget? leading);
|
||||||
FileSelectionButtonComponent title(TextWrapper? title);
|
FileSelectionButtonComponent title(TextWrapper? title);
|
||||||
FileSelectionButtonComponent subTitle(TextWrapper? subTitle);
|
FileSelectionButtonComponent subTitle(TextWrapper? subTitle);
|
||||||
FileSelectionButtonComponent disabledStyle(
|
FileSelectionButtonComponent disabledStyle(ButtonStyle? disabledStyle);
|
||||||
ButtonStyle<dynamic>? disabledStyle);
|
FileSelectionButtonComponent normalStyle(ButtonStyle? normalStyle);
|
||||||
FileSelectionButtonComponent normalStyle(ButtonStyle<dynamic>? normalStyle);
|
FileSelectionButtonComponent hoveredStyle(ButtonStyle? hoveredStyle);
|
||||||
FileSelectionButtonComponent hoveredStyle(ButtonStyle<dynamic>? hoveredStyle);
|
FileSelectionButtonComponent focusedStyle(ButtonStyle? focusedStyle);
|
||||||
FileSelectionButtonComponent focusedStyle(ButtonStyle<dynamic>? focusedStyle);
|
FileSelectionButtonComponent tappedStyle(ButtonStyle? tappedStyle);
|
||||||
FileSelectionButtonComponent tappedStyle(ButtonStyle<dynamic>? tappedStyle);
|
FileSelectionButtonComponent selectedStyle(ButtonStyle? selectedStyle);
|
||||||
FileSelectionButtonComponent selectedStyle(
|
FileSelectionButtonComponent invalidStyle(ButtonStyle? invalidStyle);
|
||||||
ButtonStyle<dynamic>? selectedStyle);
|
|
||||||
FileSelectionButtonComponent invalidStyle(ButtonStyle<dynamic>? invalidStyle);
|
|
||||||
FileSelectionButtonComponent onPressed(
|
FileSelectionButtonComponent onPressed(
|
||||||
void Function(ControlState)? onPressed);
|
void Function(ControlState)? onPressed);
|
||||||
FileSelectionButtonComponent key(Key? key);
|
FileSelectionButtonComponent key(Key? key);
|
||||||
@ -28,13 +26,13 @@ abstract class $FileSelectionButtonComponentCWProxy {
|
|||||||
Widget? leading,
|
Widget? leading,
|
||||||
TextWrapper? title,
|
TextWrapper? title,
|
||||||
TextWrapper? subTitle,
|
TextWrapper? subTitle,
|
||||||
ButtonStyle<dynamic>? disabledStyle,
|
ButtonStyle? disabledStyle,
|
||||||
ButtonStyle<dynamic>? normalStyle,
|
ButtonStyle? normalStyle,
|
||||||
ButtonStyle<dynamic>? hoveredStyle,
|
ButtonStyle? hoveredStyle,
|
||||||
ButtonStyle<dynamic>? focusedStyle,
|
ButtonStyle? focusedStyle,
|
||||||
ButtonStyle<dynamic>? tappedStyle,
|
ButtonStyle? tappedStyle,
|
||||||
ButtonStyle<dynamic>? selectedStyle,
|
ButtonStyle? selectedStyle,
|
||||||
ButtonStyle<dynamic>? invalidStyle,
|
ButtonStyle? invalidStyle,
|
||||||
void Function(ControlState)? onPressed,
|
void Function(ControlState)? onPressed,
|
||||||
Key? key,
|
Key? key,
|
||||||
});
|
});
|
||||||
|
@ -14,85 +14,42 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// 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: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/core/utils/multi_color.dart';
|
||||||
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
|
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
|
||||||
|
|
||||||
part 'file_selection_button_style.g.dart';
|
class FileSelectionButtonStyle extends ButtonStyle {
|
||||||
|
|
||||||
@CopyWith()
|
|
||||||
class FileSelectionButtonStyle extends ButtonStyle<FileSelectionButtonStyle> {
|
|
||||||
const FileSelectionButtonStyle({
|
const FileSelectionButtonStyle({
|
||||||
this.title,
|
super.radius = 12,
|
||||||
this.subTitle,
|
super.padding = 13,
|
||||||
super.radius,
|
|
||||||
super.padding,
|
|
||||||
super.foregroundColors,
|
super.foregroundColors,
|
||||||
super.backgroundColors,
|
super.backgroundColors,
|
||||||
super.borderColors,
|
super.borderColors,
|
||||||
super.stroke,
|
super.stroke = 2,
|
||||||
super.shadow,
|
super.shadow = const BoxShadow(
|
||||||
|
blurRadius: 30,
|
||||||
|
offset: Offset(0, 5),
|
||||||
|
color: Color.fromRGBO(0, 0, 0, 0.05),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Used in negociation to build a style from Flutter default values.
|
@override
|
||||||
factory FileSelectionButtonStyle.fromFlutter(BuildContext context) =>
|
FileSelectionButtonStyle copyWith({
|
||||||
|
double? radius,
|
||||||
|
double? padding,
|
||||||
|
MultiColor? foregroundColors,
|
||||||
|
MultiColor? backgroundColors,
|
||||||
|
MultiColor? borderColors,
|
||||||
|
double? stroke,
|
||||||
|
BoxShadow? shadow,
|
||||||
|
}) =>
|
||||||
FileSelectionButtonStyle(
|
FileSelectionButtonStyle(
|
||||||
title: context.textTheme.labelLarge,
|
radius: radius ?? this.radius,
|
||||||
subTitle: context.textTheme.labelSmall,
|
padding: padding ?? this.padding,
|
||||||
radius: (context.buttonTheme.shape is RoundedRectangleBorder)
|
foregroundColors: foregroundColors ?? this.foregroundColors,
|
||||||
? (context.buttonTheme.shape as RoundedRectangleBorder).borderRadius
|
backgroundColors: backgroundColors ?? this.backgroundColors,
|
||||||
: null,
|
borderColors: borderColors ?? this.borderColors,
|
||||||
padding: context.buttonTheme.padding,
|
stroke: stroke ?? this.stroke,
|
||||||
foregroundColors: MultiColor.single(context.colorScheme.onPrimary),
|
shadow: shadow ?? this.shadow,
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
@ -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);
|
|
||||||
}
|
|
@ -24,7 +24,7 @@ part 'flat_button_component.g.dart';
|
|||||||
abstract class FlatButtonComponent extends ButtonComponent
|
abstract class FlatButtonComponent extends ButtonComponent
|
||||||
with CopyWithMixin<$FlatButtonComponentCWProxy> {
|
with CopyWithMixin<$FlatButtonComponentCWProxy> {
|
||||||
const FlatButtonComponent({
|
const FlatButtonComponent({
|
||||||
this.mainAxisSize,
|
this.mainAxisSize = MainAxisSize.min,
|
||||||
this.prefix,
|
this.prefix,
|
||||||
this.suffix,
|
this.suffix,
|
||||||
this.label,
|
this.label,
|
||||||
|
@ -11,11 +11,11 @@ abstract class $FlatButtonComponentCWProxy {
|
|||||||
FlatButtonComponent prefix(Widget? prefix);
|
FlatButtonComponent prefix(Widget? prefix);
|
||||||
FlatButtonComponent suffix(Widget? suffix);
|
FlatButtonComponent suffix(Widget? suffix);
|
||||||
FlatButtonComponent label(TextWrapper? label);
|
FlatButtonComponent label(TextWrapper? label);
|
||||||
FlatButtonComponent disabledStyle(ButtonStyle<dynamic>? disabledStyle);
|
FlatButtonComponent disabledStyle(ButtonStyle? disabledStyle);
|
||||||
FlatButtonComponent normalStyle(ButtonStyle<dynamic>? normalStyle);
|
FlatButtonComponent normalStyle(ButtonStyle? normalStyle);
|
||||||
FlatButtonComponent hoveredStyle(ButtonStyle<dynamic>? hoveredStyle);
|
FlatButtonComponent hoveredStyle(ButtonStyle? hoveredStyle);
|
||||||
FlatButtonComponent focusedStyle(ButtonStyle<dynamic>? focusedStyle);
|
FlatButtonComponent focusedStyle(ButtonStyle? focusedStyle);
|
||||||
FlatButtonComponent tappedStyle(ButtonStyle<dynamic>? tappedStyle);
|
FlatButtonComponent tappedStyle(ButtonStyle? tappedStyle);
|
||||||
FlatButtonComponent onPressed(void Function(ControlState)? onPressed);
|
FlatButtonComponent onPressed(void Function(ControlState)? onPressed);
|
||||||
FlatButtonComponent key(Key? key);
|
FlatButtonComponent key(Key? key);
|
||||||
FlatButtonComponent call({
|
FlatButtonComponent call({
|
||||||
@ -23,11 +23,11 @@ abstract class $FlatButtonComponentCWProxy {
|
|||||||
Widget? prefix,
|
Widget? prefix,
|
||||||
Widget? suffix,
|
Widget? suffix,
|
||||||
TextWrapper? label,
|
TextWrapper? label,
|
||||||
ButtonStyle<dynamic>? disabledStyle,
|
ButtonStyle? disabledStyle,
|
||||||
ButtonStyle<dynamic>? normalStyle,
|
ButtonStyle? normalStyle,
|
||||||
ButtonStyle<dynamic>? hoveredStyle,
|
ButtonStyle? hoveredStyle,
|
||||||
ButtonStyle<dynamic>? focusedStyle,
|
ButtonStyle? focusedStyle,
|
||||||
ButtonStyle<dynamic>? tappedStyle,
|
ButtonStyle? tappedStyle,
|
||||||
void Function(ControlState)? onPressed,
|
void Function(ControlState)? onPressed,
|
||||||
Key? key,
|
Key? key,
|
||||||
});
|
});
|
||||||
|
@ -14,76 +14,42 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// 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: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/core/utils/multi_color.dart';
|
||||||
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
|
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
|
||||||
|
|
||||||
part 'flat_button_style.g.dart';
|
class FlatButtonStyle extends ButtonStyle {
|
||||||
|
|
||||||
@CopyWith()
|
|
||||||
class FlatButtonStyle extends ButtonStyle<FlatButtonStyle> {
|
|
||||||
const FlatButtonStyle({
|
const FlatButtonStyle({
|
||||||
this.label,
|
super.radius = 15,
|
||||||
super.radius,
|
super.padding = 10,
|
||||||
super.padding,
|
|
||||||
super.foregroundColors,
|
super.foregroundColors,
|
||||||
super.backgroundColors,
|
super.backgroundColors,
|
||||||
super.borderColors,
|
super.borderColors,
|
||||||
super.stroke,
|
super.stroke = 2,
|
||||||
super.shadow,
|
super.shadow = const BoxShadow(
|
||||||
|
blurRadius: 30,
|
||||||
|
offset: Offset(0, 5),
|
||||||
|
color: Color.fromRGBO(0, 0, 0, 0.05),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Used in negociation to build a style from Flutter default values.
|
@override
|
||||||
factory FlatButtonStyle.fromFlutter(BuildContext context) => FlatButtonStyle(
|
FlatButtonStyle copyWith({
|
||||||
label: context.textTheme.labelLarge,
|
double? radius,
|
||||||
radius: (context.buttonTheme.shape is RoundedRectangleBorder)
|
double? padding,
|
||||||
? (context.buttonTheme.shape as RoundedRectangleBorder).borderRadius
|
MultiColor? foregroundColors,
|
||||||
: null,
|
MultiColor? backgroundColors,
|
||||||
padding: context.buttonTheme.padding,
|
MultiColor? borderColors,
|
||||||
foregroundColors: MultiColor.single(context.colorScheme.onPrimary),
|
double? stroke,
|
||||||
backgroundColors: MultiColor.single(context.colorScheme.primary),
|
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 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;
|
|
||||||
}
|
}
|
||||||
|
@ -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);
|
|
||||||
}
|
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.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';
|
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
|
||||||
|
|
||||||
part 'simple_icon_button_component.g.dart';
|
part 'simple_icon_button_component.g.dart';
|
||||||
@ -30,6 +31,7 @@ abstract class SimpleIconButtonComponent extends ButtonComponent
|
|||||||
super.hoveredStyle,
|
super.hoveredStyle,
|
||||||
super.focusedStyle,
|
super.focusedStyle,
|
||||||
super.tappedStyle,
|
super.tappedStyle,
|
||||||
|
super.selectedStyle,
|
||||||
super.onPressed,
|
super.onPressed,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
@ -49,5 +51,8 @@ abstract class SimpleIconButtonComponent extends ButtonComponent
|
|||||||
@override
|
@override
|
||||||
SimpleIconButtonStyle? get tappedStyle;
|
SimpleIconButtonStyle? get tappedStyle;
|
||||||
|
|
||||||
|
@override
|
||||||
|
SimpleIconButtonStyle? get selectedStyle;
|
||||||
|
|
||||||
final Icon? icon;
|
final Icon? icon;
|
||||||
}
|
}
|
||||||
|
@ -8,20 +8,22 @@ part of 'simple_icon_button_component.dart';
|
|||||||
|
|
||||||
abstract class $SimpleIconButtonComponentCWProxy {
|
abstract class $SimpleIconButtonComponentCWProxy {
|
||||||
SimpleIconButtonComponent icon(Icon? icon);
|
SimpleIconButtonComponent icon(Icon? icon);
|
||||||
SimpleIconButtonComponent disabledStyle(ButtonStyle<dynamic>? disabledStyle);
|
SimpleIconButtonComponent disabledStyle(ButtonStyle? disabledStyle);
|
||||||
SimpleIconButtonComponent normalStyle(ButtonStyle<dynamic>? normalStyle);
|
SimpleIconButtonComponent normalStyle(ButtonStyle? normalStyle);
|
||||||
SimpleIconButtonComponent hoveredStyle(ButtonStyle<dynamic>? hoveredStyle);
|
SimpleIconButtonComponent hoveredStyle(ButtonStyle? hoveredStyle);
|
||||||
SimpleIconButtonComponent focusedStyle(ButtonStyle<dynamic>? focusedStyle);
|
SimpleIconButtonComponent focusedStyle(ButtonStyle? focusedStyle);
|
||||||
SimpleIconButtonComponent tappedStyle(ButtonStyle<dynamic>? tappedStyle);
|
SimpleIconButtonComponent tappedStyle(ButtonStyle? tappedStyle);
|
||||||
|
SimpleIconButtonComponent selectedStyle(ButtonStyle? selectedStyle);
|
||||||
SimpleIconButtonComponent onPressed(void Function(ControlState)? onPressed);
|
SimpleIconButtonComponent onPressed(void Function(ControlState)? onPressed);
|
||||||
SimpleIconButtonComponent key(Key? key);
|
SimpleIconButtonComponent key(Key? key);
|
||||||
SimpleIconButtonComponent call({
|
SimpleIconButtonComponent call({
|
||||||
Icon? icon,
|
Icon? icon,
|
||||||
ButtonStyle<dynamic>? disabledStyle,
|
ButtonStyle? disabledStyle,
|
||||||
ButtonStyle<dynamic>? normalStyle,
|
ButtonStyle? normalStyle,
|
||||||
ButtonStyle<dynamic>? hoveredStyle,
|
ButtonStyle? hoveredStyle,
|
||||||
ButtonStyle<dynamic>? focusedStyle,
|
ButtonStyle? focusedStyle,
|
||||||
ButtonStyle<dynamic>? tappedStyle,
|
ButtonStyle? tappedStyle,
|
||||||
|
ButtonStyle? selectedStyle,
|
||||||
void Function(ControlState)? onPressed,
|
void Function(ControlState)? onPressed,
|
||||||
Key? key,
|
Key? key,
|
||||||
});
|
});
|
||||||
|
@ -14,77 +14,47 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// 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: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/core/utils/multi_color.dart';
|
||||||
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
|
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
|
||||||
|
|
||||||
part 'simple_icon_button_style.g.dart';
|
class SimpleIconButtonStyle extends ButtonStyle {
|
||||||
|
|
||||||
@CopyWith()
|
|
||||||
class SimpleIconButtonStyle extends ButtonStyle<SimpleIconButtonStyle> {
|
|
||||||
const SimpleIconButtonStyle({
|
const SimpleIconButtonStyle({
|
||||||
this.dimension,
|
this.dimension = 30,
|
||||||
super.radius,
|
super.radius = 5,
|
||||||
super.padding,
|
super.padding = 5,
|
||||||
super.foregroundColors,
|
super.foregroundColors,
|
||||||
super.backgroundColors,
|
super.backgroundColors,
|
||||||
super.borderColors,
|
super.borderColors,
|
||||||
super.stroke,
|
super.stroke = 2,
|
||||||
super.shadow,
|
super.shadow = const BoxShadow(
|
||||||
|
blurRadius: 30,
|
||||||
|
offset: Offset(0, 5),
|
||||||
|
color: Color.fromRGBO(0, 0, 0, 0.05),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Used in negociation to build a style from Flutter default values.
|
|
||||||
factory SimpleIconButtonStyle.fromFlutter(BuildContext context) =>
|
|
||||||
SimpleIconButtonStyle(
|
|
||||||
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;
|
final double? dimension;
|
||||||
|
|
||||||
|
@override
|
||||||
|
SimpleIconButtonStyle copyWith({
|
||||||
|
double? dimension,
|
||||||
|
double? radius,
|
||||||
|
double? padding,
|
||||||
|
MultiColor? foregroundColors,
|
||||||
|
MultiColor? backgroundColors,
|
||||||
|
MultiColor? borderColors,
|
||||||
|
double? stroke,
|
||||||
|
BoxShadow? shadow,
|
||||||
|
}) =>
|
||||||
|
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,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -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);
|
|
||||||
}
|
|
@ -10,24 +10,24 @@ abstract class $SymbolButtonComponentCWProxy {
|
|||||||
SymbolButtonComponent mainAxisSize(MainAxisSize? mainAxisSize);
|
SymbolButtonComponent mainAxisSize(MainAxisSize? mainAxisSize);
|
||||||
SymbolButtonComponent label(TextWrapper? label);
|
SymbolButtonComponent label(TextWrapper? label);
|
||||||
SymbolButtonComponent icon(Widget? icon);
|
SymbolButtonComponent icon(Widget? icon);
|
||||||
SymbolButtonComponent disabledStyle(ButtonStyle<dynamic>? disabledStyle);
|
SymbolButtonComponent disabledStyle(ButtonStyle? disabledStyle);
|
||||||
SymbolButtonComponent normalStyle(ButtonStyle<dynamic>? normalStyle);
|
SymbolButtonComponent normalStyle(ButtonStyle? normalStyle);
|
||||||
SymbolButtonComponent hoveredStyle(ButtonStyle<dynamic>? hoveredStyle);
|
SymbolButtonComponent hoveredStyle(ButtonStyle? hoveredStyle);
|
||||||
SymbolButtonComponent focusedStyle(ButtonStyle<dynamic>? focusedStyle);
|
SymbolButtonComponent focusedStyle(ButtonStyle? focusedStyle);
|
||||||
SymbolButtonComponent tappedStyle(ButtonStyle<dynamic>? tappedStyle);
|
SymbolButtonComponent tappedStyle(ButtonStyle? tappedStyle);
|
||||||
SymbolButtonComponent selectedStyle(ButtonStyle<dynamic>? selectedStyle);
|
SymbolButtonComponent selectedStyle(ButtonStyle? selectedStyle);
|
||||||
SymbolButtonComponent onPressed(void Function(ControlState)? onPressed);
|
SymbolButtonComponent onPressed(void Function(ControlState)? onPressed);
|
||||||
SymbolButtonComponent key(Key? key);
|
SymbolButtonComponent key(Key? key);
|
||||||
SymbolButtonComponent call({
|
SymbolButtonComponent call({
|
||||||
MainAxisSize? mainAxisSize,
|
MainAxisSize? mainAxisSize,
|
||||||
TextWrapper? label,
|
TextWrapper? label,
|
||||||
Widget? icon,
|
Widget? icon,
|
||||||
ButtonStyle<dynamic>? disabledStyle,
|
ButtonStyle? disabledStyle,
|
||||||
ButtonStyle<dynamic>? normalStyle,
|
ButtonStyle? normalStyle,
|
||||||
ButtonStyle<dynamic>? hoveredStyle,
|
ButtonStyle? hoveredStyle,
|
||||||
ButtonStyle<dynamic>? focusedStyle,
|
ButtonStyle? focusedStyle,
|
||||||
ButtonStyle<dynamic>? tappedStyle,
|
ButtonStyle? tappedStyle,
|
||||||
ButtonStyle<dynamic>? selectedStyle,
|
ButtonStyle? selectedStyle,
|
||||||
void Function(ControlState)? onPressed,
|
void Function(ControlState)? onPressed,
|
||||||
Key? key,
|
Key? key,
|
||||||
});
|
});
|
||||||
|
@ -14,85 +14,47 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// 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: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/core/utils/multi_color.dart';
|
||||||
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
|
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
|
||||||
|
|
||||||
part 'symbol_button_style.g.dart';
|
class SymbolButtonStyle extends ButtonStyle {
|
||||||
|
|
||||||
@CopyWith()
|
|
||||||
class SymbolButtonStyle extends ButtonStyle<SymbolButtonStyle> {
|
|
||||||
const SymbolButtonStyle({
|
const SymbolButtonStyle({
|
||||||
this.label,
|
this.dimension = 60,
|
||||||
this.dimension,
|
super.radius = 15,
|
||||||
super.radius,
|
super.padding = 10,
|
||||||
super.padding,
|
|
||||||
super.foregroundColors,
|
super.foregroundColors,
|
||||||
super.backgroundColors,
|
super.backgroundColors,
|
||||||
super.borderColors,
|
super.borderColors,
|
||||||
super.stroke,
|
super.stroke = 2,
|
||||||
super.shadow,
|
super.shadow = const BoxShadow(
|
||||||
|
blurRadius: 30,
|
||||||
|
offset: Offset(0, 5),
|
||||||
|
color: Color.fromRGBO(0, 0, 0, 0.05),
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Used in negociation to build a style from Flutter default values.
|
|
||||||
factory SymbolButtonStyle.fromFlutter(BuildContext context) =>
|
|
||||||
SymbolButtonStyle(
|
|
||||||
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;
|
final double? dimension;
|
||||||
|
|
||||||
|
@override
|
||||||
|
SymbolButtonStyle copyWith({
|
||||||
|
double? dimension,
|
||||||
|
double? radius,
|
||||||
|
double? padding,
|
||||||
|
MultiColor? foregroundColors,
|
||||||
|
MultiColor? backgroundColors,
|
||||||
|
MultiColor? borderColors,
|
||||||
|
double? stroke,
|
||||||
|
BoxShadow? shadow,
|
||||||
|
}) =>
|
||||||
|
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,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -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);
|
|
||||||
}
|
|
@ -13,8 +13,6 @@ abstract class $SkillCardComponentCWProxy {
|
|||||||
SkillCardComponent description(TextWrapper? description);
|
SkillCardComponent description(TextWrapper? description);
|
||||||
SkillCardComponent skills(List<TextWrapper>? skills);
|
SkillCardComponent skills(List<TextWrapper>? skills);
|
||||||
SkillCardComponent leadingIcon(IconData? leadingIcon);
|
SkillCardComponent leadingIcon(IconData? leadingIcon);
|
||||||
SkillCardComponent secondaryBackgroundColors(
|
|
||||||
Color? secondaryBackgroundColors);
|
|
||||||
SkillCardComponent radius(double? radius);
|
SkillCardComponent radius(double? radius);
|
||||||
SkillCardComponent padding(double? padding);
|
SkillCardComponent padding(double? padding);
|
||||||
SkillCardComponent borderColors(List<Color>? borderColors);
|
SkillCardComponent borderColors(List<Color>? borderColors);
|
||||||
@ -23,6 +21,8 @@ abstract class $SkillCardComponentCWProxy {
|
|||||||
SkillCardComponent maxSize(Size? maxSize);
|
SkillCardComponent maxSize(Size? maxSize);
|
||||||
SkillCardComponent shadow(BoxShadow? shadow);
|
SkillCardComponent shadow(BoxShadow? shadow);
|
||||||
SkillCardComponent background(Widget? background);
|
SkillCardComponent background(Widget? background);
|
||||||
|
SkillCardComponent secondaryBackgroundColors(
|
||||||
|
Color? secondaryBackgroundColors);
|
||||||
SkillCardComponent key(Key? key);
|
SkillCardComponent key(Key? key);
|
||||||
SkillCardComponent call({
|
SkillCardComponent call({
|
||||||
IconData? icon,
|
IconData? icon,
|
||||||
@ -31,7 +31,6 @@ abstract class $SkillCardComponentCWProxy {
|
|||||||
TextWrapper? description,
|
TextWrapper? description,
|
||||||
List<TextWrapper>? skills,
|
List<TextWrapper>? skills,
|
||||||
IconData? leadingIcon,
|
IconData? leadingIcon,
|
||||||
Color? secondaryBackgroundColors,
|
|
||||||
double? radius,
|
double? radius,
|
||||||
double? padding,
|
double? padding,
|
||||||
List<Color>? borderColors,
|
List<Color>? borderColors,
|
||||||
@ -40,6 +39,7 @@ abstract class $SkillCardComponentCWProxy {
|
|||||||
Size? maxSize,
|
Size? maxSize,
|
||||||
BoxShadow? shadow,
|
BoxShadow? shadow,
|
||||||
Widget? background,
|
Widget? background,
|
||||||
|
Color? secondaryBackgroundColors,
|
||||||
Key? key,
|
Key? key,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -9,21 +9,25 @@ environment:
|
|||||||
sdk: ">=2.17.0 <3.0.0"
|
sdk: ">=2.17.0 <3.0.0"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
copy_with_extension: ^5.0.0
|
flutter:
|
||||||
flutter: { sdk: flutter }
|
sdk: flutter
|
||||||
wyatt_component_copy_with_extension:
|
wyatt_component_copy_with_extension:
|
||||||
git:
|
git:
|
||||||
url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git
|
url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git
|
||||||
path: packages/wyatt_component_copy_with_extension
|
path: packages/wyatt_component_copy_with_extension
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
flutter_test:
|
||||||
|
sdk: flutter
|
||||||
|
|
||||||
build_runner: ^2.3.3
|
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:
|
wyatt_component_copy_with_gen:
|
||||||
git:
|
git:
|
||||||
url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git
|
url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git
|
||||||
path: packages/wyatt_component_copy_with_gen
|
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
|
||||||
|
@ -21,25 +21,25 @@ class $FileSelectionButtonCWProxyImpl
|
|||||||
FileSelectionButton subTitle(TextWrapper? subTitle) =>
|
FileSelectionButton subTitle(TextWrapper? subTitle) =>
|
||||||
this(subTitle: subTitle);
|
this(subTitle: subTitle);
|
||||||
@override
|
@override
|
||||||
FileSelectionButton disabledStyle(ButtonStyle<dynamic>? disabledStyle) =>
|
FileSelectionButton disabledStyle(ButtonStyle? disabledStyle) =>
|
||||||
this(disabledStyle: disabledStyle);
|
this(disabledStyle: disabledStyle);
|
||||||
@override
|
@override
|
||||||
FileSelectionButton normalStyle(ButtonStyle<dynamic>? normalStyle) =>
|
FileSelectionButton normalStyle(ButtonStyle? normalStyle) =>
|
||||||
this(normalStyle: normalStyle);
|
this(normalStyle: normalStyle);
|
||||||
@override
|
@override
|
||||||
FileSelectionButton hoveredStyle(ButtonStyle<dynamic>? hoveredStyle) =>
|
FileSelectionButton hoveredStyle(ButtonStyle? hoveredStyle) =>
|
||||||
this(hoveredStyle: hoveredStyle);
|
this(hoveredStyle: hoveredStyle);
|
||||||
@override
|
@override
|
||||||
FileSelectionButton focusedStyle(ButtonStyle<dynamic>? focusedStyle) =>
|
FileSelectionButton focusedStyle(ButtonStyle? focusedStyle) =>
|
||||||
this(focusedStyle: focusedStyle);
|
this(focusedStyle: focusedStyle);
|
||||||
@override
|
@override
|
||||||
FileSelectionButton tappedStyle(ButtonStyle<dynamic>? tappedStyle) =>
|
FileSelectionButton tappedStyle(ButtonStyle? tappedStyle) =>
|
||||||
this(tappedStyle: tappedStyle);
|
this(tappedStyle: tappedStyle);
|
||||||
@override
|
@override
|
||||||
FileSelectionButton selectedStyle(ButtonStyle<dynamic>? selectedStyle) =>
|
FileSelectionButton selectedStyle(ButtonStyle? selectedStyle) =>
|
||||||
this(selectedStyle: selectedStyle);
|
this(selectedStyle: selectedStyle);
|
||||||
@override
|
@override
|
||||||
FileSelectionButton invalidStyle(ButtonStyle<dynamic>? invalidStyle) =>
|
FileSelectionButton invalidStyle(ButtonStyle? invalidStyle) =>
|
||||||
this(invalidStyle: invalidStyle);
|
this(invalidStyle: invalidStyle);
|
||||||
@override
|
@override
|
||||||
FileSelectionButton onPressed(void Function(ControlState)? onPressed) =>
|
FileSelectionButton onPressed(void Function(ControlState)? onPressed) =>
|
||||||
@ -52,13 +52,13 @@ class $FileSelectionButtonCWProxyImpl
|
|||||||
Widget? leading,
|
Widget? leading,
|
||||||
TextWrapper? title,
|
TextWrapper? title,
|
||||||
TextWrapper? subTitle,
|
TextWrapper? subTitle,
|
||||||
ButtonStyle<dynamic>? disabledStyle,
|
ButtonStyle? disabledStyle,
|
||||||
ButtonStyle<dynamic>? normalStyle,
|
ButtonStyle? normalStyle,
|
||||||
ButtonStyle<dynamic>? hoveredStyle,
|
ButtonStyle? hoveredStyle,
|
||||||
ButtonStyle<dynamic>? focusedStyle,
|
ButtonStyle? focusedStyle,
|
||||||
ButtonStyle<dynamic>? tappedStyle,
|
ButtonStyle? tappedStyle,
|
||||||
ButtonStyle<dynamic>? selectedStyle,
|
ButtonStyle? selectedStyle,
|
||||||
ButtonStyle<dynamic>? invalidStyle,
|
ButtonStyle? invalidStyle,
|
||||||
void Function(ControlState)? onPressed,
|
void Function(ControlState)? onPressed,
|
||||||
Key? key,
|
Key? key,
|
||||||
}) =>
|
}) =>
|
||||||
|
@ -25,7 +25,6 @@ import 'package:wyatt_ui_kit/src/components/buttons/cubit/invalid_button_cubit.d
|
|||||||
import 'package:wyatt_ui_kit/src/components/gradients/gradient_text.dart';
|
import 'package:wyatt_ui_kit/src/components/gradients/gradient_text.dart';
|
||||||
import 'package:wyatt_ui_kit/src/core/extensions/theme_extensions.dart';
|
import 'package:wyatt_ui_kit/src/core/extensions/theme_extensions.dart';
|
||||||
import 'package:wyatt_ui_kit/src/core/helpers/linear_gradient_helper.dart';
|
import 'package:wyatt_ui_kit/src/core/helpers/linear_gradient_helper.dart';
|
||||||
import 'package:wyatt_ui_kit/src/domain/button_theme_extension/file_selection_button_theme_extension.dart';
|
|
||||||
|
|
||||||
class FileSelectionButtonScreen
|
class FileSelectionButtonScreen
|
||||||
extends CubitScreen<InvalidButtonCubit, ButtonState> {
|
extends CubitScreen<InvalidButtonCubit, ButtonState> {
|
||||||
@ -48,7 +47,6 @@ class FileSelectionButtonScreen
|
|||||||
final Widget? leading;
|
final Widget? leading;
|
||||||
final TextWrapper? title;
|
final TextWrapper? title;
|
||||||
final TextWrapper? subTitle;
|
final TextWrapper? subTitle;
|
||||||
final MainAxisSize? mainAxisSize;
|
|
||||||
|
|
||||||
final FileSelectionButtonStyle? disabledStyle;
|
final FileSelectionButtonStyle? disabledStyle;
|
||||||
final FileSelectionButtonStyle? normalStyle;
|
final FileSelectionButtonStyle? normalStyle;
|
||||||
@ -60,164 +58,44 @@ class FileSelectionButtonScreen
|
|||||||
|
|
||||||
final void Function(ControlState state)? onPressed;
|
final void Function(ControlState state)? onPressed;
|
||||||
|
|
||||||
|
final MainAxisSize? mainAxisSize;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
InvalidButtonCubit create(BuildContext context) => InvalidButtonCubit();
|
InvalidButtonCubit create(BuildContext context) => InvalidButtonCubit();
|
||||||
|
|
||||||
/// Negotiate the theme to get a complete style.
|
@override
|
||||||
FileSelectionButtonStyle negotiate(BuildContext context, ButtonState state) {
|
Widget onBuild(BuildContext context, ButtonState state) {
|
||||||
// Define default style from Flutter values.
|
// Set a default style
|
||||||
FileSelectionButtonStyle style =
|
FileSelectionButtonStyle? style =
|
||||||
FileSelectionButtonStyle.fromFlutter(context);
|
normalStyle ?? const FileSelectionButtonStyle();
|
||||||
|
|
||||||
// Try to retrieve custom theme extension
|
|
||||||
final fileSelectionButtonThemeExtension =
|
|
||||||
context.themeExtension<FileSelectionButtonThemeExtension>();
|
|
||||||
|
|
||||||
switch (state.state) {
|
switch (state.state) {
|
||||||
case ControlState.disabled:
|
case ControlState.disabled:
|
||||||
style = disabledStyle ??
|
style = disabledStyle ?? style;
|
||||||
fileSelectionButtonThemeExtension?.disabledStyle ??
|
|
||||||
style.copyWith(
|
|
||||||
foregroundColors:
|
|
||||||
MultiColor.single(context.colorScheme.onSurface),
|
|
||||||
backgroundColors: MultiColor.single(context.colorScheme.surface),
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case ControlState.hovered:
|
case ControlState.hovered:
|
||||||
style = hoveredStyle ??
|
style = hoveredStyle ?? style;
|
||||||
fileSelectionButtonThemeExtension?.hoveredStyle ??
|
|
||||||
style;
|
|
||||||
break;
|
break;
|
||||||
case ControlState.tapped:
|
case ControlState.tapped:
|
||||||
style = tappedStyle ??
|
style = tappedStyle ?? style;
|
||||||
fileSelectionButtonThemeExtension?.tappedStyle ??
|
|
||||||
style;
|
|
||||||
break;
|
break;
|
||||||
case ControlState.focused:
|
case ControlState.focused:
|
||||||
style = focusedStyle ??
|
style = focusedStyle ?? style;
|
||||||
fileSelectionButtonThemeExtension?.focusedStyle ??
|
|
||||||
style;
|
|
||||||
break;
|
break;
|
||||||
case ControlState.normal:
|
case ControlState.normal:
|
||||||
style = normalStyle ??
|
// already done
|
||||||
fileSelectionButtonThemeExtension?.normalStyle ??
|
|
||||||
style;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply extra theme
|
|
||||||
if (state.isSelected) {
|
if (state.isSelected) {
|
||||||
// TODO(hpcl): enhance copyWith to copy only non-null attributes of an object
|
style = selectedStyle ?? style;
|
||||||
style = style.copyWith(
|
|
||||||
title: (selectedStyle ??
|
|
||||||
fileSelectionButtonThemeExtension?.selectedStyle ??
|
|
||||||
style)
|
|
||||||
.title,
|
|
||||||
subTitle: (selectedStyle ??
|
|
||||||
fileSelectionButtonThemeExtension?.selectedStyle ??
|
|
||||||
style)
|
|
||||||
.subTitle,
|
|
||||||
radius: (selectedStyle ??
|
|
||||||
fileSelectionButtonThemeExtension?.selectedStyle ??
|
|
||||||
style)
|
|
||||||
.radius,
|
|
||||||
padding: (selectedStyle ??
|
|
||||||
fileSelectionButtonThemeExtension?.selectedStyle ??
|
|
||||||
style)
|
|
||||||
.padding,
|
|
||||||
foregroundColors: (selectedStyle ??
|
|
||||||
fileSelectionButtonThemeExtension?.selectedStyle ??
|
|
||||||
style)
|
|
||||||
.foregroundColors,
|
|
||||||
backgroundColors: (selectedStyle ??
|
|
||||||
fileSelectionButtonThemeExtension?.selectedStyle ??
|
|
||||||
style)
|
|
||||||
.backgroundColors,
|
|
||||||
borderColors: (selectedStyle ??
|
|
||||||
fileSelectionButtonThemeExtension?.selectedStyle ??
|
|
||||||
style)
|
|
||||||
.borderColors,
|
|
||||||
stroke: (selectedStyle ??
|
|
||||||
fileSelectionButtonThemeExtension?.selectedStyle ??
|
|
||||||
style)
|
|
||||||
.stroke,
|
|
||||||
shadow: (selectedStyle ??
|
|
||||||
fileSelectionButtonThemeExtension?.selectedStyle ??
|
|
||||||
style)
|
|
||||||
.shadow,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.isInvalid) {
|
if (state.isInvalid) {
|
||||||
// TODO(hpcl): enhance copyWith to copy only non-null attributes of an object
|
style = invalidStyle ?? style;
|
||||||
style = style.copyWith(
|
|
||||||
title: (invalidStyle ??
|
|
||||||
fileSelectionButtonThemeExtension?.invalidStyle ??
|
|
||||||
style)
|
|
||||||
.title,
|
|
||||||
subTitle: (invalidStyle ??
|
|
||||||
fileSelectionButtonThemeExtension?.invalidStyle ??
|
|
||||||
style)
|
|
||||||
.subTitle,
|
|
||||||
radius: (invalidStyle ??
|
|
||||||
fileSelectionButtonThemeExtension?.invalidStyle ??
|
|
||||||
style)
|
|
||||||
.radius,
|
|
||||||
padding: (invalidStyle ??
|
|
||||||
fileSelectionButtonThemeExtension?.invalidStyle ??
|
|
||||||
style)
|
|
||||||
.padding,
|
|
||||||
foregroundColors: (invalidStyle ??
|
|
||||||
fileSelectionButtonThemeExtension?.invalidStyle ??
|
|
||||||
style)
|
|
||||||
.foregroundColors,
|
|
||||||
backgroundColors: (invalidStyle ??
|
|
||||||
fileSelectionButtonThemeExtension?.invalidStyle ??
|
|
||||||
style)
|
|
||||||
.backgroundColors,
|
|
||||||
borderColors: (invalidStyle ??
|
|
||||||
fileSelectionButtonThemeExtension?.invalidStyle ??
|
|
||||||
style)
|
|
||||||
.borderColors,
|
|
||||||
stroke: (invalidStyle ??
|
|
||||||
fileSelectionButtonThemeExtension?.invalidStyle ??
|
|
||||||
style)
|
|
||||||
.stroke,
|
|
||||||
shadow: (invalidStyle ??
|
|
||||||
fileSelectionButtonThemeExtension?.invalidStyle ??
|
|
||||||
style)
|
|
||||||
.shadow,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return style;
|
print(state);
|
||||||
}
|
|
||||||
|
|
||||||
Widget _border(
|
|
||||||
BuildContext context,
|
|
||||||
FileSelectionButtonStyle style,
|
|
||||||
Widget child,
|
|
||||||
) {
|
|
||||||
if (style.borderColors != null && style.stroke != null) {
|
|
||||||
return DottedBorder(
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
dashPattern: const [5, 5],
|
|
||||||
strokeWidth: style.stroke!,
|
|
||||||
color: style.borderColors!.color,
|
|
||||||
borderType: BorderType.RRect,
|
|
||||||
radius:
|
|
||||||
style.radius?.resolve(TextDirection.ltr).bottomLeft ?? Radius.zero,
|
|
||||||
strokeCap: StrokeCap.square,
|
|
||||||
child: child,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return child;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget onBuild(BuildContext context, ButtonState state) {
|
|
||||||
final style = negotiate(context, state);
|
|
||||||
|
|
||||||
return Focus(
|
return Focus(
|
||||||
onFocusChange: (hasFocus) =>
|
onFocusChange: (hasFocus) =>
|
||||||
@ -250,12 +128,18 @@ class FileSelectionButtonScreen
|
|||||||
onPressed?.call(state.state);
|
onPressed?.call(state.state);
|
||||||
bloc(context).onClickUpOut();
|
bloc(context).onClickUpOut();
|
||||||
},
|
},
|
||||||
child: _border(
|
child: DottedBorder(
|
||||||
context,
|
padding: EdgeInsets.zero,
|
||||||
style,
|
dashPattern: const [5, 5],
|
||||||
DecoratedBox(
|
strokeWidth: style.stroke ?? 3,
|
||||||
|
color: style.borderColors?.color ?? context.colorScheme.primary,
|
||||||
|
borderType: BorderType.RRect,
|
||||||
|
radius: Radius.circular(style.radius ?? 0),
|
||||||
|
strokeCap: StrokeCap.square,
|
||||||
|
child: DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: style.backgroundColors?.color,
|
color: style.backgroundColors?.color ??
|
||||||
|
context.colorScheme.primary,
|
||||||
// if no gradient colors => no default value
|
// if no gradient colors => no default value
|
||||||
gradient: (style.backgroundColors?.isGradient ?? false)
|
gradient: (style.backgroundColors?.isGradient ?? false)
|
||||||
? LinearGradient(
|
? LinearGradient(
|
||||||
@ -265,7 +149,9 @@ class FileSelectionButtonScreen
|
|||||||
boxShadow: [
|
boxShadow: [
|
||||||
if (style.shadow != null) ...[style.shadow!]
|
if (style.shadow != null) ...[style.shadow!]
|
||||||
],
|
],
|
||||||
borderRadius: style.radius,
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(style.radius ?? 0),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: const BoxConstraints(
|
constraints: const BoxConstraints(
|
||||||
@ -273,70 +159,81 @@ class FileSelectionButtonScreen
|
|||||||
minHeight: 50,
|
minHeight: 50,
|
||||||
), // min sizes for Material buttons
|
), // min sizes for Material buttons
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: style.padding ?? EdgeInsets.zero,
|
padding: EdgeInsets.all(style.padding ?? 0),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: mainAxisSize ?? MainAxisSize.min,
|
mainAxisSize: mainAxisSize ?? MainAxisSize.min,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
if (leading != null) ...[
|
if (leading != null) ...[
|
||||||
leading ?? const SizedBox.shrink(),
|
leading ?? const SizedBox.shrink(),
|
||||||
Gap(style.padding?.horizontal ?? 10),
|
Gap(style.padding ?? 10),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// Choose color
|
||||||
|
// label.style.color ??
|
||||||
|
// buttonStyle.foregroundColor.color ??
|
||||||
|
// context.textTheme.titleLarge.color
|
||||||
|
//
|
||||||
|
// Choose gradient
|
||||||
|
// label.gradient ??
|
||||||
|
// buttonStyle.foregroundColor.colors ??
|
||||||
|
// null
|
||||||
Column(
|
Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
/// Choose color
|
|
||||||
/// title.style.color ??
|
|
||||||
/// buttonStyle.title.style.color ??
|
|
||||||
/// context.textTheme.titleLarge.color
|
|
||||||
///
|
|
||||||
/// Choose gradient
|
|
||||||
/// title.gradient ??
|
|
||||||
/// buttonStyle.foregroundColor.colors ??
|
|
||||||
/// null
|
|
||||||
///
|
|
||||||
/// More infos in `negociate()` method
|
|
||||||
if (title != null) ...[
|
if (title != null) ...[
|
||||||
Gap(style.padding?.horizontal ?? 10),
|
Builder(
|
||||||
Text(
|
builder: (context) {
|
||||||
|
final color = title?.style?.color ??
|
||||||
|
style?.foregroundColors?.color ??
|
||||||
|
context.textTheme.titleLarge?.color;
|
||||||
|
final buttonStyleGradient =
|
||||||
|
(style?.foregroundColors?.isGradient ??
|
||||||
|
false)
|
||||||
|
? style?.foregroundColors?.colors
|
||||||
|
: null;
|
||||||
|
final gradient =
|
||||||
|
title?.gradient ?? buttonStyleGradient;
|
||||||
|
|
||||||
|
return Text(
|
||||||
title!.text,
|
title!.text,
|
||||||
style: title!.style ?? style.title,
|
style: (title!.style ??
|
||||||
|
context.textTheme.titleLarge)
|
||||||
|
?.copyWith(color: color),
|
||||||
).toGradient(
|
).toGradient(
|
||||||
LinearGradientHelper.fromNullableColors(
|
LinearGradientHelper.fromNullableColors(
|
||||||
title?.gradient ??
|
gradient,
|
||||||
((style.foregroundColors?.isGradient ??
|
|
||||||
false)
|
|
||||||
? style.foregroundColors?.colors
|
|
||||||
: null),
|
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
||||||
/// Choose color
|
|
||||||
/// subTitle.style.color ??
|
|
||||||
/// buttonStyle.subTitle.style.color ??
|
|
||||||
/// context.textTheme.subTitleLarge.color
|
|
||||||
///
|
|
||||||
/// Choose gradient
|
|
||||||
/// subTitle.gradient ??
|
|
||||||
/// buttonStyle.foregroundColor.colors ??
|
|
||||||
/// null
|
|
||||||
///
|
|
||||||
/// More infos in `negociate()` method
|
|
||||||
if (subTitle != null) ...[
|
if (subTitle != null) ...[
|
||||||
Gap(style.padding?.horizontal ?? 10),
|
Builder(
|
||||||
Text(
|
builder: (context) {
|
||||||
|
final color = subTitle?.style?.color ??
|
||||||
|
style?.foregroundColors?.color ??
|
||||||
|
context.textTheme.bodyMedium?.color;
|
||||||
|
final buttonStyleGradient =
|
||||||
|
(style?.foregroundColors?.isGradient ??
|
||||||
|
false)
|
||||||
|
? style?.foregroundColors?.colors
|
||||||
|
: null;
|
||||||
|
final gradient =
|
||||||
|
subTitle?.gradient ?? buttonStyleGradient;
|
||||||
|
|
||||||
|
return Text(
|
||||||
subTitle!.text,
|
subTitle!.text,
|
||||||
style: subTitle!.style ?? style.subTitle,
|
style: (subTitle!.style ??
|
||||||
|
context.textTheme.bodyMedium)
|
||||||
|
?.copyWith(color: color),
|
||||||
).toGradient(
|
).toGradient(
|
||||||
LinearGradientHelper.fromNullableColors(
|
LinearGradientHelper.fromNullableColors(
|
||||||
subTitle?.gradient ??
|
gradient,
|
||||||
((style.foregroundColors?.isGradient ??
|
|
||||||
false)
|
|
||||||
? style.foregroundColors?.colors
|
|
||||||
: null),
|
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
@ -19,19 +19,19 @@ class $FlatButtonCWProxyImpl implements $FlatButtonComponentCWProxy {
|
|||||||
@override
|
@override
|
||||||
FlatButton label(TextWrapper? label) => this(label: label);
|
FlatButton label(TextWrapper? label) => this(label: label);
|
||||||
@override
|
@override
|
||||||
FlatButton disabledStyle(ButtonStyle<dynamic>? disabledStyle) =>
|
FlatButton disabledStyle(ButtonStyle? disabledStyle) =>
|
||||||
this(disabledStyle: disabledStyle);
|
this(disabledStyle: disabledStyle);
|
||||||
@override
|
@override
|
||||||
FlatButton normalStyle(ButtonStyle<dynamic>? normalStyle) =>
|
FlatButton normalStyle(ButtonStyle? normalStyle) =>
|
||||||
this(normalStyle: normalStyle);
|
this(normalStyle: normalStyle);
|
||||||
@override
|
@override
|
||||||
FlatButton hoveredStyle(ButtonStyle<dynamic>? hoveredStyle) =>
|
FlatButton hoveredStyle(ButtonStyle? hoveredStyle) =>
|
||||||
this(hoveredStyle: hoveredStyle);
|
this(hoveredStyle: hoveredStyle);
|
||||||
@override
|
@override
|
||||||
FlatButton focusedStyle(ButtonStyle<dynamic>? focusedStyle) =>
|
FlatButton focusedStyle(ButtonStyle? focusedStyle) =>
|
||||||
this(focusedStyle: focusedStyle);
|
this(focusedStyle: focusedStyle);
|
||||||
@override
|
@override
|
||||||
FlatButton tappedStyle(ButtonStyle<dynamic>? tappedStyle) =>
|
FlatButton tappedStyle(ButtonStyle? tappedStyle) =>
|
||||||
this(tappedStyle: tappedStyle);
|
this(tappedStyle: tappedStyle);
|
||||||
@override
|
@override
|
||||||
FlatButton onPressed(void Function(ControlState)? onPressed) =>
|
FlatButton onPressed(void Function(ControlState)? onPressed) =>
|
||||||
@ -44,11 +44,11 @@ class $FlatButtonCWProxyImpl implements $FlatButtonComponentCWProxy {
|
|||||||
Widget? prefix,
|
Widget? prefix,
|
||||||
Widget? suffix,
|
Widget? suffix,
|
||||||
TextWrapper? label,
|
TextWrapper? label,
|
||||||
ButtonStyle<dynamic>? disabledStyle,
|
ButtonStyle? disabledStyle,
|
||||||
ButtonStyle<dynamic>? normalStyle,
|
ButtonStyle? normalStyle,
|
||||||
ButtonStyle<dynamic>? hoveredStyle,
|
ButtonStyle? hoveredStyle,
|
||||||
ButtonStyle<dynamic>? focusedStyle,
|
ButtonStyle? focusedStyle,
|
||||||
ButtonStyle<dynamic>? tappedStyle,
|
ButtonStyle? tappedStyle,
|
||||||
void Function(ControlState)? onPressed,
|
void Function(ControlState)? onPressed,
|
||||||
Key? key,
|
Key? key,
|
||||||
}) =>
|
}) =>
|
||||||
|
@ -24,7 +24,6 @@ import 'package:wyatt_ui_kit/src/components/gradients/gradient_box_border.dart';
|
|||||||
import 'package:wyatt_ui_kit/src/components/gradients/gradient_text.dart';
|
import 'package:wyatt_ui_kit/src/components/gradients/gradient_text.dart';
|
||||||
import 'package:wyatt_ui_kit/src/core/extensions/theme_extensions.dart';
|
import 'package:wyatt_ui_kit/src/core/extensions/theme_extensions.dart';
|
||||||
import 'package:wyatt_ui_kit/src/core/helpers/linear_gradient_helper.dart';
|
import 'package:wyatt_ui_kit/src/core/helpers/linear_gradient_helper.dart';
|
||||||
import 'package:wyatt_ui_kit/src/domain/button_theme_extension/flat_button_theme_extension.dart';
|
|
||||||
|
|
||||||
class FlatButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
|
class FlatButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
|
||||||
const FlatButtonScreen({
|
const FlatButtonScreen({
|
||||||
@ -44,7 +43,6 @@ class FlatButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
|
|||||||
final Widget? prefix;
|
final Widget? prefix;
|
||||||
final Widget? suffix;
|
final Widget? suffix;
|
||||||
final TextWrapper? label;
|
final TextWrapper? label;
|
||||||
final MainAxisSize? mainAxisSize;
|
|
||||||
|
|
||||||
final FlatButtonStyle? disabledStyle;
|
final FlatButtonStyle? disabledStyle;
|
||||||
final FlatButtonStyle? normalStyle;
|
final FlatButtonStyle? normalStyle;
|
||||||
@ -54,48 +52,33 @@ class FlatButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
|
|||||||
|
|
||||||
final void Function(ControlState state)? onPressed;
|
final void Function(ControlState state)? onPressed;
|
||||||
|
|
||||||
|
final MainAxisSize? mainAxisSize;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ButtonCubit create(BuildContext context) => ButtonCubit();
|
ButtonCubit create(BuildContext context) => ButtonCubit();
|
||||||
|
|
||||||
/// Negotiate the theme to get a complete style.
|
|
||||||
FlatButtonStyle negotiate(BuildContext context, ControlState state) {
|
|
||||||
// Define default style from Flutter values.
|
|
||||||
FlatButtonStyle style = FlatButtonStyle.fromFlutter(context);
|
|
||||||
|
|
||||||
// Try to retrieve custom theme extension
|
|
||||||
final flatButtonThemeExtension =
|
|
||||||
context.themeExtension<FlatButtonThemeExtension>();
|
|
||||||
|
|
||||||
switch (state) {
|
|
||||||
case ControlState.disabled:
|
|
||||||
style = disabledStyle ??
|
|
||||||
flatButtonThemeExtension?.disabledStyle ??
|
|
||||||
style.copyWith(
|
|
||||||
foregroundColors:
|
|
||||||
MultiColor.single(context.colorScheme.onSurface),
|
|
||||||
backgroundColors: MultiColor.single(context.colorScheme.surface),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case ControlState.hovered:
|
|
||||||
style = hoveredStyle ?? flatButtonThemeExtension?.hoveredStyle ?? style;
|
|
||||||
break;
|
|
||||||
case ControlState.tapped:
|
|
||||||
style = tappedStyle ?? flatButtonThemeExtension?.tappedStyle ?? style;
|
|
||||||
break;
|
|
||||||
case ControlState.focused:
|
|
||||||
style = focusedStyle ?? flatButtonThemeExtension?.focusedStyle ?? style;
|
|
||||||
break;
|
|
||||||
case ControlState.normal:
|
|
||||||
style = normalStyle ?? flatButtonThemeExtension?.normalStyle ?? style;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return style;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget onBuild(BuildContext context, ButtonState state) {
|
Widget onBuild(BuildContext context, ButtonState state) {
|
||||||
final style = negotiate(context, state.state);
|
// Set a default style
|
||||||
|
FlatButtonStyle? style = normalStyle ?? const FlatButtonStyle();
|
||||||
|
|
||||||
|
switch (state.state) {
|
||||||
|
case ControlState.disabled:
|
||||||
|
style = disabledStyle ?? style;
|
||||||
|
break;
|
||||||
|
case ControlState.hovered:
|
||||||
|
style = hoveredStyle ?? style;
|
||||||
|
break;
|
||||||
|
case ControlState.tapped:
|
||||||
|
style = tappedStyle ?? style;
|
||||||
|
break;
|
||||||
|
case ControlState.focused:
|
||||||
|
style = focusedStyle ?? style;
|
||||||
|
break;
|
||||||
|
case ControlState.normal:
|
||||||
|
// already done
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return Focus(
|
return Focus(
|
||||||
onFocusChange: (hasFocus) =>
|
onFocusChange: (hasFocus) =>
|
||||||
@ -130,19 +113,20 @@ class FlatButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
|
|||||||
},
|
},
|
||||||
child: DecoratedBox(
|
child: DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: style.backgroundColors?.color,
|
color: style.backgroundColors?.color ??
|
||||||
|
context.colorScheme.primary,
|
||||||
// If no border color => no default value
|
// If no border color => no default value
|
||||||
border: (style.borderColors != null && style.stroke != null)
|
border: (style.borderColors != null)
|
||||||
? (style.borderColors?.isGradient ?? false)
|
? (style.borderColors?.isGradient ?? false)
|
||||||
? GradientBoxBorder(
|
? GradientBoxBorder(
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
colors: style.borderColors!.colors,
|
colors: style.borderColors!.colors,
|
||||||
),
|
),
|
||||||
width: style.stroke!,
|
width: style.stroke ?? 2,
|
||||||
)
|
)
|
||||||
: Border.all(
|
: Border.all(
|
||||||
color: style.borderColors!.color,
|
color: style.borderColors!.color,
|
||||||
width: style.stroke!,
|
width: style.stroke ?? 2,
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
// if no gradient colors => no default value
|
// if no gradient colors => no default value
|
||||||
@ -154,7 +138,9 @@ class FlatButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
|
|||||||
boxShadow: [
|
boxShadow: [
|
||||||
if (style.shadow != null) ...[style.shadow!]
|
if (style.shadow != null) ...[style.shadow!]
|
||||||
],
|
],
|
||||||
borderRadius: style.radius,
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(style.radius ?? 0),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: const BoxConstraints(
|
constraints: const BoxConstraints(
|
||||||
@ -162,62 +148,76 @@ class FlatButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
|
|||||||
minHeight: 36,
|
minHeight: 36,
|
||||||
), // min sizes for Material buttons
|
), // min sizes for Material buttons
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: style.padding ?? EdgeInsets.zero,
|
padding: EdgeInsets.all(style.padding ?? 0),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: mainAxisSize ?? MainAxisSize.min,
|
mainAxisSize: mainAxisSize ?? MainAxisSize.min,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
if (style.foregroundColors?.color != null &&
|
Builder(
|
||||||
prefix != null) ...[
|
builder: (context) {
|
||||||
ColorFiltered(
|
final color = style?.foregroundColors?.color;
|
||||||
colorFilter: ColorFilter.mode(
|
if (color != null) {
|
||||||
style.foregroundColors!.color,
|
return ColorFiltered(
|
||||||
BlendMode.srcIn,
|
colorFilter:
|
||||||
|
ColorFilter.mode(color, BlendMode.srcIn),
|
||||||
|
child: prefix ?? const SizedBox.shrink(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return prefix ?? const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
child: prefix,
|
Gap(style.padding ?? 10),
|
||||||
)
|
// Choose color
|
||||||
] else ...[
|
// label.style.color ??
|
||||||
prefix ?? const SizedBox.shrink()
|
// buttonStyle.foregroundColor.color ??
|
||||||
],
|
// context.textTheme.titleLarge.color
|
||||||
Gap(style.padding?.vertical ?? 10),
|
//
|
||||||
|
// Choose gradient
|
||||||
/// Choose color
|
// label.gradient ??
|
||||||
/// label.style.color ??
|
// buttonStyle.foregroundColor.colors ??
|
||||||
/// buttonStyle.label.style.color ??
|
// null
|
||||||
/// context.textTheme.labelLarge.color
|
|
||||||
///
|
|
||||||
/// Choose gradient
|
|
||||||
/// label.gradient ??
|
|
||||||
/// buttonStyle.foregroundColor.colors ??
|
|
||||||
/// null
|
|
||||||
///
|
|
||||||
/// More infos in `negociate()` method
|
|
||||||
if (label != null) ...[
|
if (label != null) ...[
|
||||||
Text(
|
Builder(
|
||||||
|
builder: (context) {
|
||||||
|
final color = label?.style?.color ??
|
||||||
|
style?.foregroundColors?.color ??
|
||||||
|
context.textTheme.titleLarge?.color;
|
||||||
|
final buttonStyleGradient =
|
||||||
|
(style?.foregroundColors?.isGradient ?? false)
|
||||||
|
? style?.foregroundColors?.colors
|
||||||
|
: null;
|
||||||
|
final gradient =
|
||||||
|
label?.gradient ?? buttonStyleGradient;
|
||||||
|
|
||||||
|
return Text(
|
||||||
label!.text,
|
label!.text,
|
||||||
style: label!.style ?? style.label,
|
style:
|
||||||
|
(label!.style ?? context.textTheme.titleLarge)
|
||||||
|
?.copyWith(color: color),
|
||||||
).toGradient(
|
).toGradient(
|
||||||
LinearGradientHelper.fromNullableColors(
|
LinearGradientHelper.fromNullableColors(
|
||||||
label?.gradient ??
|
gradient,
|
||||||
((style.foregroundColors?.isGradient ?? false)
|
|
||||||
? style.foregroundColors?.colors
|
|
||||||
: null),
|
|
||||||
),
|
),
|
||||||
)
|
);
|
||||||
],
|
},
|
||||||
Gap(style.padding?.vertical ?? 10),
|
|
||||||
if (style.foregroundColors?.color != null &&
|
|
||||||
suffix != null) ...[
|
|
||||||
ColorFiltered(
|
|
||||||
colorFilter: ColorFilter.mode(
|
|
||||||
style.foregroundColors!.color,
|
|
||||||
BlendMode.srcIn,
|
|
||||||
),
|
),
|
||||||
child: suffix,
|
|
||||||
)
|
|
||||||
] else ...[
|
|
||||||
suffix ?? const SizedBox.shrink()
|
|
||||||
],
|
],
|
||||||
|
Gap(style.padding ?? 10),
|
||||||
|
Builder(
|
||||||
|
builder: (context) {
|
||||||
|
final color = style?.foregroundColors?.color;
|
||||||
|
if (color != null) {
|
||||||
|
return ColorFiltered(
|
||||||
|
colorFilter:
|
||||||
|
ColorFilter.mode(color, BlendMode.srcIn),
|
||||||
|
child: suffix ?? const SizedBox.shrink(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return suffix ?? const SizedBox.shrink();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -33,6 +33,7 @@ class SimpleIconButton extends SimpleIconButtonComponent
|
|||||||
super.hoveredStyle,
|
super.hoveredStyle,
|
||||||
super.focusedStyle,
|
super.focusedStyle,
|
||||||
super.tappedStyle,
|
super.tappedStyle,
|
||||||
|
super.selectedStyle,
|
||||||
super.onPressed,
|
super.onPressed,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
@ -62,6 +63,9 @@ class SimpleIconButton extends SimpleIconButtonComponent
|
|||||||
SimpleIconButtonStyle? get tappedStyle =>
|
SimpleIconButtonStyle? get tappedStyle =>
|
||||||
super.tappedStyle as SimpleIconButtonStyle?;
|
super.tappedStyle as SimpleIconButtonStyle?;
|
||||||
|
|
||||||
|
@override
|
||||||
|
SimpleIconButtonStyle? get selectedStyle =>
|
||||||
|
super.selectedStyle as SimpleIconButtonStyle?;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => exportBloc(
|
Widget build(BuildContext context) => exportBloc(
|
||||||
@ -72,6 +76,7 @@ class SimpleIconButton extends SimpleIconButtonComponent
|
|||||||
hoveredStyle: hoveredStyle,
|
hoveredStyle: hoveredStyle,
|
||||||
focusedStyle: focusedStyle,
|
focusedStyle: focusedStyle,
|
||||||
tappedStyle: tappedStyle,
|
tappedStyle: tappedStyle,
|
||||||
|
selectedStyle: selectedStyle,
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
key: key,
|
key: key,
|
||||||
),
|
),
|
||||||
|
@ -13,21 +13,24 @@ class $SimpleIconButtonCWProxyImpl
|
|||||||
@override
|
@override
|
||||||
SimpleIconButton icon(Icon? icon) => this(icon: icon);
|
SimpleIconButton icon(Icon? icon) => this(icon: icon);
|
||||||
@override
|
@override
|
||||||
SimpleIconButton disabledStyle(ButtonStyle<dynamic>? disabledStyle) =>
|
SimpleIconButton disabledStyle(ButtonStyle? disabledStyle) =>
|
||||||
this(disabledStyle: disabledStyle);
|
this(disabledStyle: disabledStyle);
|
||||||
@override
|
@override
|
||||||
SimpleIconButton normalStyle(ButtonStyle<dynamic>? normalStyle) =>
|
SimpleIconButton normalStyle(ButtonStyle? normalStyle) =>
|
||||||
this(normalStyle: normalStyle);
|
this(normalStyle: normalStyle);
|
||||||
@override
|
@override
|
||||||
SimpleIconButton hoveredStyle(ButtonStyle<dynamic>? hoveredStyle) =>
|
SimpleIconButton hoveredStyle(ButtonStyle? hoveredStyle) =>
|
||||||
this(hoveredStyle: hoveredStyle);
|
this(hoveredStyle: hoveredStyle);
|
||||||
@override
|
@override
|
||||||
SimpleIconButton focusedStyle(ButtonStyle<dynamic>? focusedStyle) =>
|
SimpleIconButton focusedStyle(ButtonStyle? focusedStyle) =>
|
||||||
this(focusedStyle: focusedStyle);
|
this(focusedStyle: focusedStyle);
|
||||||
@override
|
@override
|
||||||
SimpleIconButton tappedStyle(ButtonStyle<dynamic>? tappedStyle) =>
|
SimpleIconButton tappedStyle(ButtonStyle? tappedStyle) =>
|
||||||
this(tappedStyle: tappedStyle);
|
this(tappedStyle: tappedStyle);
|
||||||
@override
|
@override
|
||||||
|
SimpleIconButton selectedStyle(ButtonStyle? selectedStyle) =>
|
||||||
|
this(selectedStyle: selectedStyle);
|
||||||
|
@override
|
||||||
SimpleIconButton onPressed(void Function(ControlState)? onPressed) =>
|
SimpleIconButton onPressed(void Function(ControlState)? onPressed) =>
|
||||||
this(onPressed: onPressed);
|
this(onPressed: onPressed);
|
||||||
@override
|
@override
|
||||||
@ -35,11 +38,12 @@ class $SimpleIconButtonCWProxyImpl
|
|||||||
@override
|
@override
|
||||||
SimpleIconButton call({
|
SimpleIconButton call({
|
||||||
Icon? icon,
|
Icon? icon,
|
||||||
ButtonStyle<dynamic>? disabledStyle,
|
ButtonStyle? disabledStyle,
|
||||||
ButtonStyle<dynamic>? normalStyle,
|
ButtonStyle? normalStyle,
|
||||||
ButtonStyle<dynamic>? hoveredStyle,
|
ButtonStyle? hoveredStyle,
|
||||||
ButtonStyle<dynamic>? focusedStyle,
|
ButtonStyle? focusedStyle,
|
||||||
ButtonStyle<dynamic>? tappedStyle,
|
ButtonStyle? tappedStyle,
|
||||||
|
ButtonStyle? selectedStyle,
|
||||||
void Function(ControlState)? onPressed,
|
void Function(ControlState)? onPressed,
|
||||||
Key? key,
|
Key? key,
|
||||||
}) =>
|
}) =>
|
||||||
@ -50,6 +54,7 @@ class $SimpleIconButtonCWProxyImpl
|
|||||||
hoveredStyle: hoveredStyle ?? _value.hoveredStyle,
|
hoveredStyle: hoveredStyle ?? _value.hoveredStyle,
|
||||||
focusedStyle: focusedStyle ?? _value.focusedStyle,
|
focusedStyle: focusedStyle ?? _value.focusedStyle,
|
||||||
tappedStyle: tappedStyle ?? _value.tappedStyle,
|
tappedStyle: tappedStyle ?? _value.tappedStyle,
|
||||||
|
selectedStyle: selectedStyle ?? _value.selectedStyle,
|
||||||
onPressed: onPressed ?? _value.onPressed,
|
onPressed: onPressed ?? _value.onPressed,
|
||||||
key: key ?? _value.key,
|
key: key ?? _value.key,
|
||||||
);
|
);
|
||||||
|
@ -20,10 +20,7 @@ import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart';
|
|||||||
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
|
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
|
||||||
import 'package:wyatt_ui_kit/src/components/buttons/cubit/button_cubit.dart';
|
import 'package:wyatt_ui_kit/src/components/buttons/cubit/button_cubit.dart';
|
||||||
import 'package:wyatt_ui_kit/src/components/gradients/gradient_box_border.dart';
|
import 'package:wyatt_ui_kit/src/components/gradients/gradient_box_border.dart';
|
||||||
import 'package:wyatt_ui_kit/src/components/gradients/gradient_icon.dart';
|
|
||||||
import 'package:wyatt_ui_kit/src/core/extensions/theme_extensions.dart';
|
import 'package:wyatt_ui_kit/src/core/extensions/theme_extensions.dart';
|
||||||
import 'package:wyatt_ui_kit/src/core/helpers/linear_gradient_helper.dart';
|
|
||||||
import 'package:wyatt_ui_kit/src/domain/button_theme_extension/simple_icon_button_theme_extension.dart';
|
|
||||||
|
|
||||||
class SimpleIconButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
|
class SimpleIconButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
|
||||||
const SimpleIconButtonScreen({
|
const SimpleIconButtonScreen({
|
||||||
@ -33,6 +30,7 @@ class SimpleIconButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
|
|||||||
this.hoveredStyle,
|
this.hoveredStyle,
|
||||||
this.focusedStyle,
|
this.focusedStyle,
|
||||||
this.tappedStyle,
|
this.tappedStyle,
|
||||||
|
this.selectedStyle,
|
||||||
this.onPressed,
|
this.onPressed,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
@ -44,57 +42,34 @@ class SimpleIconButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
|
|||||||
final SimpleIconButtonStyle? hoveredStyle;
|
final SimpleIconButtonStyle? hoveredStyle;
|
||||||
final SimpleIconButtonStyle? focusedStyle;
|
final SimpleIconButtonStyle? focusedStyle;
|
||||||
final SimpleIconButtonStyle? tappedStyle;
|
final SimpleIconButtonStyle? tappedStyle;
|
||||||
|
final SimpleIconButtonStyle? selectedStyle;
|
||||||
|
|
||||||
final void Function(ControlState state)? onPressed;
|
final void Function(ControlState state)? onPressed;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ButtonCubit create(BuildContext context) => ButtonCubit();
|
ButtonCubit create(BuildContext context) => ButtonCubit();
|
||||||
|
|
||||||
/// Negotiate the theme to get a complete style.
|
|
||||||
SimpleIconButtonStyle negotiate(BuildContext context, ControlState state) {
|
|
||||||
// Define default style from Flutter values.
|
|
||||||
SimpleIconButtonStyle style = SimpleIconButtonStyle.fromFlutter(context);
|
|
||||||
|
|
||||||
// Try to retrieve custom theme extension
|
|
||||||
final simpleIconButtonThemeExtension =
|
|
||||||
context.themeExtension<SimpleIconButtonThemeExtension>();
|
|
||||||
|
|
||||||
switch (state) {
|
|
||||||
case ControlState.disabled:
|
|
||||||
style = disabledStyle ??
|
|
||||||
simpleIconButtonThemeExtension?.disabledStyle ??
|
|
||||||
style.copyWith(
|
|
||||||
foregroundColors:
|
|
||||||
MultiColor.single(context.colorScheme.onSurface),
|
|
||||||
backgroundColors: MultiColor.single(context.colorScheme.surface),
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case ControlState.hovered:
|
|
||||||
style = hoveredStyle ??
|
|
||||||
simpleIconButtonThemeExtension?.hoveredStyle ??
|
|
||||||
style;
|
|
||||||
break;
|
|
||||||
case ControlState.tapped:
|
|
||||||
style =
|
|
||||||
tappedStyle ?? simpleIconButtonThemeExtension?.tappedStyle ?? style;
|
|
||||||
break;
|
|
||||||
case ControlState.focused:
|
|
||||||
style = focusedStyle ??
|
|
||||||
simpleIconButtonThemeExtension?.focusedStyle ??
|
|
||||||
style;
|
|
||||||
break;
|
|
||||||
case ControlState.normal:
|
|
||||||
style =
|
|
||||||
normalStyle ?? simpleIconButtonThemeExtension?.normalStyle ?? style;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return style;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget onBuild(BuildContext context, ButtonState state) {
|
Widget onBuild(BuildContext context, ButtonState state) {
|
||||||
final style = negotiate(context, state.state);
|
// Set a default style
|
||||||
|
SimpleIconButtonStyle? style = normalStyle ?? const SimpleIconButtonStyle();
|
||||||
|
|
||||||
|
switch (state.state) {
|
||||||
|
case ControlState.disabled:
|
||||||
|
style = disabledStyle ?? style;
|
||||||
|
break;
|
||||||
|
case ControlState.hovered:
|
||||||
|
style = hoveredStyle ?? style;
|
||||||
|
break;
|
||||||
|
case ControlState.tapped:
|
||||||
|
style = tappedStyle ?? style;
|
||||||
|
break;
|
||||||
|
case ControlState.focused:
|
||||||
|
style = focusedStyle ?? style;
|
||||||
|
break;
|
||||||
|
case ControlState.normal:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return Focus(
|
return Focus(
|
||||||
onFocusChange: (hasFocus) =>
|
onFocusChange: (hasFocus) =>
|
||||||
@ -129,24 +104,25 @@ class SimpleIconButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
|
|||||||
bloc(context).onClickUpOut();
|
bloc(context).onClickUpOut();
|
||||||
},
|
},
|
||||||
child: SizedBox.square(
|
child: SizedBox.square(
|
||||||
dimension: style.dimension,
|
dimension: style.dimension ?? 30,
|
||||||
child: AspectRatio(
|
child: AspectRatio(
|
||||||
aspectRatio: 1,
|
aspectRatio: 1,
|
||||||
child: DecoratedBox(
|
child: DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: style.backgroundColors?.color,
|
color: style.backgroundColors?.color ??
|
||||||
|
context.colorScheme.tertiary,
|
||||||
// If no border color => no default value
|
// If no border color => no default value
|
||||||
border: (style.borderColors != null && style.stroke != null)
|
border: (style.borderColors != null)
|
||||||
? (style.borderColors?.isGradient ?? false)
|
? (style.borderColors?.isGradient ?? false)
|
||||||
? GradientBoxBorder(
|
? GradientBoxBorder(
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
colors: style.borderColors!.colors,
|
colors: style.borderColors!.colors,
|
||||||
),
|
),
|
||||||
width: style.stroke!,
|
width: style.stroke ?? 2,
|
||||||
)
|
)
|
||||||
: Border.all(
|
: Border.all(
|
||||||
color: style.borderColors!.color,
|
color: style.borderColors!.color,
|
||||||
width: style.stroke!,
|
width: style.stroke ?? 2,
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
// if no gradient colors => no default value
|
// if no gradient colors => no default value
|
||||||
@ -158,40 +134,52 @@ class SimpleIconButtonScreen extends CubitScreen<ButtonCubit, ButtonState> {
|
|||||||
boxShadow: [
|
boxShadow: [
|
||||||
if (style.shadow != null) ...[style.shadow!]
|
if (style.shadow != null) ...[style.shadow!]
|
||||||
],
|
],
|
||||||
borderRadius: style.radius,
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(style.radius ?? 0),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
minWidth: style.dimension ?? 30,
|
minWidth: style.dimension ?? 30,
|
||||||
),
|
), // min sizes for Material buttons
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: style.padding ?? EdgeInsets.zero,
|
padding: EdgeInsets.all(style.padding ?? 0),
|
||||||
child: Center(
|
child: Center(
|
||||||
/// Choose color
|
// Choose color
|
||||||
/// icon.color ??
|
// button.foreground.colors (gradient) ??
|
||||||
/// button.foregroundColors.colors ??
|
// buttonStyle.foregroundColor.color ??
|
||||||
/// buttonStyle.foregroundColors.colors ??
|
// context.colorScheme.onTertiary
|
||||||
/// context.buttonTheme.onPrimary
|
|
||||||
child: Builder(
|
child: Builder(
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
if (icon?.color != null) {
|
if (icon?.color != null) {
|
||||||
return icon!;
|
return icon!;
|
||||||
}
|
}
|
||||||
|
final gradient =
|
||||||
if (!(style.foregroundColors?.isGradient ?? false)) {
|
(style?.foregroundColors?.isGradient ?? false)
|
||||||
return ColorFiltered(
|
? LinearGradient(
|
||||||
colorFilter: ColorFilter.mode(
|
colors: style!.foregroundColors!.colors,
|
||||||
style.foregroundColors!.color,
|
)
|
||||||
BlendMode.srcIn,
|
: null;
|
||||||
|
final color = style?.foregroundColors?.color ??
|
||||||
|
context.colorScheme.onTertiary;
|
||||||
|
if (gradient != null) {
|
||||||
|
return ShaderMask(
|
||||||
|
blendMode: BlendMode.srcIn,
|
||||||
|
shaderCallback: (bounds) => gradient.createShader(
|
||||||
|
Rect.fromLTWH(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
bounds.width,
|
||||||
|
bounds.height,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: icon,
|
child: icon,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
return ColorFiltered(
|
||||||
return icon!.toGradient(
|
colorFilter:
|
||||||
LinearGradientHelper.fromMultiColor(
|
ColorFilter.mode(color, BlendMode.srcIn),
|
||||||
style.foregroundColors!,
|
child: icon,
|
||||||
),
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
@ -17,22 +17,22 @@ class $SymbolButtonCWProxyImpl implements $SymbolButtonComponentCWProxy {
|
|||||||
@override
|
@override
|
||||||
SymbolButton icon(Widget? icon) => this(icon: icon);
|
SymbolButton icon(Widget? icon) => this(icon: icon);
|
||||||
@override
|
@override
|
||||||
SymbolButton disabledStyle(ButtonStyle<dynamic>? disabledStyle) =>
|
SymbolButton disabledStyle(ButtonStyle? disabledStyle) =>
|
||||||
this(disabledStyle: disabledStyle);
|
this(disabledStyle: disabledStyle);
|
||||||
@override
|
@override
|
||||||
SymbolButton normalStyle(ButtonStyle<dynamic>? normalStyle) =>
|
SymbolButton normalStyle(ButtonStyle? normalStyle) =>
|
||||||
this(normalStyle: normalStyle);
|
this(normalStyle: normalStyle);
|
||||||
@override
|
@override
|
||||||
SymbolButton hoveredStyle(ButtonStyle<dynamic>? hoveredStyle) =>
|
SymbolButton hoveredStyle(ButtonStyle? hoveredStyle) =>
|
||||||
this(hoveredStyle: hoveredStyle);
|
this(hoveredStyle: hoveredStyle);
|
||||||
@override
|
@override
|
||||||
SymbolButton focusedStyle(ButtonStyle<dynamic>? focusedStyle) =>
|
SymbolButton focusedStyle(ButtonStyle? focusedStyle) =>
|
||||||
this(focusedStyle: focusedStyle);
|
this(focusedStyle: focusedStyle);
|
||||||
@override
|
@override
|
||||||
SymbolButton tappedStyle(ButtonStyle<dynamic>? tappedStyle) =>
|
SymbolButton tappedStyle(ButtonStyle? tappedStyle) =>
|
||||||
this(tappedStyle: tappedStyle);
|
this(tappedStyle: tappedStyle);
|
||||||
@override
|
@override
|
||||||
SymbolButton selectedStyle(ButtonStyle<dynamic>? selectedStyle) =>
|
SymbolButton selectedStyle(ButtonStyle? selectedStyle) =>
|
||||||
this(selectedStyle: selectedStyle);
|
this(selectedStyle: selectedStyle);
|
||||||
@override
|
@override
|
||||||
SymbolButton onPressed(void Function(ControlState)? onPressed) =>
|
SymbolButton onPressed(void Function(ControlState)? onPressed) =>
|
||||||
@ -44,12 +44,12 @@ class $SymbolButtonCWProxyImpl implements $SymbolButtonComponentCWProxy {
|
|||||||
MainAxisSize? mainAxisSize,
|
MainAxisSize? mainAxisSize,
|
||||||
TextWrapper? label,
|
TextWrapper? label,
|
||||||
Widget? icon,
|
Widget? icon,
|
||||||
ButtonStyle<dynamic>? disabledStyle,
|
ButtonStyle? disabledStyle,
|
||||||
ButtonStyle<dynamic>? normalStyle,
|
ButtonStyle? normalStyle,
|
||||||
ButtonStyle<dynamic>? hoveredStyle,
|
ButtonStyle? hoveredStyle,
|
||||||
ButtonStyle<dynamic>? focusedStyle,
|
ButtonStyle? focusedStyle,
|
||||||
ButtonStyle<dynamic>? tappedStyle,
|
ButtonStyle? tappedStyle,
|
||||||
ButtonStyle<dynamic>? selectedStyle,
|
ButtonStyle? selectedStyle,
|
||||||
void Function(ControlState)? onPressed,
|
void Function(ControlState)? onPressed,
|
||||||
Key? key,
|
Key? key,
|
||||||
}) =>
|
}) =>
|
||||||
|
@ -25,7 +25,6 @@ import 'package:wyatt_ui_kit/src/components/gradients/gradient_box_border.dart';
|
|||||||
import 'package:wyatt_ui_kit/src/components/gradients/gradient_text.dart';
|
import 'package:wyatt_ui_kit/src/components/gradients/gradient_text.dart';
|
||||||
import 'package:wyatt_ui_kit/src/core/extensions/theme_extensions.dart';
|
import 'package:wyatt_ui_kit/src/core/extensions/theme_extensions.dart';
|
||||||
import 'package:wyatt_ui_kit/src/core/helpers/linear_gradient_helper.dart';
|
import 'package:wyatt_ui_kit/src/core/helpers/linear_gradient_helper.dart';
|
||||||
import 'package:wyatt_ui_kit/src/domain/button_theme_extension/symbol_button_theme_extension.dart';
|
|
||||||
|
|
||||||
class SymbolButtonScreen
|
class SymbolButtonScreen
|
||||||
extends CubitScreen<SelectableButtonCubit, ButtonState> {
|
extends CubitScreen<SelectableButtonCubit, ButtonState> {
|
||||||
@ -45,7 +44,6 @@ class SymbolButtonScreen
|
|||||||
|
|
||||||
final Widget? icon;
|
final Widget? icon;
|
||||||
final TextWrapper? label;
|
final TextWrapper? label;
|
||||||
final MainAxisSize? mainAxisSize;
|
|
||||||
|
|
||||||
final SymbolButtonStyle? disabledStyle;
|
final SymbolButtonStyle? disabledStyle;
|
||||||
final SymbolButtonStyle? normalStyle;
|
final SymbolButtonStyle? normalStyle;
|
||||||
@ -56,94 +54,37 @@ class SymbolButtonScreen
|
|||||||
|
|
||||||
final void Function(ControlState state)? onPressed;
|
final void Function(ControlState state)? onPressed;
|
||||||
|
|
||||||
|
final MainAxisSize? mainAxisSize;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
SelectableButtonCubit create(BuildContext context) => SelectableButtonCubit();
|
SelectableButtonCubit create(BuildContext context) => SelectableButtonCubit();
|
||||||
|
|
||||||
/// Negotiate the theme to get a complete style.
|
@override
|
||||||
SymbolButtonStyle negotiate(BuildContext context, ButtonState state) {
|
Widget onBuild(BuildContext context, ButtonState state) {
|
||||||
// Define default style from Flutter values.
|
// Set a default style
|
||||||
SymbolButtonStyle style = SymbolButtonStyle.fromFlutter(context);
|
SymbolButtonStyle? style = normalStyle ?? const SymbolButtonStyle();
|
||||||
|
|
||||||
// Try to retrieve custom theme extension
|
|
||||||
final symbolButtonThemeExtension =
|
|
||||||
context.themeExtension<SymbolButtonThemeExtension>();
|
|
||||||
|
|
||||||
switch (state.state) {
|
switch (state.state) {
|
||||||
case ControlState.disabled:
|
case ControlState.disabled:
|
||||||
style = disabledStyle ??
|
style = disabledStyle ?? style;
|
||||||
symbolButtonThemeExtension?.disabledStyle ??
|
|
||||||
style.copyWith(
|
|
||||||
foregroundColors:
|
|
||||||
MultiColor.single(context.colorScheme.onSurface),
|
|
||||||
backgroundColors: MultiColor.single(context.colorScheme.surface),
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
case ControlState.hovered:
|
case ControlState.hovered:
|
||||||
style =
|
style = hoveredStyle ?? style;
|
||||||
hoveredStyle ?? symbolButtonThemeExtension?.hoveredStyle ?? style;
|
|
||||||
break;
|
break;
|
||||||
case ControlState.tapped:
|
case ControlState.tapped:
|
||||||
style = tappedStyle ?? symbolButtonThemeExtension?.tappedStyle ?? style;
|
style = tappedStyle ?? style;
|
||||||
break;
|
break;
|
||||||
case ControlState.focused:
|
case ControlState.focused:
|
||||||
style =
|
style = focusedStyle ?? style;
|
||||||
focusedStyle ?? symbolButtonThemeExtension?.focusedStyle ?? style;
|
|
||||||
break;
|
break;
|
||||||
case ControlState.normal:
|
case ControlState.normal:
|
||||||
style = normalStyle ?? symbolButtonThemeExtension?.normalStyle ?? style;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply extra theme
|
|
||||||
if (state.isSelected) {
|
if (state.isSelected) {
|
||||||
// TODO(hpcl): enhance copyWith to copy only non-null attributes of an object
|
style = selectedStyle ?? style;
|
||||||
style = style.copyWith(
|
|
||||||
label: (selectedStyle ??
|
|
||||||
symbolButtonThemeExtension?.selectedStyle ??
|
|
||||||
style)
|
|
||||||
.label,
|
|
||||||
dimension: (selectedStyle ??
|
|
||||||
symbolButtonThemeExtension?.selectedStyle ??
|
|
||||||
style)
|
|
||||||
.dimension,
|
|
||||||
radius: (selectedStyle ??
|
|
||||||
symbolButtonThemeExtension?.selectedStyle ??
|
|
||||||
style)
|
|
||||||
.radius,
|
|
||||||
padding: (selectedStyle ??
|
|
||||||
symbolButtonThemeExtension?.selectedStyle ??
|
|
||||||
style)
|
|
||||||
.padding,
|
|
||||||
foregroundColors: (selectedStyle ??
|
|
||||||
symbolButtonThemeExtension?.selectedStyle ??
|
|
||||||
style)
|
|
||||||
.foregroundColors,
|
|
||||||
backgroundColors: (selectedStyle ??
|
|
||||||
symbolButtonThemeExtension?.selectedStyle ??
|
|
||||||
style)
|
|
||||||
.backgroundColors,
|
|
||||||
borderColors: (selectedStyle ??
|
|
||||||
symbolButtonThemeExtension?.selectedStyle ??
|
|
||||||
style)
|
|
||||||
.borderColors,
|
|
||||||
stroke: (selectedStyle ??
|
|
||||||
symbolButtonThemeExtension?.selectedStyle ??
|
|
||||||
style)
|
|
||||||
.stroke,
|
|
||||||
shadow: (selectedStyle ??
|
|
||||||
symbolButtonThemeExtension?.selectedStyle ??
|
|
||||||
style)
|
|
||||||
.shadow,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return style;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget onBuild(BuildContext context, ButtonState state) {
|
|
||||||
final style = negotiate(context, state);
|
|
||||||
|
|
||||||
return Focus(
|
return Focus(
|
||||||
onFocusChange: (hasFocus) =>
|
onFocusChange: (hasFocus) =>
|
||||||
hasFocus ? bloc(context).onFocus() : bloc(context).onUnfocus(),
|
hasFocus ? bloc(context).onFocus() : bloc(context).onUnfocus(),
|
||||||
@ -181,25 +122,25 @@ class SymbolButtonScreen
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
SizedBox.square(
|
SizedBox.square(
|
||||||
dimension: style.dimension,
|
dimension: style.dimension ?? 60,
|
||||||
child: AspectRatio(
|
child: AspectRatio(
|
||||||
aspectRatio: 1,
|
aspectRatio: 1,
|
||||||
child: DecoratedBox(
|
child: DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: style.backgroundColors?.color,
|
color: style.backgroundColors?.color ??
|
||||||
|
context.colorScheme.primary,
|
||||||
// If no border color => no default value
|
// If no border color => no default value
|
||||||
border:
|
border: (style.borderColors != null)
|
||||||
(style.borderColors != null && style.stroke != null)
|
|
||||||
? (style.borderColors?.isGradient ?? false)
|
? (style.borderColors?.isGradient ?? false)
|
||||||
? GradientBoxBorder(
|
? GradientBoxBorder(
|
||||||
gradient: LinearGradient(
|
gradient: LinearGradient(
|
||||||
colors: style.borderColors!.colors,
|
colors: style.borderColors!.colors,
|
||||||
),
|
),
|
||||||
width: style.stroke!,
|
width: style.stroke ?? 2,
|
||||||
)
|
)
|
||||||
: Border.all(
|
: Border.all(
|
||||||
color: style.borderColors!.color,
|
color: style.borderColors!.color,
|
||||||
width: style.stroke!,
|
width: style.stroke ?? 2,
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
// if no gradient colors => no default value
|
// if no gradient colors => no default value
|
||||||
@ -211,44 +152,92 @@ class SymbolButtonScreen
|
|||||||
boxShadow: [
|
boxShadow: [
|
||||||
if (style.shadow != null) ...[style.shadow!]
|
if (style.shadow != null) ...[style.shadow!]
|
||||||
],
|
],
|
||||||
borderRadius: style.radius,
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(style.radius ?? 0),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
minWidth: style.dimension ?? 60,
|
minWidth: style.dimension ?? 60,
|
||||||
), // min sizes for Material buttons
|
), // min sizes for Material buttons
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: style.padding ?? EdgeInsets.zero,
|
padding: EdgeInsets.all(style.padding ?? 0),
|
||||||
child: Center(child: icon),
|
child: Center(
|
||||||
|
// Choose color
|
||||||
|
// button.foreground.colors (gradient) ??
|
||||||
|
// buttonStyle.foregroundColor.color ??
|
||||||
|
// context.colorScheme.secondary
|
||||||
|
child: Builder(
|
||||||
|
builder: (context) {
|
||||||
|
final gradient =
|
||||||
|
(style?.foregroundColors?.isGradient ?? false)
|
||||||
|
? LinearGradient(
|
||||||
|
colors:
|
||||||
|
style!.foregroundColors!.colors,
|
||||||
|
)
|
||||||
|
: null;
|
||||||
|
final color = style?.foregroundColors?.color ??
|
||||||
|
context.colorScheme.secondary;
|
||||||
|
if (gradient != null) {
|
||||||
|
return ShaderMask(
|
||||||
|
blendMode: BlendMode.srcIn,
|
||||||
|
shaderCallback: (bounds) =>
|
||||||
|
gradient.createShader(
|
||||||
|
Rect.fromLTWH(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
bounds.width,
|
||||||
|
bounds.height,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: icon,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return ColorFiltered(
|
||||||
|
colorFilter:
|
||||||
|
ColorFilter.mode(color, BlendMode.srcIn),
|
||||||
|
child: icon,
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
/// Choose color
|
),
|
||||||
/// label.style.color ??
|
// Choose color
|
||||||
/// buttonStyle.label.style.color ??
|
// label.style.color ??
|
||||||
/// context.textTheme.labelLarge.color
|
// buttonStyle.foregroundColor.color ??
|
||||||
///
|
// context.textTheme.titleLarge.color
|
||||||
/// Choose gradient
|
//
|
||||||
/// label.gradient ??
|
// Choose gradient
|
||||||
/// buttonStyle.foregroundColor.colors ??
|
// label.gradient ??
|
||||||
/// null
|
// buttonStyle.foregroundColor.colors ??
|
||||||
///
|
// null
|
||||||
/// More infos in `negociate()` method
|
|
||||||
if (label != null) ...[
|
if (label != null) ...[
|
||||||
Gap(style.padding?.horizontal ?? 10),
|
const Gap(10),
|
||||||
Text(
|
Builder(
|
||||||
|
builder: (context) {
|
||||||
|
final color = label?.style?.color ??
|
||||||
|
style?.foregroundColors?.color ??
|
||||||
|
context.textTheme.titleLarge?.color;
|
||||||
|
final buttonStyleGradient =
|
||||||
|
(style?.foregroundColors?.isGradient ?? false)
|
||||||
|
? style?.foregroundColors?.colors
|
||||||
|
: null;
|
||||||
|
final gradient = label?.gradient ?? buttonStyleGradient;
|
||||||
|
|
||||||
|
return Text(
|
||||||
label!.text,
|
label!.text,
|
||||||
style: label!.style ?? style.label,
|
style: (label!.style ?? context.textTheme.titleMedium)
|
||||||
|
?.copyWith(color: color),
|
||||||
).toGradient(
|
).toGradient(
|
||||||
LinearGradientHelper.fromNullableColors(
|
LinearGradientHelper.fromNullableColors(
|
||||||
label?.gradient ??
|
gradient,
|
||||||
((style.foregroundColors?.isGradient ?? false)
|
|
||||||
? style.foregroundColors?.colors
|
|
||||||
: null),
|
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
extension GradientIconExtension on Icon {
|
extension GradientTextExtension on Icon {
|
||||||
GradientIcon toGradient(Gradient? gradient) =>
|
GradientIcon toGradient(Gradient? gradient) =>
|
||||||
GradientIcon.from(this, gradient);
|
GradientIcon.from(this, gradient);
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
extension BuildContextThemeExtension on BuildContext {
|
extension ThemeExtension on BuildContext {
|
||||||
T? themeExtension<T>() => Theme.of(this).extension<T>();
|
TextTheme get textTheme => Theme.of(this).textTheme;
|
||||||
|
ColorScheme get colorScheme => Theme.of(this).colorScheme;
|
||||||
|
ButtonThemeData get buttonTheme => Theme.of(this).buttonTheme;
|
||||||
}
|
}
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
// 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 <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
export 'file_selection_button_theme_extension.dart';
|
|
||||||
export 'flat_button_theme_extension.dart';
|
|
||||||
export 'simple_icon_button_theme_extension.dart';
|
|
||||||
export 'symbol_button_theme_extension.dart';
|
|
@ -1,52 +0,0 @@
|
|||||||
// 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 <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
|
|
||||||
|
|
||||||
abstract class FileSelectionButtonThemeExtension
|
|
||||||
extends ThemeExtension<FileSelectionButtonThemeExtension> {
|
|
||||||
const FileSelectionButtonThemeExtension({
|
|
||||||
this.disabledStyle,
|
|
||||||
this.focusedStyle,
|
|
||||||
this.hoveredStyle,
|
|
||||||
this.normalStyle,
|
|
||||||
this.tappedStyle,
|
|
||||||
this.selectedStyle,
|
|
||||||
this.invalidStyle,
|
|
||||||
});
|
|
||||||
|
|
||||||
/// Style of this button in disabled state
|
|
||||||
final FileSelectionButtonStyle? disabledStyle;
|
|
||||||
|
|
||||||
/// Style of this button in focused state
|
|
||||||
final FileSelectionButtonStyle? focusedStyle;
|
|
||||||
|
|
||||||
/// Style of this button in hovered state
|
|
||||||
final FileSelectionButtonStyle? hoveredStyle;
|
|
||||||
|
|
||||||
/// Style of this button in normal state
|
|
||||||
final FileSelectionButtonStyle? normalStyle;
|
|
||||||
|
|
||||||
/// Style of this button in tapped state
|
|
||||||
final FileSelectionButtonStyle? tappedStyle;
|
|
||||||
|
|
||||||
/// Style of this button in selected state
|
|
||||||
final FileSelectionButtonStyle? selectedStyle;
|
|
||||||
|
|
||||||
/// Style of this button in invalid state
|
|
||||||
final FileSelectionButtonStyle? invalidStyle;
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
// 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 <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
|
|
||||||
|
|
||||||
abstract class FlatButtonThemeExtension
|
|
||||||
extends ThemeExtension<FlatButtonThemeExtension> {
|
|
||||||
const FlatButtonThemeExtension({
|
|
||||||
this.disabledStyle,
|
|
||||||
this.focusedStyle,
|
|
||||||
this.hoveredStyle,
|
|
||||||
this.normalStyle,
|
|
||||||
this.tappedStyle,
|
|
||||||
});
|
|
||||||
|
|
||||||
/// Style of this button in disabled state
|
|
||||||
final FlatButtonStyle? disabledStyle;
|
|
||||||
|
|
||||||
/// Style of this button in focused state
|
|
||||||
final FlatButtonStyle? focusedStyle;
|
|
||||||
|
|
||||||
/// Style of this button in hovered state
|
|
||||||
final FlatButtonStyle? hoveredStyle;
|
|
||||||
|
|
||||||
/// Style of this button in normal state
|
|
||||||
final FlatButtonStyle? normalStyle;
|
|
||||||
|
|
||||||
/// Style of this button in tapped state
|
|
||||||
final FlatButtonStyle? tappedStyle;
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
// 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 <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
|
|
||||||
|
|
||||||
abstract class SimpleIconButtonThemeExtension
|
|
||||||
extends ThemeExtension<SimpleIconButtonThemeExtension> {
|
|
||||||
const SimpleIconButtonThemeExtension({
|
|
||||||
this.disabledStyle,
|
|
||||||
this.focusedStyle,
|
|
||||||
this.hoveredStyle,
|
|
||||||
this.normalStyle,
|
|
||||||
this.tappedStyle,
|
|
||||||
});
|
|
||||||
|
|
||||||
/// Style of this button in disabled state
|
|
||||||
final SimpleIconButtonStyle? disabledStyle;
|
|
||||||
|
|
||||||
/// Style of this button in focused state
|
|
||||||
final SimpleIconButtonStyle? focusedStyle;
|
|
||||||
|
|
||||||
/// Style of this button in hovered state
|
|
||||||
final SimpleIconButtonStyle? hoveredStyle;
|
|
||||||
|
|
||||||
/// Style of this button in normal state
|
|
||||||
final SimpleIconButtonStyle? normalStyle;
|
|
||||||
|
|
||||||
/// Style of this button in tapped state
|
|
||||||
final SimpleIconButtonStyle? tappedStyle;
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
// 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 <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
|
|
||||||
|
|
||||||
abstract class SymbolButtonThemeExtension
|
|
||||||
extends ThemeExtension<SymbolButtonThemeExtension> {
|
|
||||||
const SymbolButtonThemeExtension({
|
|
||||||
this.disabledStyle,
|
|
||||||
this.focusedStyle,
|
|
||||||
this.hoveredStyle,
|
|
||||||
this.normalStyle,
|
|
||||||
this.tappedStyle,
|
|
||||||
this.selectedStyle,
|
|
||||||
});
|
|
||||||
|
|
||||||
/// Style of this button in disabled state
|
|
||||||
final SymbolButtonStyle? disabledStyle;
|
|
||||||
|
|
||||||
/// Style of this button in focused state
|
|
||||||
final SymbolButtonStyle? focusedStyle;
|
|
||||||
|
|
||||||
/// Style of this button in hovered state
|
|
||||||
final SymbolButtonStyle? hoveredStyle;
|
|
||||||
|
|
||||||
/// Style of this button in normal state
|
|
||||||
final SymbolButtonStyle? normalStyle;
|
|
||||||
|
|
||||||
/// Style of this button in tapped state
|
|
||||||
final SymbolButtonStyle? tappedStyle;
|
|
||||||
|
|
||||||
/// Style of this button in selected state
|
|
||||||
final SymbolButtonStyle? selectedStyle;
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
// 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 <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
export 'button_theme_extension/button_theme_extension.dart';
|
|
||||||
export 'card_theme_extension.dart';
|
|
@ -14,6 +14,22 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// 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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
export './components/components.dart';
|
export './components/components.dart';
|
||||||
export './core/core.dart';
|
export './core/core.dart';
|
||||||
export './domain/domain.dart';
|
export './domain/card_theme_extension.dart';
|
||||||
|
@ -17,6 +17,4 @@
|
|||||||
/// UIKit and Design System used in Wyatt Studio.
|
/// UIKit and Design System used in Wyatt Studio.
|
||||||
library wyatt_ui_kit;
|
library wyatt_ui_kit;
|
||||||
|
|
||||||
export 'package:wyatt_ui_components/src/core/extensions/build_context_extensions.dart';
|
|
||||||
|
|
||||||
export './src/src.dart';
|
export './src/src.dart';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user