refactor(ui_components): migrate components using code generator packages (#115)

This commit is contained in:
Malo Léon 2023-02-07 09:44:03 +01:00
parent 46c51525e8
commit cd3ed0fe69
25 changed files with 273 additions and 104 deletions

View File

@ -12,8 +12,10 @@ dependencies:
source_gen: ^1.2.7
analyzer: ^5.4.0
wyatt_component_copy_with_extension:
path: ../wyatt_component_copy_with_extension
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:
test: ^1.21.0

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 WYATT GROUP
* Copyright (C) 2023 WYATT GROUP
* Please see the AUTHORS file for details.
*
* This program is free software: you can redistribute it and/or modify
@ -17,8 +17,5 @@
*/
{
"recommendations": [
"psioniq.psi-header",
"blaugold.melos-code"
]
"recommendations": ["psioniq.psi-header", "blaugold.melos-code"]
}

View File

@ -1,5 +1,5 @@
<!--
* Copyright (C) 2022 WYATT GROUP
* Copyright (C) 2023 WYATT GROUP
* Please see the AUTHORS file for details.
* This program is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
# Copyright (C) 2022 WYATT GROUP
# Copyright (C) 2023 WYATT GROUP
# Please see the AUTHORS file for details.
#
# This program is free software: you can redistribute it and/or modify
@ -14,6 +14,4 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
include: package:wyatt_analysis/analysis_options.flutter.experimental.yaml

View File

@ -1,4 +1,4 @@
// Copyright (C) 2022 WYATT GROUP
// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright (C) 2022 WYATT GROUP
// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify

View File

@ -0,0 +1,19 @@
// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
mixin CopyWithMixin<Proxy> {
Proxy get copyWith;
}

View File

@ -1,4 +1,4 @@
// Copyright (C) 2022 WYATT GROUP
// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
@ -14,4 +14,4 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
export 'entities/components.dart';
export './entities/entities.dart';

View File

@ -0,0 +1,36 @@
// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:flutter/material.dart';
import 'package:wyatt_ui_components/src/core/mixins/copy_with_mixin.dart';
import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart';
import 'package:wyatt_ui_components/src/domain/entities/component.dart';
part 'app_bar_component.g.dart';
@ComponentProxyExtension()
abstract class AppBarComponent extends Component
with CopyWithMixin<$AppBarComponentCWProxy> {
final String? title;
final Widget? leading;
final List<Widget>? actions;
const AppBarComponent({
this.title,
this.leading,
this.actions,
super.key,
});
}

View File

@ -0,0 +1,20 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'app_bar_component.dart';
// **************************************************************************
// ComponentProxyGenerator
// **************************************************************************
abstract class $AppBarComponentCWProxy {
AppBarComponent title(String? title);
AppBarComponent leading(Widget? leading);
AppBarComponent actions(List<Widget>? actions);
AppBarComponent key(Key? key);
AppBarComponent call({
String? title,
Widget? leading,
List<Widget>? actions,
Key? key,
});
}

View File

@ -0,0 +1,34 @@
import 'package:flutter/material.dart';
// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:wyatt_ui_components/src/core/mixins/copy_with_mixin.dart';
import 'package:wyatt_ui_components/src/domain/entities/component.dart';
import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart';
part 'bottom_navigation_bar_component.g.dart';
@ComponentProxyExtension()
abstract class BottomNavigationBarComponent extends Component
with CopyWithMixin<$BottomNavigationBarComponentCWProxy> {
final int currentIndex;
final void Function(BuildContext, int)? onTap;
const BottomNavigationBarComponent({
this.onTap,
this.currentIndex = 0,
super.key,
});
}

View File

@ -0,0 +1,17 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'bottom_navigation_bar_component.dart';
// **************************************************************************
// ComponentProxyGenerator
// **************************************************************************
abstract class $BottomNavigationBarComponentCWProxy {
BottomNavigationBarComponent onTap(void Function(BuildContext, int)? onTap);
BottomNavigationBarComponent currentIndex(int? currentIndex);
BottomNavigationBarComponent key(Key? key);
BottomNavigationBarComponent call({
void Function(BuildContext, int)? onTap,
Key? key,
});
}

View File

@ -1,4 +1,4 @@
// Copyright (C) 2022 WYATT GROUP
// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
@ -18,6 +18,4 @@ import 'package:flutter/material.dart';
abstract class Component extends StatelessWidget {
const Component({super.key});
Component? configure();
}

View File

@ -1,69 +0,0 @@
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:flutter/material.dart';
import 'package:wyatt_ui_components/src/domain/entities/component.dart';
abstract class AppBarComponent extends Component {
final String? title;
final Widget? leading;
final List<Widget>? actions;
const AppBarComponent({
this.title,
this.leading,
this.actions,
super.key,
});
@override
AppBarComponent? configure({
String? title,
Widget? leading,
List<Widget>? actions,
});
}
abstract class BottomNavigationBarComponent extends Component {
final int currentIndex;
final void Function(BuildContext, int)? onTap;
const BottomNavigationBarComponent({
this.onTap,
this.currentIndex = 0,
super.key,
});
@override
BottomNavigationBarComponent? configure({
void Function(BuildContext, int)? onTap,
int currentIndex = 0,
});
}
abstract class ErrorWidgetComponent extends Component {
final String? error;
const ErrorWidgetComponent({required this.error, super.key});
@override
ErrorWidgetComponent? configure({String? error});
}
abstract class LoadingWidgetComponent extends Component {
final Color? color;
const LoadingWidgetComponent({required this.color, super.key});
@override
LoadingWidgetComponent? configure({Color? color});
}

View File

@ -0,0 +1,21 @@
// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
export './app_bar_component.dart';
export './bottom_navigation_bar_component.dart';
export './error_widget_component.dart';
export './loading_widget_component.dart';
export './component.dart';

View File

@ -0,0 +1,29 @@
// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:wyatt_ui_components/src/core/mixins/copy_with_mixin.dart';
import 'package:wyatt_ui_components/src/domain/entities/component.dart';
import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart';
import 'package:flutter/material.dart';
part 'error_widget_component.g.dart';
@ComponentProxyExtension()
abstract class ErrorWidgetComponent extends Component
with CopyWithMixin<$ErrorWidgetComponentCWProxy> {
final String? error;
const ErrorWidgetComponent({required this.error, super.key});
}

View File

@ -0,0 +1,16 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'error_widget_component.dart';
// **************************************************************************
// ComponentProxyGenerator
// **************************************************************************
abstract class $ErrorWidgetComponentCWProxy {
ErrorWidgetComponent error(String? error);
ErrorWidgetComponent key(Key? key);
ErrorWidgetComponent call({
String? error,
Key? key,
});
}

View File

@ -0,0 +1,29 @@
// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:flutter/material.dart';
import 'package:wyatt_ui_components/src/core/mixins/copy_with_mixin.dart';
import 'package:wyatt_ui_components/src/domain/entities/component.dart';
import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart';
part 'loading_widget_component.g.dart';
@ComponentProxyExtension()
abstract class LoadingWidgetComponent extends Component
with CopyWithMixin<$LoadingWidgetComponentCWProxy> {
final Color? color;
const LoadingWidgetComponent({required this.color, super.key});
}

View File

@ -0,0 +1,16 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'loading_widget_component.dart';
// **************************************************************************
// ComponentProxyGenerator
// **************************************************************************
abstract class $LoadingWidgetComponentCWProxy {
LoadingWidgetComponent color(Color? color);
LoadingWidgetComponent key(Key? key);
LoadingWidgetComponent call({
Color? color,
Key? key,
});
}

View File

@ -1,4 +1,4 @@
// Copyright (C) 2022 WYATT GROUP
// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright (C) 2022 WYATT GROUP
// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:wyatt_ui_components/src/domain/entities/components.dart';
import 'package:wyatt_ui_components/src/domain/entities/entities.dart';
class ComponentThemeData {
final AppBarComponent? appBar;

View File

@ -1,4 +1,4 @@
// Copyright (C) 2022 WYATT GROUP
// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify

View File

@ -1,4 +1,4 @@
// Copyright (C) 2022 WYATT GROUP
// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
export 'core/core.dart';
export 'core/core.dart';
export 'domain/domain.dart';
export 'features/features.dart';

View File

@ -1,4 +1,4 @@
// Copyright (C) 2022 WYATT GROUP
// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify

View File

@ -4,18 +4,25 @@ repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/mas
version: 0.0.1
environment:
sdk: '>=2.17.0 <3.0.0'
sdk: ">=2.17.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
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: