diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/button_component.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/button_component.dart index 1a1c30ed..f87c19e7 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/button_component.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/button_component.dart @@ -16,38 +16,23 @@ 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/component.dart'; abstract class ButtonComponent extends Component { const ButtonComponent({ this.state = ControlState.normal, - this.radius = 12, - this.padding = 25, - this.borderColors, - this.backgroundColor, - this.shadow = const BoxShadow( - blurRadius: 30, - offset: Offset(0, 5), - color: Color.fromRGBO(0, 0, 0, 0.05), - ), + this.mainAxisSize = MainAxisSize.min, + this.style, super.key, }); /// Actual state of the button final ControlState? state; - /// Button radius - final double? radius; + /// Main axis size + final MainAxisSize? mainAxisSize; - /// Padding and gaps of this card - final double? padding; - - /// Border gradient color (from left to right) - final List? borderColors; - - /// Button background color - final Color? backgroundColor; - - /// Drop shadow - final BoxShadow? shadow; + /// Style of this button + final ButtonStyle? style; } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/button_style.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/button_style.dart new file mode 100644 index 00000000..47483bb7 --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/button_style.dart @@ -0,0 +1,48 @@ +// 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 . + +import 'package:flutter/widgets.dart'; + +abstract class ButtonStyle { + const ButtonStyle({ + this.radius = 15, + this.padding = 10, + this.borderColors, + this.backgroundColor, + this.shadow = const BoxShadow( + blurRadius: 30, + offset: Offset(0, 5), + color: Color.fromRGBO(0, 0, 0, 0.05), + ), + }); + + /// Button radius + final double? radius; + + /// Padding and gaps of this card + final double? padding; + + /// Border gradient color (from left to right) + final List? borderColors; + + /// Button background color + final Color? backgroundColor; + + /// Drop shadow + final BoxShadow? shadow; + + ButtonStyle copyWith(); +} diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/buttons.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/buttons.dart index 8e646b7f..c3c58180 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/buttons.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/buttons.dart @@ -14,4 +14,9 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +export './button_component.dart'; +export './button_style.dart'; export './flat_button_component.dart'; +export './flat_button_style.dart'; +export './outlined_button_component.dart'; +export './outlined_button_style.dart'; diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_component.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_component.dart index a5b1c00e..33cdbb7f 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_component.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_component.dart @@ -16,7 +16,6 @@ import 'package:flutter/widgets.dart'; import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart'; -import 'package:wyatt_ui_components/src/domain/entities/buttons/button_component.dart'; import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart'; part 'flat_button_component.g.dart'; @@ -29,14 +28,14 @@ abstract class FlatButtonComponent extends ButtonComponent this.suffix, this.label, super.state, - super.radius, - super.padding, - super.borderColors, - super.backgroundColor, - super.shadow, + super.style, + super.mainAxisSize, super.key, }); + @override + FlatButtonStyle? get style; + final Widget? prefix; final Widget? suffix; final TextWrapper? label; diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_component.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_component.g.dart index 359ec686..2d54e3ca 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_component.g.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_component.g.dart @@ -7,8 +7,20 @@ part of 'flat_button_component.dart'; // ************************************************************************** abstract class $FlatButtonComponentCWProxy { + FlatButtonComponent prefix(Widget? prefix); + FlatButtonComponent suffix(Widget? suffix); + FlatButtonComponent label(TextWrapper? label); + FlatButtonComponent state(ControlState? state); + FlatButtonComponent style(ButtonStyle? style); + FlatButtonComponent mainAxisSize(MainAxisSize? mainAxisSize); FlatButtonComponent key(Key? key); FlatButtonComponent call({ + Widget? prefix, + Widget? suffix, + TextWrapper? label, + ControlState? state, + ButtonStyle? style, + MainAxisSize? mainAxisSize, Key? key, }); } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_style.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_style.dart new file mode 100644 index 00000000..e35b35b7 --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/flat_button_style.dart @@ -0,0 +1,50 @@ +// ignore_for_file: public_member_api_docs, sort_constructors_first +// 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 . + +import 'package:flutter/widgets.dart'; +import 'package:wyatt_ui_components/src/domain/entities/buttons/button_style.dart'; + +class FlatButtonStyle extends ButtonStyle { + const FlatButtonStyle({ + super.radius = 15, + super.padding = 10, + super.borderColors, + super.backgroundColor, + super.shadow = const BoxShadow( + blurRadius: 30, + offset: Offset(0, 5), + color: Color.fromRGBO(0, 0, 0, 0.05), + ), + }); + + @override + FlatButtonStyle copyWith({ + double? radius, + double? padding, + List? borderColors, + Color? backgroundColor, + BoxShadow? shadow, + double? stroke, + }) => + FlatButtonStyle( + radius: radius ?? this.radius, + padding: padding ?? this.padding, + borderColors: borderColors ?? this.borderColors, + backgroundColor: backgroundColor ?? this.backgroundColor, + shadow: shadow ?? this.shadow, + ); +} diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/outlined_button_component.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/outlined_button_component.dart new file mode 100644 index 00000000..36ebac09 --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/outlined_button_component.dart @@ -0,0 +1,42 @@ +// 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 . + +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; +} diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/outlined_button_component.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/outlined_button_component.g.dart new file mode 100644 index 00000000..f2471b16 --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/outlined_button_component.g.dart @@ -0,0 +1,26 @@ +// 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, + }); +} diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/buttons/outlined_button_style.dart b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/outlined_button_style.dart new file mode 100644 index 00000000..f6babbed --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/buttons/outlined_button_style.dart @@ -0,0 +1,55 @@ +// ignore_for_file: public_member_api_docs, sort_constructors_first +// 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 . + +import 'package:flutter/widgets.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.borderColors, + super.backgroundColor, + super.shadow = const BoxShadow( + blurRadius: 30, + offset: Offset(0, 5), + color: Color.fromRGBO(0, 0, 0, 0.05), + ), + this.stroke = 2, + }); + + /// Stroke of the border + final double? stroke; + + @override + OutlinedButtonStyle copyWith({ + double? radius, + double? padding, + List? borderColors, + Color? backgroundColor, + BoxShadow? shadow, + double? stroke, + }) => + OutlinedButtonStyle( + radius: radius ?? this.radius, + padding: padding ?? this.padding, + borderColors: borderColors ?? this.borderColors, + backgroundColor: backgroundColor ?? this.backgroundColor, + shadow: shadow ?? this.shadow, + stroke: stroke ?? this.stroke, + ); +}