master #81

Closed
malo wants to merge 322 commits from master into feat/bloc_layout/new-package
8 changed files with 165 additions and 22 deletions
Showing only changes of commit aea71fa32c - Show all commits

View File

@ -28,19 +28,11 @@ enum ControlState {
tapped, tapped,
/// When the control is focused (like pressing tab) /// When the control is focused (like pressing tab)
focused, focused;
/// When the control is selected
selected,
/// When the control content is invalid
invalid;
bool isDisabled() => this == ControlState.disabled; bool isDisabled() => this == ControlState.disabled;
bool isEnabled() => this != ControlState.disabled; bool isEnabled() => this != ControlState.disabled;
bool isHovered() => this == ControlState.hovered; bool isHovered() => this == ControlState.hovered;
bool isTapped() => this == ControlState.tapped; bool isTapped() => this == ControlState.tapped;
bool isFocused() => this == ControlState.focused; bool isFocused() => this == ControlState.focused;
bool isSelected() => this == ControlState.selected;
bool isInvalid() => this == ControlState.invalid;
} }

View File

@ -14,25 +14,21 @@
// 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 'package:flutter/widgets.dart'; import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.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.mainAxisSize = MainAxisSize.min,
this.disabledStyle, this.disabledStyle,
this.normalStyle, this.normalStyle,
this.hoveredStyle, this.hoveredStyle,
this.focusedStyle, this.focusedStyle,
this.tappedStyle, this.tappedStyle,
this.selectedStyle,
this.invalidStyle,
this.onPressed, this.onPressed,
super.key, super.key,
}); });
/// Main axis size
final MainAxisSize? mainAxisSize;
/// Style of this button in disabled state /// Style of this button in disabled state
final ButtonStyle? disabledStyle; final ButtonStyle? disabledStyle;
@ -48,6 +44,12 @@ abstract class ButtonComponent extends Component {
/// Style of this button in tapped state /// Style of this button in tapped state
final ButtonStyle? tappedStyle; 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 /// Callback on button press
final VoidCallback? onPressed; final void Function(ControlState state)? onPressed;
} }

View File

@ -18,3 +18,5 @@ 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 './symbol_button_component.dart';
export './symbol_button_style.dart';

View File

@ -24,6 +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 = MainAxisSize.min,
this.prefix, this.prefix,
this.suffix, this.suffix,
this.label, this.label,
@ -33,7 +34,6 @@ abstract class FlatButtonComponent extends ButtonComponent
super.focusedStyle, super.focusedStyle,
super.tappedStyle, super.tappedStyle,
super.onPressed, super.onPressed,
super.mainAxisSize,
super.key, super.key,
}); });
@ -52,6 +52,7 @@ abstract class FlatButtonComponent extends ButtonComponent
@override @override
FlatButtonStyle? get tappedStyle; FlatButtonStyle? get tappedStyle;
final MainAxisSize? mainAxisSize;
final Widget? prefix; final Widget? prefix;
final Widget? suffix; final Widget? suffix;
final TextWrapper? label; final TextWrapper? label;

View File

@ -7,6 +7,7 @@ part of 'flat_button_component.dart';
// ************************************************************************** // **************************************************************************
abstract class $FlatButtonComponentCWProxy { abstract class $FlatButtonComponentCWProxy {
FlatButtonComponent mainAxisSize(MainAxisSize? mainAxisSize);
FlatButtonComponent prefix(Widget? prefix); FlatButtonComponent prefix(Widget? prefix);
FlatButtonComponent suffix(Widget? suffix); FlatButtonComponent suffix(Widget? suffix);
FlatButtonComponent label(TextWrapper? label); FlatButtonComponent label(TextWrapper? label);
@ -15,10 +16,10 @@ abstract class $FlatButtonComponentCWProxy {
FlatButtonComponent hoveredStyle(ButtonStyle? hoveredStyle); FlatButtonComponent hoveredStyle(ButtonStyle? hoveredStyle);
FlatButtonComponent focusedStyle(ButtonStyle? focusedStyle); FlatButtonComponent focusedStyle(ButtonStyle? focusedStyle);
FlatButtonComponent tappedStyle(ButtonStyle? tappedStyle); FlatButtonComponent tappedStyle(ButtonStyle? tappedStyle);
FlatButtonComponent onPressed(void Function()? onPressed); FlatButtonComponent onPressed(void Function(ControlState)? onPressed);
FlatButtonComponent mainAxisSize(MainAxisSize? mainAxisSize);
FlatButtonComponent key(Key? key); FlatButtonComponent key(Key? key);
FlatButtonComponent call({ FlatButtonComponent call({
MainAxisSize? mainAxisSize,
Widget? prefix, Widget? prefix,
Widget? suffix, Widget? suffix,
TextWrapper? label, TextWrapper? label,
@ -27,8 +28,7 @@ abstract class $FlatButtonComponentCWProxy {
ButtonStyle? hoveredStyle, ButtonStyle? hoveredStyle,
ButtonStyle? focusedStyle, ButtonStyle? focusedStyle,
ButtonStyle? tappedStyle, ButtonStyle? tappedStyle,
void Function()? onPressed, void Function(ControlState)? onPressed,
MainAxisSize? mainAxisSize,
Key? key, Key? key,
}); });
} }

View File

@ -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;
}

View File

@ -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,
});
}

View File

@ -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,
);
}