Compare commits

..

No commits in common. "4f49f4931cbd7ab380dd2aeb05693e065220672a" and "45c7bd6fcabe43520c2defda0cb603be6326204b" have entirely different histories.

16 changed files with 35 additions and 41 deletions

View File

@ -18,7 +18,7 @@ class CustomAppBar extends AppBarComponent {
); );
@override @override
AppBarComponent? configure( AppBarComponent configure(
{String? title, Widget? leading, List<Widget>? actions}) => {String? title, Widget? leading, List<Widget>? actions}) =>
CustomAppBar( CustomAppBar(
title: title ?? this.title, title: title ?? this.title,
@ -44,7 +44,7 @@ class CustomBottomBar extends BottomNavigationBarComponent {
); );
@override @override
BottomNavigationBarComponent? configure( BottomNavigationBarComponent configure(
{void Function(BuildContext p1, int p2)? onTap, {void Function(BuildContext p1, int p2)? onTap,
int currentIndex = 0}) => int currentIndex = 0}) =>
this; this;
@ -58,7 +58,7 @@ class CustomLoadingWidget extends LoadingWidgetComponent {
Center(child: CircularProgressIndicator(color: color)); Center(child: CircularProgressIndicator(color: color));
@override @override
LoadingWidgetComponent? configure({Color? color}) => CustomLoadingWidget( LoadingWidgetComponent configure({Color? color}) => CustomLoadingWidget(
color: color ?? this.color, color: color ?? this.color,
); );
} }
@ -73,7 +73,7 @@ class CustomErrorWidget extends ErrorWidgetComponent {
); );
@override @override
ErrorWidgetComponent? configure({String? error}) => CustomErrorWidget( ErrorWidgetComponent configure({String? error}) => CustomErrorWidget(
error: error ?? this.error, error: error ?? this.error,
); );
} }

View File

@ -27,11 +27,10 @@ abstract class CrudCubitConsumerScreenBase<
const CrudCubitConsumerScreenBase({super.key}); const CrudCubitConsumerScreenBase({super.key});
Widget errorBuilder(BuildContext context, CrudError state) => 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) => Widget loadingBuilder(BuildContext context, CrudLoading state) =>
context.components.loadingWidget ?? const SizedBox.shrink(); context.components.loadingWidget;
Widget initialBuilder(BuildContext context, CrudInitial state) => Widget initialBuilder(BuildContext context, CrudInitial state) =>
const SizedBox.shrink(); const SizedBox.shrink();

View File

@ -16,17 +16,17 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart' as bloc_base; 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'; import 'package:wyatt_bloc_layout/wyatt_bloc_layout.dart';
abstract class CrudCubitScreenBase<Cubit extends bloc_base.Cubit<CrudState>, abstract class CrudCubitScreenBase<Cubit extends bloc_base.Cubit<CrudState>,
SuccessState extends CrudSuccess> extends CubitScreen<Cubit, CrudState> { SuccessState extends CrudSuccess> extends CubitScreen<Cubit, CrudState> {
const CrudCubitScreenBase(); const CrudCubitScreenBase();
Widget errorBuilder(BuildContext context, CrudError state) => Widget errorBuilder(BuildContext context, CrudError state) =>
context.components.errorWidget?.configure(error: state.message) ?? context.components.errorWidget;
const SizedBox.shrink();
Widget loadingBuilder(BuildContext context, CrudLoading state) => Widget loadingBuilder(BuildContext context, CrudLoading state) =>
context.components.loadingWidget ?? const SizedBox.shrink(); context.components.loadingWidget;
Widget initialBuilder(BuildContext context, CrudInitial state) => Widget initialBuilder(BuildContext context, CrudInitial state) =>
const SizedBox.shrink(); const SizedBox.shrink();

View File

@ -10,7 +10,7 @@ class CustomAppBar extends AppBarComponent {
); );
@override @override
AppBarComponent? configure( AppBarComponent configure(
{String? title, Widget? leading, List<Widget>? actions}) => {String? title, Widget? leading, List<Widget>? actions}) =>
CustomAppBar( CustomAppBar(
title: title ?? this.title, title: title ?? this.title,

View File

@ -29,7 +29,7 @@ class CustomBottomNavigationBar extends BottomNavigationBarComponent {
); );
@override @override
CustomBottomNavigationBar? configure({ CustomBottomNavigationBar configure({
void Function(BuildContext, int)? onTap, void Function(BuildContext, int)? onTap,
int currentIndex = 0, int currentIndex = 0,
}) => }) =>

View File

@ -11,6 +11,6 @@ class CustomErrorWidget extends ErrorWidgetComponent {
); );
@override @override
ErrorWidgetComponent? configure({String? error}) => ErrorWidgetComponent configure({String? error}) =>
CustomErrorWidget(error: error ?? this.error); CustomErrorWidget(error: error ?? this.error);
} }

View File

@ -12,7 +12,7 @@ class CustomLoadingWidget extends LoadingWidgetComponent {
); );
@override @override
CustomLoadingWidget? configure({Color? color}) => CustomLoadingWidget( CustomLoadingWidget configure({Color? color}) => CustomLoadingWidget(
color: color ?? this.color, color: color ?? this.color,
); );
} }

View File

@ -50,23 +50,20 @@ class Home extends StatelessWidget {
Widget build(BuildContext context) => Scaffold( Widget build(BuildContext context) => Scaffold(
appBar: PreferredSize( appBar: PreferredSize(
preferredSize: const Size.fromHeight(60), 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( body: Column(
children: [ children: [
Expanded( Expanded(
child: context.components.errorWidget child: context.components.errorWidget
?.configure(error: 'Example erreur') ?? .configure(error: 'Example erreur'),
const SizedBox.shrink(),
), ),
const SizedBox( const SizedBox(
height: 10, height: 10,
), ),
Expanded( Expanded(
child: context.components.loadingWidget child: context.components.loadingWidget
?.configure(color: Colors.green) ?? .configure(color: Colors.green),
const SizedBox.shrink(),
), ),
], ],
), ),

View File

@ -19,5 +19,5 @@ import 'package:flutter/material.dart';
abstract class Component extends StatelessWidget { abstract class Component extends StatelessWidget {
const Component({super.key}); const Component({super.key});
Component? configure(); Component configure();
} }

View File

@ -29,7 +29,7 @@ abstract class AppBarComponent extends Component {
}); });
@override @override
AppBarComponent? configure({ AppBarComponent configure({
String? title, String? title,
Widget? leading, Widget? leading,
List<Widget>? actions, List<Widget>? actions,
@ -46,7 +46,7 @@ abstract class BottomNavigationBarComponent extends Component {
}); });
@override @override
BottomNavigationBarComponent? configure({ BottomNavigationBarComponent configure({
void Function(BuildContext, int)? onTap, void Function(BuildContext, int)? onTap,
int currentIndex = 0, int currentIndex = 0,
}); });
@ -57,7 +57,7 @@ abstract class ErrorWidgetComponent extends Component {
const ErrorWidgetComponent({required this.error, super.key}); const ErrorWidgetComponent({required this.error, super.key});
@override @override
ErrorWidgetComponent? configure({String? error}); ErrorWidgetComponent configure({String? error});
} }
abstract class LoadingWidgetComponent extends Component { abstract class LoadingWidgetComponent extends Component {
@ -65,5 +65,5 @@ abstract class LoadingWidgetComponent extends Component {
const LoadingWidgetComponent({required this.color, super.key}); const LoadingWidgetComponent({required this.color, super.key});
@override @override
LoadingWidgetComponent? configure({Color? color}); LoadingWidgetComponent configure({Color? color});
} }

View File

@ -17,15 +17,15 @@
import 'package:wyatt_ui_components/src/domain/entities/components.dart'; import 'package:wyatt_ui_components/src/domain/entities/components.dart';
class ComponentThemeData { class ComponentThemeData {
final AppBarComponent? appBar; final AppBarComponent appBar;
final BottomNavigationBarComponent? bottomNavigationBar; final BottomNavigationBarComponent bottomNavigationBar;
final ErrorWidgetComponent? errorWidget; final ErrorWidgetComponent errorWidget;
final LoadingWidgetComponent? loadingWidget; final LoadingWidgetComponent loadingWidget;
const ComponentThemeData.raw({ const ComponentThemeData.raw({
this.appBar, required this.appBar,
this.bottomNavigationBar, required this.bottomNavigationBar,
this.errorWidget, required this.errorWidget,
this.loadingWidget, required this.loadingWidget,
}); });
} }

View File

@ -13,7 +13,7 @@ class CustomAppBar extends AppBarComponent {
); );
@override @override
AppBarComponent? configure({ AppBarComponent configure({
String? title, String? title,
Widget? leading, Widget? leading,
List<Widget>? actions, List<Widget>? actions,

View File

@ -29,7 +29,7 @@ class CustomBottomNavigationBar extends BottomNavigationBarComponent {
); );
@override @override
CustomBottomNavigationBar? configure({ CustomBottomNavigationBar configure({
void Function(BuildContext, int)? onTap, void Function(BuildContext, int)? onTap,
int currentIndex = 0, int currentIndex = 0,
}) => }) =>

View File

@ -31,8 +31,7 @@ class AppBarLayout extends Layout {
Widget build(BuildContext context) => Scaffold( Widget build(BuildContext context) => Scaffold(
appBar: PreferredSize( appBar: PreferredSize(
preferredSize: const Size.fromHeight(60), preferredSize: const Size.fromHeight(60),
child: context.components.appBar?.configure(title: title) ?? child: context.components.appBar.configure(title: title),
const SizedBox.shrink(),
), ),
body: body, body: body,
); );

View File

@ -14,7 +14,7 @@ class BottomNavigationBarLayout extends Layout {
@override @override
Widget build(BuildContext context) => Scaffold( Widget build(BuildContext context) => Scaffold(
body: body, body: body,
bottomNavigationBar: context.components.bottomNavigationBar?.configure( bottomNavigationBar: context.components.bottomNavigationBar.configure(
currentIndex: currentIndex, currentIndex: currentIndex,
), ),
); );

View File

@ -34,11 +34,10 @@ class FrameLayout extends Layout {
Widget build(BuildContext context) => Scaffold( Widget build(BuildContext context) => Scaffold(
appBar: PreferredSize( appBar: PreferredSize(
preferredSize: const Size.fromHeight(60), preferredSize: const Size.fromHeight(60),
child: context.components.appBar?.configure(title: title) ?? child: context.components.appBar.configure(title: title),
const SizedBox.shrink(),
), ),
body: body, body: body,
bottomNavigationBar: context.components.bottomNavigationBar?.configure( bottomNavigationBar: context.components.bottomNavigationBar.configure(
currentIndex: currentIndex, currentIndex: currentIndex,
), ),
); );