-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bricks): add bloc brick (#3293)
- Loading branch information
Showing
11 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
analyzer: | ||
exclude: | ||
- bricks/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Bloc Bricks 🧱 | ||
|
||
[Mason](https://github.com/felange/mason) support for the [Bloc Library](https://bloclibrary.dev). A collection of bricks for effectively working with the bloc state management library. | ||
|
||
## Installation | ||
|
||
Ensure you have the [mason_cli](https://github.com/felangel/mason/packages/mason_cli) installed. Bricks can be installed from [brickhub.dev](https://brickhub.dev). | ||
|
||
```sh | ||
mason add <BRICK> | ||
``` | ||
|
||
## Bricks | ||
|
||
| Brick | Description | | ||
| ------ | ------------------- | | ||
| `bloc` | Generate a new Bloc | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# 0.1.0 | ||
|
||
- feat: initial release with support for basic bloc generation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# bloc | ||
|
||
Generate a new Bloc in [Dart][1]. Built for the [bloc state management library][2]. | ||
|
||
## Usage 🚀 | ||
|
||
```sh | ||
mason make bloc --name counter | ||
``` | ||
|
||
## Variables ✨ | ||
|
||
| Variable | Description | Default | Type | | ||
| -------- | -------------------------- | --------- | -------- | | ||
| `name` | The name of the bloc class | `counter` | `string` | | ||
|
||
## Output 📦 | ||
|
||
```sh | ||
├── counter_bloc.dart | ||
├── counter_event.dart | ||
└── counter_state.dart | ||
``` | ||
|
||
[1]: https://dart.dev | ||
[2]: https://github.com/felangel/bloc |
12 changes: 12 additions & 0 deletions
12
bricks/bloc/__brick__/{{#snakeCase}}{{name}}{{/snakeCase}}_bloc.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'package:bloc/bloc.dart'; | ||
|
||
part '{{#snakeCase}}{{name}}{{/snakeCase}}_event.dart'; | ||
part '{{#snakeCase}}{{name}}{{/snakeCase}}_state.dart'; | ||
|
||
class {{#pascalCase}}{{name}}{{/pascalCase}}Bloc extends Bloc<{{#pascalCase}}{{name}}{{/pascalCase}}Event, {{#pascalCase}}{{name}}{{/pascalCase}}State> { | ||
{{#pascalCase}}{{name}}{{/pascalCase}}Bloc() : super(const {{#pascalCase}}{{name}}{{/pascalCase}}State()) { | ||
on<{{#pascalCase}}{{name}}{{/pascalCase}}Event>((event, emit) { | ||
// TODO: implement event handler | ||
}); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
bricks/bloc/__brick__/{{#snakeCase}}{{name}}{{/snakeCase}}_event.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
part of '{{#snakeCase}}{{name}}{{/snakeCase}}_bloc.dart'; | ||
|
||
abstract class {{#pascalCase}}{{name}}{{/pascalCase}}Event { | ||
const {{#pascalCase}}{{name}}{{/pascalCase}}Event(); | ||
} |
5 changes: 5 additions & 0 deletions
5
bricks/bloc/__brick__/{{#snakeCase}}{{name}}{{/snakeCase}}_state.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
part of '{{#snakeCase}}{{name}}{{/snakeCase}}_bloc.dart'; | ||
|
||
class {{#pascalCase}}{{name}}{{/pascalCase}}State { | ||
const {{#pascalCase}}{{name}}{{/pascalCase}}State(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: bloc | ||
description: Generate a new Bloc 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 bloc class. | ||
default: counter | ||
prompt: Please enter the bloc name. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
bricks: | ||
bloc: | ||
path: ./bloc |