Compare commits

..

7 Commits

Author SHA1 Message Date
AN12345
4f49f4931c refactor(ui_layout): update example (#92)
Some checks failed
continuous-integration/drone/push Build is failing
2022-12-12 14:21:48 -05:00
AN12345
e8172004a3 refactor(ui_component): update example (#92) 2022-12-12 14:21:13 -05:00
AN12345
c6d8ca37fe refactor(bloc_layout): update example (#92) 2022-12-12 14:20:20 -05:00
AN12345
e01f47d41a refactor(ui_layout): update package using nullable component data (#92) 2022-12-12 14:14:15 -05:00
AN12345
7a24a36af0 refactor(bloc_layout): update package using nullable component data (#92) 2022-12-12 14:13:00 -05:00
AN12345
244a286509 refactor(ui_components): update example (#92) 2022-12-12 14:10:41 -05:00
AN12345
81a7ca5a1f feat(ui_components): make component data field nullable (#92) 2022-12-12 14:08:36 -05:00
16 changed files with 41 additions and 35 deletions

View File

@ -18,7 +18,7 @@ class CustomAppBar extends AppBarComponent {
);
@override
AppBarComponent configure(
AppBarComponent? configure(
{String? title, Widget? leading, List<Widget>? 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,
);
}

View File

@ -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();

View File

@ -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<Cubit extends bloc_base.Cubit<CrudState>,
SuccessState extends CrudSuccess> extends CubitScreen<Cubit, CrudState> {
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();

View File

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

View File

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

View File

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

View File

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

View File

@ -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(),
),
],
),

View File

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

View File

@ -29,7 +29,7 @@ abstract class AppBarComponent extends Component {
});
@override
AppBarComponent configure({
AppBarComponent? configure({
String? title,
Widget? leading,
List<Widget>? 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});
}

View File

@ -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,
});
}

View File

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

View File

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

View File

@ -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,
);

View File

@ -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,
),
);

View File

@ -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,
),
);