From be22a3d6fac9ba7e6cfb2487c1dcb6d19a69b0aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Tue, 9 Aug 2022 11:20:13 +0100 Subject: [PATCH] update Readme --- bricks/wyatt_feature_brick/README.md | 121 ++++++++++++++++++++++++--- 1 file changed, 108 insertions(+), 13 deletions(-) diff --git a/bricks/wyatt_feature_brick/README.md b/bricks/wyatt_feature_brick/README.md index a8678ed..3a04ebf 100644 --- a/bricks/wyatt_feature_brick/README.md +++ b/bricks/wyatt_feature_brick/README.md @@ -1,21 +1,116 @@ -# wyatt_feature_brick +# Feature Brick [![Powered by Mason](https://img.shields.io/endpoint?url=https%3A%2F%2Ftinyurl.com%2Fmason-badge)](https://github.com/felangel/mason) -A new brick created with the Mason CLI. -_Generated by [mason][1] 🧱_ -## Getting Started 🚀 -This is a starting point for a new brick. -A few resources to get you started if this is your first brick template: +A brick to create a feature using best practices and your state management of choice! Supports Bloc & Cubit. -- [Official Mason Documentation][2] -- [Code generation with Mason Blog][3] -- [Very Good Livestream: Felix Angelov Demos Mason][4] +## How to use 🚀 -[1]: https://github.com/felangel/mason -[2]: https://github.com/felangel/mason/tree/master/packages/mason_cli#readme -[3]: https://verygood.ventures/blog/code-generation-with-mason -[4]: https://youtu.be/G4PTjA6tpTU +``` +mason make feature_brick --feature_name audit --state_management cubit --use_equatable true +``` + +## Variables ✨ + +| Variable | Description | Default | Type | +| ------------------ | ------------------------------- | ------- | --------- | +| `feature_name` | The name of the feature | login | `string` | +| `state_management` | The state management of the app | cubit | `enum` | +| `use_equatable` | Use the equatable package | true | `boolean` | + +## Outputs 📦 + +### Using Bloc + +```shell +--feature_name login --state_management bloc +``` + +``` +├── feature +│ ├── blocs +| | └── feature_bloc +│ │ ├── feature_bloc.dart +│ │ ├── feature_event.dart +│ │ └── feature_state.dart +│ ├── state_management +| | └── ... +│ └── feature.dart +└── ... +``` + +- {{featureName}}_bloc.dart + +```dart +class FeatureBloc extends Bloc { + // TODO: Add repo if needed + FeatureBloc() : super(const FeatureInitial()) { + on(_onCustomFeatureEvent); + } + + FutureOr _onCustomFeatureEvent( + CustomFeatureEvent event, + Emitter emit, + ) { + // TODO: Add your logic + } +} +``` + +- {{featureName}}.dart + +only one event is generated. It is up to you to rename it and add other events. + +```dart +class CustomFeatureEvent extends FeatureEvent {} +``` + +- {{featureName}}_state.dart + +only one state is generated. It is up to you to rename it and add other states. + +```dart +class FeatureInitial extends FeatureState { + const FeatureInitial() : super(); +} +``` + + +### Using Cubit + +```shell +--feature_name login --state_management cubit +``` + +``` +├── feature +│ ├── cubits +| | └── feature_cubit +│ │ ├── feature_cubit.dart +│ │ └── feature_state.dart +│ ├── state_management +| | └── ... +│ └── feature.dart +└── ... +``` + +- {{featureName}}_cubit.dart + +```dart +class FeatureCubit extends Cubit { + // Add repo if needed + FeatureCubit() : super(const FeatureInitial()); + + FutureOr yourCustomFunction() { + // TODO: Add your logic + } +} +``` + +{{featureName}}_state.dart is the same file as before + +### None +TODO \ No newline at end of file