feat(ui): make gradient as component
continuous-integration/drone/pr Build is failing

This commit is contained in:
2023-04-26 18:15:47 +02:00
parent 3fb4020594
commit 0d5109fc77
13 changed files with 569 additions and 65 deletions
@@ -49,14 +49,14 @@ class Home extends StatelessWidget {
appBar: PreferredSize(
preferredSize: const Size.fromHeight(60),
child: context.components.appBar?.copyWith
.title('Example title'.wrap()) ??
.title(const TextWrapper('Example title')) ??
const SizedBox.shrink(),
),
body: Column(
children: [
Expanded(
child: context.components.errorWidget
?.copyWith(error: 'Example erreur'.wrap()) ??
?.copyWith(error: const TextWrapper('Example erreur')) ??
const SizedBox.shrink(),
),
const SizedBox(
@@ -21,6 +21,7 @@ import 'package:wyatt_ui_components/src/core/utils/theme_resolver.dart';
/// Base class for all components.
/// {@endtemplate}
abstract class Component extends StatelessWidget {
/// {@macro component}
const Component({this.themeResolver, super.key});
/// Theme Resolver for this component
@@ -19,6 +19,7 @@ export './buttons/buttons.dart';
export './cards/cards.dart';
export './component.dart';
export './error_widget_component.dart';
export './gradients/gradients.dart';
export './loader/loader.dart';
export './loading_widget_component.dart';
export './rich_text_builder/rich_text_builder.dart';
@@ -0,0 +1,31 @@
// 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:wyatt_ui_components/src/core/utils/multi_color.dart';
import 'package:wyatt_ui_components/src/domain/entities/component.dart';
/// {@template gradient_component}
/// Base class for all gradient components.
///
/// For example, text, icons, and box borders.
/// {@endtemplate}
abstract class GradientComponent extends Component {
/// {@macro gradient_component}
const GradientComponent({super.key});
/// Returns colors for the gradient.
MultiColor get gradientColors;
}
@@ -0,0 +1,47 @@
// 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/wyatt_component_copy_with_extension.dart';
import 'package:wyatt_ui_components/wyatt_ui_components.dart';
part 'gradient_icon_component.g.dart';
@ComponentProxyExtension()
abstract class GradientIconComponent extends Icon
with CopyWithMixin<$GradientIconComponentCWProxy>
implements GradientComponent {
GradientIconComponent({
required IconData? icon,
required this.gradientColors,
super.key,
super.size,
super.fill,
super.weight,
super.grade,
super.opticalSize,
super.color,
super.shadows,
super.semanticLabel,
super.textDirection,
}) : super(icon);
@override
final MultiColor gradientColors;
@override
ThemeResolver<dynamic, dynamic, dynamic>? get themeResolver => null;
}
@@ -0,0 +1,36 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'gradient_icon_component.dart';
// **************************************************************************
// ComponentProxyGenerator
// **************************************************************************
abstract class $GradientIconComponentCWProxy {
GradientIconComponent icon(IconData? icon);
GradientIconComponent gradientColors(MultiColor? gradientColors);
GradientIconComponent key(Key? key);
GradientIconComponent size(double? size);
GradientIconComponent fill(double? fill);
GradientIconComponent weight(double? weight);
GradientIconComponent grade(double? grade);
GradientIconComponent opticalSize(double? opticalSize);
GradientIconComponent color(Color? color);
GradientIconComponent shadows(List<Shadow>? shadows);
GradientIconComponent semanticLabel(String? semanticLabel);
GradientIconComponent textDirection(TextDirection? textDirection);
GradientIconComponent call({
IconData? icon,
MultiColor? gradientColors,
Key? key,
double? size,
double? fill,
double? weight,
double? grade,
double? opticalSize,
Color? color,
List<Shadow>? shadows,
String? semanticLabel,
TextDirection? textDirection,
});
}
@@ -0,0 +1,54 @@
// 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/wyatt_component_copy_with_extension.dart';
import 'package:wyatt_ui_components/src/core/mixins/copy_with_mixin.dart';
import 'package:wyatt_ui_components/src/core/utils/multi_color.dart';
import 'package:wyatt_ui_components/src/core/utils/theme_resolver.dart';
import 'package:wyatt_ui_components/src/domain/entities/gradients/gradients.dart';
part 'gradient_text_component.g.dart';
@ComponentProxyExtension()
abstract class GradientTextComponent extends Text
with CopyWithMixin<$GradientTextComponentCWProxy>
implements GradientComponent {
const GradientTextComponent({
required String? data,
required this.gradientColors,
super.style,
super.key,
super.strutStyle,
super.textAlign,
super.textDirection,
super.locale,
super.softWrap,
super.overflow,
super.textScaleFactor,
super.maxLines,
super.semanticsLabel,
super.textWidthBasis,
super.textHeightBehavior,
super.selectionColor,
}) : super(data ?? '');
@override
final MultiColor gradientColors;
@override
ThemeResolver<dynamic, dynamic, dynamic>? get themeResolver => null;
}
@@ -0,0 +1,45 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'gradient_text_component.dart';
// **************************************************************************
// ComponentProxyGenerator
// **************************************************************************
abstract class $GradientTextComponentCWProxy {
GradientTextComponent data(String? data);
GradientTextComponent gradientColors(MultiColor? gradientColors);
GradientTextComponent style(TextStyle? style);
GradientTextComponent key(Key? key);
GradientTextComponent strutStyle(StrutStyle? strutStyle);
GradientTextComponent textAlign(TextAlign? textAlign);
GradientTextComponent textDirection(TextDirection? textDirection);
GradientTextComponent locale(Locale? locale);
GradientTextComponent softWrap(bool? softWrap);
GradientTextComponent overflow(TextOverflow? overflow);
GradientTextComponent textScaleFactor(double? textScaleFactor);
GradientTextComponent maxLines(int? maxLines);
GradientTextComponent semanticsLabel(String? semanticsLabel);
GradientTextComponent textWidthBasis(TextWidthBasis? textWidthBasis);
GradientTextComponent textHeightBehavior(
TextHeightBehavior? textHeightBehavior);
GradientTextComponent selectionColor(Color? selectionColor);
GradientTextComponent call({
String? data,
MultiColor? gradientColors,
TextStyle? style,
Key? key,
StrutStyle? strutStyle,
TextAlign? textAlign,
TextDirection? textDirection,
Locale? locale,
bool? softWrap,
TextOverflow? overflow,
double? textScaleFactor,
int? maxLines,
String? semanticsLabel,
TextWidthBasis? textWidthBasis,
TextHeightBehavior? textHeightBehavior,
Color? selectionColor,
});
}
@@ -0,0 +1,19 @@
// 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/>.
export 'gradient_component.dart';
export 'gradient_icon_component.dart';
export 'gradient_text_component.dart';