feat(ui): add colors and rework ComponentThemeData
continuous-integration/drone/pr Build is failing

This commit is contained in:
2023-04-28 14:04:55 +02:00
parent a024b7e70a
commit abd5e1b558
28 changed files with 650 additions and 387 deletions
@@ -2,13 +2,13 @@ import 'package:wyatt_ui_components/wyatt_ui_components.dart';
import 'package:wyatt_ui_components_example/components/custom_app_bar.dart';
import 'package:wyatt_ui_components_example/components/custom_bottom_bar.dart';
import 'package:wyatt_ui_components_example/components/custom_error_widget.dart';
import 'package:wyatt_ui_components_example/components/custom_loading_widget.dart';
import 'package:wyatt_ui_components_example/components/custom_loader_widget.dart';
class AppThemeComponent {
static ComponentThemeData get components => const ComponentThemeData.raw(
appBar: CustomAppBar(),
topAppBar: CustomAppBar(),
bottomNavigationBar: CustomBottomNavigationBar(),
errorWidget: CustomErrorWidget(),
loadingWidget: CustomLoadingWidget(),
error: CustomErrorWidget(),
loader: CustomLoaderWidget(),
);
}
@@ -5,13 +5,17 @@ import 'package:wyatt_ui_components/wyatt_ui_components.dart';
part 'custom_error_widget.g.dart';
@ComponentCopyWithExtension()
class CustomErrorWidget extends ErrorWidgetComponent
with $CustomErrorWidgetCWMixin {
const CustomErrorWidget({super.error, super.key});
class CustomErrorWidget extends ErrorComponent with $CustomErrorWidgetCWMixin {
const CustomErrorWidget({
super.colors,
super.message,
super.details,
super.key,
});
@override
Widget build(BuildContext context) => ColoredBox(
color: Colors.red,
child: Center(child: Text(error?.data ?? 'Error')),
color: colors?.color ?? Colors.red,
child: Center(child: Text(message?.data ?? 'Error')),
);
}
@@ -6,25 +6,38 @@ part of 'custom_error_widget.dart';
// ComponentCopyWithGenerator
// **************************************************************************
class $CustomErrorWidgetCWProxyImpl implements $ErrorWidgetComponentCWProxy {
class $CustomErrorWidgetCWProxyImpl implements $ErrorComponentCWProxy {
const $CustomErrorWidgetCWProxyImpl(this._value);
final CustomErrorWidget _value;
@override
CustomErrorWidget error(TextWrapper? error) => this(error: error);
CustomErrorWidget colors(MultiColor? colors) => this(colors: colors);
@override
CustomErrorWidget message(TextWrapper? message) => this(message: message);
@override
CustomErrorWidget details(TextWrapper? details) => this(details: details);
@override
CustomErrorWidget themeResolver(
ThemeResolver<dynamic, dynamic, dynamic>? themeResolver) =>
this(themeResolver: themeResolver);
@override
CustomErrorWidget key(Key? key) => this(key: key);
@override
CustomErrorWidget call({
TextWrapper? error,
MultiColor? colors,
TextWrapper? message,
TextWrapper? details,
ThemeResolver<dynamic, dynamic, dynamic>? themeResolver,
Key? key,
}) =>
CustomErrorWidget(
error: error ?? _value.error,
colors: colors ?? _value.colors,
message: message ?? _value.message,
details: details ?? _value.details,
key: key ?? _value.key,
);
}
mixin $CustomErrorWidgetCWMixin on Component {
$ErrorWidgetComponentCWProxy get copyWith =>
$ErrorComponentCWProxy get copyWith =>
$CustomErrorWidgetCWProxyImpl(this as CustomErrorWidget);
}
@@ -2,17 +2,24 @@ import 'package:flutter/material.dart';
import 'package:wyatt_component_copy_with_extension/wyatt_component_copy_with_extension.dart';
import 'package:wyatt_ui_components/wyatt_ui_components.dart';
part 'custom_loading_widget.g.dart';
part 'custom_loader_widget.g.dart';
@ComponentCopyWithExtension()
class CustomLoadingWidget extends LoadingWidgetComponent
with $CustomLoadingWidgetCWMixin {
const CustomLoadingWidget({super.color, super.key});
class CustomLoaderWidget extends LoaderComponent
with $CustomLoaderWidgetCWMixin {
const CustomLoaderWidget({
super.colors,
super.duration,
super.flip,
super.radius,
super.stroke,
super.key,
});
@override
Widget build(BuildContext context) => Center(
child: CircularProgressIndicator(
color: color,
color: colors?.color ?? Colors.blue,
),
);
}
@@ -0,0 +1,51 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'custom_loader_widget.dart';
// **************************************************************************
// ComponentCopyWithGenerator
// **************************************************************************
class $CustomLoaderWidgetCWProxyImpl implements $LoaderComponentCWProxy {
const $CustomLoaderWidgetCWProxyImpl(this._value);
final CustomLoaderWidget _value;
@override
CustomLoaderWidget colors(MultiColor? colors) => this(colors: colors);
@override
CustomLoaderWidget radius(double? radius) => this(radius: radius);
@override
CustomLoaderWidget stroke(double? stroke) => this(stroke: stroke);
@override
CustomLoaderWidget duration(Duration? duration) => this(duration: duration);
@override
CustomLoaderWidget flip(bool? flip) => this(flip: flip);
@override
CustomLoaderWidget themeResolver(
ThemeResolver<dynamic, dynamic, dynamic>? themeResolver) =>
this(themeResolver: themeResolver);
@override
CustomLoaderWidget key(Key? key) => this(key: key);
@override
CustomLoaderWidget call({
MultiColor? colors,
double? radius,
double? stroke,
Duration? duration,
bool? flip,
ThemeResolver<dynamic, dynamic, dynamic>? themeResolver,
Key? key,
}) =>
CustomLoaderWidget(
colors: colors ?? _value.colors,
duration: duration ?? _value.duration,
flip: flip ?? _value.flip,
radius: radius ?? _value.radius,
stroke: stroke ?? _value.stroke,
key: key ?? _value.key,
);
}
mixin $CustomLoaderWidgetCWMixin on Component {
$LoaderComponentCWProxy get copyWith =>
$CustomLoaderWidgetCWProxyImpl(this as CustomLoaderWidget);
}
@@ -1,31 +0,0 @@
// 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,
key: key ?? _value.key,
);
}
mixin $CustomLoadingWidgetCWMixin on Component {
$LoadingWidgetComponentCWProxy get copyWith =>
$CustomLoadingWidgetCWProxyImpl(this as CustomLoadingWidget);
}
@@ -48,24 +48,23 @@ class Home extends StatelessWidget {
Widget build(BuildContext context) => Scaffold(
appBar: PreferredSize(
preferredSize: const Size.fromHeight(60),
child: context.components.appBar?.copyWith
.title(const TextWrapper('Example title')) ??
const SizedBox.shrink(),
child: context.components.topAppBarComponent
.title(const TextWrapper('Example title')),
),
body: Column(
children: [
Expanded(
child: context.components.errorWidget
?.copyWith(error: const TextWrapper('Example erreur')) ??
const SizedBox.shrink(),
child: context.components.errorComponent.call(
message: const TextWrapper('Example error'),
),
),
const SizedBox(
height: 10,
),
Expanded(
child: context.components.loadingWidget
?.copyWith(color: Colors.green) ??
const SizedBox.shrink(),
child: context.components.loaderComponent.call(
colors: const MultiColor.single(Colors.green),
),
),
],
),