master #81

Closed
malo wants to merge 322 commits from master into feat/bloc_layout/new-package
5 changed files with 63 additions and 20 deletions
Showing only changes of commit 442baa6882 - Show all commits

View File

@ -18,4 +18,5 @@ export 'enums/control_state.dart';
export 'extensions/build_context_extensions.dart'; export 'extensions/build_context_extensions.dart';
export 'extensions/string_extension.dart'; export 'extensions/string_extension.dart';
export 'mixins/copy_with_mixin.dart'; export 'mixins/copy_with_mixin.dart';
export 'utils/multi_color.dart';
export 'utils/text_wrapper.dart'; export 'utils/text_wrapper.dart';

View File

@ -0,0 +1,45 @@
// 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 <https://www.gnu.org/licenses/>.
import 'package:flutter/widgets.dart';
class MultiColor {
const MultiColor(this._colors) : _color = null;
const MultiColor.single(this._color) : _colors = null;
final List<Color>? _colors;
final Color? _color;
Color get color {
if (_color != null) {
return _color!;
}
if (_colors?.isNotEmpty ?? false) {
return _colors!.first;
}
throw IndexError.withLength(
0,
_colors?.length ?? 0,
message: '_color is not defined or _colors is empty.',
);
}
List<Color> get colors => _colors ?? [];
bool get isGradient =>
(_colors?.isNotEmpty ?? false) && (_colors?.length ?? 0) > 1;
}

View File

@ -15,13 +15,13 @@
// 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/utils/multi_color.dart';
abstract class ButtonStyle { abstract class ButtonStyle {
const ButtonStyle({ const ButtonStyle({
this.radius = 15, this.radius = 15,
this.padding = 10, this.padding = 10,
this.borderColors, this.backgroundColors,
this.backgroundColor,
this.shadow = const BoxShadow( this.shadow = const BoxShadow(
blurRadius: 30, blurRadius: 30,
offset: Offset(0, 5), offset: Offset(0, 5),
@ -35,11 +35,8 @@ abstract class ButtonStyle {
/// Padding and gaps of this card /// Padding and gaps of this card
final double? padding; final double? padding;
/// Border gradient color (from left to right) /// Button background gradient colors (from left to right)
final List<Color>? borderColors; final MultiColor? backgroundColors;
/// Button background color
final Color? backgroundColor;
/// Drop shadow /// Drop shadow
final BoxShadow? shadow; final BoxShadow? shadow;

View File

@ -1,4 +1,3 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
// Copyright (C) 2023 WYATT GROUP // Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details. // Please see the AUTHORS file for details.
// //
@ -16,14 +15,14 @@
// 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/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';
class FlatButtonStyle extends ButtonStyle { class FlatButtonStyle extends ButtonStyle {
const FlatButtonStyle({ const FlatButtonStyle({
super.radius = 15, super.radius = 15,
super.padding = 10, super.padding = 10,
super.borderColors, super.backgroundColors,
super.backgroundColor,
super.shadow = const BoxShadow( super.shadow = const BoxShadow(
blurRadius: 30, blurRadius: 30,
offset: Offset(0, 5), offset: Offset(0, 5),
@ -35,16 +34,14 @@ class FlatButtonStyle extends ButtonStyle {
FlatButtonStyle copyWith({ FlatButtonStyle copyWith({
double? radius, double? radius,
double? padding, double? padding,
List<Color>? borderColors, MultiColor? backgroundColors,
Color? backgroundColor,
BoxShadow? shadow, BoxShadow? shadow,
double? stroke, double? stroke,
}) => }) =>
FlatButtonStyle( FlatButtonStyle(
radius: radius ?? this.radius, radius: radius ?? this.radius,
padding: padding ?? this.padding, padding: padding ?? this.padding,
borderColors: borderColors ?? this.borderColors, backgroundColors: backgroundColors ?? this.backgroundColors,
backgroundColor: backgroundColor ?? this.backgroundColor,
shadow: shadow ?? this.shadow, shadow: shadow ?? this.shadow,
); );
} }

View File

@ -1,4 +1,3 @@
// ignore_for_file: public_member_api_docs, sort_constructors_first
// Copyright (C) 2023 WYATT GROUP // Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details. // Please see the AUTHORS file for details.
// //
@ -16,22 +15,26 @@
// 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/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';
class OutlinedButtonStyle extends ButtonStyle { class OutlinedButtonStyle extends ButtonStyle {
const OutlinedButtonStyle({ const OutlinedButtonStyle({
super.radius = 15, super.radius = 15,
super.padding = 10, super.padding = 10,
super.borderColors, super.backgroundColors,
super.backgroundColor,
super.shadow = const BoxShadow( super.shadow = const BoxShadow(
blurRadius: 30, blurRadius: 30,
offset: Offset(0, 5), offset: Offset(0, 5),
color: Color.fromRGBO(0, 0, 0, 0.05), color: Color.fromRGBO(0, 0, 0, 0.05),
), ),
this.borderColors,
this.stroke = 2, this.stroke = 2,
}); });
/// Border colors (from left to right).
final MultiColor? borderColors;
/// Stroke of the border /// Stroke of the border
final double? stroke; final double? stroke;
@ -39,8 +42,8 @@ class OutlinedButtonStyle extends ButtonStyle {
OutlinedButtonStyle copyWith({ OutlinedButtonStyle copyWith({
double? radius, double? radius,
double? padding, double? padding,
List<Color>? borderColors, MultiColor? borderColors,
Color? backgroundColor, MultiColor? backgroundColors,
BoxShadow? shadow, BoxShadow? shadow,
double? stroke, double? stroke,
}) => }) =>
@ -48,7 +51,7 @@ class OutlinedButtonStyle extends ButtonStyle {
radius: radius ?? this.radius, radius: radius ?? this.radius,
padding: padding ?? this.padding, padding: padding ?? this.padding,
borderColors: borderColors ?? this.borderColors, borderColors: borderColors ?? this.borderColors,
backgroundColor: backgroundColor ?? this.backgroundColor, backgroundColors: backgroundColors ?? this.backgroundColors,
shadow: shadow ?? this.shadow, shadow: shadow ?? this.shadow,
stroke: stroke ?? this.stroke, stroke: stroke ?? this.stroke,
); );