refactor(bloc_layout): migrate bloc layouts using copywith component method (close #121) #122
| @ -0,0 +1,14 @@ | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:wyatt_bloc_layout/wyatt_bloc_layout.dart'; | ||||
| import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart'; | ||||
| 
 | ||||
| part 'custom_app_bar.g.dart'; | ||||
| 
 | ||||
| @ComponentCopyWithExtension() | ||||
| class CustomAppBar extends AppBarComponent with $CustomAppBarCWMixin { | ||||
|   const CustomAppBar({super.title}); | ||||
|   @override | ||||
|   Widget build(BuildContext context) => AppBar( | ||||
|         title: Text(title ?? 'Title'), | ||||
|       ); | ||||
| } | ||||
| @ -0,0 +1,35 @@ | ||||
| // GENERATED CODE - DO NOT MODIFY BY HAND | ||||
| 
 | ||||
| part of 'custom_app_bar.dart'; | ||||
| 
 | ||||
| // ************************************************************************** | ||||
| // ComponentCopyWithGenerator | ||||
| // ************************************************************************** | ||||
| 
 | ||||
| class $CustomAppBarCWProxyImpl implements $AppBarComponentCWProxy { | ||||
|   const $CustomAppBarCWProxyImpl(this._value); | ||||
|   final CustomAppBar _value; | ||||
|   @override | ||||
|   CustomAppBar title(String? title) => this(title: title); | ||||
|   @override | ||||
|   CustomAppBar leading(Widget? leading) => this(leading: leading); | ||||
|   @override | ||||
|   CustomAppBar actions(List<Widget>? actions) => this(actions: actions); | ||||
|   @override | ||||
|   CustomAppBar key(Key? key) => this(key: key); | ||||
|   @override | ||||
|   CustomAppBar call({ | ||||
|     String? title, | ||||
|     Widget? leading, | ||||
|     List<Widget>? actions, | ||||
|     Key? key, | ||||
|   }) => | ||||
|       CustomAppBar( | ||||
|         title: title ?? _value.title, | ||||
|       ); | ||||
| } | ||||
| 
 | ||||
| mixin $CustomAppBarCWMixin on Component { | ||||
|   $AppBarComponentCWProxy get copyWith => | ||||
|       $CustomAppBarCWProxyImpl(this as CustomAppBar); | ||||
| } | ||||
| @ -0,0 +1,26 @@ | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:wyatt_bloc_layout/wyatt_bloc_layout.dart'; | ||||
| import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart'; | ||||
| 
 | ||||
| part 'custom_bottom_bar.g.dart'; | ||||
| 
 | ||||
| @ComponentCopyWithExtension() | ||||
| class CustomBottomBar extends BottomNavigationBarComponent | ||||
|     with $CustomBottomBarCWMixin { | ||||
|   @override | ||||
|   Widget build(BuildContext context) => BottomNavigationBar( | ||||
|         items: [ | ||||
|           BottomNavigationBarItem( | ||||
|               icon: Icon( | ||||
|                 Icons.e_mobiledata, | ||||
|               ), | ||||
|               label: 'Icon 1'), | ||||
|           BottomNavigationBarItem( | ||||
|               icon: Icon( | ||||
|                 Icons.do_not_disturb_off, | ||||
|               ), | ||||
|               label: 'Icon 2'), | ||||
|         ], | ||||
|         backgroundColor: Colors.blue, | ||||
|       ); | ||||
| } | ||||
| @ -0,0 +1,33 @@ | ||||
| // GENERATED CODE - DO NOT MODIFY BY HAND | ||||
| 
 | ||||
| part of 'custom_bottom_bar.dart'; | ||||
| 
 | ||||
| // ************************************************************************** | ||||
| // ComponentCopyWithGenerator | ||||
| // ************************************************************************** | ||||
| 
 | ||||
| class $CustomBottomBarCWProxyImpl | ||||
|     implements $BottomNavigationBarComponentCWProxy { | ||||
|   const $CustomBottomBarCWProxyImpl(this._value); | ||||
|   final CustomBottomBar _value; | ||||
|   @override | ||||
|   CustomBottomBar onTap(void Function(BuildContext, int)? onTap) => | ||||
|       this(onTap: onTap); | ||||
|   @override | ||||
|   CustomBottomBar currentIndex(int? currentIndex) => | ||||
|       this(currentIndex: currentIndex); | ||||
|   @override | ||||
|   CustomBottomBar key(Key? key) => this(key: key); | ||||
|   @override | ||||
|   CustomBottomBar call({ | ||||
|     void Function(BuildContext, int)? onTap, | ||||
|     int? currentIndex, | ||||
|     Key? key, | ||||
|   }) => | ||||
|       CustomBottomBar(); | ||||
| } | ||||
| 
 | ||||
| mixin $CustomBottomBarCWMixin on Component { | ||||
|   $BottomNavigationBarComponentCWProxy get copyWith => | ||||
|       $CustomBottomBarCWProxyImpl(this as CustomBottomBar); | ||||
| } | ||||
| @ -0,0 +1,17 @@ | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:wyatt_bloc_layout/wyatt_bloc_layout.dart'; | ||||
| import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart'; | ||||
| 
 | ||||
| part 'custom_error_widget.g.dart'; | ||||
| 
 | ||||
| @ComponentCopyWithExtension() | ||||
| class CustomErrorWidget extends ErrorWidgetComponent | ||||
|     with $CustomErrorWidgetCWMixin { | ||||
|   CustomErrorWidget({super.error}); | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) => ColoredBox( | ||||
|         color: Colors.red, | ||||
|         child: Center(child: Text(error ?? 'Error')), | ||||
|       ); | ||||
| } | ||||
| @ -0,0 +1,29 @@ | ||||
| // GENERATED CODE - DO NOT MODIFY BY HAND | ||||
| 
 | ||||
| part of 'custom_error_widget.dart'; | ||||
| 
 | ||||
| // ************************************************************************** | ||||
| // ComponentCopyWithGenerator | ||||
| // ************************************************************************** | ||||
| 
 | ||||
| class $CustomErrorWidgetCWProxyImpl implements $ErrorWidgetComponentCWProxy { | ||||
|   const $CustomErrorWidgetCWProxyImpl(this._value); | ||||
|   final CustomErrorWidget _value; | ||||
|   @override | ||||
|   CustomErrorWidget error(String? error) => this(error: error); | ||||
|   @override | ||||
|   CustomErrorWidget key(Key? key) => this(key: key); | ||||
|   @override | ||||
|   CustomErrorWidget call({ | ||||
|     String? error, | ||||
|     Key? key, | ||||
|   }) => | ||||
|       CustomErrorWidget( | ||||
|         error: error ?? _value.error, | ||||
|       ); | ||||
| } | ||||
| 
 | ||||
| mixin $CustomErrorWidgetCWMixin on Component { | ||||
|   $ErrorWidgetComponentCWProxy get copyWith => | ||||
|       $CustomErrorWidgetCWProxyImpl(this as CustomErrorWidget); | ||||
| } | ||||
| @ -0,0 +1,15 @@ | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:wyatt_bloc_layout/wyatt_bloc_layout.dart'; | ||||
| import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart'; | ||||
| 
 | ||||
| part 'custom_loading_widget.g.dart'; | ||||
| 
 | ||||
| @ComponentCopyWithExtension() | ||||
| class CustomLoadingWidget extends LoadingWidgetComponent | ||||
|     with $CustomLoadingWidgetCWMixin { | ||||
|   CustomLoadingWidget({super.color}); | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) => | ||||
|       Center(child: CircularProgressIndicator(color: color)); | ||||
| } | ||||
| @ -0,0 +1,30 @@ | ||||
| // GENERATED CODE - DO NOT MODIFY BY HAND | ||||
| 
 | ||||
| part of 'custom_loading_widget.dart'; | ||||
| 
 | ||||
| // ************************************************************************** | ||||
| // ComponentCopyWithGenerator | ||||
| // ************************************************************************** | ||||
| 
 | ||||
| class $CustomLoadingWidgetCWProxyImpl | ||||
|     implements $LoadingWidgetComponentCWProxy { | ||||
|   const $CustomLoadingWidgetCWProxyImpl(this._value); | ||||
|   final CustomLoadingWidget _value; | ||||
|   @override | ||||
|   CustomLoadingWidget color(Color? color) => this(color: color); | ||||
|   @override | ||||
|   CustomLoadingWidget key(Key? key) => this(key: key); | ||||
|   @override | ||||
|   CustomLoadingWidget call({ | ||||
|     Color? color, | ||||
|     Key? key, | ||||
|   }) => | ||||
|       CustomLoadingWidget( | ||||
|         color: color ?? _value.color, | ||||
|       ); | ||||
| } | ||||
| 
 | ||||
| mixin $CustomLoadingWidgetCWMixin on Component { | ||||
|   $LoadingWidgetComponentCWProxy get copyWith => | ||||
|       $CustomLoadingWidgetCWProxyImpl(this as CustomLoadingWidget); | ||||
| } | ||||
| @ -1,4 +1,7 @@ | ||||
| import 'package:flutter/material.dart'; | ||||
| import 'package:bloc_layout_example/components/custom_app_bar.dart'; | ||||
| import 'package:bloc_layout_example/components/custom_bottom_bar.dart'; | ||||
| import 'package:bloc_layout_example/components/custom_error_widget.dart'; | ||||
| import 'package:bloc_layout_example/components/custom_loading_widget.dart'; | ||||
| import 'package:wyatt_bloc_layout/wyatt_bloc_layout.dart'; | ||||
| 
 | ||||
| class AppThemeComponent { | ||||
| @ -9,71 +12,3 @@ class AppThemeComponent { | ||||
|         errorWidget: CustomErrorWidget(), | ||||
|       ); | ||||
| } | ||||
| 
 | ||||
| class CustomAppBar extends AppBarComponent { | ||||
|   const CustomAppBar({super.title}); | ||||
|   @override | ||||
|   Widget build(BuildContext context) => AppBar( | ||||
|         title: Text(title ?? 'Title'), | ||||
|       ); | ||||
| 
 | ||||
|   @override | ||||
|   AppBarComponent? configure( | ||||
|           {String? title, Widget? leading, List<Widget>? actions}) => | ||||
|       CustomAppBar( | ||||
|         title: title ?? this.title, | ||||
|       ); | ||||
| } | ||||
| 
 | ||||
| class CustomBottomBar extends BottomNavigationBarComponent { | ||||
|   @override | ||||
|   Widget build(BuildContext context) => BottomNavigationBar( | ||||
|         items: [ | ||||
|           BottomNavigationBarItem( | ||||
|               icon: Icon( | ||||
|                 Icons.e_mobiledata, | ||||
|               ), | ||||
|               label: 'Icon 1'), | ||||
|           BottomNavigationBarItem( | ||||
|               icon: Icon( | ||||
|                 Icons.do_not_disturb_off, | ||||
|               ), | ||||
|               label: 'Icon 2'), | ||||
|         ], | ||||
|         backgroundColor: Colors.blue, | ||||
|       ); | ||||
| 
 | ||||
|   @override | ||||
|   BottomNavigationBarComponent? configure( | ||||
|           {void Function(BuildContext p1, int p2)? onTap, | ||||
|           int currentIndex = 0}) => | ||||
|       this; | ||||
| } | ||||
| 
 | ||||
| class CustomLoadingWidget extends LoadingWidgetComponent { | ||||
|   CustomLoadingWidget({super.color}); | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) => | ||||
|       Center(child: CircularProgressIndicator(color: color)); | ||||
| 
 | ||||
|   @override | ||||
|   LoadingWidgetComponent? configure({Color? color}) => CustomLoadingWidget( | ||||
|         color: color ?? this.color, | ||||
|       ); | ||||
| } | ||||
| 
 | ||||
| class CustomErrorWidget extends ErrorWidgetComponent { | ||||
|   CustomErrorWidget({super.error}); | ||||
| 
 | ||||
|   @override | ||||
|   Widget build(BuildContext context) => ColoredBox( | ||||
|         color: Colors.red, | ||||
|         child: Center(child: Text(error ?? 'Error')), | ||||
|       ); | ||||
| 
 | ||||
|   @override | ||||
|   ErrorWidgetComponent? configure({String? error}) => CustomErrorWidget( | ||||
|         error: error ?? this.error, | ||||
|       ); | ||||
| } | ||||
|  | ||||
| @ -3,7 +3,7 @@ description: A new Flutter project. | ||||
| 
 | ||||
| # The following line prevents the package from being accidentally published to | ||||
| # pub.dev using `flutter pub publish`. This is preferred for private packages. | ||||
| publish_to: 'none' # Remove this line if you wish to publish to pub.dev | ||||
| publish_to: "none" # Remove this line if you wish to publish to pub.dev | ||||
| 
 | ||||
| # The following defines the version and build number for your application. | ||||
| # A version number is three numbers separated by dots, like 1.2.43 | ||||
| @ -27,19 +27,26 @@ environment: | ||||
| # the latest version available on pub.dev. To see which dependencies have newer | ||||
| # versions available, run `flutter pub outdated`. | ||||
| dependencies: | ||||
|    | ||||
|   flutter: | ||||
|     sdk: flutter | ||||
| 
 | ||||
|    | ||||
|   wyatt_bloc_layout: | ||||
|     path: "../" | ||||
| 
 | ||||
| dev_dependencies: | ||||
|   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: | ||||
|     sdk: flutter | ||||
| 
 | ||||
|   build_runner: ^2.3.3 | ||||
|   wyatt_component_copy_with_gen: | ||||
|     git: | ||||
|       url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git | ||||
|       path: packages/wyatt_component_copy_with_gen | ||||
| 
 | ||||
|   wyatt_analysis: | ||||
|     git: | ||||
| @ -50,10 +57,8 @@ dev_dependencies: | ||||
| # For information on the generic Dart part of this file, see the | ||||
| # following page: https://dart.dev/tools/pub/pubspec | ||||
| 
 | ||||
| 
 | ||||
| # The following section is specific to Flutter. | ||||
| flutter: | ||||
| 
 | ||||
|   # The following line ensures that the Material Icons font is | ||||
|   # included with your application, so that you can use the icons in | ||||
|   # the material Icons class. | ||||
|  | ||||
| @ -23,7 +23,7 @@ import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart'; | ||||
| mixin CrudMixin<Cubit extends bloc_base.Cubit, | ||||
|     SuccessState extends CrudSuccess> { | ||||
|   Widget errorBuilder(BuildContext context, CrudError state) => | ||||
|       context.components.errorWidget?.configure(error: state.message) ?? | ||||
|       context.components.errorWidget?.copyWith(error: state.message) ?? | ||||
|       const SizedBox.shrink(); | ||||
| 
 | ||||
|   Widget loadingBuilder(BuildContext context, CrudLoading state) => | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user