From 3ab2826d51aff562dd241802a973c4cc40e01906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Wed, 22 Feb 2023 16:10:25 +0100 Subject: [PATCH] refactor(ui_components): migrate top nav bar using generify top bar --- .../lib/components/custom_app_bar.dart | 2 +- .../lib/components/custom_app_bar.g.dart | 16 +++--- .../entities/bars/app_bar_component.g.dart | 54 ------------------ .../lib/src/domain/entities/bars/bars.dart | 2 +- ...ponent.dart => top_app_bar_component.dart} | 8 +-- .../bars/top_app_bar_component.g.dart | 55 +++++++++++++++++++ .../bars/top_navigation_bar_component.dart | 27 +++++++-- .../src/features/component_theme_data.dart | 2 +- 8 files changed, 91 insertions(+), 75 deletions(-) delete mode 100644 packages/wyatt_ui_components/lib/src/domain/entities/bars/app_bar_component.g.dart rename packages/wyatt_ui_components/lib/src/domain/entities/bars/{app_bar_component.dart => top_app_bar_component.dart} (90%) create mode 100644 packages/wyatt_ui_components/lib/src/domain/entities/bars/top_app_bar_component.g.dart diff --git a/packages/wyatt_ui_components/example/lib/components/custom_app_bar.dart b/packages/wyatt_ui_components/example/lib/components/custom_app_bar.dart index 7a0088fe..fcd0cff8 100644 --- a/packages/wyatt_ui_components/example/lib/components/custom_app_bar.dart +++ b/packages/wyatt_ui_components/example/lib/components/custom_app_bar.dart @@ -5,7 +5,7 @@ import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart'; part 'custom_app_bar.g.dart'; @ComponentCopyWithExtension() -class CustomAppBar extends AppBarComponent with $CustomAppBarCWMixin { +class CustomAppBar extends TopAppBarComponent with $CustomAppBarCWMixin { const CustomAppBar({super.title, super.key}); @override diff --git a/packages/wyatt_ui_components/example/lib/components/custom_app_bar.g.dart b/packages/wyatt_ui_components/example/lib/components/custom_app_bar.g.dart index 911b0f37..125680d9 100644 --- a/packages/wyatt_ui_components/example/lib/components/custom_app_bar.g.dart +++ b/packages/wyatt_ui_components/example/lib/components/custom_app_bar.g.dart @@ -6,10 +6,14 @@ part of 'custom_app_bar.dart'; // ComponentCopyWithGenerator // ************************************************************************** -class $CustomAppBarCWProxyImpl implements $AppBarComponentCWProxy { +class $CustomAppBarCWProxyImpl implements $TopAppBarComponentCWProxy { const $CustomAppBarCWProxyImpl(this._value); final CustomAppBar _value; @override + CustomAppBar title(TextWrapper? title) => this(title: title); + @override + CustomAppBar centerTitle(bool? centerTitle) => this(centerTitle: centerTitle); + @override CustomAppBar shape(ShapeBorder? shape) => this(shape: shape); @override CustomAppBar systemOverlayStyle(SystemUiOverlayStyle? systemOverlayStyle) => @@ -51,20 +55,18 @@ class $CustomAppBarCWProxyImpl implements $AppBarComponentCWProxy { CustomAppBar leadingWidth(double? leadingWidth) => this(leadingWidth: leadingWidth); @override - CustomAppBar title(TextWrapper? title) => this(title: title); - @override CustomAppBar leading(Widget? leading) => this(leading: leading); @override CustomAppBar actions(List? actions) => this(actions: actions); @override - CustomAppBar centerTitle(bool? centerTitle) => this(centerTitle: centerTitle); - @override CustomAppBar expandedWidget(List? expandedWidget) => this(expandedWidget: expandedWidget); @override CustomAppBar key(Key? key) => this(key: key); @override CustomAppBar call({ + TextWrapper? title, + bool? centerTitle, ShapeBorder? shape, SystemUiOverlayStyle? systemOverlayStyle, bool? automaticallyImplyLeading, @@ -80,10 +82,8 @@ class $CustomAppBarCWProxyImpl implements $AppBarComponentCWProxy { bool? excludeHeaderSemantics, double? toolbarHeight, double? leadingWidth, - TextWrapper? title, Widget? leading, List? actions, - bool? centerTitle, List? expandedWidget, Key? key, }) => @@ -94,6 +94,6 @@ class $CustomAppBarCWProxyImpl implements $AppBarComponentCWProxy { } mixin $CustomAppBarCWMixin on Component { - $AppBarComponentCWProxy get copyWith => + $TopAppBarComponentCWProxy get copyWith => $CustomAppBarCWProxyImpl(this as CustomAppBar); } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/bars/app_bar_component.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/bars/app_bar_component.g.dart deleted file mode 100644 index bb6bcf5e..00000000 --- a/packages/wyatt_ui_components/lib/src/domain/entities/bars/app_bar_component.g.dart +++ /dev/null @@ -1,54 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'app_bar_component.dart'; - -// ************************************************************************** -// ComponentProxyGenerator -// ************************************************************************** - -abstract class $AppBarComponentCWProxy { - AppBarComponent shape(ShapeBorder? shape); - AppBarComponent systemOverlayStyle(SystemUiOverlayStyle? systemOverlayStyle); - AppBarComponent automaticallyImplyLeading(bool? automaticallyImplyLeading); - AppBarComponent flexibleSpace(Widget? flexibleSpace); - AppBarComponent bottom(PreferredSizeWidget? bottom); - AppBarComponent elevation(double? elevation); - AppBarComponent scrolledUnderElevation(double? scrolledUnderElevation); - AppBarComponent shadowColor(Color? shadowColor); - AppBarComponent surfaceTintColor(Color? surfaceTintColor); - AppBarComponent backgroundColor(MultiColor? backgroundColor); - AppBarComponent iconTheme(IconThemeData? iconTheme); - AppBarComponent primary(bool? primary); - AppBarComponent excludeHeaderSemantics(bool? excludeHeaderSemantics); - AppBarComponent toolbarHeight(double? toolbarHeight); - AppBarComponent leadingWidth(double? leadingWidth); - AppBarComponent title(TextWrapper? title); - AppBarComponent leading(Widget? leading); - AppBarComponent actions(List? actions); - AppBarComponent centerTitle(bool? centerTitle); - AppBarComponent expandedWidget(List? expandedWidget); - AppBarComponent key(Key? key); - AppBarComponent call({ - ShapeBorder? shape, - SystemUiOverlayStyle? systemOverlayStyle, - bool? automaticallyImplyLeading, - Widget? flexibleSpace, - PreferredSizeWidget? bottom, - double? elevation, - double? scrolledUnderElevation, - Color? shadowColor, - Color? surfaceTintColor, - MultiColor? backgroundColor, - IconThemeData? iconTheme, - bool? primary, - bool? excludeHeaderSemantics, - double? toolbarHeight, - double? leadingWidth, - TextWrapper? title, - Widget? leading, - List? actions, - bool? centerTitle, - List? expandedWidget, - Key? key, - }); -} diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/bars/bars.dart b/packages/wyatt_ui_components/lib/src/domain/entities/bars/bars.dart index 3334ba20..16fbd451 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/bars/bars.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/bars/bars.dart @@ -14,6 +14,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -export './app_bar_component.dart'; +export 'top_app_bar_component.dart'; export './bottom_navigation_bar_component.dart'; export './top_navigation_bar_component.dart'; diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/bars/app_bar_component.dart b/packages/wyatt_ui_components/lib/src/domain/entities/bars/top_app_bar_component.dart similarity index 90% rename from packages/wyatt_ui_components/lib/src/domain/entities/bars/app_bar_component.dart rename to packages/wyatt_ui_components/lib/src/domain/entities/bars/top_app_bar_component.dart index f13710a2..7be231f2 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/bars/app_bar_component.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/bars/top_app_bar_component.dart @@ -20,12 +20,12 @@ import 'package:wyatt_component_copy_with_extension/component_copy_with_extensio import 'package:wyatt_ui_components/src/domain/entities/bars/top_bar_component.dart'; import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart'; -part 'app_bar_component.g.dart'; +part 'top_app_bar_component.g.dart'; @ComponentProxyExtension() -abstract class AppBarComponent extends TopBarComponent - with CopyWithMixin<$AppBarComponentCWProxy> { - const AppBarComponent({ +abstract class TopAppBarComponent extends TopBarComponent + with CopyWithMixin<$TopAppBarComponentCWProxy> { + const TopAppBarComponent({ this.title, this.centerTitle, super.shape, diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/bars/top_app_bar_component.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/bars/top_app_bar_component.g.dart new file mode 100644 index 00000000..e71c01be --- /dev/null +++ b/packages/wyatt_ui_components/lib/src/domain/entities/bars/top_app_bar_component.g.dart @@ -0,0 +1,55 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'top_app_bar_component.dart'; + +// ************************************************************************** +// ComponentProxyGenerator +// ************************************************************************** + +abstract class $TopAppBarComponentCWProxy { + TopAppBarComponent title(TextWrapper? title); + TopAppBarComponent centerTitle(bool? centerTitle); + TopAppBarComponent shape(ShapeBorder? shape); + TopAppBarComponent systemOverlayStyle( + SystemUiOverlayStyle? systemOverlayStyle); + TopAppBarComponent automaticallyImplyLeading(bool? automaticallyImplyLeading); + TopAppBarComponent flexibleSpace(Widget? flexibleSpace); + TopAppBarComponent bottom(PreferredSizeWidget? bottom); + TopAppBarComponent elevation(double? elevation); + TopAppBarComponent scrolledUnderElevation(double? scrolledUnderElevation); + TopAppBarComponent shadowColor(Color? shadowColor); + TopAppBarComponent surfaceTintColor(Color? surfaceTintColor); + TopAppBarComponent backgroundColor(MultiColor? backgroundColor); + TopAppBarComponent iconTheme(IconThemeData? iconTheme); + TopAppBarComponent primary(bool? primary); + TopAppBarComponent excludeHeaderSemantics(bool? excludeHeaderSemantics); + TopAppBarComponent toolbarHeight(double? toolbarHeight); + TopAppBarComponent leadingWidth(double? leadingWidth); + TopAppBarComponent leading(Widget? leading); + TopAppBarComponent actions(List? actions); + TopAppBarComponent expandedWidget(List? expandedWidget); + TopAppBarComponent key(Key? key); + TopAppBarComponent call({ + TextWrapper? title, + bool? centerTitle, + ShapeBorder? shape, + SystemUiOverlayStyle? systemOverlayStyle, + bool? automaticallyImplyLeading, + Widget? flexibleSpace, + PreferredSizeWidget? bottom, + double? elevation, + double? scrolledUnderElevation, + Color? shadowColor, + Color? surfaceTintColor, + MultiColor? backgroundColor, + IconThemeData? iconTheme, + bool? primary, + bool? excludeHeaderSemantics, + double? toolbarHeight, + double? leadingWidth, + Widget? leading, + List? actions, + List? expandedWidget, + Key? key, + }); +} diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/bars/top_navigation_bar_component.dart b/packages/wyatt_ui_components/lib/src/domain/entities/bars/top_navigation_bar_component.dart index cb23bf07..a5cc6977 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/bars/top_navigation_bar_component.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/bars/top_navigation_bar_component.dart @@ -17,22 +17,37 @@ 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_ui_components/src/domain/entities/bars/top_bar_component.dart'; part 'top_navigation_bar_component.g.dart'; @ComponentProxyExtension() -abstract class TopNavigationBarComponent extends Component +abstract class TopNavigationBarComponent extends TopBarComponent with CopyWithMixin<$TopNavigationBarComponentCWProxy> { const TopNavigationBarComponent({ - this.leading, - this.actions, this.onTap, this.currentIndex = 0, + super.shape, + super.systemOverlayStyle, + super.automaticallyImplyLeading, + super.flexibleSpace, + super.bottom, + super.elevation, + super.scrolledUnderElevation, + super.shadowColor, + super.surfaceTintColor, + super.backgroundColor, + super.iconTheme, + super.primary, + super.excludeHeaderSemantics, + super.toolbarHeight, + super.leadingWidth, + super.leading, + super.actions, + super.expandedWidget, super.key, }); + final int currentIndex; final void Function(BuildContext, int)? onTap; - final Widget? leading; - final List? actions; } 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 1f58e87c..71f1b221 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 @@ -35,7 +35,7 @@ class ComponentThemeData { this.quoteCardComponent, this.skillCardComponent, }); - final AppBarComponent? appBar; + final TopAppBarComponent? appBar; final TopNavigationBarComponent? topNavigationBarComponent; final BottomNavigationBarComponent? bottomNavigationBar;