From 617cdf3de0508b1c35cbe4955c9eeff12bfacadc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Tue, 7 Feb 2023 18:30:46 +0100 Subject: [PATCH] feat(ui_components): add information_card & quote_card (#126) --- .../wyatt_ui_components/analysis_options.yaml | 2 +- .../wyatt_ui_components/example/lib/main.dart | 4 +- .../example/test/widget_test.dart | 15 ----- .../domain/entities/app_bar_component.dart | 8 +-- .../bottom_navigation_bar_component.dart | 6 +- .../domain/entities/cards/card_component.dart | 60 +++++++++++++++++++ .../cards/information_card_component.dart | 54 +++++++++++++++++ .../cards/information_card_component.g.dart | 42 +++++++++++++ .../entities/cards/quote_card_component.dart | 43 +++++++++++++ .../cards/quote_card_component.g.dart | 46 ++++++++++++++ .../lib/src/domain/entities/entities.dart | 2 +- .../entities/error_widget_component.dart | 6 +- .../entities/loading_widget_component.dart | 4 +- .../lib/src/features/component_theme.dart | 6 +- .../src/features/component_theme_data.dart | 8 +-- .../lib/src/features/features.dart | 2 +- packages/wyatt_ui_components/pubspec.yaml | 10 ++-- 17 files changed, 274 insertions(+), 44 deletions(-) delete mode 100644 packages/wyatt_ui_components/example/test/widget_test.dart create mode 100644 packages/wyatt_ui_components/lib/src/domain/entities/cards/card_component.dart create mode 100644 packages/wyatt_ui_components/lib/src/domain/entities/cards/information_card_component.dart create mode 100644 packages/wyatt_ui_components/lib/src/domain/entities/cards/information_card_component.g.dart create mode 100644 packages/wyatt_ui_components/lib/src/domain/entities/cards/quote_card_component.dart create mode 100644 packages/wyatt_ui_components/lib/src/domain/entities/cards/quote_card_component.g.dart diff --git a/packages/wyatt_ui_components/analysis_options.yaml b/packages/wyatt_ui_components/analysis_options.yaml index 225c0796..90d6bd51 100644 --- a/packages/wyatt_ui_components/analysis_options.yaml +++ b/packages/wyatt_ui_components/analysis_options.yaml @@ -14,4 +14,4 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -include: package:wyatt_analysis/analysis_options.flutter.experimental.yaml +include: package:wyatt_analysis/analysis_options.flutter.yaml diff --git a/packages/wyatt_ui_components/example/lib/main.dart b/packages/wyatt_ui_components/example/lib/main.dart index 7cb59bf7..2ee31aeb 100644 --- a/packages/wyatt_ui_components/example/lib/main.dart +++ b/packages/wyatt_ui_components/example/lib/main.dart @@ -27,8 +27,7 @@ class MyApp extends StatelessWidget { // This widget is the root of your application. @override - Widget build(BuildContext context) { - return ComponentTheme( + Widget build(BuildContext context) => ComponentTheme( componentThemeWidget: AppThemeComponent.components, child: MaterialApp( title: 'Wyatt Ui Components Example', @@ -40,7 +39,6 @@ class MyApp extends StatelessWidget { ), ), ); - } } class Home extends StatelessWidget { diff --git a/packages/wyatt_ui_components/example/test/widget_test.dart b/packages/wyatt_ui_components/example/test/widget_test.dart deleted file mode 100644 index bc890a0c..00000000 --- a/packages/wyatt_ui_components/example/test/widget_test.dart +++ /dev/null @@ -1,15 +0,0 @@ -// 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 . \ No newline at end of file diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/app_bar_component.dart b/packages/wyatt_ui_components/lib/src/domain/entities/app_bar_component.dart index 1a12cb97..be5dc624 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/app_bar_component.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/app_bar_component.dart @@ -15,8 +15,8 @@ // along with this program. If not, see . import 'package:flutter/material.dart'; -import 'package:wyatt_ui_components/src/core/mixins/copy_with_mixin.dart'; import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart'; +import 'package:wyatt_ui_components/src/core/mixins/copy_with_mixin.dart'; import 'package:wyatt_ui_components/src/domain/entities/component.dart'; part 'app_bar_component.g.dart'; @@ -24,13 +24,13 @@ part 'app_bar_component.g.dart'; @ComponentProxyExtension() abstract class AppBarComponent extends Component with CopyWithMixin<$AppBarComponentCWProxy> { - final String? title; - final Widget? leading; - final List? actions; const AppBarComponent({ this.title, this.leading, this.actions, super.key, }); + final String? title; + final Widget? leading; + final List? actions; } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/bottom_navigation_bar_component.dart b/packages/wyatt_ui_components/lib/src/domain/entities/bottom_navigation_bar_component.dart index 0620ef87..0daf25fd 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/bottom_navigation_bar_component.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/bottom_navigation_bar_component.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart'; // Copyright (C) 2023 WYATT GROUP // Please see the AUTHORS file for details. // @@ -17,18 +18,17 @@ import 'package:flutter/material.dart'; import 'package:wyatt_ui_components/src/core/mixins/copy_with_mixin.dart'; import 'package:wyatt_ui_components/src/domain/entities/component.dart'; -import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart'; part 'bottom_navigation_bar_component.g.dart'; @ComponentProxyExtension() abstract class BottomNavigationBarComponent extends Component with CopyWithMixin<$BottomNavigationBarComponentCWProxy> { - final int currentIndex; - final void Function(BuildContext, int)? onTap; const BottomNavigationBarComponent({ this.onTap, this.currentIndex = 0, super.key, }); + final int currentIndex; + final void Function(BuildContext, int)? onTap; } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/cards/card_component.dart b/packages/wyatt_ui_components/lib/src/domain/entities/cards/card_component.dart new file mode 100644 index 00000000..73f7ce79 --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/cards/card_component.dart @@ -0,0 +1,60 @@ +// 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/component.dart'; + +abstract class CardComponent extends Component { + const CardComponent({ + this.radius, + this.padding, + this.borderColors, + this.backgroundColor, + this.minSize, + this.maxSize, + this.shadow, + this.isDarkModeEnabled, + this.background, + super.key, + }); + + /// Card radius + final double? radius; + + /// Padding and gaps of this card + final double? padding; + + /// Border gradient color (from left to right) + final List? borderColors; + + /// Card background color + final Color? backgroundColor; + + /// Minimum size for this card + final Size? minSize; + + /// Maximum size for this card + final Size? maxSize; + + /// Drop shadow + final BoxShadow? shadow; + + /// Is this component in dark mode or not + final bool? isDarkModeEnabled; + + /// Background of the card + final Widget? background; +} diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/cards/information_card_component.dart b/packages/wyatt_ui_components/lib/src/domain/entities/cards/information_card_component.dart new file mode 100644 index 00000000..a6676d0c --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/cards/information_card_component.dart @@ -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 . + +import 'package:flutter/widgets.dart'; +import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart'; +import 'package:wyatt_ui_components/src/core/mixins/copy_with_mixin.dart'; +import 'package:wyatt_ui_components/src/domain/entities/cards/card_component.dart'; + +part 'information_card_component.g.dart'; + +@ComponentProxyExtension() +abstract class InformationCardComponent extends CardComponent + with CopyWithMixin<$InformationCardComponentCWProxy> { + const InformationCardComponent({ + this.icons, + this.title, + this.subtitle, + this.body, + this.axis = Axis.vertical, + super.radius = 12, + super.padding = 25, + super.borderColors = const [Color(0xFFDDE0E3), Color(0xFFCACCD4)], + super.backgroundColor = const Color(0xFFF6F6F6), + super.minSize = const Size(330, 230), + super.maxSize = const Size(330, 530), + super.shadow = const BoxShadow( + blurRadius: 30, + offset: Offset(0, 5), + color: Color.fromRGBO(0, 0, 0, 0.05), + ), + super.isDarkModeEnabled = false, + super.background, + super.key, + }); + + final Axis? axis; + final List? icons; + final Widget? title; + final Widget? subtitle; + final Widget? body; +} diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/cards/information_card_component.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/cards/information_card_component.g.dart new file mode 100644 index 00000000..78cdc783 --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/cards/information_card_component.g.dart @@ -0,0 +1,42 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'information_card_component.dart'; + +// ************************************************************************** +// ComponentProxyGenerator +// ************************************************************************** + +abstract class $InformationCardComponentCWProxy { + InformationCardComponent icons(List? icons); + InformationCardComponent title(Widget? title); + InformationCardComponent subtitle(Widget? subtitle); + InformationCardComponent body(Widget? body); + InformationCardComponent axis(Axis? axis); + InformationCardComponent radius(double? radius); + InformationCardComponent padding(double? padding); + InformationCardComponent borderColors(List? borderColors); + InformationCardComponent backgroundColor(Color? backgroundColor); + InformationCardComponent minSize(Size? minSize); + InformationCardComponent maxSize(Size? maxSize); + InformationCardComponent shadow(BoxShadow? shadow); + InformationCardComponent isDarkModeEnabled(bool? isDarkModeEnabled); + InformationCardComponent background(Widget? background); + InformationCardComponent key(Key? key); + InformationCardComponent call({ + List? icons, + Widget? title, + Widget? subtitle, + Widget? body, + Axis? axis, + double? radius, + double? padding, + List? borderColors, + Color? backgroundColor, + Size? minSize, + Size? maxSize, + BoxShadow? shadow, + bool? isDarkModeEnabled, + Widget? background, + Key? key, + }); +} diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/cards/quote_card_component.dart b/packages/wyatt_ui_components/lib/src/domain/entities/cards/quote_card_component.dart new file mode 100644 index 00000000..76892c39 --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/cards/quote_card_component.dart @@ -0,0 +1,43 @@ +import 'package:flutter/widgets.dart'; +import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart'; +import 'package:wyatt_ui_components/src/core/mixins/copy_with_mixin.dart'; +import 'package:wyatt_ui_components/src/domain/entities/cards/card_component.dart'; + +part 'quote_card_component.g.dart'; + +@ComponentProxyExtension() +abstract class QuoteCardComponent extends CardComponent + with CopyWithMixin<$QuoteCardComponentCWProxy> { + const QuoteCardComponent({ + required this.avatar, + required this.name, + required this.subtitle, + required this.gradient, + required this.quote, + this.leftQuote, + this.rightQuote, + super.radius = 12, + super.padding = 25, + super.borderColors = const [Color(0xFFDDE0E3), Color(0xFFCACCD4)], + super.backgroundColor = const Color(0xFFF6F6F6), + super.minSize = const Size(330, 230), + super.maxSize = const Size(330, 530), + super.shadow = const BoxShadow( + blurRadius: 30, + offset: Offset(0, 5), + color: Color.fromRGBO(0, 0, 0, 0.05), + ), + super.isDarkModeEnabled = false, + super.background, + super.key, + }); + + final Widget avatar; + final Widget name; + final Text subtitle; + final Gradient gradient; + final Widget quote; + + final Widget? leftQuote; + final Widget? rightQuote; +} diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/cards/quote_card_component.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/cards/quote_card_component.g.dart new file mode 100644 index 00000000..e48b6963 --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/cards/quote_card_component.g.dart @@ -0,0 +1,46 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'quote_card_component.dart'; + +// ************************************************************************** +// ComponentProxyGenerator +// ************************************************************************** + +abstract class $QuoteCardComponentCWProxy { + QuoteCardComponent avatar(Widget? avatar); + QuoteCardComponent name(Widget? name); + QuoteCardComponent subtitle(Text? subtitle); + QuoteCardComponent gradient(Gradient? gradient); + QuoteCardComponent quote(Widget? quote); + QuoteCardComponent leftQuote(Widget? leftQuote); + QuoteCardComponent rightQuote(Widget? rightQuote); + QuoteCardComponent radius(double? radius); + QuoteCardComponent padding(double? padding); + QuoteCardComponent borderColors(List? borderColors); + QuoteCardComponent backgroundColor(Color? backgroundColor); + QuoteCardComponent minSize(Size? minSize); + QuoteCardComponent maxSize(Size? maxSize); + QuoteCardComponent shadow(BoxShadow? shadow); + QuoteCardComponent isDarkModeEnabled(bool? isDarkModeEnabled); + QuoteCardComponent background(Widget? background); + QuoteCardComponent key(Key? key); + QuoteCardComponent call({ + Widget? avatar, + Widget? name, + Text? subtitle, + Gradient? gradient, + Widget? quote, + Widget? leftQuote, + Widget? rightQuote, + double? radius, + double? padding, + List? borderColors, + Color? backgroundColor, + Size? minSize, + Size? maxSize, + BoxShadow? shadow, + bool? isDarkModeEnabled, + Widget? background, + Key? key, + }); +} diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/entities.dart b/packages/wyatt_ui_components/lib/src/domain/entities/entities.dart index 51d081f6..3a2811ae 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/entities.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/entities.dart @@ -16,6 +16,6 @@ export './app_bar_component.dart'; export './bottom_navigation_bar_component.dart'; +export './component.dart'; export './error_widget_component.dart'; export './loading_widget_component.dart'; -export './component.dart'; diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/error_widget_component.dart b/packages/wyatt_ui_components/lib/src/domain/entities/error_widget_component.dart index e4a0ae83..c896417a 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/error_widget_component.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/error_widget_component.dart @@ -14,16 +14,16 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +import 'package:flutter/material.dart'; +import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart'; import 'package:wyatt_ui_components/src/core/mixins/copy_with_mixin.dart'; import 'package:wyatt_ui_components/src/domain/entities/component.dart'; -import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart'; -import 'package:flutter/material.dart'; part 'error_widget_component.g.dart'; @ComponentProxyExtension() abstract class ErrorWidgetComponent extends Component with CopyWithMixin<$ErrorWidgetComponentCWProxy> { - final String? error; const ErrorWidgetComponent({required this.error, super.key}); + final String? error; } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/loading_widget_component.dart b/packages/wyatt_ui_components/lib/src/domain/entities/loading_widget_component.dart index c565b6e3..41783f4e 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/loading_widget_component.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/loading_widget_component.dart @@ -15,15 +15,15 @@ // along with this program. If not, see . import 'package:flutter/material.dart'; +import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart'; import 'package:wyatt_ui_components/src/core/mixins/copy_with_mixin.dart'; import 'package:wyatt_ui_components/src/domain/entities/component.dart'; -import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart'; part 'loading_widget_component.g.dart'; @ComponentProxyExtension() abstract class LoadingWidgetComponent extends Component with CopyWithMixin<$LoadingWidgetComponentCWProxy> { - final Color? color; const LoadingWidgetComponent({required this.color, super.key}); + final Color? color; } diff --git a/packages/wyatt_ui_components/lib/src/features/component_theme.dart b/packages/wyatt_ui_components/lib/src/features/component_theme.dart index 9e3b64d3..49de4780 100644 --- a/packages/wyatt_ui_components/lib/src/features/component_theme.dart +++ b/packages/wyatt_ui_components/lib/src/features/component_theme.dart @@ -18,14 +18,14 @@ import 'package:flutter/material.dart'; import 'package:wyatt_ui_components/src/features/features.dart'; class ComponentTheme extends StatelessWidget { - final Widget child; - final ComponentThemeData componentThemeWidget; const ComponentTheme({ required this.child, required this.componentThemeWidget, super.key, }); + final Widget child; + final ComponentThemeData componentThemeWidget; static ComponentThemeData of(BuildContext context) { final _InheritedComponentTheme? inheritedThemeComponent = @@ -46,11 +46,11 @@ class ComponentTheme extends StatelessWidget { } class _InheritedComponentTheme extends InheritedWidget { - final ComponentTheme themeWidget; const _InheritedComponentTheme( this.themeWidget, { required super.child, }); + final ComponentTheme themeWidget; @override bool updateShouldNotify(covariant InheritedWidget oldWidget) => diff --git a/packages/wyatt_ui_components/lib/src/features/component_theme_data.dart b/packages/wyatt_ui_components/lib/src/features/component_theme_data.dart index f518caa7..0d247bf3 100644 --- a/packages/wyatt_ui_components/lib/src/features/component_theme_data.dart +++ b/packages/wyatt_ui_components/lib/src/features/component_theme_data.dart @@ -17,10 +17,6 @@ import 'package:wyatt_ui_components/src/domain/entities/entities.dart'; class ComponentThemeData { - final AppBarComponent? appBar; - final BottomNavigationBarComponent? bottomNavigationBar; - final ErrorWidgetComponent? errorWidget; - final LoadingWidgetComponent? loadingWidget; const ComponentThemeData.raw({ this.appBar, @@ -28,4 +24,8 @@ class ComponentThemeData { this.errorWidget, this.loadingWidget, }); + final AppBarComponent? appBar; + final BottomNavigationBarComponent? bottomNavigationBar; + final ErrorWidgetComponent? errorWidget; + final LoadingWidgetComponent? loadingWidget; } diff --git a/packages/wyatt_ui_components/lib/src/features/features.dart b/packages/wyatt_ui_components/lib/src/features/features.dart index 806071dc..6c0f1b4a 100644 --- a/packages/wyatt_ui_components/lib/src/features/features.dart +++ b/packages/wyatt_ui_components/lib/src/features/features.dart @@ -14,5 +14,5 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -export 'component_theme_data.dart'; export 'component_theme.dart'; +export 'component_theme_data.dart'; diff --git a/packages/wyatt_ui_components/pubspec.yaml b/packages/wyatt_ui_components/pubspec.yaml index 47955e53..42033ddd 100644 --- a/packages/wyatt_ui_components/pubspec.yaml +++ b/packages/wyatt_ui_components/pubspec.yaml @@ -3,16 +3,18 @@ description: Primary ui components repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_ui_components version: 0.0.1 +publish_to: none + environment: sdk: ">=2.17.0 <3.0.0" dependencies: flutter: sdk: flutter -wyatt_component_copy_with_extension: - git: - url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git - path: packages/wyatt_component_copy_with_extension + wyatt_component_copy_with_extension: + git: + url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git + path: packages/wyatt_component_copy_with_extension dev_dependencies: flutter_test: