Skip to content

Commit

Permalink
feat(bricks): add cubit brick (#3296)
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel authored Mar 26, 2022
1 parent ae7fe06 commit c15ebe6
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bricks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mason add <BRICK>

## Bricks

| Brick | Description |
| ------ | ------------------- |
| `bloc` | Generate a new Bloc |
| Brick | Description |
| ------- | -------------------- |
| `bloc` | Generate a new Bloc |
| `cubit` | Generate a new Cubit |
3 changes: 3 additions & 0 deletions bricks/cubit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 0.1.0

- feat: initial release with support for basic cubit generation
21 changes: 21 additions & 0 deletions bricks/cubit/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Felix Angelov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
25 changes: 25 additions & 0 deletions bricks/cubit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# cubit

Generate a new Cubit in [Dart][1]. Built for the [bloc state management library][2].

## Usage 🚀

```sh
mason make cubit --name counter
```

## Variables ✨

| Variable | Description | Default | Type |
| -------- | --------------------------- | --------- | -------- |
| `name` | The name of the cubit class | `counter` | `string` |

## Output 📦

```sh
├── counter_cubit.dart
└── counter_state.dart
```

[1]: https://dart.dev
[2]: https://github.com/felangel/bloc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'package:bloc/bloc.dart';

part '{{#snakeCase}}{{name}}{{/snakeCase}}_state.dart';

class {{#pascalCase}}{{name}}{{/pascalCase}}Cubit extends Cubit<{{#pascalCase}}{{name}}{{/pascalCase}}State> {
{{#pascalCase}}{{name}}{{/pascalCase}}Cubit() : super(const {{#pascalCase}}{{name}}{{/pascalCase}}State());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
part of '{{#snakeCase}}{{name}}{{/snakeCase}}_cubit.dart';

class {{#pascalCase}}{{name}}{{/pascalCase}}State {
const {{#pascalCase}}{{name}}{{/pascalCase}}State();
}
13 changes: 13 additions & 0 deletions bricks/cubit/brick.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: cubit
description: Generate a new Cubit in Dart | Built for the bloc state management library.
version: 0.1.0

environment:
mason: ">=0.1.0-dev <0.1.0"

vars:
name:
type: string
description: The name of the cubit class.
default: counter
prompt: Please enter the cubit name.
2 changes: 2 additions & 0 deletions bricks/mason.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
bricks:
bloc:
path: ./bloc
cubit:
path: ./cubit

0 comments on commit c15ebe6

Please sign in to comment.