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, ); } 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(); 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, ); } diff --git a/packages/wyatt_ui_components/example/lib/main.dart b/packages/wyatt_ui_components/example/lib/main.dart index 673d614a..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(), ), ], ), 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, }); } 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, }) => 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, ), );