ui_kit/feat/button-components #134
@ -28,19 +28,11 @@ enum ControlState {
|
||||
tapped,
|
||||
|
||||
/// When the control is focused (like pressing tab)
|
||||
focused,
|
||||
|
||||
/// When the control is selected
|
||||
selected,
|
||||
|
||||
/// When the control content is invalid
|
||||
invalid;
|
||||
focused;
|
||||
|
||||
bool isDisabled() => this == ControlState.disabled;
|
||||
bool isEnabled() => this != ControlState.disabled;
|
||||
bool isHovered() => this == ControlState.hovered;
|
||||
bool isTapped() => this == ControlState.tapped;
|
||||
bool isFocused() => this == ControlState.focused;
|
||||
bool isSelected() => this == ControlState.selected;
|
||||
bool isInvalid() => this == ControlState.invalid;
|
||||
}
|
||||
|
@ -14,25 +14,21 @@
|
||||
// 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/domain/entities/buttons/button_style.dart';
|
||||
import 'package:wyatt_ui_components/src/domain/entities/component.dart';
|
||||
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
|
||||
|
||||
abstract class ButtonComponent extends Component {
|
||||
const ButtonComponent({
|
||||
this.mainAxisSize = MainAxisSize.min,
|
||||
this.disabledStyle,
|
||||
this.normalStyle,
|
||||
this.hoveredStyle,
|
||||
this.focusedStyle,
|
||||
this.tappedStyle,
|
||||
this.selectedStyle,
|
||||
this.invalidStyle,
|
||||
this.onPressed,
|
||||
super.key,
|
||||
});
|
||||
|
||||
/// Main axis size
|
||||
final MainAxisSize? mainAxisSize;
|
||||
|
||||
/// Style of this button in disabled state
|
||||
final ButtonStyle? disabledStyle;
|
||||
|
||||
@ -48,6 +44,12 @@ abstract class ButtonComponent extends Component {
|
||||
/// Style of this button in tapped state
|
||||
final ButtonStyle? tappedStyle;
|
||||
|
||||
/// Style of this button in selected state
|
||||
final ButtonStyle? selectedStyle;
|
||||
|
||||
/// Style of this button in invalid state
|
||||
final ButtonStyle? invalidStyle;
|
||||
|
||||
/// Callback on button press
|
||||
final VoidCallback? onPressed;
|
||||
final void Function(ControlState state)? onPressed;
|
||||
}
|
||||
|
@ -18,3 +18,5 @@ export './button_component.dart';
|
||||
export './button_style.dart';
|
||||
export './flat_button_component.dart';
|
||||
export './flat_button_style.dart';
|
||||
export './symbol_button_component.dart';
|
||||
export './symbol_button_style.dart';
|
||||
|
@ -24,6 +24,7 @@ part 'flat_button_component.g.dart';
|
||||
abstract class FlatButtonComponent extends ButtonComponent
|
||||
with CopyWithMixin<$FlatButtonComponentCWProxy> {
|
||||
const FlatButtonComponent({
|
||||
this.mainAxisSize = MainAxisSize.min,
|
||||
this.prefix,
|
||||
this.suffix,
|
||||
this.label,
|
||||
@ -33,7 +34,6 @@ abstract class FlatButtonComponent extends ButtonComponent
|
||||
super.focusedStyle,
|
||||
super.tappedStyle,
|
||||
super.onPressed,
|
||||
super.mainAxisSize,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@ -52,6 +52,7 @@ abstract class FlatButtonComponent extends ButtonComponent
|
||||
@override
|
||||
FlatButtonStyle? get tappedStyle;
|
||||
|
||||
final MainAxisSize? mainAxisSize;
|
||||
final Widget? prefix;
|
||||
final Widget? suffix;
|
||||
final TextWrapper? label;
|
||||
|
@ -7,6 +7,7 @@ part of 'flat_button_component.dart';
|
||||
// **************************************************************************
|
||||
|
||||
abstract class $FlatButtonComponentCWProxy {
|
||||
FlatButtonComponent mainAxisSize(MainAxisSize? mainAxisSize);
|
||||
FlatButtonComponent prefix(Widget? prefix);
|
||||
FlatButtonComponent suffix(Widget? suffix);
|
||||
FlatButtonComponent label(TextWrapper? label);
|
||||
@ -15,10 +16,10 @@ abstract class $FlatButtonComponentCWProxy {
|
||||
FlatButtonComponent hoveredStyle(ButtonStyle? hoveredStyle);
|
||||
FlatButtonComponent focusedStyle(ButtonStyle? focusedStyle);
|
||||
FlatButtonComponent tappedStyle(ButtonStyle? tappedStyle);
|
||||
FlatButtonComponent onPressed(void Function()? onPressed);
|
||||
FlatButtonComponent mainAxisSize(MainAxisSize? mainAxisSize);
|
||||
FlatButtonComponent onPressed(void Function(ControlState)? onPressed);
|
||||
FlatButtonComponent key(Key? key);
|
||||
FlatButtonComponent call({
|
||||
MainAxisSize? mainAxisSize,
|
||||
Widget? prefix,
|
||||
Widget? suffix,
|
||||
TextWrapper? label,
|
||||
@ -27,8 +28,7 @@ abstract class $FlatButtonComponentCWProxy {
|
||||
ButtonStyle? hoveredStyle,
|
||||
ButtonStyle? focusedStyle,
|
||||
ButtonStyle? tappedStyle,
|
||||
void Function()? onPressed,
|
||||
MainAxisSize? mainAxisSize,
|
||||
void Function(ControlState)? onPressed,
|
||||
Key? key,
|
||||
});
|
||||
}
|
||||
|
@ -0,0 +1,61 @@
|
||||
// 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 'symbol_button_component.g.dart';
|
||||
|
||||
@ComponentProxyExtension()
|
||||
abstract class SymbolButtonComponent extends ButtonComponent
|
||||
with CopyWithMixin<$SymbolButtonComponentCWProxy> {
|
||||
const SymbolButtonComponent({
|
||||
this.mainAxisSize = MainAxisSize.min,
|
||||
this.label,
|
||||
this.icon,
|
||||
super.disabledStyle,
|
||||
super.normalStyle,
|
||||
super.hoveredStyle,
|
||||
super.focusedStyle,
|
||||
super.tappedStyle,
|
||||
super.selectedStyle,
|
||||
super.onPressed,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
SymbolButtonStyle? get disabledStyle;
|
||||
|
||||
@override
|
||||
SymbolButtonStyle? get normalStyle;
|
||||
|
||||
@override
|
||||
SymbolButtonStyle? get hoveredStyle;
|
||||
|
||||
@override
|
||||
SymbolButtonStyle? get focusedStyle;
|
||||
|
||||
@override
|
||||
SymbolButtonStyle? get tappedStyle;
|
||||
|
||||
@override
|
||||
SymbolButtonStyle? get selectedStyle;
|
||||
|
||||
final MainAxisSize? mainAxisSize;
|
||||
final Widget? icon;
|
||||
final TextWrapper? label;
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'symbol_button_component.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// ComponentProxyGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class $SymbolButtonComponentCWProxy {
|
||||
SymbolButtonComponent icon(Widget? icon);
|
||||
SymbolButtonComponent disabledStyle(ButtonStyle? disabledStyle);
|
||||
SymbolButtonComponent normalStyle(ButtonStyle? normalStyle);
|
||||
SymbolButtonComponent hoveredStyle(ButtonStyle? hoveredStyle);
|
||||
SymbolButtonComponent focusedStyle(ButtonStyle? focusedStyle);
|
||||
SymbolButtonComponent tappedStyle(ButtonStyle? tappedStyle);
|
||||
SymbolButtonComponent selectedStyle(ButtonStyle? selectedStyle);
|
||||
SymbolButtonComponent onPressed(void Function(ControlState)? onPressed);
|
||||
SymbolButtonComponent key(Key? key);
|
||||
SymbolButtonComponent call({
|
||||
Widget? icon,
|
||||
ButtonStyle? disabledStyle,
|
||||
ButtonStyle? normalStyle,
|
||||
ButtonStyle? hoveredStyle,
|
||||
ButtonStyle? focusedStyle,
|
||||
ButtonStyle? tappedStyle,
|
||||
ButtonStyle? selectedStyle,
|
||||
void Function(ControlState)? onPressed,
|
||||
Key? key,
|
||||
});
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
// 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 SymbolButtonStyle extends ButtonStyle {
|
||||
const SymbolButtonStyle({
|
||||
super.radius = 15,
|
||||
super.padding = 10,
|
||||
super.foregroundColors,
|
||||
super.backgroundColors,
|
||||
super.borderColors,
|
||||
super.stroke = 2,
|
||||
super.shadow = const BoxShadow(
|
||||
blurRadius: 30,
|
||||
offset: Offset(0, 5),
|
||||
color: Color.fromRGBO(0, 0, 0, 0.05),
|
||||
),
|
||||
});
|
||||
|
||||
@override
|
||||
SymbolButtonStyle copyWith({
|
||||
double? radius,
|
||||
double? padding,
|
||||
MultiColor? foregroundColors,
|
||||
MultiColor? backgroundColors,
|
||||
MultiColor? borderColors,
|
||||
double? stroke,
|
||||
BoxShadow? shadow,
|
||||
}) =>
|
||||
SymbolButtonStyle(
|
||||
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,
|
||||
);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user