From 81a7ca5a1fce62e14c9e9cbca59b181ffc754794 Mon Sep 17 00:00:00 2001 From: AN12345 Date: Mon, 12 Dec 2022 14:08:36 -0500 Subject: [PATCH 1/7] feat(ui_components): make component data field nullable (#92) --- .../wyatt_ui_components/example/lib/main.dart | 2 +- .../lib/src/domain/entities/component.dart | 2 +- .../lib/src/domain/entities/components.dart | 8 ++++---- .../lib/src/features/component_theme_data.dart | 16 ++++++++-------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/wyatt_ui_components/example/lib/main.dart b/packages/wyatt_ui_components/example/lib/main.dart index 673d614a..e8aebaa0 100644 --- a/packages/wyatt_ui_components/example/lib/main.dart +++ b/packages/wyatt_ui_components/example/lib/main.dart @@ -50,7 +50,7 @@ class Home extends StatelessWidget { Widget build(BuildContext context) => Scaffold( appBar: PreferredSize( preferredSize: const Size.fromHeight(60), - child: context.components.appBar.configure(title: 'Example title'), + child: context.components.appBar?.configure(title: 'Example title'), ), body: Column( children: [ diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/component.dart b/packages/wyatt_ui_components/lib/src/domain/entities/component.dart index ca2d18dc..7a03682f 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/component.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/component.dart @@ -19,5 +19,5 @@ import 'package:flutter/material.dart'; abstract class Component extends StatelessWidget { const Component({super.key}); - Component configure(); + Component? configure(); } diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/components.dart b/packages/wyatt_ui_components/lib/src/domain/entities/components.dart index a758ae6b..44c16697 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/components.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/components.dart @@ -29,7 +29,7 @@ abstract class AppBarComponent extends Component { }); @override - AppBarComponent configure({ + AppBarComponent? configure({ String? title, Widget? leading, List? actions, @@ -46,7 +46,7 @@ abstract class BottomNavigationBarComponent extends Component { }); @override - BottomNavigationBarComponent configure({ + BottomNavigationBarComponent? configure({ void Function(BuildContext, int)? onTap, int currentIndex = 0, }); @@ -57,7 +57,7 @@ abstract class ErrorWidgetComponent extends Component { const ErrorWidgetComponent({required this.error, super.key}); @override - ErrorWidgetComponent configure({String? error}); + ErrorWidgetComponent? configure({String? error}); } abstract class LoadingWidgetComponent extends Component { @@ -65,5 +65,5 @@ abstract class LoadingWidgetComponent extends Component { const LoadingWidgetComponent({required this.color, super.key}); @override - LoadingWidgetComponent configure({Color? color}); + LoadingWidgetComponent? configure({Color? color}); } 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 66540540..e613e826 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,15 +17,15 @@ import 'package:wyatt_ui_components/src/domain/entities/components.dart'; class ComponentThemeData { - final AppBarComponent appBar; - final BottomNavigationBarComponent bottomNavigationBar; - final ErrorWidgetComponent errorWidget; - final LoadingWidgetComponent loadingWidget; + final AppBarComponent? appBar; + final BottomNavigationBarComponent? bottomNavigationBar; + final ErrorWidgetComponent? errorWidget; + final LoadingWidgetComponent? loadingWidget; const ComponentThemeData.raw({ - required this.appBar, - required this.bottomNavigationBar, - required this.errorWidget, - required this.loadingWidget, + this.appBar, + this.bottomNavigationBar, + this.errorWidget, + this.loadingWidget, }); } -- 2.47.2 From 244a2865091fe316d391c469a3ae523089d1ca0c Mon Sep 17 00:00:00 2001 From: AN12345 Date: Mon, 12 Dec 2022 14:10:41 -0500 Subject: [PATCH 2/7] refactor(ui_components): update example (#92) --- packages/wyatt_ui_components/example/lib/main.dart | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/wyatt_ui_components/example/lib/main.dart b/packages/wyatt_ui_components/example/lib/main.dart index e8aebaa0..1587122a 100644 --- a/packages/wyatt_ui_components/example/lib/main.dart +++ b/packages/wyatt_ui_components/example/lib/main.dart @@ -50,20 +50,23 @@ class Home extends StatelessWidget { Widget build(BuildContext context) => Scaffold( appBar: PreferredSize( preferredSize: const Size.fromHeight(60), - child: context.components.appBar?.configure(title: 'Example title'), + child: context.components.appBar?.configure(title: 'Example title') ?? + const SizedBox.shrink(), ), body: Column( children: [ Expanded( child: context.components.errorWidget - .configure(error: 'Example erreur'), + ?.configure(error: 'Example erreur') ?? + const SizedBox.shrink(), ), const SizedBox( height: 10, ), Expanded( child: context.components.loadingWidget - .configure(color: Colors.green), + ?.configure(color: Colors.green) ?? + const SizedBox.shrink(), ), ], ), -- 2.47.2 From 7a24a36af00c916ff471648642d610348f1a8922 Mon Sep 17 00:00:00 2001 From: AN12345 Date: Mon, 12 Dec 2022 14:13:00 -0500 Subject: [PATCH 3/7] refactor(bloc_layout): update package using nullable component data (#92) --- .../consumers/crud_cubit_consumer_screen_bases.dart | 5 +++-- .../src/presentation/screens/crud_cubit_screen_base.dart | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/wyatt_bloc_layout/lib/src/presentation/consumers/crud_cubit_consumer_screen_bases.dart b/packages/wyatt_bloc_layout/lib/src/presentation/consumers/crud_cubit_consumer_screen_bases.dart index 7090ff17..e3f58686 100644 --- a/packages/wyatt_bloc_layout/lib/src/presentation/consumers/crud_cubit_consumer_screen_bases.dart +++ b/packages/wyatt_bloc_layout/lib/src/presentation/consumers/crud_cubit_consumer_screen_bases.dart @@ -27,10 +27,11 @@ abstract class CrudCubitConsumerScreenBase< const CrudCubitConsumerScreenBase({super.key}); Widget errorBuilder(BuildContext context, CrudError state) => - context.components.errorWidget.configure(error: state.message); + context.components.errorWidget?.configure(error: state.message) ?? + const SizedBox.shrink(); Widget loadingBuilder(BuildContext context, CrudLoading state) => - context.components.loadingWidget; + context.components.loadingWidget ?? const SizedBox.shrink(); Widget initialBuilder(BuildContext context, CrudInitial state) => const SizedBox.shrink(); diff --git a/packages/wyatt_bloc_layout/lib/src/presentation/screens/crud_cubit_screen_base.dart b/packages/wyatt_bloc_layout/lib/src/presentation/screens/crud_cubit_screen_base.dart index 4240f819..04f35bbf 100644 --- a/packages/wyatt_bloc_layout/lib/src/presentation/screens/crud_cubit_screen_base.dart +++ b/packages/wyatt_bloc_layout/lib/src/presentation/screens/crud_cubit_screen_base.dart @@ -16,17 +16,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart' as bloc_base; -import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart'; import 'package:wyatt_bloc_layout/wyatt_bloc_layout.dart'; abstract class CrudCubitScreenBase, SuccessState extends CrudSuccess> extends CubitScreen { const CrudCubitScreenBase(); Widget errorBuilder(BuildContext context, CrudError state) => - context.components.errorWidget; + context.components.errorWidget?.configure(error: state.message) ?? + const SizedBox.shrink(); Widget loadingBuilder(BuildContext context, CrudLoading state) => - context.components.loadingWidget; + context.components.loadingWidget ?? const SizedBox.shrink(); Widget initialBuilder(BuildContext context, CrudInitial state) => const SizedBox.shrink(); -- 2.47.2 From e01f47d41a327b0beafa53101c896a4939439bde Mon Sep 17 00:00:00 2001 From: AN12345 Date: Mon, 12 Dec 2022 14:14:15 -0500 Subject: [PATCH 4/7] refactor(ui_layout): update package using nullable component data (#92) --- .../lib/src/presentation/layouts/app_bar_layout.dart | 3 ++- .../presentation/layouts/bottom_navigation_bar_layout.dart | 2 +- .../lib/src/presentation/layouts/frame_layout.dart | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/wyatt_ui_layout/lib/src/presentation/layouts/app_bar_layout.dart b/packages/wyatt_ui_layout/lib/src/presentation/layouts/app_bar_layout.dart index 9d392e1e..1bf8f571 100644 --- a/packages/wyatt_ui_layout/lib/src/presentation/layouts/app_bar_layout.dart +++ b/packages/wyatt_ui_layout/lib/src/presentation/layouts/app_bar_layout.dart @@ -31,7 +31,8 @@ class AppBarLayout extends Layout { Widget build(BuildContext context) => Scaffold( appBar: PreferredSize( preferredSize: const Size.fromHeight(60), - child: context.components.appBar.configure(title: title), + child: context.components.appBar?.configure(title: title) ?? + const SizedBox.shrink(), ), body: body, ); diff --git a/packages/wyatt_ui_layout/lib/src/presentation/layouts/bottom_navigation_bar_layout.dart b/packages/wyatt_ui_layout/lib/src/presentation/layouts/bottom_navigation_bar_layout.dart index 5c214ef9..58ee146f 100644 --- a/packages/wyatt_ui_layout/lib/src/presentation/layouts/bottom_navigation_bar_layout.dart +++ b/packages/wyatt_ui_layout/lib/src/presentation/layouts/bottom_navigation_bar_layout.dart @@ -14,7 +14,7 @@ class BottomNavigationBarLayout extends Layout { @override Widget build(BuildContext context) => Scaffold( body: body, - bottomNavigationBar: context.components.bottomNavigationBar.configure( + bottomNavigationBar: context.components.bottomNavigationBar?.configure( currentIndex: currentIndex, ), ); diff --git a/packages/wyatt_ui_layout/lib/src/presentation/layouts/frame_layout.dart b/packages/wyatt_ui_layout/lib/src/presentation/layouts/frame_layout.dart index f32b869f..355716d3 100644 --- a/packages/wyatt_ui_layout/lib/src/presentation/layouts/frame_layout.dart +++ b/packages/wyatt_ui_layout/lib/src/presentation/layouts/frame_layout.dart @@ -34,10 +34,11 @@ class FrameLayout extends Layout { Widget build(BuildContext context) => Scaffold( appBar: PreferredSize( preferredSize: const Size.fromHeight(60), - child: context.components.appBar.configure(title: title), + child: context.components.appBar?.configure(title: title) ?? + const SizedBox.shrink(), ), body: body, - bottomNavigationBar: context.components.bottomNavigationBar.configure( + bottomNavigationBar: context.components.bottomNavigationBar?.configure( currentIndex: currentIndex, ), ); -- 2.47.2 From c6d8ca37fe7dd508bac37307d31942f36c0c75db Mon Sep 17 00:00:00 2001 From: AN12345 Date: Mon, 12 Dec 2022 14:20:20 -0500 Subject: [PATCH 5/7] refactor(bloc_layout): update example (#92) --- .../example/lib/components/theme_components.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/wyatt_bloc_layout/example/lib/components/theme_components.dart b/packages/wyatt_bloc_layout/example/lib/components/theme_components.dart index 2c57df62..2357586c 100644 --- a/packages/wyatt_bloc_layout/example/lib/components/theme_components.dart +++ b/packages/wyatt_bloc_layout/example/lib/components/theme_components.dart @@ -18,7 +18,7 @@ class CustomAppBar extends AppBarComponent { ); @override - AppBarComponent configure( + AppBarComponent? configure( {String? title, Widget? leading, List? actions}) => CustomAppBar( title: title ?? this.title, @@ -44,7 +44,7 @@ class CustomBottomBar extends BottomNavigationBarComponent { ); @override - BottomNavigationBarComponent configure( + BottomNavigationBarComponent? configure( {void Function(BuildContext p1, int p2)? onTap, int currentIndex = 0}) => this; @@ -58,7 +58,7 @@ class CustomLoadingWidget extends LoadingWidgetComponent { Center(child: CircularProgressIndicator(color: color)); @override - LoadingWidgetComponent configure({Color? color}) => CustomLoadingWidget( + LoadingWidgetComponent? configure({Color? color}) => CustomLoadingWidget( color: color ?? this.color, ); } @@ -73,7 +73,7 @@ class CustomErrorWidget extends ErrorWidgetComponent { ); @override - ErrorWidgetComponent configure({String? error}) => CustomErrorWidget( + ErrorWidgetComponent? configure({String? error}) => CustomErrorWidget( error: error ?? this.error, ); } -- 2.47.2 From e8172004a3d32683923ca4ece85cff3a72974ecd Mon Sep 17 00:00:00 2001 From: AN12345 Date: Mon, 12 Dec 2022 14:21:13 -0500 Subject: [PATCH 6/7] refactor(ui_component): update example (#92) --- .../example/lib/components/custom_app_bar.dart | 2 +- .../example/lib/components/custom_bottom_bar.dart | 2 +- .../example/lib/components/custom_error_widget.dart | 2 +- .../example/lib/components/custom_loading_widget.dart | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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 384fdf8e..80b9b396 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 @@ -10,7 +10,7 @@ class CustomAppBar extends AppBarComponent { ); @override - AppBarComponent configure( + AppBarComponent? configure( {String? title, Widget? leading, List? actions}) => CustomAppBar( title: title ?? this.title, diff --git a/packages/wyatt_ui_components/example/lib/components/custom_bottom_bar.dart b/packages/wyatt_ui_components/example/lib/components/custom_bottom_bar.dart index d3c13033..42eacfab 100644 --- a/packages/wyatt_ui_components/example/lib/components/custom_bottom_bar.dart +++ b/packages/wyatt_ui_components/example/lib/components/custom_bottom_bar.dart @@ -29,7 +29,7 @@ class CustomBottomNavigationBar extends BottomNavigationBarComponent { ); @override - CustomBottomNavigationBar configure({ + CustomBottomNavigationBar? configure({ void Function(BuildContext, int)? onTap, int currentIndex = 0, }) => diff --git a/packages/wyatt_ui_components/example/lib/components/custom_error_widget.dart b/packages/wyatt_ui_components/example/lib/components/custom_error_widget.dart index 8b2a9b5a..736ae98a 100644 --- a/packages/wyatt_ui_components/example/lib/components/custom_error_widget.dart +++ b/packages/wyatt_ui_components/example/lib/components/custom_error_widget.dart @@ -11,6 +11,6 @@ class CustomErrorWidget extends ErrorWidgetComponent { ); @override - ErrorWidgetComponent configure({String? error}) => + ErrorWidgetComponent? configure({String? error}) => CustomErrorWidget(error: error ?? this.error); } diff --git a/packages/wyatt_ui_components/example/lib/components/custom_loading_widget.dart b/packages/wyatt_ui_components/example/lib/components/custom_loading_widget.dart index 912312fe..6d28e690 100644 --- a/packages/wyatt_ui_components/example/lib/components/custom_loading_widget.dart +++ b/packages/wyatt_ui_components/example/lib/components/custom_loading_widget.dart @@ -12,7 +12,7 @@ class CustomLoadingWidget extends LoadingWidgetComponent { ); @override - CustomLoadingWidget configure({Color? color}) => CustomLoadingWidget( + CustomLoadingWidget? configure({Color? color}) => CustomLoadingWidget( color: color ?? this.color, ); } -- 2.47.2 From 4f49f4931cbd7ab380dd2aeb05693e065220672a Mon Sep 17 00:00:00 2001 From: AN12345 Date: Mon, 12 Dec 2022 14:21:48 -0500 Subject: [PATCH 7/7] refactor(ui_layout): update example (#92) --- .../wyatt_ui_layout/example/lib/components/custom_app_bar.dart | 2 +- .../example/lib/components/custom_bottom_navigation_bar.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/wyatt_ui_layout/example/lib/components/custom_app_bar.dart b/packages/wyatt_ui_layout/example/lib/components/custom_app_bar.dart index d025a569..d31297fa 100644 --- a/packages/wyatt_ui_layout/example/lib/components/custom_app_bar.dart +++ b/packages/wyatt_ui_layout/example/lib/components/custom_app_bar.dart @@ -13,7 +13,7 @@ class CustomAppBar extends AppBarComponent { ); @override - AppBarComponent configure({ + AppBarComponent? configure({ String? title, Widget? leading, List? actions, diff --git a/packages/wyatt_ui_layout/example/lib/components/custom_bottom_navigation_bar.dart b/packages/wyatt_ui_layout/example/lib/components/custom_bottom_navigation_bar.dart index d3c13033..42eacfab 100644 --- a/packages/wyatt_ui_layout/example/lib/components/custom_bottom_navigation_bar.dart +++ b/packages/wyatt_ui_layout/example/lib/components/custom_bottom_navigation_bar.dart @@ -29,7 +29,7 @@ class CustomBottomNavigationBar extends BottomNavigationBarComponent { ); @override - CustomBottomNavigationBar configure({ + CustomBottomNavigationBar? configure({ void Function(BuildContext, int)? onTap, int currentIndex = 0, }) => -- 2.47.2