master #81

Closed
malo wants to merge 322 commits from master into feat/bloc_layout/new-package
8 changed files with 104 additions and 47 deletions
Showing only changes of commit 5fe8d84cf6 - Show all commits

View File

@ -16,15 +16,32 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
--> -->
# Flutter - Component Copy With Extension # Component Copy With Extension
<p align="left"> <p align="left">
<a href="https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_analysis"><img src="https://img.shields.io/badge/Style-Wyatt%20Analysis-blue.svg?style=flat-square" alt="Style: Wyatt Analysis" /></a> <a href="https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_analysis"><img src="https://img.shields.io/badge/Style-Wyatt%20Analysis-blue.svg?style=flat-square" alt="Style: Wyatt Analysis" /></a>
<img src="https://img.shields.io/badge/SDK-Flutter-blue?style=flat-square" alt="SDK: Flutter" /> <img src="https://img.shields.io/badge/SDK-Dart%20%7C%20Flutter-blue?style=flat-square" alt="SDK: Dart & Flutter" />
</p> </p>
This package provides annotations for generating code and simplifying the use of an UI kit within a Flutter application. **The package contains only the annotation classes**. This package provides annotations for generating code and simplifying the use of an UI kit within a Flutter application. **The package contains only the annotation classes**.
> This package does not contain Flutter specific code, but there is no sense in using it without Flutter.
## Summary
* `ComponentProxyExtension` - Annotation class for generating a proxy of a component of an UI kit.
* `ComponentCopyWithExtension` - Annotation class for generating the copyWith method of a component implementation.
For example, let's say we have a component of an UI kit that we want to use in our application.
1) We create the component in the `wyatt_ui_components` , add the `ComponentProxyExtension` annotation and generate the code. This component does not have any specific implementation, and only have a set of properties.
2) Now we implement the component in our ui kit, `wyatt_ui_kit` , add the `ComponentCopyWithExtension` annotation and generate the code. This component has a specific implementation and can be used in the application.
3) But we can implement multiple ui kits, and each of them can have their own implementation of the same component. And at the top of the application tree we can use the `wyatt_ui_components` package, which contains only the proxy of the component.
> In that way, the **application is UI kit agnostic**, and we can easily change the UI kit without changing the code of the application.
We will use the `LoaderComponent` component as an example in this documentation.
## Annotation Classes ## Annotation Classes
#### `ComponentProxyExtension` #### `ComponentProxyExtension`
@ -32,13 +49,13 @@ This package provides annotations for generating code and simplifying the use of
This annotation class is used to annotate a new component of an UI kit in the `wyatt_ui_components` package. It generates the abstract proxy of the component and allows access to all its properties in different packages and throughout the application. This annotation class is used to annotate a new component of an UI kit in the `wyatt_ui_components` package. It generates the abstract proxy of the component and allows access to all its properties in different packages and throughout the application.
```dart ```dart
part 'text_field_component.g.dart'; part 'loader_component.g.dart';
@ComponentProxyExtension() @ComponentProxyExtension()
abstract class TextFieldComponent extends Component { abstract class LoaderComponent extends Component
with CopyWithMixin<$TextFieldComponentCWProxy> { with CopyWithMixin<$LoaderComponentCWProxy> {
const TextFieldComponent({ const LoaderComponent({
... ...
}); });
} }
@ -46,16 +63,15 @@ abstract class TextFieldComponent extends Component {
#### `ComponentCopyWithExtension` #### `ComponentCopyWithExtension`
This annotation class is used to annotate the implementation of components directly in the application. It generates the implementation of the proxy and the mixin to ensure that the component meets the specifications defined in the `wyatt_ui_components package`. This annotation class is used to annotate the implementation of components directly in the application. It generates the implementation of the proxy and the mixin to ensure that the component meets the specifications defined in the `wyatt_ui_components package` .
```dart ```dart
part 'text_field_component.g.dart'; part 'loader.g.dart';
@ComponentProxyExtension() @ComponentCopyWithExtension()
abstract class TextFieldComponent extends Component { class Loader extends LoaderComponent with $LoaderCWMixin {
with CopyWithMixin<$TextFieldComponentCWProxy> {
const TextFieldComponent({ const Loader({
... ...
}); });
} }

View File

@ -1,5 +1,5 @@
include: package:wyatt_analysis/analysis_options.flutter.yaml include: package:wyatt_analysis/analysis_options.yaml

View File

@ -17,9 +17,29 @@
import 'package:meta/meta_meta.dart'; import 'package:meta/meta_meta.dart';
import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart'; import 'package:wyatt_component_copy_with_extension/component_copy_with_extension.dart';
/// Annotation used to indicate that the `copyWith` extension /// {@template component_copy_with_extension}
/// should be generated for the compononent. /// This annotation class is used to annotate the implementation of components
/// directly in the application. It generates the implementation of the proxy
/// and the mixin to ensure that the component meets the specifications
/// defined in the UI Kit.
///
/// Basically it indicate that the `copyWith` extension
/// should be generated for the component.
///
/// ```dart
/// part 'loader.g.dart';
///
/// @ComponentCopyWithExtension()
/// class Loader extends LoaderComponent with $LoaderCWMixin {
///
/// const Loader({
/// ...
/// });
/// }
/// ```
/// {@endtemplate}
@Target({TargetKind.classType}) @Target({TargetKind.classType})
class ComponentCopyWithExtension extends ComponentAnnotation { class ComponentCopyWithExtension extends ComponentAnnotation {
/// {@macro component_copy_with_extension}
const ComponentCopyWithExtension({super.skipFields}); const ComponentCopyWithExtension({super.skipFields});
} }

View File

@ -14,12 +14,32 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'package:meta/meta_meta.dart'; import 'package:meta/meta_meta.dart';
import 'package:wyatt_component_copy_with_extension/src/domain/component_annotation.dart';
/// {@template component_proxy_extension}
/// This annotation class is used to annotate a new component of an UI kit.
/// It generates the abstract proxy of the component and allows access to
/// all its properties in different packages and throughout the application.
///
/// ```dart
/// part 'loader_component.g.dart';
///
/// @ComponentProxyExtension()
/// abstract class LoaderComponent extends Component
/// with CopyWithMixin<$LoaderComponentCWProxy> {
///
/// const LoaderComponent({
/// ...
/// });
/// }
/// ```
///
/// The [skipFields] option allows you to directly and specifically change
/// a field. This makes it easier to use.
///
/// {@endtemplate}
@Target({TargetKind.classType}) @Target({TargetKind.classType})
class ComponentProxyExtension { class ComponentProxyExtension extends ComponentAnnotation {
const ComponentProxyExtension({ /// {@macro component_proxy_extension}
this.skipFields = true, const ComponentProxyExtension({super.skipFields});
});
final bool? skipFields;
} }

View File

@ -14,7 +14,11 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
/// {@template component_annotation}
/// Abstract class that is used as a base for all annotations
/// {@endtemplate}
abstract class ComponentAnnotation { abstract class ComponentAnnotation {
/// {@macro component_annotation}
const ComponentAnnotation({this.skipFields = true}); const ComponentAnnotation({this.skipFields = true});
/// Prevent the library from generating `copyWith` functions for individual /// Prevent the library from generating `copyWith` functions for individual

View File

@ -3,18 +3,15 @@ description: Extension for component copy with feature.
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/component_copy_with_extension repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/component_copy_with_extension
version: 1.0.0 version: 1.0.0
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
environment: environment:
sdk: ">=2.19.0 <3.0.0" sdk: ">=2.19.0 <3.0.0"
dependencies: dependencies:
meta: ^1.8.0 meta: ^1.8.0
path: ^1.8.0
dev_dependencies: dev_dependencies:
wyatt_analysis: wyatt_analysis:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^2.4.1 version: ^2.4.1
# The following section is specific to Flutter.
flutter:
uses-material-design: true

View File

@ -16,30 +16,32 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
--> -->
# Dart - Component Copy With Gen # Component Copy With Gen
<p align="left"> <p align="left">
<a href="https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_analysis"><img src="https://img.shields.io/badge/Style-Wyatt%20Analysis-blue.svg?style=flat-square" alt="Style: Wyatt Analysis" /></a> <a href="https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_analysis"><img src="https://img.shields.io/badge/Style-Wyatt%20Analysis-blue.svg?style=flat-square" alt="Style: Wyatt Analysis" /></a>
<img src="https://img.shields.io/badge/SDK-Dart%20%7C%20Flutter-blue?style=flat-square" alt="SDK: Dart & Flutter" /> <img src="https://img.shields.io/badge/SDK-Dart%20%7C%20Flutter-blue?style=flat-square" alt="SDK: Dart & Flutter" />
</p> </p>
A Dart package for generating code from annotations to ease the use of a UIKit in Flutter applications. The generated code is based on the annotation classes present in the 'wyatt_component_copy_with_extension' package. A Dart package for generating code from annotations to ease the use of a UIKit in Flutter applications. The generated code is based on the annotation classes present in the [ `wyatt_component_copy_with_extension` package](https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_component_copy_with_extension)
> This package does not contain Flutter specific code, but there is no sense in using it without Flutter.
## Features ## Features
- Supports the generation of abstract proxies in the `wyatt_ui_components` package. * Supports the generation of abstract proxies in the `wyatt_ui_components` package.
- Supports direct use in Flutter applications. * Supports direct use in Flutter applications.
## Usage ## Usage
### In the 'wyatt_ui_components' package ### In the 'wyatt_ui_components' package
- Add the appropriate annotation when addicdng a new component. * Add the appropriate annotation when adding a new component.
- Run the build runner command to generate the proxy. * Run the build runner command to generate the proxy.
### In Flutter applications ### In Flutter applications (or UI Kit implementations)
- Add the following dependencies to your pubspec.yaml: * Add the following dependencies to your pubspec.yaml:
```yaml ```yaml
dependencies: dependencies:
@ -51,7 +53,7 @@ dev_dependencies:
build_runner: ^2.3.3 build_runner: ^2.3.3
``` ```
- In your UIKit, extend the desired component class and add the appropriate annotation. * In your UIKit, extend the desired component class and add the appropriate annotation.
- Run the code generation command via the build runner. * Run the code generation command via the build runner.
For further details and additional features on class annotation, see the 'wyatt_component_copy_with_extension' package's README. For further details and additional features on class annotation, see the 'wyatt_component_copy_with_extension' package's README.

View File

@ -3,21 +3,19 @@ description: Generator for copywith method for components.
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/component_copy_with_gen repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/component_copy_with_gen
version: 1.0.0 version: 1.0.0
publish_to: "none" publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
environment: environment:
sdk: ">=2.19.0 <3.0.0" sdk: ">=2.19.0 <3.0.0"
dependencies: dependencies:
path: ^1.8.0
build: ^2.3.1 build: ^2.3.1
source_gen: ^1.2.7 source_gen: ^1.2.7
analyzer: ^5.4.0 analyzer: ^5.4.0
wyatt_component_copy_with_extension: wyatt_component_copy_with_extension:
git: hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git version: ^1.0.0
path: packages/wyatt_component_copy_with_extension
dev_dependencies: dev_dependencies:
test: ^1.21.0 test: ^1.21.0