ui_kit/feat/button-components #134
@ -15,24 +15,39 @@
|
|||||||
// 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 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:wyatt_ui_components/src/core/enums/control_state.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';
|
||||||
import 'package:wyatt_ui_components/src/domain/entities/component.dart';
|
import 'package:wyatt_ui_components/src/domain/entities/component.dart';
|
||||||
|
|
||||||
abstract class ButtonComponent extends Component {
|
abstract class ButtonComponent extends Component {
|
||||||
const ButtonComponent({
|
const ButtonComponent({
|
||||||
this.state = ControlState.normal,
|
|
||||||
this.mainAxisSize = MainAxisSize.min,
|
this.mainAxisSize = MainAxisSize.min,
|
||||||
this.style,
|
this.disabledStyle,
|
||||||
|
this.normalStyle,
|
||||||
|
this.hoveredStyle,
|
||||||
|
this.focusedStyle,
|
||||||
|
this.tappedStyle,
|
||||||
|
this.onPressed,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
/// Actual state of the button
|
|
||||||
final ControlState? state;
|
|
||||||
|
|
||||||
/// Main axis size
|
/// Main axis size
|
||||||
final MainAxisSize? mainAxisSize;
|
final MainAxisSize? mainAxisSize;
|
||||||
|
|
||||||
/// Style of this button
|
/// Style of this button in disabled state
|
||||||
final ButtonStyle? style;
|
final ButtonStyle? disabledStyle;
|
||||||
|
|
||||||
|
/// Style of this button in normal state
|
||||||
|
final ButtonStyle? normalStyle;
|
||||||
|
|
||||||
|
/// Style of this button in hovered state
|
||||||
|
final ButtonStyle? hoveredStyle;
|
||||||
|
|
||||||
|
/// Style of this button in focused state
|
||||||
|
final ButtonStyle? focusedStyle;
|
||||||
|
|
||||||
|
/// Style of this button in tapped state
|
||||||
|
final ButtonStyle? tappedStyle;
|
||||||
|
|
||||||
|
/// Callback on button press
|
||||||
|
final VoidCallback? onPressed;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,10 @@ abstract class ButtonStyle {
|
|||||||
const ButtonStyle({
|
const ButtonStyle({
|
||||||
this.radius = 15,
|
this.radius = 15,
|
||||||
this.padding = 10,
|
this.padding = 10,
|
||||||
|
this.foregroundColors,
|
||||||
this.backgroundColors,
|
this.backgroundColors,
|
||||||
|
this.borderColors,
|
||||||
|
this.stroke = 2,
|
||||||
this.shadow = const BoxShadow(
|
this.shadow = const BoxShadow(
|
||||||
blurRadius: 30,
|
blurRadius: 30,
|
||||||
offset: Offset(0, 5),
|
offset: Offset(0, 5),
|
||||||
@ -35,9 +38,18 @@ abstract class ButtonStyle {
|
|||||||
/// Padding and gaps of this card
|
/// Padding and gaps of this card
|
||||||
final double? padding;
|
final double? padding;
|
||||||
|
|
||||||
|
/// Button foreground gradient colors (from left to right)
|
||||||
|
final MultiColor? foregroundColors;
|
||||||
|
|
||||||
/// Button background gradient colors (from left to right)
|
/// Button background gradient colors (from left to right)
|
||||||
final MultiColor? backgroundColors;
|
final MultiColor? backgroundColors;
|
||||||
|
|
||||||
|
/// Border colors (from left to right).
|
||||||
|
final MultiColor? borderColors;
|
||||||
|
|
||||||
|
/// Stroke of the border
|
||||||
|
final double? stroke;
|
||||||
|
|
||||||
/// Drop shadow
|
/// Drop shadow
|
||||||
final BoxShadow? shadow;
|
final BoxShadow? shadow;
|
||||||
|
|
||||||
|
@ -18,5 +18,3 @@ export './button_component.dart';
|
|||||||
export './button_style.dart';
|
export './button_style.dart';
|
||||||
export './flat_button_component.dart';
|
export './flat_button_component.dart';
|
||||||
export './flat_button_style.dart';
|
export './flat_button_style.dart';
|
||||||
export './outlined_button_component.dart';
|
|
||||||
export './outlined_button_style.dart';
|
|
||||||
|
@ -27,14 +27,30 @@ abstract class FlatButtonComponent extends ButtonComponent
|
|||||||
this.prefix,
|
this.prefix,
|
||||||
this.suffix,
|
this.suffix,
|
||||||
this.label,
|
this.label,
|
||||||
super.state,
|
super.disabledStyle,
|
||||||
super.style,
|
super.normalStyle,
|
||||||
|
super.hoveredStyle,
|
||||||
|
super.focusedStyle,
|
||||||
|
super.tappedStyle,
|
||||||
|
super.onPressed,
|
||||||
super.mainAxisSize,
|
super.mainAxisSize,
|
||||||
super.key,
|
super.key,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
FlatButtonStyle? get style;
|
FlatButtonStyle? get disabledStyle;
|
||||||
|
|
||||||
|
@override
|
||||||
|
FlatButtonStyle? get normalStyle;
|
||||||
|
|
||||||
|
@override
|
||||||
|
FlatButtonStyle? get hoveredStyle;
|
||||||
|
|
||||||
|
@override
|
||||||
|
FlatButtonStyle? get focusedStyle;
|
||||||
|
|
||||||
|
@override
|
||||||
|
FlatButtonStyle? get tappedStyle;
|
||||||
|
|
||||||
final Widget? prefix;
|
final Widget? prefix;
|
||||||
final Widget? suffix;
|
final Widget? suffix;
|
||||||
|
@ -10,16 +10,24 @@ 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 state(ControlState? state);
|
FlatButtonComponent disabledStyle(ButtonStyle? disabledStyle);
|
||||||
FlatButtonComponent style(ButtonStyle? style);
|
FlatButtonComponent normalStyle(ButtonStyle? normalStyle);
|
||||||
|
FlatButtonComponent hoveredStyle(ButtonStyle? hoveredStyle);
|
||||||
|
FlatButtonComponent focusedStyle(ButtonStyle? focusedStyle);
|
||||||
|
FlatButtonComponent tappedStyle(ButtonStyle? tappedStyle);
|
||||||
|
FlatButtonComponent onPressed(void Function()? onPressed);
|
||||||
FlatButtonComponent mainAxisSize(MainAxisSize? mainAxisSize);
|
FlatButtonComponent mainAxisSize(MainAxisSize? mainAxisSize);
|
||||||
FlatButtonComponent key(Key? key);
|
FlatButtonComponent key(Key? key);
|
||||||
FlatButtonComponent call({
|
FlatButtonComponent call({
|
||||||
Widget? prefix,
|
Widget? prefix,
|
||||||
Widget? suffix,
|
Widget? suffix,
|
||||||
TextWrapper? label,
|
TextWrapper? label,
|
||||||
ControlState? state,
|
ButtonStyle? disabledStyle,
|
||||||
ButtonStyle? style,
|
ButtonStyle? normalStyle,
|
||||||
|
ButtonStyle? hoveredStyle,
|
||||||
|
ButtonStyle? focusedStyle,
|
||||||
|
ButtonStyle? tappedStyle,
|
||||||
|
void Function()? onPressed,
|
||||||
MainAxisSize? mainAxisSize,
|
MainAxisSize? mainAxisSize,
|
||||||
Key? key,
|
Key? key,
|
||||||
});
|
});
|
||||||
|
@ -22,7 +22,10 @@ class FlatButtonStyle extends ButtonStyle {
|
|||||||
const FlatButtonStyle({
|
const FlatButtonStyle({
|
||||||
super.radius = 15,
|
super.radius = 15,
|
||||||
super.padding = 10,
|
super.padding = 10,
|
||||||
|
super.foregroundColors,
|
||||||
super.backgroundColors,
|
super.backgroundColors,
|
||||||
|
super.borderColors,
|
||||||
|
super.stroke = 2,
|
||||||
super.shadow = const BoxShadow(
|
super.shadow = const BoxShadow(
|
||||||
blurRadius: 30,
|
blurRadius: 30,
|
||||||
offset: Offset(0, 5),
|
offset: Offset(0, 5),
|
||||||
@ -34,14 +37,19 @@ class FlatButtonStyle extends ButtonStyle {
|
|||||||
FlatButtonStyle copyWith({
|
FlatButtonStyle copyWith({
|
||||||
double? radius,
|
double? radius,
|
||||||
double? padding,
|
double? padding,
|
||||||
|
MultiColor? foregroundColors,
|
||||||
MultiColor? backgroundColors,
|
MultiColor? backgroundColors,
|
||||||
BoxShadow? shadow,
|
MultiColor? borderColors,
|
||||||
double? stroke,
|
double? stroke,
|
||||||
|
BoxShadow? shadow,
|
||||||
}) =>
|
}) =>
|
||||||
FlatButtonStyle(
|
FlatButtonStyle(
|
||||||
radius: radius ?? this.radius,
|
radius: radius ?? this.radius,
|
||||||
padding: padding ?? this.padding,
|
padding: padding ?? this.padding,
|
||||||
|
foregroundColors: foregroundColors ?? this.foregroundColors,
|
||||||
backgroundColors: backgroundColors ?? this.backgroundColors,
|
backgroundColors: backgroundColors ?? this.backgroundColors,
|
||||||
|
borderColors: borderColors ?? this.borderColors,
|
||||||
|
stroke: stroke ?? this.stroke,
|
||||||
shadow: shadow ?? this.shadow,
|
shadow: shadow ?? this.shadow,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,42 +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/widgets.dart';
|
|
||||||
import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart';
|
|
||||||
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
|
|
||||||
|
|
||||||
part 'outlined_button_component.g.dart';
|
|
||||||
|
|
||||||
@ComponentProxyExtension()
|
|
||||||
abstract class OutlinedButtonComponent extends ButtonComponent
|
|
||||||
with CopyWithMixin<$OutlinedButtonComponentCWProxy> {
|
|
||||||
const OutlinedButtonComponent({
|
|
||||||
this.prefix,
|
|
||||||
this.suffix,
|
|
||||||
this.label,
|
|
||||||
super.state,
|
|
||||||
super.style,
|
|
||||||
super.mainAxisSize,
|
|
||||||
super.key,
|
|
||||||
});
|
|
||||||
|
|
||||||
@override
|
|
||||||
OutlinedButtonStyle? get style;
|
|
||||||
|
|
||||||
final Widget? prefix;
|
|
||||||
final Widget? suffix;
|
|
||||||
final TextWrapper? label;
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
||||||
|
|
||||||
part of 'outlined_button_component.dart';
|
|
||||||
|
|
||||||
// **************************************************************************
|
|
||||||
// ComponentProxyGenerator
|
|
||||||
// **************************************************************************
|
|
||||||
|
|
||||||
abstract class $OutlinedButtonComponentCWProxy {
|
|
||||||
OutlinedButtonComponent prefix(Widget? prefix);
|
|
||||||
OutlinedButtonComponent suffix(Widget? suffix);
|
|
||||||
OutlinedButtonComponent label(TextWrapper? label);
|
|
||||||
OutlinedButtonComponent state(ControlState? state);
|
|
||||||
OutlinedButtonComponent style(ButtonStyle? style);
|
|
||||||
OutlinedButtonComponent mainAxisSize(MainAxisSize? mainAxisSize);
|
|
||||||
OutlinedButtonComponent key(Key? key);
|
|
||||||
OutlinedButtonComponent call({
|
|
||||||
Widget? prefix,
|
|
||||||
Widget? suffix,
|
|
||||||
TextWrapper? label,
|
|
||||||
ControlState? state,
|
|
||||||
ButtonStyle? style,
|
|
||||||
MainAxisSize? mainAxisSize,
|
|
||||||
Key? key,
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,58 +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/widgets.dart';
|
|
||||||
import 'package:wyatt_ui_components/src/core/utils/multi_color.dart';
|
|
||||||
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart';
|
|
||||||
|
|
||||||
class OutlinedButtonStyle extends ButtonStyle {
|
|
||||||
const OutlinedButtonStyle({
|
|
||||||
super.radius = 15,
|
|
||||||
super.padding = 10,
|
|
||||||
super.backgroundColors,
|
|
||||||
super.shadow = const BoxShadow(
|
|
||||||
blurRadius: 30,
|
|
||||||
offset: Offset(0, 5),
|
|
||||||
color: Color.fromRGBO(0, 0, 0, 0.05),
|
|
||||||
),
|
|
||||||
this.borderColors,
|
|
||||||
this.stroke = 2,
|
|
||||||
});
|
|
||||||
|
|
||||||
/// Border colors (from left to right).
|
|
||||||
final MultiColor? borderColors;
|
|
||||||
|
|
||||||
/// Stroke of the border
|
|
||||||
final double? stroke;
|
|
||||||
|
|
||||||
@override
|
|
||||||
OutlinedButtonStyle copyWith({
|
|
||||||
double? radius,
|
|
||||||
double? padding,
|
|
||||||
MultiColor? borderColors,
|
|
||||||
MultiColor? backgroundColors,
|
|
||||||
BoxShadow? shadow,
|
|
||||||
double? stroke,
|
|
||||||
}) =>
|
|
||||||
OutlinedButtonStyle(
|
|
||||||
radius: radius ?? this.radius,
|
|
||||||
padding: padding ?? this.padding,
|
|
||||||
borderColors: borderColors ?? this.borderColors,
|
|
||||||
backgroundColors: backgroundColors ?? this.backgroundColors,
|
|
||||||
shadow: shadow ?? this.shadow,
|
|
||||||
stroke: stroke ?? this.stroke,
|
|
||||||
);
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user