<!--
 * 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/>.
-->

# Component Copy With Extension

<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>
  <img src="https://img.shields.io/badge/SDK-Dart%20%7C%20Flutter-blue?style=flat-square" alt="SDK: Dart & Flutter" />
</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 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

#### `ComponentProxyExtension`

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
part 'loader_component.g.dart';

@ComponentProxyExtension()
abstract class LoaderComponent extends Component
    with CopyWithMixin<$LoaderComponentCWProxy> {
  
  const LoaderComponent({
    ...
  });
}
```

#### `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` .

```dart
part 'loader.g.dart';

@ComponentCopyWithExtension()
class Loader extends LoaderComponent with $LoaderCWMixin {
  
  const Loader({
    ...
  });
}
```

## Additional features

The skipFields field allows you to directly and specifically change a field. This makes it easier to use. You can disable it through annotation.
