ui_layout/refactor/migrate-package-using-copywith-feature #120

Merged
hugo merged 2 commits from ui_layout/refactor/migrate-package-using-copywith-feature into master 2023-02-07 09:52:46 +00:00
9 changed files with 106 additions and 43 deletions

View File

@ -1,7 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart';
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart'; import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
class CustomAppBar extends AppBarComponent { part 'custom_app_bar.g.dart';
@ComponentCopyWithExtension()
class CustomAppBar extends AppBarComponent with $CustomAppBarCWMixin {
const CustomAppBar({ const CustomAppBar({
super.title, super.title,
super.key, super.key,
@ -11,14 +15,4 @@ class CustomAppBar extends AppBarComponent {
Widget build(BuildContext context) => AppBar( Widget build(BuildContext context) => AppBar(
title: Text(title ?? ''), title: Text(title ?? ''),
); );
@override
AppBarComponent? configure({
String? title,
Widget? leading,
List<Widget>? actions,
}) =>
CustomAppBar(
title: title ?? this.title,
);
} }

View File

@ -0,0 +1,36 @@
// 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,
key: key ?? _value.key,
);
}
mixin $CustomAppBarCWMixin on Component {
$AppBarComponentCWProxy get copyWith =>
$CustomAppBarCWProxyImpl(this as CustomAppBar);
}

View File

@ -1,7 +1,12 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart';
import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart'; import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart';
class CustomBottomNavigationBar extends BottomNavigationBarComponent { part 'custom_bottom_navigation_bar.g.dart';
@ComponentCopyWithExtension()
class CustomBottomNavigationBar extends BottomNavigationBarComponent
with $CustomBottomNavigationBarCWMixin {
const CustomBottomNavigationBar({ const CustomBottomNavigationBar({
super.currentIndex, super.currentIndex,
super.onTap, super.onTap,
@ -27,14 +32,4 @@ class CustomBottomNavigationBar extends BottomNavigationBarComponent {
), ),
], ],
); );
@override
CustomBottomNavigationBar? configure({
void Function(BuildContext, int)? onTap,
int currentIndex = 0,
}) =>
CustomBottomNavigationBar(
onTap: onTap ?? this.onTap,
currentIndex: currentIndex,
);
} }

View File

@ -0,0 +1,37 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'custom_bottom_navigation_bar.dart';
// **************************************************************************
// ComponentCopyWithGenerator
// **************************************************************************
class $CustomBottomNavigationBarCWProxyImpl
implements $BottomNavigationBarComponentCWProxy {
const $CustomBottomNavigationBarCWProxyImpl(this._value);
final CustomBottomNavigationBar _value;
@override
CustomBottomNavigationBar onTap(void Function(BuildContext, int)? onTap) =>
this(onTap: onTap);
@override
CustomBottomNavigationBar currentIndex(int? currentIndex) =>
this(currentIndex: currentIndex);
@override
CustomBottomNavigationBar key(Key? key) => this(key: key);
@override
CustomBottomNavigationBar call({
void Function(BuildContext, int)? onTap,
int? currentIndex,
Key? key,
}) =>
CustomBottomNavigationBar(
currentIndex: currentIndex ?? _value.currentIndex,
onTap: onTap ?? _value.onTap,
key: key ?? _value.key,
);
}
mixin $CustomBottomNavigationBarCWMixin on Component {
$BottomNavigationBarComponentCWProxy get copyWith =>
$CustomBottomNavigationBarCWProxyImpl(this as CustomBottomNavigationBar);
}

View File

@ -3,7 +3,7 @@ description: A new Flutter project.
# The following line prevents the package from being accidentally published to # The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages. # 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. # The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43 # A version number is three numbers separated by dots, like 1.2.43
@ -27,24 +27,32 @@ environment:
# the latest version available on pub.dev. To see which dependencies have newer # the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`. # versions available, run `flutter pub outdated`.
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
wyatt_ui_layout: wyatt_ui_layout:
path: "../" path: "../"
wyatt_ui_components: wyatt_ui_components:
git: git:
url: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages url: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages
path: packages/wyatt_ui_components path: packages/wyatt_ui_components
wyatt_component_copy_with_extension:
git:
url: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages
path: packages/wyatt_component_copy_with_extension
go_router: ^5.0.1 go_router: ^5.0.1
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
build_runner: ^2.3.3
wyatt_component_copy_with_gen:
git:
url: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages
path: packages/wyatt_component_copy_with_gen
wyatt_analysis: wyatt_analysis:
git: git:
@ -55,10 +63,8 @@ dev_dependencies:
# For information on the generic Dart part of this file, see the # For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec # following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter. # The following section is specific to Flutter.
flutter: flutter:
# The following line ensures that the Material Icons font is # The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in # included with your application, so that you can use the icons in
# the material Icons class. # the material Icons class.

View File

@ -35,7 +35,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( child: context.components.appBar?.copyWith(
title: title, title: title,
leading: leading, leading: leading,
actions: actions, actions: actions,

View File

@ -13,7 +13,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?.copyWith(
currentIndex: currentIndex ?? 0, currentIndex: currentIndex ?? 0,
), ),
); );

View File

@ -37,7 +37,7 @@ 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( child: context.components.appBar?.copyWith(
title: title, title: title,
leading: leading, leading: leading,
actions: actions, actions: actions,
@ -45,7 +45,7 @@ class FrameLayout extends Layout {
const SizedBox.shrink(), const SizedBox.shrink(),
), ),
body: body, body: body,
bottomNavigationBar: context.components.bottomNavigationBar?.configure( bottomNavigationBar: context.components.bottomNavigationBar?.copyWith(
currentIndex: currentIndex ?? 0, currentIndex: currentIndex ?? 0,
), ),
); );

View File

@ -4,28 +4,23 @@ repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/mas
version: 0.0.1 version: 0.0.1
environment: environment:
sdk: '>=2.17.0 <3.0.0' sdk: ">=2.17.0 <3.0.0"
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
wyatt_ui_components: wyatt_ui_components:
git: git:
url: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages url: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages
path: packages/wyatt_ui_components path: packages/wyatt_ui_components
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
wyatt_analysis: wyatt_analysis:
git: git:
url: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages url: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages
ref: wyatt_analysis-v2.3.0 ref: wyatt_analysis-v2.3.0
path: packages/wyatt_analysis path: packages/wyatt_analysis