Compare commits

...
Author SHA1 Message Date
hugo 7fcb9e8ac3 chore(release): publish packages
- wyatt_bloc_helper@2.0.0
 - wyatt_type_utils@0.0.4
 - wyatt_authentication_bloc@0.4.0+3
 - wyatt_crud_bloc@0.1.0+2
 - wyatt_architecture@0.1.0+1
 - wyatt_form_bloc@0.2.0+2
2022-12-04 21:08:15 -05:00
hugo 2a4e29f38c chore(release): publish packages
- wyatt_architecture@0.1.0
 - wyatt_authentication_bloc@0.4.0+2
 - wyatt_crud_bloc@0.1.0+1
 - wyatt_form_bloc@0.2.0+1
2022-12-03 20:40:23 -05:00
hugo ca70f2eb1d feat(authentication)!: add repo in callback usecases (close #55) 2022-12-03 18:53:20 -05:00
hugo f123e537ae fix(authentication): allow email/password validators customization (closes #57) 2022-12-03 18:41:04 -05:00
AN12345 c3315d968c refactor(bloc_helper)!: update onWrap label (close #46) 2022-11-24 18:16:20 -05:00
AN12345 45312473d1 feat: add gen-class-models in melos scripts 2022-11-24 17:55:07 -05:00
AN12345 17e7bce9e6 refactor(architecture): update naming methodes (close #47) 2022-11-24 17:25:44 -05:00
hugo 3886ef080e fix(crud)!: use FutureOrResult extension (close #42) 2022-11-24 15:24:59 -05:00
hugo 626d951443 fix(authentication)!: use FutureOrResult extension (close #41) 2022-11-24 11:18:16 -05:00
hugo f36e0b51e0 feat(type): add Result extension on FutureOr type (close #40) 2022-11-23 19:13:04 -05:00
AN12345 80ce7aff91 fix(architecture): fix execute method on error handler. (#38) 2022-11-23 23:11:04 +00:00
AN12345 a9121b6862 refactor(architecture): update example. (close #38) 2022-11-23 23:11:04 +00:00
AN12345 54f92e8042 docs(architecture): generate class model. (#38) 2022-11-23 23:11:04 +00:00
AN12345 00393a6ba7 docs(architecture): update Readme. (#38) 2022-11-23 23:11:04 +00:00
AN12345 136e0e8c98 chore(architecture)!: update exports. (#38) 2022-11-23 23:11:04 +00:00
AN12345 500a6ae51d feat(architecture): update usecase en add & sepcific case. (#38) 2022-11-23 23:11:04 +00:00
AN12345 79fdde25fc feat(architecture): add obsevers for alternative usecase scenarions (#38) 2022-11-23 23:11:04 +00:00
Malo Léon 742bf1d614 Merge pull request 'config/update_project_management' (#32) from config/update_project_management into master
Reviewed-on: #32
Reviewed-by: Hugo Pointcheval <hugo@noreply@wyatt-studio.fr>
2022-11-22 02:33:48 +00:00
AN12345 0dbde68d7d typo: fix readme typo error 2022-11-21 21:32:36 -05:00
AN12345 cd881da072 doc: update readme 2022-11-21 21:20:25 -05:00
AN12345 5918a5cf1f doc: add simple workflow diagramm 2022-11-21 21:20:01 -05:00
AN12345 775d766d14 build: update melos configuration and update targets 2022-11-21 20:59:36 -05:00
AN12345 383098b147 build: add mason configuration files 2022-11-21 20:59:02 -05:00
AN12345 4d51e2b786 build: add coverage script 2022-11-21 20:58:18 -05:00
AN12345 32cc1f55d9 chore: update gitignore 2022-11-21 20:57:52 -05:00
AN12345 6ee101bf36 doc: update readme 2022-11-21 20:54:57 -05:00
hugo f0ed08bd49 feat(auth): add reloadCache method in AuthenticationCubit 2022-11-16 19:52:24 -05:00
hugo 390fb81b1e fix(auth): fix stream account, now including correctly extra data 2022-11-16 19:51:45 -05:00
hugo 279d451cd8 fix(auth): fix mock isNewUser 2022-11-16 19:48:03 -05:00
hugo a66db23ace chore(release): publish packages
- wyatt_authentication_bloc@0.4.0+1
2022-11-16 17:20:57 -05:00
hugo 3d7af98ac9 fix(auth): add sort of mutex on onAuthChanges callback trigger 2022-11-16 17:16:41 -05:00
AN12345 b033b97917 feat(notification_bloc) add new package for push notification management 2022-11-16 16:58:19 -05:00
hugo 14b7f31b53 chore(form): use hard link for vscode folder 2022-11-16 16:32:05 -05:00
hugo 403bcafe93 chore(form): remove vscode symlink 2022-11-16 16:30:49 -05:00
hugo 21ab6f6021 chore(auth): use hardlink for vscode folder 2022-11-16 16:27:51 -05:00
hugo 198ecac5da chore(auth): remove vscode symlink to fix publish 2022-11-16 16:18:23 -05:00
146 changed files with 3083 additions and 230 deletions
+3
View File
@@ -198,3 +198,6 @@ $RECYCLE.BIN/
*.iml *.iml
google-services.json google-services.json
pubspec_overrides.yaml pubspec_overrides.yaml
# Mason
.mason/
+97
View File
@@ -3,6 +3,103 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## 2022-12-04
### Changes
---
Packages with breaking changes:
- [`wyatt_bloc_helper` - `v2.0.0`](#wyatt_bloc_helper---v200)
Packages with other changes:
- [`wyatt_type_utils` - `v0.0.4`](#wyatt_type_utils---v004)
- [`wyatt_authentication_bloc` - `v0.4.0+3`](#wyatt_authentication_bloc---v0403)
- [`wyatt_crud_bloc` - `v0.1.0+2`](#wyatt_crud_bloc---v0102)
- [`wyatt_architecture` - `v0.1.0+1`](#wyatt_architecture---v0101)
- [`wyatt_form_bloc` - `v0.2.0+2`](#wyatt_form_bloc---v0202)
Packages with dependency updates only:
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
- `wyatt_authentication_bloc` - `v0.4.0+3`
- `wyatt_crud_bloc` - `v0.1.0+2`
- `wyatt_architecture` - `v0.1.0+1`
- `wyatt_form_bloc` - `v0.2.0+2`
---
#### `wyatt_bloc_helper` - `v2.0.0`
- **BREAKING** **REFACTOR**: update onWrap label (close #46).
#### `wyatt_type_utils` - `v0.0.4`
- **FEAT**: add Result extension on FutureOr type (close #40).
## 2022-12-03
### Changes
---
Packages with breaking changes:
- [`wyatt_architecture` - `v0.1.0`](#wyatt_architecture---v010)
Packages with other changes:
- [`wyatt_authentication_bloc` - `v0.4.0+2`](#wyatt_authentication_bloc---v0402)
- [`wyatt_crud_bloc` - `v0.1.0+1`](#wyatt_crud_bloc---v0101)
- [`wyatt_form_bloc` - `v0.2.0+1`](#wyatt_form_bloc---v0201)
Packages with dependency updates only:
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
- `wyatt_authentication_bloc` - `v0.4.0+2`
- `wyatt_crud_bloc` - `v0.1.0+1`
- `wyatt_form_bloc` - `v0.2.0+1`
---
#### `wyatt_architecture` - `v0.1.0`
- **REFACTOR**: update naming methodes (close #47).
- **REFACTOR**: update example. (close #38).
- **FIX**: fix execute method on error handler. (#38).
- **FEAT**: update usecase en add & sepcific case. (#38).
- **FEAT**: add obsevers for alternative usecase scenarions (#38).
- **DOCS**: generate class model. (#38).
- **DOCS**: update Readme. (#38).
- **BREAKING** **CHORE**: update exports. (#38).
## 2022-11-16
### Changes
---
Packages with breaking changes:
- There are no breaking changes in this release.
Packages with other changes:
- [`wyatt_authentication_bloc` - `v0.4.0+1`](#wyatt_authentication_bloc---v0401)
---
#### `wyatt_authentication_bloc` - `v0.4.0+1`
- **FIX**: add sort of mutex on onAuthChanges callback trigger.
## 2022-11-16 ## 2022-11-16
### Changes ### Changes
+125 -17
View File
@@ -51,36 +51,51 @@ and open source.
--- ---
## Development ## Contribution
Clone this repo. Clone this repo.
You have to install [melos](https://github.com/invertase/melos). ```shell
git clone ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-packages.git
```
### Prerequisite
- [Flutter](https://github.com/flutter/flutter).
- [Melos](https://github.com/invertase/melos). Used to manage Dart projects with multiple packages.
```shell ```shell
dart pub global activate melos dart pub global activate melos
``` ```
Then bootstrap with `melos bs`. - [Mason](https://github.com/felangel/mason). Used for code generation.
```shell
dart pub global activate mason_cli
```
- [Lcov](https://github.com/linux-test-project/lcov). Used to generate coverage data.
```shell
# on macos
brew install lcov
```
- genhtml. Used to convert coverage data into html pages.
After installing all these packages, bootstrap with `melos bs`.
### Create a new package ### Create a new package
Create a new package in `packages/` folder. Create a new package in `packages/` folder.
```shell ```shell
dart create -t package-simple wyatt_<name> mason make wyatt_package --package_name wyatt_<name> --description A new Wyatt package --flutter_only false
```
Remove any `example/` subfolder. Then create a new sample project.
```shell
flutter create --platforms android --project-name <name>_example example
``` ```
Then bootstrap project with `melos bs` command. Then bootstrap project with `melos bs` command.
### Convention
#### Naming #### Naming
In the previous instructions `<name>` variable is important. In the previous instructions `<name>` variable is important.
@@ -93,15 +108,44 @@ You **MUST** use `wyatt` prefix for package.
You **MUST** name example with specific name. You **MUST** name example with specific name.
For example, if name is CRUD BLOC For example, if name is CRUD BLOC
- name will be crud_bloc - name will be crud_bloc
- so the package will be: `wyatt_crud_bloc` - so the package will be: `wyatt_crud_bloc`
- and the example will be: `crud_bloc_example` - and the example will be: `crud_bloc_example`
#### Commits ### Create issues
Add the issues directly related to what you want to develop and label them correctly.
```
Type(scope): issue.
```
For example, on notification bloc package :
- `Feature(notification_bloc): add firebase messaging data source.`
- `Test(notification_bloc): add test for pushwoosh datasource.`
### Branches
Master is protected. You can't push on it. Please develop your feature on another branch. The name of your branch has to match with the issue opened.
`type(scope):issue`
Example :
Issue :
- `Feature(notification_bloc): add firebase messaging data source.`
Branch related to this issue :
- `feature(notification_bloc)/add_firebase_messaging_data_source`
### Commits
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
tl;dr : `type(scope): description`. tl;dr : `type(scope): description #issue`.
Here allowed <type> values: Here allowed <type> values:
- **feat** for a new feature for the user, not a new feature for build script. Such commit will trigger a release bumping a MINOR version. - **feat** for a new feature for the user, not a new feature for build script. Such commit will trigger a release bumping a MINOR version.
@@ -115,11 +159,68 @@ Here allowed <type> values:
Some examples : Some examples :
- `feat(auth): add AWS support.` = add a feature in authentication_bloc package. - `feat(auth): add AWS support. (#31)` = add a feature in authentication_bloc package, linked to the 31st issue.
- `docs: update readme.` = update **this** readme file. - `docs: update readme.` = update **this** readme file.
- `fix(crud)!: fix bug in awesome() function.` = fix a bug, `!` is important and indicate `BREAKING CHANGES`. - `fix(crud)!: fix bug in awesome() function. (#32)` = fix a bug, `!` is important and indicate `BREAKING CHANGES` linked with the 32nd issue.
Conventional commits are important for `melos version` command ! When you have finished developing, and are ready to close the issue, close it via your commit :
`feat(auth): add AWS support. (close #31)`
Note that your issue will be close after merging on master.
Before closing the issue, please check tests and update coverage. You might run :
```shell
melos run test
melos run gen_coverage
```
#### Merge your work
After closing your issue, some work may have been done on master in the meantime. To keep a clean git history, please rebase before opening a change request.
Two situations :
- You have not yet created your branch and have committed locally :
```shell
git pull --rebase
```
- You are already working on your branch :
```shell
git rebase -i master
```
If possible, please use `--fixup` on your commit in interactive rebase.
Then, opend your PR, get the necessary approval and merge your work. Then you're done ✅.
#### Update version.
Once your work is on the master, you can update your package version. Please filter packages to update only your package. `--scope` is used to do it.
For example, after merging changes on `wyatt_otification_bloc` package, you might run :
```shell
melos version --scope="*wyatt_notification_bloc*"
```
In fact, melos will filter all packages that match the `wyatt_notification_block` pattern.
You can update check all packages tests by running :
```shell
melos run test
```
#### Publish your package
If package is ready for procution, publish it runnig :
```shell
melos publish --scope"*package*"
```
#### Badging #### Badging
@@ -130,6 +231,7 @@ In the package `readme.md` file, please specify the supported SDK:
```markdown ```markdown
![SDK: Dart & Flutter](https://img.shields.io/badge/SDK-Dart%20%7C%20Flutter-blue?style=flat-square) ![SDK: Dart & Flutter](https://img.shields.io/badge/SDK-Dart%20%7C%20Flutter-blue?style=flat-square)
``` ```
or or
![SDK: Dart](https://img.shields.io/badge/SDK-Dart-blue?style=flat-square) ![SDK: Dart](https://img.shields.io/badge/SDK-Dart-blue?style=flat-square)
@@ -162,3 +264,9 @@ Here you can change `package name` and `package version`.
![Status: Experimental](https://img.shields.io/badge/Status-WIP-red?style=flat-square) ![Status: Experimental](https://img.shields.io/badge/Status-WIP-red?style=flat-square)
This repository is maintained by Wyatt Studio but work is in progress. This repository is maintained by Wyatt Studio but work is in progress.
## Simple work flow diagramm
To sum up, here a simple work flow diagramm.
![Dev Wokflow](doc/workflow.svg)
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
escapedPath="$(echo `pwd` | sed 's/\//\\\//g')"
if grep flutter pubspec.yaml > /dev/null; then
if [ -d "coverage" ]; then
# combine line coverage info from package tests to a common file
if [ ! -d "$MELOS_ROOT_PATH/coverage" ]; then
mkdir "$MELOS_ROOT_PATH/coverage"
fi
sed "s/^SF:lib/SF:$escapedPath\/lib/g" coverage/lcov.info >> "$MELOS_ROOT_PATH/coverage/lcov.info"
rm -rf "coverage"
fi
fi
+15
View File
@@ -0,0 +1,15 @@
@startuml Simple Developpment Workflow
start
:Create an issue;
:Create branch related to the issue;
repeat :Commit related to the issue;
repeat while (feature is done)
:Update coverage;
:Close issue via last commit;
:Rebase from `master`;
:Create pull request;
:Merge branches;
:Update version;
:Publish package;
stop
@enduml
+25
View File
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 7.5 KiB

+1
View File
@@ -0,0 +1 @@
{"bricks":{"wyatt_clean_code":{"git":{"url":"ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-bricks.git","path":"bricks/wyatt_clean_code","ref":"033baa65408ec6b68e6a2ef43e64c24708ef16a1"}},"wyatt_feature_brick":{"git":{"url":"ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-bricks.git","path":"bricks/wyatt_feature_brick","ref":"033baa65408ec6b68e6a2ef43e64c24708ef16a1"}},"wyatt_package":{"git":{"url":"ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-bricks.git","path":"bricks/wyatt_package","ref":"033baa65408ec6b68e6a2ef43e64c24708ef16a1"}}}}
+13
View File
@@ -0,0 +1,13 @@
bricks:
wyatt_clean_code:
git:
url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-bricks.git
path: bricks/wyatt_clean_code
wyatt_feature_brick:
git:
url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-bricks.git
path: bricks/wyatt_feature_brick
wyatt_package:
git:
url: ssh://git@git.wyatt-studio.fr:993/Wyatt-FOSS/wyatt-bricks.git
path: bricks/wyatt_package
+14
View File
@@ -37,6 +37,20 @@ scripts:
run: git clean -x -d -f -q run: git clean -x -d -f -q
description: Clean things very deeply with `git clean`. description: Clean things very deeply with `git clean`.
test:selective_unit_test:
run: melos exec --dir-exists="test" -- flutter test --no-pub --coverage
description: Run Flutter tests for a specific package in this project.
select-package:
flutter: true
test:
run: melos run test:selective_unit_test --no-select
description: Run all Flutter tests in this project.
gen-coverage: melos exec -- sh "\$MELOS_ROOT_PATH/combine_coverage.sh" && genhtml coverage/lcov.info -o coverage/html
gen-class-models: melos exec --scope="*wyatt_*" -- dart pub global run dcdg -o models/class-models.puml
# Additional cleanup lifecycle script, executed when `melos clean` is run. # Additional cleanup lifecycle script, executed when `melos clean` is run.
postclean: > postclean: >
melos exec -c 6 -- "flutter clean" melos exec -c 6 -- "flutter clean"
+17
View File
@@ -1,3 +1,20 @@
## 0.1.0+1
- Update a dependency to the latest release.
## 0.1.0
> Note: This release has breaking changes.
- **REFACTOR**: update naming methodes (close #47).
- **REFACTOR**: update example. (close #38).
- **FIX**: fix execute method on error handler. (#38).
- **FEAT**: update usecase en add & sepcific case. (#38).
- **FEAT**: add obsevers for alternative usecase scenarions (#38).
- **DOCS**: generate class model. (#38).
- **DOCS**: update Readme. (#38).
- **BREAKING** **CHORE**: update exports. (#38).
## 0.0.2 ## 0.0.2
- Graduate package to a stable release. See pre-releases prior to this version for changelog entries. - Graduate package to a stable release. See pre-releases prior to this version for changelog entries.
+59 -10
View File
@@ -31,10 +31,10 @@ The Wyatt Architecture for Flutter.
## Features ## Features
* Usecase - Usecase
* Repository - Repository
* DataSource - DataSource
* Entity - Entity
## Usage ## Usage
@@ -75,16 +75,17 @@ abstract class PhotoRepository extends BaseRepository {
> Here the repository is just a proxy of the data sources with result type (to have beautiful error handling). > Here the repository is just a proxy of the data sources with result type (to have beautiful error handling).
And finaly create your different usecases by using `UseCase<Parameters, ReturnType>` : And finaly create your different usecases :
Several use cases are supported :
- Classic usecase :
```dart ```dart
class RetrieveAllPhoto extends UseCase<QueryParameters, List<Photo>> { class Test extends AsyncUseCase<QueryParameters, List<Photo>>> {
final PhotoRepository _photoRepository;
RetrieveAllPhotos(this._photoRepository);
@override @override
FutureResult<List<Photo>> call(QueryParameters params) { FuturOrResult<List<Photo>>> call(QueryParameters? params) {
final photos = _photoRepository.getAllPhotos( final photos = _photoRepository.getAllPhotos(
start: params.start, start: params.start,
limit: params.limit, limit: params.limit,
@@ -94,6 +95,54 @@ class RetrieveAllPhoto extends UseCase<QueryParameters, List<Photo>> {
} }
``` ```
You can add alternatve scenarios and check pre/post conditions using our extensions :
```dart
class SearchPhotos extends AsyncUseCase<QueryParameters, List<Photo>>> {
@override
FutureOrResult<List<Photo>>> call(QueryParameters? params) {
final photos = _photoRepository.getAllPhotos(
start: params.start,
limit: params.limit,
);
return photos;
}
@override
FutureOr<void> onStart(QueryParameters? params) {
if(params.start == null || params.limit == null){
throw ClientException('Préconndition non valides');
}
}
}
```
You can implement error scenarios overriding `onError`, or check postconditions by overriding `onComplete` .
- Stream usecase :
```dart
class SearchPhotos extends StreamUseCase<QueryParameters, List<Photo>>> {
@override
FutureOrResult<Stream<List<Photo>>>> call(QueryParameters? params) {
final photos = _photoRepository.getAllPhotos(
start: params.start,
limit: params.limit,
);
return photos;
}
}
```
On this case, observers allow you to add alternative scénarios when data changed, overriding `onData` or `onDone`.
Please note that to use handlers, call `call` method and not `execute`.
> In fact, here we need a new parameter object, so let's create it: > In fact, here we need a new parameter object, so let's create it:
```dart ```dart
@@ -35,46 +35,47 @@ class PhotoRepositoryImpl extends PhotoRepository {
); );
@override @override
FutureResult<void> addPhotoToFavorites(Photo photo) => Result.tryCatchAsync( FutureOrResult<void> addPhotoToFavorites(Photo photo) => Result.tryCatchAsync(
() => _favoriteLocalDataSource.addPhotoToFavorites(photo), () => _favoriteLocalDataSource.addPhotoToFavorites(photo),
(error) => ClientException('Cannot add photo to favorites.'), (error) => ClientException('Cannot add photo to favorites.'),
); );
@override @override
FutureResult<bool> checkIfPhotoIsInFavorites(int id) => Result.tryCatchAsync( FutureOrResult<bool> checkIfPhotoIsInFavorites(int id) =>
Result.tryCatchAsync(
() => _favoriteLocalDataSource.checkIfPhotoIsInFavorites(id), () => _favoriteLocalDataSource.checkIfPhotoIsInFavorites(id),
(error) => (error) =>
ClientException('Cannot check if photo `$id` is in favorites.'), ClientException('Cannot check if photo `$id` is in favorites.'),
); );
@override @override
FutureResult<void> deletePhotoFromFavorites(int id) => Result.tryCatchAsync( FutureOrResult<void> deletePhotoFromFavorites(int id) => Result.tryCatchAsync(
() => _favoriteLocalDataSource.deletePhotoFromFavorites(id), () => _favoriteLocalDataSource.deletePhotoFromFavorites(id),
(error) => ClientException('Cannot delete photo `$id` from favorites.'), (error) => ClientException('Cannot delete photo `$id` from favorites.'),
); );
@override @override
FutureResult<Album> getAlbum(int id) => Result.tryCatchAsync( FutureOrResult<Album> getAlbum(int id) => Result.tryCatchAsync(
() => _albumRemoteDataSource.getAlbum(id), () => _albumRemoteDataSource.getAlbum(id),
(error) => ServerException('Cannot retrieve album $id.'), (error) => ServerException('Cannot retrieve album $id.'),
); );
@override @override
FutureResult<List<Album>> getAllAlbums({int? start, int? limit}) => FutureOrResult<List<Album>> getAllAlbums({int? start, int? limit}) =>
Result.tryCatchAsync( Result.tryCatchAsync(
() => _albumRemoteDataSource.getAllAlbums(start: start, limit: limit), () => _albumRemoteDataSource.getAllAlbums(start: start, limit: limit),
(error) => ServerException('Cannot retrieve all albums.'), (error) => ServerException('Cannot retrieve all albums.'),
); );
@override @override
FutureResult<List<Photo>> getAllPhotos({int? start, int? limit}) async => FutureOrResult<List<Photo>> getAllPhotos({int? start, int? limit}) async =>
Result.tryCatchAsync( Result.tryCatchAsync(
() => _photoRemoteDataSource.getAllPhotos(start: start, limit: limit), () => _photoRemoteDataSource.getAllPhotos(start: start, limit: limit),
(error) => ServerException('Cannot retrieve all photos.'), (error) => ServerException('Cannot retrieve all photos.'),
); );
@override @override
FutureResult<List<Photo>> getAllPhotosFromFavorites() async { FutureOrResult<List<Photo>> getAllPhotosFromFavorites() async {
try { try {
final response = <Photo>[]; final response = <Photo>[];
final favorites = final favorites =
@@ -95,13 +96,13 @@ class PhotoRepositoryImpl extends PhotoRepository {
} }
@override @override
FutureResult<Photo> getPhoto(int id) => Result.tryCatchAsync( FutureOrResult<Photo> getPhoto(int id) => Result.tryCatchAsync(
() => _photoRemoteDataSource.getPhoto(id), () => _photoRemoteDataSource.getPhoto(id),
(error) => ServerException('Cannot retrieve photo $id.'), (error) => ServerException('Cannot retrieve photo $id.'),
); );
@override @override
FutureResult<List<Photo>> getPhotosFromAlbum( FutureOrResult<List<Photo>> getPhotosFromAlbum(
int albumId, { int albumId, {
int? start, int? start,
int? limit, int? limit,
@@ -19,17 +19,17 @@ import 'package:architecture_example/domain/entities/photo.dart';
import 'package:wyatt_architecture/wyatt_architecture.dart'; import 'package:wyatt_architecture/wyatt_architecture.dart';
abstract class PhotoRepository extends BaseRepository { abstract class PhotoRepository extends BaseRepository {
FutureResult<Album> getAlbum(int id); FutureOrResult<Album> getAlbum(int id);
FutureResult<List<Album>> getAllAlbums({int? start, int? limit}); FutureOrResult<List<Album>> getAllAlbums({int? start, int? limit});
FutureResult<Photo> getPhoto(int id); FutureOrResult<Photo> getPhoto(int id);
FutureResult<List<Photo>> getAllPhotos({int? start, int? limit}); FutureOrResult<List<Photo>> getAllPhotos({int? start, int? limit});
FutureResult<List<Photo>> getPhotosFromAlbum( FutureOrResult<List<Photo>> getPhotosFromAlbum(
int albumId, { int albumId, {
int? start, int? start,
int? limit, int? limit,
}); });
FutureResult<void> addPhotoToFavorites(Photo photo); FutureOrResult<void> addPhotoToFavorites(Photo photo);
FutureResult<void> deletePhotoFromFavorites(int id); FutureOrResult<void> deletePhotoFromFavorites(int id);
FutureResult<List<Photo>> getAllPhotosFromFavorites(); FutureOrResult<List<Photo>> getAllPhotosFromFavorites();
FutureResult<bool> checkIfPhotoIsInFavorites(int id); FutureOrResult<bool> checkIfPhotoIsInFavorites(int id);
} }
@@ -14,18 +14,27 @@
// 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/>.
import 'dart:async';
import 'package:architecture_example/domain/entities/photo.dart'; import 'package:architecture_example/domain/entities/photo.dart';
import 'package:architecture_example/domain/repositories/photo_repository.dart'; import 'package:architecture_example/domain/repositories/photo_repository.dart';
import 'package:wyatt_architecture/wyatt_architecture.dart'; import 'package:wyatt_architecture/wyatt_architecture.dart';
class AddPhotoToFavorites extends UseCase<Photo, List<Photo>> { class AddPhotoToFavorites extends AsyncUseCase<Photo, List<Photo>> {
final PhotoRepository _photoRepository; final PhotoRepository _photoRepository;
AddPhotoToFavorites(this._photoRepository); AddPhotoToFavorites(this._photoRepository);
@override @override
FutureResult<List<Photo>> call(Photo params) async { FutureOrResult<List<Photo>> execute(Photo? params) async {
await _photoRepository.addPhotoToFavorites(params); await _photoRepository.addPhotoToFavorites(params!);
return _photoRepository.getAllPhotosFromFavorites(); return _photoRepository.getAllPhotosFromFavorites();
} }
@override
FutureOr<void> onStart(Photo? params) {
if (params == null) {
throw ClientException('Photo cannot be null');
}
}
} }
@@ -14,15 +14,24 @@
// 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/>.
import 'dart:async';
import 'package:architecture_example/domain/repositories/photo_repository.dart'; import 'package:architecture_example/domain/repositories/photo_repository.dart';
import 'package:wyatt_architecture/wyatt_architecture.dart'; import 'package:wyatt_architecture/wyatt_architecture.dart';
class CheckIfPhotoIsInFavorites extends UseCase<int, bool> { class CheckIfPhotoIsInFavorites extends AsyncUseCase<int, bool> {
final PhotoRepository _photoRepository; final PhotoRepository _photoRepository;
CheckIfPhotoIsInFavorites(this._photoRepository); CheckIfPhotoIsInFavorites(this._photoRepository);
@override @override
FutureResult<bool> call(int params) async => FutureOrResult<bool> execute(int? params) async =>
_photoRepository.checkIfPhotoIsInFavorites(params); _photoRepository.checkIfPhotoIsInFavorites(params!);
@override
FutureOr<void> onStart(int? params) {
if (params == null) {
throw ClientException('id cannot be null');
}
}
} }
@@ -18,13 +18,13 @@ import 'package:architecture_example/domain/entities/photo.dart';
import 'package:architecture_example/domain/repositories/photo_repository.dart'; import 'package:architecture_example/domain/repositories/photo_repository.dart';
import 'package:wyatt_architecture/wyatt_architecture.dart'; import 'package:wyatt_architecture/wyatt_architecture.dart';
class DisplayFavorites extends UseCase<void, List<Photo>> { class DisplayFavorites extends AsyncUseCase<NoParam, List<Photo>> {
final PhotoRepository _photoRepository; final PhotoRepository _photoRepository;
DisplayFavorites(this._photoRepository); DisplayFavorites(this._photoRepository);
@override @override
FutureResult<List<Photo>> call(void params) { FutureOrResult<List<Photo>> execute(void params) {
final photos = _photoRepository.getAllPhotosFromFavorites(); final photos = _photoRepository.getAllPhotosFromFavorites();
return photos; return photos;
} }
@@ -14,18 +14,27 @@
// 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/>.
import 'dart:async';
import 'package:architecture_example/domain/entities/photo.dart'; import 'package:architecture_example/domain/entities/photo.dart';
import 'package:architecture_example/domain/repositories/photo_repository.dart'; import 'package:architecture_example/domain/repositories/photo_repository.dart';
import 'package:wyatt_architecture/wyatt_architecture.dart'; import 'package:wyatt_architecture/wyatt_architecture.dart';
class DisplayPhoto extends UseCase<int, Photo> { class DisplayPhoto extends AsyncUseCase<int, Photo> {
final PhotoRepository _photoRepository; final PhotoRepository _photoRepository;
DisplayPhoto(this._photoRepository); DisplayPhoto(this._photoRepository);
@override @override
FutureResult<Photo> call(int params) { FutureOrResult<Photo> execute(int? params) {
final photo = _photoRepository.getPhoto(params); final photo = _photoRepository.getPhoto(params!);
return photo; return photo;
} }
@override
FutureOr<void> onStart(int? params) {
if (params == null) {
throw ClientException('id cannot be null');
}
}
} }
@@ -14,24 +14,33 @@
// 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/>.
import 'dart:async';
import 'package:architecture_example/domain/entities/photo.dart'; import 'package:architecture_example/domain/entities/photo.dart';
import 'package:architecture_example/domain/repositories/photo_repository.dart'; import 'package:architecture_example/domain/repositories/photo_repository.dart';
import 'package:architecture_example/domain/usecases/photos/params/query_parameters.dart'; import 'package:architecture_example/domain/usecases/photos/params/query_parameters.dart';
import 'package:wyatt_architecture/wyatt_architecture.dart'; import 'package:wyatt_architecture/wyatt_architecture.dart';
class OpenAlbum extends UseCase<QueryParameters, List<Photo>> { class OpenAlbum extends AsyncUseCase<QueryParameters, List<Photo>> {
final PhotoRepository _photoRepository; final PhotoRepository _photoRepository;
OpenAlbum(this._photoRepository); OpenAlbum(this._photoRepository);
@override @override
FutureResult<List<Photo>> call(QueryParameters params) { FutureOrResult<List<Photo>> execute(QueryParameters? params) {
final photos = _photoRepository.getPhotosFromAlbum( final photos = _photoRepository.getPhotosFromAlbum(
params.albumId, params!.albumId,
start: params.start, start: params.start,
limit: params.limit, limit: params.limit,
); );
return photos; return photos;
} }
@override
FutureOr<void> onStart(QueryParameters? params) {
if (params == null) {
throw ClientException('params cannot be null');
}
}
} }
@@ -14,18 +14,27 @@
// 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/>.
import 'dart:async';
import 'package:architecture_example/domain/entities/photo.dart'; import 'package:architecture_example/domain/entities/photo.dart';
import 'package:architecture_example/domain/repositories/photo_repository.dart'; import 'package:architecture_example/domain/repositories/photo_repository.dart';
import 'package:wyatt_architecture/wyatt_architecture.dart'; import 'package:wyatt_architecture/wyatt_architecture.dart';
class RemovePhotoFromFavorites extends UseCase<int, List<Photo>> { class RemovePhotoFromFavorites extends AsyncUseCase<int, List<Photo>> {
final PhotoRepository _photoRepository; final PhotoRepository _photoRepository;
RemovePhotoFromFavorites(this._photoRepository); RemovePhotoFromFavorites(this._photoRepository);
@override @override
FutureResult<List<Photo>> call(int params) async { FutureOrResult<List<Photo>> execute(int? params) async {
await _photoRepository.deletePhotoFromFavorites(params); await _photoRepository.deletePhotoFromFavorites(params!);
return _photoRepository.getAllPhotosFromFavorites(); return _photoRepository.getAllPhotosFromFavorites();
} }
@override
FutureOr<void> onStart(int? params) {
if (params == null) {
throw ClientException('id cannot be null');
}
}
} }
@@ -14,22 +14,31 @@
// 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/>.
import 'dart:async';
import 'package:architecture_example/domain/entities/album.dart'; import 'package:architecture_example/domain/entities/album.dart';
import 'package:architecture_example/domain/repositories/photo_repository.dart'; import 'package:architecture_example/domain/repositories/photo_repository.dart';
import 'package:architecture_example/domain/usecases/photos/params/query_parameters.dart'; import 'package:architecture_example/domain/usecases/photos/params/query_parameters.dart';
import 'package:wyatt_architecture/wyatt_architecture.dart'; import 'package:wyatt_architecture/wyatt_architecture.dart';
class RetrieveAllAlbums extends UseCase<QueryParameters, List<Album>> { class RetrieveAllAlbums extends AsyncUseCase<QueryParameters, List<Album>> {
final PhotoRepository _photoRepository; final PhotoRepository _photoRepository;
RetrieveAllAlbums(this._photoRepository); RetrieveAllAlbums(this._photoRepository);
@override @override
FutureResult<List<Album>> call(QueryParameters params) { FutureOrResult<List<Album>> execute(QueryParameters? params) {
final albums = _photoRepository.getAllAlbums( final albums = _photoRepository.getAllAlbums(
start: params.start, start: params!.start,
limit: params.limit, limit: params.limit,
); );
return albums; return albums;
} }
@override
FutureOr<void> onStart(QueryParameters? params) {
if (params == null) {
throw ClientException('params cannot be null');
}
}
} }
@@ -36,7 +36,7 @@ dependencies:
wyatt_type_utils: wyatt_type_utils:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^0.0.3+1 version: ^0.0.4
wyatt_http_client: wyatt_http_client:
git: git:
@@ -49,7 +49,7 @@ dependencies:
wyatt_bloc_helper: wyatt_bloc_helper:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/ hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^1.2.0 version: ^2.0.0
equatable: ^2.0.5 equatable: ^2.0.5
stream_transform: ^2.1.0 stream_transform: ^2.1.0
bloc_concurrency: ^0.2.0 bloc_concurrency: ^0.2.0
@@ -0,0 +1,44 @@
// Copyright (C) 2022 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/>.
import 'dart:async';
import 'package:wyatt_architecture/wyatt_architecture.dart';
/// Usecase observers
mixin Observer<Parameters, ReturnType> {
/// Called before usecase is runned.
/// Usefull to check the preconditions
FutureOr<void> onStart(Parameters? params) {}
/// Called when error occures during main scenario
/// Usefull to run alternative scenario
FutureOr<void> onError(AppException? error) {}
}
/// Specific observer for classic usecase
mixin AsyncObserver<ReturnType> {
FutureOr<void> onComplete(ReturnType? data) {}
}
/// Specific observer for stream case usecase
mixin StreamObserver<ReturnType> {
/// Replaces the data event handler of this subscription.
void onDone() {}
/// Replaces the done event handler of this subscription.
void onData(ReturnType? data) {}
}
@@ -14,14 +14,67 @@
// 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/>.
import 'dart:async';
import 'package:wyatt_architecture/src/core/exceptions/exceptions.dart'; import 'package:wyatt_architecture/src/core/exceptions/exceptions.dart';
import 'package:wyatt_architecture/src/domain/usecases/observers.dart';
import 'package:wyatt_type_utils/wyatt_type_utils.dart'; import 'package:wyatt_type_utils/wyatt_type_utils.dart';
typedef FutureResult<T> = Future<Result<T, AppException>>; typedef FutureOrResult<T> = FutureOr<Result<T, AppException>>;
typedef StreamResult<T> = Stream<Result<T, AppException>>; typedef StreamResult<T> = Stream<Result<T, AppException>>;
typedef Res<T> = Result<T, AppException>;
// ignore: one_member_abstracts /// Abstract class of a use case
abstract class UseCase<Parameters, ReturnType> { abstract class BaseUseCase<Parameters, ReturnType> {
FutureResult<ReturnType> call(Parameters params); /// Run use case scenarios
ReturnType call(Parameters parameters);
/// Private function to implement main scenario
/// of your usecase.
ReturnType execute(Parameters params);
}
/// Abstract class of a use case that deals specifically
/// with the response and its state.
abstract class UseCase<Parameters, ReturnType>
extends BaseUseCase<Parameters?, FutureOrResult<ReturnType>>
with Observer<Parameters, ReturnType> {
FutureOr<void> _onSuccess(ReturnType data);
/// Supports the result of the main scenario and integrates
/// some alternative scenarios if necessary.
@override
FutureOrResult<ReturnType> call(Parameters? parameters) async {
try {
await onStart(parameters);
final response = await execute(parameters);
if (response.isErr) {
await onError(response.err);
} else if (response.isOk && response.ok != null) {
await _onSuccess(response.ok as ReturnType);
}
return response;
} catch (e) {
return Err(ClientException(e.toString()));
}
}
}
/// Abtstract classic usecase.
abstract class AsyncUseCase<Parameters, ReturnType>
extends UseCase<Parameters?, ReturnType> with AsyncObserver<ReturnType> {
@override
FutureOr<void> _onSuccess(ReturnType data) => onComplete(data);
}
/// Abstract specific usecase bases on streams
abstract class StreamUseCase<Parameters, ReturnType>
extends UseCase<Parameters?, Stream<ReturnType>>
with StreamObserver<ReturnType> {
@override
FutureOr<void> _onSuccess(Stream<ReturnType> data) {
data.listen(
onData,
onDone: onDone,
);
}
} }
@@ -15,4 +15,5 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
export 'no_param.dart'; export 'no_param.dart';
export 'observers.dart';
export 'usecase.dart'; export 'usecase.dart';
Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

@@ -0,0 +1,86 @@
@startuml
set namespaceSeparator ::
abstract class "wyatt_architecture::src::core::exceptions::exceptions.dart::AppException" {
+String? message
+String toString()
}
"dart::core::Exception" <|-- "wyatt_architecture::src::core::exceptions::exceptions.dart::AppException"
class "wyatt_architecture::src::core::exceptions::exceptions.dart::ClientException" {
}
"wyatt_architecture::src::core::exceptions::exceptions.dart::AppException" <|-- "wyatt_architecture::src::core::exceptions::exceptions.dart::ClientException"
class "wyatt_architecture::src::core::exceptions::exceptions.dart::ServerException" {
}
"wyatt_architecture::src::core::exceptions::exceptions.dart::AppException" <|-- "wyatt_architecture::src::core::exceptions::exceptions.dart::ServerException"
abstract class "wyatt_architecture::src::domain::repositories::base_repository.dart::BaseRepository" {
}
abstract class "wyatt_architecture::src::domain::data_sources::local::base_local_data_source.dart::BaseLocalDataSource" {
}
"wyatt_architecture::src::domain::data_sources::base_data_source.dart::BaseDataSource" <|-- "wyatt_architecture::src::domain::data_sources::local::base_local_data_source.dart::BaseLocalDataSource"
abstract class "wyatt_architecture::src::domain::data_sources::base_data_source.dart::BaseDataSource" {
}
abstract class "wyatt_architecture::src::domain::data_sources::remote::base_remote_data_source.dart::BaseRemoteDataSource" {
}
"wyatt_architecture::src::domain::data_sources::base_data_source.dart::BaseDataSource" <|-- "wyatt_architecture::src::domain::data_sources::remote::base_remote_data_source.dart::BaseRemoteDataSource"
class "wyatt_architecture::src::domain::usecases::no_param.dart::NoParam" {
}
"wyatt_architecture::src::domain::entities::entity.dart::Entity" <|-- "wyatt_architecture::src::domain::usecases::no_param.dart::NoParam"
abstract class "wyatt_architecture::src::domain::usecases::observers.dart::Observer" {
+FutureOr<void> onStart()
+FutureOr<void> onError()
}
abstract class "wyatt_architecture::src::domain::usecases::observers.dart::AsyncObserver" {
+FutureOr<void> onComplete()
}
abstract class "wyatt_architecture::src::domain::usecases::observers.dart::StreamObserver" {
+void onDone()
+void onData()
}
abstract class "wyatt_architecture::src::domain::usecases::usecase.dart::BaseUseCase" {
+ReturnType execute()
+ReturnType call()
}
abstract class "wyatt_architecture::src::domain::usecases::usecase.dart::UseCase" {
-FutureOr<void> _onSuccess()
+FutureOr<Result<ReturnType, AppException>> execute()
}
"wyatt_architecture::src::domain::usecases::usecase.dart::BaseUseCase" <|-- "wyatt_architecture::src::domain::usecases::usecase.dart::UseCase"
"wyatt_architecture::src::domain::usecases::observers.dart::Observer" <|-- "wyatt_architecture::src::domain::usecases::usecase.dart::UseCase"
abstract class "wyatt_architecture::src::domain::usecases::usecase.dart::AsyncUseCase" {
-FutureOr<void> _onSuccess()
}
"wyatt_architecture::src::domain::usecases::usecase.dart::UseCase" <|-- "wyatt_architecture::src::domain::usecases::usecase.dart::AsyncUseCase"
"wyatt_architecture::src::domain::usecases::observers.dart::AsyncObserver" <|-- "wyatt_architecture::src::domain::usecases::usecase.dart::AsyncUseCase"
abstract class "wyatt_architecture::src::domain::usecases::usecase.dart::StreamUseCase" {
-FutureOr<void> _onSuccess()
}
"wyatt_architecture::src::domain::usecases::usecase.dart::UseCase" <|-- "wyatt_architecture::src::domain::usecases::usecase.dart::StreamUseCase"
"wyatt_architecture::src::domain::usecases::observers.dart::StreamObserver" <|-- "wyatt_architecture::src::domain::usecases::usecase.dart::StreamUseCase"
abstract class "wyatt_architecture::src::domain::entities::entity.dart::Entity" {
}
@enduml
+2 -2
View File
@@ -1,7 +1,7 @@
name: wyatt_architecture name: wyatt_architecture
description: A new Wyatt package description: A new Wyatt package
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_architecture repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_architecture
version: 0.0.2 version: 0.1.0+1
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
@@ -15,7 +15,7 @@ dependencies:
wyatt_type_utils: wyatt_type_utils:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
version: ^0.0.3+1 version: ^0.0.4
dev_dependencies: dev_dependencies:
@@ -1 +1,2 @@
firebase_options.dart firebase_options.dart
.vscode
@@ -1 +0,0 @@
../../.vscode/
@@ -0,0 +1,76 @@
{
// Dart
"dart.runPubGetOnPubspecChanges": "never",
// Gitea
"gitea.owner": "Wyatt-FOSS",
"gitea.repo": "wyatt-packages",
// Header
"psi-header.changes-tracking": {
"isActive": true
},
"psi-header.config": {
"blankLinesAfter": 1,
"forceToTop": true
},
"psi-header.lang-config": [
{
"beforeHeader": [
"# -*- coding:utf-8 -*-",
"#!/usr/bin/env python3"
],
"begin": "###",
"end": "###",
"language": "python",
"prefix": "# "
},
{
"beforeHeader": [
"#!/usr/bin/env sh",
""
],
"language": "shellscript",
"begin": "",
"end": "",
"prefix": "# "
},
{
"begin": "",
"end": "",
"language": "dart",
"prefix": "// "
},
{
"begin": "",
"end": "",
"language": "yaml",
"prefix": "# "
},
{
"begin": "<!--",
"end": "-->",
"language": "markdown",
},
],
"psi-header.templates": [
{
"language": "*",
"template": [
"Copyright (C) <<year>> 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/>."
],
}
],
}
@@ -1,3 +1,15 @@
## 0.4.0+3
- Update a dependency to the latest release.
## 0.4.0+2
- Update a dependency to the latest release.
## 0.4.0+1
- **FIX**: add sort of mutex on onAuthChanges callback trigger.
## 0.4.0 ## 0.4.0
> Note: This release has breaking changes. > Note: This release has breaking changes.
@@ -0,0 +1,30 @@
// Copyright (C) 2022 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/>.
import 'package:wyatt_form_bloc/wyatt_form_bloc.dart';
class CustomPassword extends RegexValidator<ValidationStandardError> {
const CustomPassword.pure([super.value]) : super.pure();
const CustomPassword.dirty([super.value]) : super.dirty();
@override
ValidationStandardError get onEmpty => ValidationStandardError.empty;
@override
ValidationStandardError get onError => ValidationStandardError.invalid;
@override
RegExp get regex => RegExp(r'^(?=.*[A-Za-z\w\s])(?=.*\d).{6,}$');
}
@@ -3,7 +3,7 @@
// ----- // -----
// File: app.dart // File: app.dart
// Created Date: 19/08/2022 12:05:38 // Created Date: 19/08/2022 12:05:38
// Last Modified: Thu Nov 10 2022 // Last Modified: Sat Dec 03 2022
// ----- // -----
// Copyright (c) 2022 // Copyright (c) 2022
@@ -13,6 +13,7 @@ import 'dart:math';
import 'package:example_router/core/constants/form_field.dart'; import 'package:example_router/core/constants/form_field.dart';
import 'package:example_router/core/dependency_injection/get_it.dart'; import 'package:example_router/core/dependency_injection/get_it.dart';
import 'package:example_router/core/routes/router.dart'; import 'package:example_router/core/routes/router.dart';
import 'package:example_router/core/utils/custom_password.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
@@ -21,7 +22,8 @@ import 'package:wyatt_form_bloc/wyatt_form_bloc.dart';
import 'package:wyatt_type_utils/wyatt_type_utils.dart'; import 'package:wyatt_type_utils/wyatt_type_utils.dart';
import 'package:wyatt_architecture/wyatt_architecture.dart'; import 'package:wyatt_architecture/wyatt_architecture.dart';
FutureResult<int?> onSignUpSuccess( FutureOrResult<int?> onSignUpSuccess(
AuthenticationRepository<int> repo,
Account? account, Account? account,
WyattForm form, WyattForm form,
) async { ) async {
@@ -34,9 +36,15 @@ FutureResult<int?> onSignUpSuccess(
return const Ok<int, AppException>(id); return const Ok<int, AppException>(id);
} }
FutureResult<int?> onAccountChanges(Account? account) async { FutureOrResult<int?> onAccountChanges(
AuthenticationRepository<int> repo,
Account? account,
) async {
final id = Random().nextInt(1000); final id = Random().nextInt(1000);
debugPrint('onAccountChanges: $account, generatedId: $id'); final token =
await repo.getIdentityToken().fold((value) => value, (error) => 'null');
debugPrint('onAccountChanges: $account, token: $token, generatedId: $id');
return Ok<int, AppException>(id); return Ok<int, AppException>(id);
} }
@@ -47,6 +55,7 @@ class App extends StatelessWidget {
authenticationRemoteDataSource: getIt<AuthenticationRemoteDataSource>(), authenticationRemoteDataSource: getIt<AuthenticationRemoteDataSource>(),
onSignUpSuccess: onSignUpSuccess, onSignUpSuccess: onSignUpSuccess,
onAuthChange: onAccountChanges, onAuthChange: onAccountChanges,
customPasswordValidator: const CustomPassword.pure(),
extraSignUpInputs: [ extraSignUpInputs: [
FormInput( FormInput(
AppFormField.confirmedPassword, AppFormField.confirmedPassword,
@@ -3,10 +3,11 @@
// ----- // -----
// File: sign_in_form.dart // File: sign_in_form.dart
// Created Date: 19/08/2022 15:24:37 // Created Date: 19/08/2022 15:24:37
// Last Modified: Wed Nov 16 2022 // Last Modified: Sat Dec 03 2022
// ----- // -----
// Copyright (c) 2022 // Copyright (c) 2022
import 'package:example_router/core/utils/custom_password.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:wyatt_authentication_bloc/wyatt_authentication_bloc.dart'; import 'package:wyatt_authentication_bloc/wyatt_authentication_bloc.dart';
import 'package:wyatt_form_bloc/wyatt_form_bloc.dart'; import 'package:wyatt_form_bloc/wyatt_form_bloc.dart';
@@ -38,7 +39,8 @@ class _PasswordInput extends StatelessWidget {
field: AuthFormField.password, field: AuthFormField.password,
builder: ((context, cubit, state, field, input) { builder: ((context, cubit, state, field, input) {
return TextField( return TextField(
onChanged: (pwd) => cubit.passwordChanged(pwd), onChanged: (pwd) => cubit
.passwordCustomChanged<CustomPassword>(CustomPassword.dirty(pwd)),
obscureText: true, obscureText: true,
decoration: InputDecoration( decoration: InputDecoration(
labelText: 'Password', labelText: 'Password',
@@ -59,7 +61,9 @@ class _SignInButton extends StatelessWidget {
return status.isSubmissionInProgress return status.isSubmissionInProgress
? const CircularProgressIndicator() ? const CircularProgressIndicator()
: ElevatedButton( : ElevatedButton(
onPressed: status.isValidated ? () => cubit.signInWithEmailAndPassword() : null, onPressed: status.isValidated
? () => cubit.signInWithEmailAndPassword()
: null,
child: const Text('Sign in with credentials'), child: const Text('Sign in with credentials'),
); );
}), }),
@@ -3,11 +3,12 @@
// ----- // -----
// File: sign_up_form.dart // File: sign_up_form.dart
// Created Date: 19/08/2022 14:41:08 // Created Date: 19/08/2022 14:41:08
// Last Modified: Wed Nov 16 2022 // Last Modified: Sat Dec 03 2022
// ----- // -----
// Copyright (c) 2022 // Copyright (c) 2022
import 'package:example_router/core/constants/form_field.dart'; import 'package:example_router/core/constants/form_field.dart';
import 'package:example_router/core/utils/custom_password.dart';
import 'package:flutter/material.dart' hide FormField; import 'package:flutter/material.dart' hide FormField;
import 'package:wyatt_authentication_bloc/wyatt_authentication_bloc.dart'; import 'package:wyatt_authentication_bloc/wyatt_authentication_bloc.dart';
import 'package:wyatt_form_bloc/wyatt_form_bloc.dart'; import 'package:wyatt_form_bloc/wyatt_form_bloc.dart';
@@ -40,7 +41,8 @@ class _PasswordInput extends StatelessWidget {
builder: ((context, cubit, state, field, input) { builder: ((context, cubit, state, field, input) {
return TextField( return TextField(
onChanged: (pwd) { onChanged: (pwd) {
cubit.passwordChanged(pwd); cubit.passwordCustomChanged<CustomPassword>(
CustomPassword.dirty(pwd));
cubit.dataChanged( cubit.dataChanged(
AppFormField.confirmedPassword, AppFormField.confirmedPassword,
ConfirmedPassword.dirty( ConfirmedPassword.dirty(
@@ -40,15 +40,15 @@ dependencies:
wyatt_form_bloc: wyatt_form_bloc:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/ hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: 0.2.0 version: 0.2.0+2
wyatt_architecture: wyatt_architecture:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/ hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: 0.0.2 version: 0.1.0+1
wyatt_type_utils: wyatt_type_utils:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/ hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: 0.0.3+1 version: 0.0.4
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
@@ -114,6 +114,7 @@ class AuthenticationMockDataSourceImpl extends AuthenticationRemoteDataSource {
providerId: 'wyatt', providerId: 'wyatt',
creationTime: creation, creationTime: creation,
lastSignInTime: creation, lastSignInTime: creation,
isNewUser: creation == creation,
); );
_streamAccount.add(mock); _streamAccount.add(mock);
_connectedMock = _connectedMock?.copyWith(left: mock); _connectedMock = _connectedMock?.copyWith(left: mock);
@@ -188,6 +189,7 @@ class AuthenticationMockDataSourceImpl extends AuthenticationRemoteDataSource {
email: email, email: email,
creationTime: creation, creationTime: creation,
lastSignInTime: creation, lastSignInTime: creation,
isNewUser: creation == creation,
); );
_streamAccount.add(mock); _streamAccount.add(mock);
_registeredMock = Pair(mock, password); _registeredMock = Pair(mock, password);
@@ -14,6 +14,9 @@
// 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/>.
import 'dart:async';
import 'package:rxdart/rxdart.dart';
import 'package:wyatt_architecture/wyatt_architecture.dart'; import 'package:wyatt_architecture/wyatt_architecture.dart';
import 'package:wyatt_authentication_bloc/src/core/constants/form_field.dart'; import 'package:wyatt_authentication_bloc/src/core/constants/form_field.dart';
import 'package:wyatt_authentication_bloc/src/core/constants/form_name.dart'; import 'package:wyatt_authentication_bloc/src/core/constants/form_name.dart';
@@ -26,12 +29,16 @@ import 'package:wyatt_authentication_bloc/src/domain/repositories/authentication
import 'package:wyatt_form_bloc/wyatt_form_bloc.dart'; import 'package:wyatt_form_bloc/wyatt_form_bloc.dart';
import 'package:wyatt_type_utils/wyatt_type_utils.dart'; import 'package:wyatt_type_utils/wyatt_type_utils.dart';
typedef OnSignUpSuccess<T> = FutureResult<T?> Function( typedef OnSignUpSuccess<T> = FutureOrResult<T?> Function(
AuthenticationRepository<T> repo,
Account? account, Account? account,
WyattForm form, WyattForm form,
); );
typedef OnAuthChange<T> = FutureResult<T?> Function(Account? account); typedef OnAuthChange<T> = FutureOrResult<T?> Function(
AuthenticationRepository<T> repo,
Account? account,
);
class AuthenticationRepositoryImpl<T extends Object> class AuthenticationRepositoryImpl<T extends Object>
extends AuthenticationRepository<T> { extends AuthenticationRepository<T> {
@@ -43,6 +50,10 @@ class AuthenticationRepositoryImpl<T extends Object>
final OnSignUpSuccess<T>? _onSignUpSuccess; final OnSignUpSuccess<T>? _onSignUpSuccess;
final OnAuthChange<T>? _onAccountChanges; final OnAuthChange<T>? _onAccountChanges;
final StreamController<FutureOrResult<AccountWrapper<T>>> _signUpStream =
StreamController();
bool _pause = false; // Semaphore
AuthenticationRepositoryImpl({ AuthenticationRepositoryImpl({
required AuthenticationCacheDataSource<T> authenticationCacheDataSource, required AuthenticationCacheDataSource<T> authenticationCacheDataSource,
@@ -50,6 +61,8 @@ class AuthenticationRepositoryImpl<T extends Object>
FormRepository? formRepository, FormRepository? formRepository,
// ignore: strict_raw_type // ignore: strict_raw_type
List<FormInput>? extraSignUpInputs, List<FormInput>? extraSignUpInputs,
FormInputValidator<String?, ValidationError>? customEmailValidator,
FormInputValidator<String?, ValidationError>? customPasswordValidator,
OnSignUpSuccess<T>? onSignUpSuccess, OnSignUpSuccess<T>? onSignUpSuccess,
OnAuthChange<T>? onAuthChange, OnAuthChange<T>? onAuthChange,
}) : _authenticationLocalDataSource = authenticationCacheDataSource, }) : _authenticationLocalDataSource = authenticationCacheDataSource,
@@ -64,8 +77,14 @@ class AuthenticationRepositoryImpl<T extends Object>
..registerForm( ..registerForm(
WyattFormImpl( WyattFormImpl(
[ [
FormInput(AuthFormField.email, const Email.pure()), FormInput(
FormInput(AuthFormField.password, const Password.pure()) AuthFormField.email,
customEmailValidator ?? const Email.pure(),
),
FormInput(
AuthFormField.password,
customPasswordValidator ?? const Password.pure(),
)
], ],
name: AuthFormName.signInForm, name: AuthFormName.signInForm,
), ),
@@ -73,8 +92,14 @@ class AuthenticationRepositoryImpl<T extends Object>
..registerForm( ..registerForm(
WyattFormImpl( WyattFormImpl(
[ [
FormInput(AuthFormField.email, const Email.pure()), FormInput(
FormInput(AuthFormField.password, const Password.pure()), AuthFormField.email,
customEmailValidator ?? const Email.pure(),
),
FormInput(
AuthFormField.password,
customPasswordValidator ?? const Password.pure(),
),
...extraSignUpInputs ?? [] ...extraSignUpInputs ?? []
], ],
name: AuthFormName.signUpForm, name: AuthFormName.signUpForm,
@@ -86,7 +111,7 @@ class AuthenticationRepositoryImpl<T extends Object>
FormRepository get formRepository => _formRepository; FormRepository get formRepository => _formRepository;
@override @override
FutureResult<Account> signInWithEmailAndPassword({ FutureOrResult<Account> signInWithEmailAndPassword({
required String email, required String email,
required String password, required String password,
}) => }) =>
@@ -104,7 +129,7 @@ class AuthenticationRepositoryImpl<T extends Object>
); );
@override @override
FutureResult<void> signOut() => FutureOrResult<void> signOut() =>
Result.tryCatchAsync<void, AppException, AppException>( Result.tryCatchAsync<void, AppException, AppException>(
() async { () async {
await _authenticationRemoteDataSource.signOut(); await _authenticationRemoteDataSource.signOut();
@@ -114,12 +139,13 @@ class AuthenticationRepositoryImpl<T extends Object>
); );
@override @override
FutureResult<Account> signUp({ FutureOrResult<Account> signUp({
required String email, required String email,
required String password, required String password,
}) => }) =>
Result.tryCatchAsync<Account, AppException, AppException>( Result.tryCatchAsync<Account, AppException, AppException>(
() async { () async {
_pause = true;
final account = await _authenticationRemoteDataSource.signUp( final account = await _authenticationRemoteDataSource.signUp(
email: email, email: email,
password: password, password: password,
@@ -127,42 +153,51 @@ class AuthenticationRepositoryImpl<T extends Object>
await _authenticationLocalDataSource.storeAccount(account); await _authenticationLocalDataSource.storeAccount(account);
if (_onSignUpSuccess.isNotNull) { if (_onSignUpSuccess.isNotNull) {
final dataResult = await _onSignUpSuccess!.call( final dataResult = await _onSignUpSuccess!.call(
this,
account, account,
_formRepository.accessForm(AuthFormName.signUpForm).clone(), _formRepository.accessForm(AuthFormName.signUpForm).clone(),
); );
await dataResult.foldAsync( await dataResult.foldAsync(
_authenticationLocalDataSource.storeData, (data) async {
await _authenticationLocalDataSource.storeData(data);
_signUpStream
.add(Future.value(Ok(AccountWrapperModel(account, data))));
},
(error) async => error, (error) async => error,
); );
} }
_pause = false;
return account; return account;
}, },
(error) => error, (error) {
_pause = false;
return error;
},
); );
@override @override
FutureResult<void> destroyCache() => FutureOrResult<void> destroyCache() =>
Result.tryCatchAsync<void, AppException, AppException>( Result.tryCatchAsync<void, AppException, AppException>(
_authenticationLocalDataSource.destroy, _authenticationLocalDataSource.destroy,
(error) => error, (error) => error,
); );
@override @override
FutureResult<AccountWrapper<T>> getCache() => FutureOrResult<AccountWrapper<T>> getCache() =>
Result.tryCatchAsync<AccountWrapper<T>, AppException, AppException>( Result.tryCatchAsync<AccountWrapper<T>, AppException, AppException>(
_authenticationLocalDataSource.load, _authenticationLocalDataSource.load,
(error) => error, (error) => error,
); );
@override @override
FutureResult<Account> getAccount() => FutureOrResult<Account> getAccount() =>
Result.tryCatchAsync<Account, AppException, AppException>( Result.tryCatchAsync<Account, AppException, AppException>(
_authenticationLocalDataSource.loadAccount, _authenticationLocalDataSource.loadAccount,
(error) => error, (error) => error,
); );
@override @override
FutureResult<void> setAccount( FutureOrResult<void> setAccount(
Account account, Account account,
) => ) =>
Result.tryCatchAsync<void, AppException, AppException>( Result.tryCatchAsync<void, AppException, AppException>(
@@ -173,14 +208,14 @@ class AuthenticationRepositoryImpl<T extends Object>
); );
@override @override
FutureResult<T> getData() => FutureOrResult<T> getData() =>
Result.tryCatchAsync<T, AppException, AppException>( Result.tryCatchAsync<T, AppException, AppException>(
_authenticationLocalDataSource.loadData, _authenticationLocalDataSource.loadData,
(error) => error, (error) => error,
); );
@override @override
FutureResult<void> setData( FutureOrResult<void> setData(
T? data, T? data,
) => ) =>
Result.tryCatchAsync<void, AppException, AppException>( Result.tryCatchAsync<void, AppException, AppException>(
@@ -191,26 +226,31 @@ class AuthenticationRepositoryImpl<T extends Object>
); );
@override @override
FutureResult<String> getIdentityToken() => FutureOrResult<String> getIdentityToken() =>
Result.tryCatchAsync<String, AppException, AppException>( Result.tryCatchAsync<String, AppException, AppException>(
_authenticationRemoteDataSource.getIdentityToken, _authenticationRemoteDataSource.getIdentityToken,
(error) => error, (error) => error,
); );
@override @override
Stream<FutureResult<AccountWrapper<T>>> streamAccount() => Stream<FutureOrResult<AccountWrapper<T>>> streamAccount() => MergeStream([
_signUpStream.stream.asBroadcastStream(),
_authenticationRemoteDataSource.streamAccount().map((account) async { _authenticationRemoteDataSource.streamAccount().map((account) async {
if (_onAccountChanges.isNotNull) { if (_onAccountChanges.isNotNull && !_pause) {
final dataResult = await _onAccountChanges!.call(account); final dataResult = await _onAccountChanges!.call(this, account);
return dataResult.map((data) => AccountWrapperModel(account, data)); return dataResult.map((data) {
_authenticationLocalDataSource.storeData(data);
return AccountWrapperModel(account, data);
});
} }
return Ok<AccountWrapperModel<T>, AppException>( return Ok<AccountWrapperModel<T>, AppException>(
AccountWrapperModel<T>(account, null), AccountWrapperModel<T>(account, null),
); );
}); })
]);
@override @override
FutureResult<void> confirmPasswordReset({ FutureOrResult<void> confirmPasswordReset({
required String code, required String code,
required String newPassword, required String newPassword,
}) => }) =>
@@ -225,7 +265,7 @@ class AuthenticationRepositoryImpl<T extends Object>
); );
@override @override
FutureResult<void> sendEmailVerification() => FutureOrResult<void> sendEmailVerification() =>
Result.tryCatchAsync<void, AppException, AppException>( Result.tryCatchAsync<void, AppException, AppException>(
() async { () async {
await _authenticationRemoteDataSource.sendEmailVerification(); await _authenticationRemoteDataSource.sendEmailVerification();
@@ -234,7 +274,7 @@ class AuthenticationRepositoryImpl<T extends Object>
); );
@override @override
FutureResult<void> sendPasswordResetEmail({required String email}) => FutureOrResult<void> sendPasswordResetEmail({required String email}) =>
Result.tryCatchAsync<void, AppException, AppException>( Result.tryCatchAsync<void, AppException, AppException>(
() async { () async {
await _authenticationRemoteDataSource.sendPasswordResetEmail( await _authenticationRemoteDataSource.sendPasswordResetEmail(
@@ -245,7 +285,7 @@ class AuthenticationRepositoryImpl<T extends Object>
); );
@override @override
FutureResult<Account> signInAnonymously() => FutureOrResult<Account> signInAnonymously() =>
Result.tryCatchAsync<Account, AppException, AppException>( Result.tryCatchAsync<Account, AppException, AppException>(
() async { () async {
final account = final account =
@@ -256,7 +296,7 @@ class AuthenticationRepositoryImpl<T extends Object>
); );
@override @override
FutureResult<bool> verifyPasswordResetCode({required String code}) => FutureOrResult<bool> verifyPasswordResetCode({required String code}) =>
Result.tryCatchAsync<bool, AppException, AppException>( Result.tryCatchAsync<bool, AppException, AppException>(
() async { () async {
final response = await _authenticationRemoteDataSource final response = await _authenticationRemoteDataSource
@@ -267,7 +307,7 @@ class AuthenticationRepositoryImpl<T extends Object>
); );
@override @override
FutureResult<void> refresh() => FutureOrResult<void> refresh() =>
Result.tryCatchAsync<void, AppException, AppException>( Result.tryCatchAsync<void, AppException, AppException>(
() async { () async {
await _authenticationRemoteDataSource.refresh(); await _authenticationRemoteDataSource.refresh();
@@ -30,7 +30,7 @@ abstract class AuthenticationRepository<T> extends BaseRepository {
/// Throws a SignUpWithEmailAndPasswordFailureInterface if /// Throws a SignUpWithEmailAndPasswordFailureInterface if
/// an exception occurs. /// an exception occurs.
/// {@endtemplate} /// {@endtemplate}
FutureResult<Account> signUp({ FutureOrResult<Account> signUp({
required String email, required String email,
required String password, required String password,
}); });
@@ -40,21 +40,21 @@ abstract class AuthenticationRepository<T> extends BaseRepository {
/// ///
/// Throws a SendEmailVerificationFailureInterface if an exception occurs. /// Throws a SendEmailVerificationFailureInterface if an exception occurs.
/// {@endtemplate} /// {@endtemplate}
FutureResult<void> sendEmailVerification(); FutureOrResult<void> sendEmailVerification();
/// {@template send_password_reset_email} /// {@template send_password_reset_email}
/// Sends a password reset email to the provided [email]. /// Sends a password reset email to the provided [email].
/// ///
/// Throws a SendPasswordResetEmailFailureInterface if an exception occurs. /// Throws a SendPasswordResetEmailFailureInterface if an exception occurs.
/// {@endtemplate} /// {@endtemplate}
FutureResult<void> sendPasswordResetEmail({required String email}); FutureOrResult<void> sendPasswordResetEmail({required String email});
/// {@template confirm_password_reset} /// {@template confirm_password_reset}
/// Confirms the password reset with the provided [newPassword] and [code]. /// Confirms the password reset with the provided [newPassword] and [code].
/// ///
/// Throws a ConfirmPasswordResetFailureInterface if an exception occurs. /// Throws a ConfirmPasswordResetFailureInterface if an exception occurs.
/// {@endtemplate} /// {@endtemplate}
FutureResult<void> confirmPasswordReset({ FutureOrResult<void> confirmPasswordReset({
required String code, required String code,
required String newPassword, required String newPassword,
}); });
@@ -64,14 +64,14 @@ abstract class AuthenticationRepository<T> extends BaseRepository {
/// ///
/// Throws a VerifyPasswordResetCodeFailureInterface if an exception occurs. /// Throws a VerifyPasswordResetCodeFailureInterface if an exception occurs.
/// {@endtemplate} /// {@endtemplate}
FutureResult<bool> verifyPasswordResetCode({required String code}); FutureOrResult<bool> verifyPasswordResetCode({required String code});
/// {@template signin_anom} /// {@template signin_anom}
/// Sign in anonymously. /// Sign in anonymously.
/// ///
/// Throws a SignInAnonymouslyFailureInterface if an exception occurs. /// Throws a SignInAnonymouslyFailureInterface if an exception occurs.
/// {@endtemplate} /// {@endtemplate}
FutureResult<Account> signInAnonymously(); FutureOrResult<Account> signInAnonymously();
/// {@template signin_pwd} /// {@template signin_pwd}
/// Signs in with the provided [email] and [password]. /// Signs in with the provided [email] and [password].
@@ -79,7 +79,7 @@ abstract class AuthenticationRepository<T> extends BaseRepository {
/// Throws a SignInWithEmailAndPasswordFailureInterface if /// Throws a SignInWithEmailAndPasswordFailureInterface if
/// an exception occurs. /// an exception occurs.
/// {@endtemplate} /// {@endtemplate}
FutureResult<Account> signInWithEmailAndPassword({ FutureOrResult<Account> signInWithEmailAndPassword({
required String email, required String email,
required String password, required String password,
}); });
@@ -88,9 +88,9 @@ abstract class AuthenticationRepository<T> extends BaseRepository {
/// Signs out the current user. /// Signs out the current user.
/// It also clears the cache and the associated data. /// It also clears the cache and the associated data.
/// {@endtemplate} /// {@endtemplate}
FutureResult<void> signOut(); FutureOrResult<void> signOut();
FutureResult<void> refresh(); FutureOrResult<void> refresh();
/// {@template stream_account} /// {@template stream_account}
/// Stream of [AccountWrapper] which will emit the current account when /// Stream of [AccountWrapper] which will emit the current account when
@@ -99,16 +99,16 @@ abstract class AuthenticationRepository<T> extends BaseRepository {
/// Emits [AccountWrapper] with null [Account] if the user is not /// Emits [AccountWrapper] with null [Account] if the user is not
/// authenticated. /// authenticated.
/// {@endtemplate} /// {@endtemplate}
Stream<FutureResult<AccountWrapper<T>>> streamAccount(); Stream<FutureOrResult<AccountWrapper<T>>> streamAccount();
FutureResult<String> getIdentityToken(); FutureOrResult<String> getIdentityToken();
FutureResult<Account> getAccount(); FutureOrResult<Account> getAccount();
FutureResult<void> setAccount(Account account); FutureOrResult<void> setAccount(Account account);
FutureResult<T> getData(); FutureOrResult<T> getData();
FutureResult<void> setData(T? data); FutureOrResult<void> setData(T? data);
FutureResult<AccountWrapper<T>> getCache(); FutureOrResult<AccountWrapper<T>> getCache();
FutureResult<void> destroyCache(); FutureOrResult<void> destroyCache();
} }
@@ -56,6 +56,19 @@ class AuthenticationCubit<Extra> extends Cubit<AuthenticationState<Extra>> {
}); });
} }
/// If authenticated, re-emits state with data freshly loaded from cache.
FutureOr<void> reloadCache() async {
if (state.status == AuthenticationStatus.authenticated) {
final data = await _authenticationRepository.getCache();
emit(
data.fold(
AuthenticationState<Extra>.authenticated,
(error) => state,
),
);
}
}
FutureOr<void> signOut() { FutureOr<void> signOut() {
// TODO(hpcl): maybe force unauthenticated by emitting an event // TODO(hpcl): maybe force unauthenticated by emitting an event
_authenticationRepository.signOut(); _authenticationRepository.signOut();
@@ -41,15 +41,52 @@ class SignInCubit<Extra> extends FormDataCubit<SignInState> {
String get formName => AuthFormName.signInForm; String get formName => AuthFormName.signInForm;
void emailChanged(String value) { void emailChanged(String value) {
final emailValidatorType = _formRepository
.accessForm(formName)
.validatorOf(AuthFormField.email)
.runtimeType;
assert(
emailValidatorType == Email,
'Use emailCustomChanged(...) with validator $emailValidatorType',
);
final Email email = Email.dirty(value); final Email email = Email.dirty(value);
dataChanged(AuthFormField.email, email); dataChanged(AuthFormField.email, email);
} }
void passwordChanged(String value) { void passwordChanged(String value) {
final passwordValidatorType = _formRepository
.accessForm(formName)
.validatorOf(AuthFormField.password)
.runtimeType;
assert(
passwordValidatorType == Password,
'Use passwordCustomChanged(...) with validator $passwordValidatorType',
);
final Password password = Password.dirty(value); final Password password = Password.dirty(value);
dataChanged(AuthFormField.password, password); dataChanged(AuthFormField.password, password);
} }
/// Same as [emailChanged] but with a custom [Validator].
///
/// Sort of short hand for [dataChanged].
void emailCustomChanged<
Validator extends FormInputValidator<String?, ValidationError>>(
Validator validator,
) {
dataChanged(AuthFormField.email, validator);
}
/// Same as [passwordChanged] but with a custom [Validator].
///
/// Sort of short hand for [dataChanged].
void passwordCustomChanged<
Validator extends FormInputValidator<String?, ValidationError>>(
Validator validator,
) {
dataChanged(AuthFormField.password, validator);
}
@override @override
FutureOr<void> dataChanged<Value>( FutureOr<void> dataChanged<Value>(
String key, String key,
@@ -17,8 +17,10 @@
part of 'sign_in_cubit.dart'; part of 'sign_in_cubit.dart';
class SignInState extends FormDataState { class SignInState extends FormDataState {
Email get email => form.validatorOf(AuthFormField.email); FormInputValidator<String?, ValidationError> get email =>
Password get password => form.validatorOf(AuthFormField.password); form.validatorOf(AuthFormField.email);
FormInputValidator<String?, ValidationError> get password =>
form.validatorOf(AuthFormField.password);
const SignInState({ const SignInState({
required super.form, required super.form,
@@ -43,15 +43,52 @@ class SignUpCubit<Extra> extends FormDataCubit<SignUpState> {
String get formName => AuthFormName.signUpForm; String get formName => AuthFormName.signUpForm;
void emailChanged(String value) { void emailChanged(String value) {
final emailValidatorType = _formRepository
.accessForm(formName)
.validatorOf(AuthFormField.email)
.runtimeType;
assert(
emailValidatorType == Email,
'Use emailCustomChanged(...) with validator $emailValidatorType',
);
final Email email = Email.dirty(value); final Email email = Email.dirty(value);
dataChanged(AuthFormField.email, email); dataChanged(AuthFormField.email, email);
} }
void passwordChanged(String value) { void passwordChanged(String value) {
final passwordValidatorType = _formRepository
.accessForm(formName)
.validatorOf(AuthFormField.password)
.runtimeType;
assert(
passwordValidatorType == Password,
'Use passwordCustomChanged(...) with validator $passwordValidatorType',
);
final Password password = Password.dirty(value); final Password password = Password.dirty(value);
dataChanged(AuthFormField.password, password); dataChanged(AuthFormField.password, password);
} }
/// Same as [emailChanged] but with a custom [Validator].
///
/// Sort of short hand for [dataChanged].
void emailCustomChanged<
Validator extends FormInputValidator<String?, ValidationError>>(
Validator validator,
) {
dataChanged(AuthFormField.email, validator);
}
/// Same as [passwordChanged] but with a custom [Validator].
///
/// Sort of short hand for [dataChanged].
void passwordCustomChanged<
Validator extends FormInputValidator<String?, ValidationError>>(
Validator validator,
) {
dataChanged(AuthFormField.password, validator);
}
@override @override
FutureOr<void> dataChanged<Value>( FutureOr<void> dataChanged<Value>(
String key, String key,
@@ -17,8 +17,10 @@
part of 'sign_up_cubit.dart'; part of 'sign_up_cubit.dart';
class SignUpState extends FormDataState { class SignUpState extends FormDataState {
Email get email => form.validatorOf(AuthFormField.email); FormInputValidator<String?, ValidationError> get email =>
Password get password => form.validatorOf(AuthFormField.password); form.validatorOf(AuthFormField.email);
FormInputValidator<String?, ValidationError> get password =>
form.validatorOf(AuthFormField.password);
const SignUpState({ const SignUpState({
required super.form, required super.form,
@@ -1,7 +1,7 @@
name: wyatt_authentication_bloc name: wyatt_authentication_bloc
description: Authentication BLoC for Flutter description: Authentication BLoC for Flutter
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_authentication_bloc repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_authentication_bloc
version: 0.4.0 version: 0.4.0+3
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
@@ -21,18 +21,19 @@ dependencies:
flutter_facebook_auth: ^4.3.0 flutter_facebook_auth: ^4.3.0
sign_in_with_apple: ^3.3.0 sign_in_with_apple: ^3.3.0
twitter_login: ^4.2.3 twitter_login: ^4.2.3
rxdart: ^0.27.7
wyatt_form_bloc: wyatt_form_bloc:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/ hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^0.2.0 version: ^0.2.0+2
wyatt_architecture: wyatt_architecture:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/ hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^0.0.2 version: ^0.1.0+1
wyatt_type_utils: wyatt_type_utils:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/ hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^0.0.3+1 version: ^0.0.4
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
+6
View File
@@ -1,3 +1,9 @@
## 2.0.0
> Note: This release has breaking changes.
- **BREAKING** **REFACTOR**: update onWrap label (close #46).
## 1.2.0 ## 1.2.0
- **REFACTOR**: general code update. - **REFACTOR**: general code update.
+2 -2
View File
@@ -116,11 +116,11 @@ Widget onBuild(BuildContext context, CounterState state) {
} }
``` ```
If needed, you can wrap what depends on the state with the function `onWrap`. If needed, you can wrap what depends on the state with the function `parent`.
```dart ```dart
@override @override
Widget onWrap(BuildContext context, Widget child) { Widget parent(BuildContext context, Widget child) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: const Text('Title'), title: const Text('Title'),
+1 -1
View File
@@ -62,7 +62,7 @@ abstract class BlocProviderScreen<Bloc extends blocbase.Bloc<Event, State>,
/// [shouldListenWhen] and [shouldBuildWhen] are optional and if they /// [shouldListenWhen] and [shouldBuildWhen] are optional and if they
/// aren't implemented, they will default to `true`. /// aren't implemented, they will default to `true`.
/// ///
/// An optional [onWrap] can also be implemented. This build a wrapper arround /// An optional [parent] can also be implemented. This build a wrapper arround
/// the built BlocConsumer that is **not** rebuild on each state. /// the built BlocConsumer that is **not** rebuild on each state.
/// {@endtemplate} /// {@endtemplate}
abstract class BlocConsumerScreen<Bloc extends blocbase.Bloc<Event, State>, abstract class BlocConsumerScreen<Bloc extends blocbase.Bloc<Event, State>,
@@ -33,7 +33,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
/// [shouldListenWhen] and [shouldBuildWhen] are optional and if they /// [shouldListenWhen] and [shouldBuildWhen] are optional and if they
/// aren't implemented, they will default to `true`. /// aren't implemented, they will default to `true`.
/// ///
/// An optional [onWrap] can also be implemented. This build a wrapper arround /// An optional [parent] can also be implemented. This build a wrapper arround
/// the built [BlocConsumer] that is **not** rebuild on each state. /// the built [BlocConsumer] that is **not** rebuild on each state.
/// {@endtemplate} /// {@endtemplate}
abstract class BlocBaseConsumerScreen<Bloc extends BlocBase<State>, abstract class BlocBaseConsumerScreen<Bloc extends BlocBase<State>,
@@ -51,10 +51,10 @@ abstract class BlocBaseConsumerScreen<Bloc extends BlocBase<State>,
/// [onListen] with the current `state`. /// [onListen] with the current `state`.
bool shouldListenWhen(State previous, State current) => true; bool shouldListenWhen(State previous, State current) => true;
/// The [onWrap] function which will be invoked on build. /// The [parent] function which will be invoked on build.
/// The [onWrap] takes a `BuildContext` that **doesn't have** access /// The [parent] takes a `BuildContext` that **doesn't have** access
/// to the [Bloc] or [Cubit]. /// to the [Bloc] or [Cubit].
Widget onWrap(BuildContext context, Widget child) => child; Widget parent(BuildContext context, Widget child) => child;
/// The [onBuild] function which will be invoked on each widget build. /// The [onBuild] function which will be invoked on each widget build.
/// The [onBuild] takes the `BuildContext` and current `state` and /// The [onBuild] takes the `BuildContext` and current `state` and
@@ -66,7 +66,7 @@ abstract class BlocBaseConsumerScreen<Bloc extends BlocBase<State>,
void onListen(BuildContext context, State state) {} void onListen(BuildContext context, State state) {}
@override @override
Widget build(BuildContext context) => onWrap( Widget build(BuildContext context) => parent(
context, context,
BlocConsumer<Bloc, State>( BlocConsumer<Bloc, State>(
listenWhen: shouldListenWhen, listenWhen: shouldListenWhen,
@@ -58,7 +58,7 @@ abstract class CubitProviderScreen<Cubit extends blocbase.Cubit<State>,
/// [shouldListenWhen] and [shouldBuildWhen] are optional and if they /// [shouldListenWhen] and [shouldBuildWhen] are optional and if they
/// aren't implemented, they will default to `true`. /// aren't implemented, they will default to `true`.
/// ///
/// An optional [onWrap] can also be implemented. This build a wrapper arround /// An optional [parent] can also be implemented. This build a wrapper arround
/// the built BlocConsumer that is **not** rebuild on each state. /// the built BlocConsumer that is **not** rebuild on each state.
/// {@endtemplate} /// {@endtemplate}
abstract class CubitConsumerScreen<Cubit extends blocbase.Cubit<State>, abstract class CubitConsumerScreen<Cubit extends blocbase.Cubit<State>,
+1 -1
View File
@@ -1,7 +1,7 @@
name: wyatt_bloc_helper name: wyatt_bloc_helper
description: Your best friend for blocs in Flutter description: Your best friend for blocs in Flutter
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_bloc_helper repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_bloc_helper
version: 1.2.0 version: 2.0.0
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
+8
View File
@@ -1,3 +1,11 @@
## 0.1.0+2
- Update a dependency to the latest release.
## 0.1.0+1
- Update a dependency to the latest release.
## 0.1.0 ## 0.1.0
> Note: This release has breaking changes. > Note: This release has breaking changes.
@@ -30,7 +30,7 @@ class CrudRepositoryImpl<Model extends ObjectModel>
}) : _crudDataSource = crudDataSource; }) : _crudDataSource = crudDataSource;
@override @override
FutureResult<void> create(Model object, {String? id}) => FutureOrResult<void> create(Model object, {String? id}) =>
Result.tryCatchAsync<void, AppException, AppException>( Result.tryCatchAsync<void, AppException, AppException>(
() async { () async {
await _crudDataSource.create(object, id: id); await _crudDataSource.create(object, id: id);
@@ -39,21 +39,21 @@ class CrudRepositoryImpl<Model extends ObjectModel>
); );
@override @override
FutureResult<Model?> get(String id) => FutureOrResult<Model?> get(String id) =>
Result.tryCatchAsync<Model?, AppException, AppException>( Result.tryCatchAsync<Model?, AppException, AppException>(
() async => _crudDataSource.get(id), () async => _crudDataSource.get(id),
(error) => error, (error) => error,
); );
@override @override
FutureResult<List<Model?>> getAll() => FutureOrResult<List<Model?>> getAll() =>
Result.tryCatchAsync<List<Model?>, AppException, AppException>( Result.tryCatchAsync<List<Model?>, AppException, AppException>(
() async => _crudDataSource.getAll(), () async => _crudDataSource.getAll(),
(error) => error, (error) => error,
); );
@override @override
FutureResult<void> update( FutureOrResult<void> update(
String id, { String id, {
Model? object, Model? object,
Map<String, dynamic>? raw, Map<String, dynamic>? raw,
@@ -64,28 +64,28 @@ class CrudRepositoryImpl<Model extends ObjectModel>
); );
@override @override
FutureResult<void> updateAll(Map<String, Object?> raw) => FutureOrResult<void> updateAll(Map<String, Object?> raw) =>
Result.tryCatchAsync<void, AppException, AppException>( Result.tryCatchAsync<void, AppException, AppException>(
() async => _crudDataSource.updateAll(raw), () async => _crudDataSource.updateAll(raw),
(error) => error, (error) => error,
); );
@override @override
FutureResult<void> delete(String id) => FutureOrResult<void> delete(String id) =>
Result.tryCatchAsync<void, AppException, AppException>( Result.tryCatchAsync<void, AppException, AppException>(
() async => _crudDataSource.delete(id), () async => _crudDataSource.delete(id),
(error) => error, (error) => error,
); );
@override @override
FutureResult<void> deleteAll() => FutureOrResult<void> deleteAll() =>
Result.tryCatchAsync<void, AppException, AppException>( Result.tryCatchAsync<void, AppException, AppException>(
() async => _crudDataSource.deleteAll(), () async => _crudDataSource.deleteAll(),
(error) => error, (error) => error,
); );
@override @override
FutureResult<List<Model?>> query(List<QueryInterface> conditions) => FutureOrResult<List<Model?>> query(List<QueryInterface> conditions) =>
Result.tryCatchAsync<List<Model?>, AppException, AppException>( Result.tryCatchAsync<List<Model?>, AppException, AppException>(
() async => _crudDataSource.query(conditions), () async => _crudDataSource.query(conditions),
(error) => error, (error) => error,
@@ -20,18 +20,18 @@ import 'package:wyatt_crud_bloc/src/domain/entities/query.dart';
abstract class CrudRepository<Model extends ObjectModel> abstract class CrudRepository<Model extends ObjectModel>
extends BaseRepository { extends BaseRepository {
FutureResult<void> create(Model object, {String? id}); FutureOrResult<void> create(Model object, {String? id});
FutureResult<Model?> get(String id); FutureOrResult<Model?> get(String id);
FutureResult<List<Model?>> getAll(); FutureOrResult<List<Model?>> getAll();
FutureResult<void> update( FutureOrResult<void> update(
String id, { String id, {
Model? object, Model? object,
Map<String, dynamic>? raw, Map<String, dynamic>? raw,
}); });
FutureResult<void> updateAll(Map<String, Object?> raw); FutureOrResult<void> updateAll(Map<String, Object?> raw);
FutureResult<void> delete(String id); FutureOrResult<void> delete(String id);
FutureResult<void> deleteAll(); FutureOrResult<void> deleteAll();
FutureResult<List<Model?>> query(List<QueryInterface> conditions); FutureOrResult<List<Model?>> query(List<QueryInterface> conditions);
StreamResult<List<Model?>> stream({ StreamResult<List<Model?>> stream({
String? id, String? id,
List<QueryInterface>? conditions, List<QueryInterface>? conditions,
@@ -15,15 +15,24 @@
// 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/>.
import 'dart:async';
import 'package:wyatt_architecture/wyatt_architecture.dart'; import 'package:wyatt_architecture/wyatt_architecture.dart';
import 'package:wyatt_crud_bloc/src/domain/entities/object_model.dart'; import 'package:wyatt_crud_bloc/src/domain/entities/object_model.dart';
import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart'; import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart';
class Create<Model extends ObjectModel> extends UseCase<Model, void> { class Create<Model extends ObjectModel> extends AsyncUseCase<Model, void> {
final CrudRepository<Model> _crudRepository; final CrudRepository<Model> _crudRepository;
Create(this._crudRepository); Create(this._crudRepository);
@override @override
FutureResult<void> call(Model params) => _crudRepository.create(params); FutureOr<void> onStart(Model? params) {
if(params == null){
throw ClientException('$Model cannot be null.');
}
}
@override
FutureOrResult<void> call(Model? params) => _crudRepository.create(params!);
} }
@@ -14,15 +14,24 @@
// 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/>.
import 'dart:async';
import 'package:wyatt_architecture/wyatt_architecture.dart'; import 'package:wyatt_architecture/wyatt_architecture.dart';
import 'package:wyatt_crud_bloc/src/domain/entities/object_model.dart'; import 'package:wyatt_crud_bloc/src/domain/entities/object_model.dart';
import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart'; import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart';
class Delete<Model extends ObjectModel> extends UseCase<String, void> { class Delete<Model extends ObjectModel> extends AsyncUseCase<String, void> {
final CrudRepository<Model> _crudRepository; final CrudRepository<Model> _crudRepository;
Delete(this._crudRepository); Delete(this._crudRepository);
@override @override
FutureResult<void> call(String params) => _crudRepository.delete(params); FutureOr<void> onStart(String? params) {
if(params == null){
throw ClientException('Id cannot be null.');
}
}
@override
FutureOrResult<void> call(String? params) => _crudRepository.delete(params!);
} }
@@ -18,11 +18,11 @@ import 'package:wyatt_architecture/wyatt_architecture.dart';
import 'package:wyatt_crud_bloc/src/domain/entities/object_model.dart'; import 'package:wyatt_crud_bloc/src/domain/entities/object_model.dart';
import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart'; import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart';
class DeleteAll<Model extends ObjectModel> extends UseCase<void, void> { class DeleteAll<Model extends ObjectModel> extends AsyncUseCase<void, void> {
final CrudRepository<Model> _crudRepository; final CrudRepository<Model> _crudRepository;
DeleteAll(this._crudRepository); DeleteAll(this._crudRepository);
@override @override
FutureResult<void> call(void params) => _crudRepository.deleteAll(); FutureOrResult<void> call(void params) => _crudRepository.deleteAll();
} }
@@ -14,15 +14,24 @@
// 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/>.
import 'dart:async';
import 'package:wyatt_architecture/wyatt_architecture.dart'; import 'package:wyatt_architecture/wyatt_architecture.dart';
import 'package:wyatt_crud_bloc/src/domain/entities/object_model.dart'; import 'package:wyatt_crud_bloc/src/domain/entities/object_model.dart';
import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart'; import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart';
class Get<Model extends ObjectModel> extends UseCase<String, Model?> { class Get<Model extends ObjectModel> extends AsyncUseCase<String, Model?> {
final CrudRepository<Model> _crudRepository; final CrudRepository<Model> _crudRepository;
Get(this._crudRepository); Get(this._crudRepository);
@override @override
FutureResult<Model?> call(String params) => _crudRepository.get(params); FutureOr<void> onStart(String? params) {
if(params == null){
throw ClientException('Id cannot be null.');
}
}
@override
FutureOrResult<Model?> call(String? params) => _crudRepository.get(params!);
} }
@@ -18,11 +18,12 @@ import 'package:wyatt_architecture/wyatt_architecture.dart';
import 'package:wyatt_crud_bloc/src/domain/entities/object_model.dart'; import 'package:wyatt_crud_bloc/src/domain/entities/object_model.dart';
import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart'; import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart';
class GetAll<Model extends ObjectModel> extends UseCase<void, List<Model?>> { class GetAll<Model extends ObjectModel>
extends AsyncUseCase<void, List<Model?>> {
final CrudRepository<Model> _crudRepository; final CrudRepository<Model> _crudRepository;
GetAll(this._crudRepository); GetAll(this._crudRepository);
@override @override
FutureResult<List<Model?>> call(void params) => _crudRepository.getAll(); FutureOrResult<List<Model?>> call(void params) => _crudRepository.getAll();
} }
@@ -14,18 +14,27 @@
// 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/>.
import 'dart:async';
import 'package:wyatt_architecture/wyatt_architecture.dart'; import 'package:wyatt_architecture/wyatt_architecture.dart';
import 'package:wyatt_crud_bloc/src/domain/entities/object_model.dart'; import 'package:wyatt_crud_bloc/src/domain/entities/object_model.dart';
import 'package:wyatt_crud_bloc/src/domain/entities/query.dart'; import 'package:wyatt_crud_bloc/src/domain/entities/query.dart';
import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart'; import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart';
class Query<Model extends ObjectModel> class Query<Model extends ObjectModel>
extends UseCase<List<QueryInterface>, List<Model?>> { extends AsyncUseCase<List<QueryInterface>, List<Model?>> {
final CrudRepository<Model> _crudRepository; final CrudRepository<Model> _crudRepository;
Query(this._crudRepository); Query(this._crudRepository);
@override @override
FutureResult<List<Model?>> call(List<QueryInterface> params) => FutureOr<void> onStart(List<QueryInterface>? params) {
_crudRepository.query(params); if(params == null){
throw ClientException('List of conditions cannot be null.');
}
}
@override
FutureOrResult<List<Model?>> call(List<QueryInterface>? params) =>
_crudRepository.query(params!);
} }
@@ -14,11 +14,7 @@
// 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/>.
// TODO(hpcl): add streamed usecase in wyatt_architecture
// import 'package:wyatt_architecture/wyatt_architecture.dart';
// import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart';
// import 'package:wyatt_crud_bloc/src/domain/usecases/params/stream_parameters.dart';
// class Stream<Model extends ObjectModel> extends UseCase<StreamParameters, List<Model?>> { // class Stream<Model extends ObjectModel> extends UseCase<StreamParameters, List<Model?>> {
// final CrudRepository<Model> _crudRepository; // final CrudRepository<Model> _crudRepository;
@@ -29,3 +25,20 @@
// StreamResult<List<Model?>> call(StreamParameters params) => // StreamResult<List<Model?>> call(StreamParameters params) =>
// _crudRepository.stream(id: params.id, conditions: params.conditions); // _crudRepository.stream(id: params.id, conditions: params.conditions);
// } // }
// class StreamQuery<Model extends ObjectModel>
// extends StreamUseCase<StreamParameters, List<Model?>> {
// final CrudRepository<Model> _crudRepository;
// StreamQuery(this._crudRepository);
// @override
// FutureOr<void> onStart(StreamParameters? params) {
// if(params == null){
// throw ClientException('Stream parameters cannot be null.');
// }
// }
// @override
// FutureOrResult<Stream<List<Model?>>> call(StreamParameters? params) => _crudRepository.stream();
// }
@@ -14,21 +14,30 @@
// 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/>.
import 'dart:async';
import 'package:wyatt_architecture/wyatt_architecture.dart'; import 'package:wyatt_architecture/wyatt_architecture.dart';
import 'package:wyatt_crud_bloc/src/domain/entities/object_model.dart'; import 'package:wyatt_crud_bloc/src/domain/entities/object_model.dart';
import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart'; import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart';
import 'package:wyatt_crud_bloc/src/domain/usecases/params/update_parameters.dart'; import 'package:wyatt_crud_bloc/src/domain/usecases/params/update_parameters.dart';
class Update<Model extends ObjectModel> class Update<Model extends ObjectModel>
extends UseCase<UpdateParameters<Model>, void> { extends AsyncUseCase<UpdateParameters<Model>, void> {
final CrudRepository<Model> _crudRepository; final CrudRepository<Model> _crudRepository;
Update(this._crudRepository); Update(this._crudRepository);
@override @override
FutureResult<void> call(UpdateParameters<Model> params) => FutureOr<void> onStart(UpdateParameters<Model>? params) {
if(params == null){
throw ClientException('Update parameters cannot be null.');
}
}
@override
FutureOrResult<void> call(UpdateParameters<Model>? params) =>
_crudRepository.update( _crudRepository.update(
params.id, params!.id,
object: params.object, object: params.object,
raw: params.raw, raw: params.raw,
); );
@@ -14,17 +14,26 @@
// 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/>.
import 'dart:async';
import 'package:wyatt_architecture/wyatt_architecture.dart'; import 'package:wyatt_architecture/wyatt_architecture.dart';
import 'package:wyatt_crud_bloc/src/domain/entities/object_model.dart'; import 'package:wyatt_crud_bloc/src/domain/entities/object_model.dart';
import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart'; import 'package:wyatt_crud_bloc/src/domain/repositories/crud_repository.dart';
class UpdateAll<Model extends ObjectModel> class UpdateAll<Model extends ObjectModel>
extends UseCase<Map<String, Object?>, void> { extends AsyncUseCase<Map<String, Object?>, void> {
final CrudRepository<Model> _crudRepository; final CrudRepository<Model> _crudRepository;
UpdateAll(this._crudRepository); UpdateAll(this._crudRepository);
@override @override
FutureResult<void> call(Map<String, Object?> params) => FutureOr<void> onStart(Map<String, Object?>? params) {
_crudRepository.updateAll(params); if(params == null){
throw ClientException('Data cannot be null.');
}
}
@override
FutureOrResult<void> call(Map<String, Object?>? params) =>
_crudRepository.updateAll(params!);
} }
@@ -21,6 +21,6 @@ export 'get.dart';
export 'get_all.dart'; export 'get_all.dart';
export 'params/params.dart'; export 'params/params.dart';
export 'query.dart'; export 'query.dart';
export 'stream.dart'; export 'stream_query.dart';
export 'update.dart'; export 'update.dart';
export 'update_all.dart'; export 'update_all.dart';
+3 -3
View File
@@ -1,7 +1,7 @@
name: wyatt_crud_bloc name: wyatt_crud_bloc
description: Create/Read/Update/Delete BLoC for Flutter description: Create/Read/Update/Delete BLoC for Flutter
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_crud_bloc repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_crud_bloc
version: 0.1.0 version: 0.1.0+2
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
@@ -19,11 +19,11 @@ dependencies:
wyatt_architecture: wyatt_architecture:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/ hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: 0.0.2 version: 0.1.0+1
wyatt_type_utils: wyatt_type_utils:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/ hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: 0.0.3+1 version: 0.0.4
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
+2
View File
@@ -0,0 +1,2 @@
firebase_options.dart
.vscode
-1
View File
@@ -1 +0,0 @@
../../.vscode/
+76
View File
@@ -0,0 +1,76 @@
{
// Dart
"dart.runPubGetOnPubspecChanges": "never",
// Gitea
"gitea.owner": "Wyatt-FOSS",
"gitea.repo": "wyatt-packages",
// Header
"psi-header.changes-tracking": {
"isActive": true
},
"psi-header.config": {
"blankLinesAfter": 1,
"forceToTop": true
},
"psi-header.lang-config": [
{
"beforeHeader": [
"# -*- coding:utf-8 -*-",
"#!/usr/bin/env python3"
],
"begin": "###",
"end": "###",
"language": "python",
"prefix": "# "
},
{
"beforeHeader": [
"#!/usr/bin/env sh",
""
],
"language": "shellscript",
"begin": "",
"end": "",
"prefix": "# "
},
{
"begin": "",
"end": "",
"language": "dart",
"prefix": "// "
},
{
"begin": "",
"end": "",
"language": "yaml",
"prefix": "# "
},
{
"begin": "<!--",
"end": "-->",
"language": "markdown",
},
],
"psi-header.templates": [
{
"language": "*",
"template": [
"Copyright (C) <<year>> 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/>."
],
}
],
}
+8
View File
@@ -1,3 +1,11 @@
## 0.2.0+2
- Update a dependency to the latest release.
## 0.2.0+1
- Update a dependency to the latest release.
## 0.2.0 ## 0.2.0
> Note: This release has breaking changes. > Note: This release has breaking changes.
+3 -3
View File
@@ -1,7 +1,7 @@
name: wyatt_form_bloc name: wyatt_form_bloc
description: Manage forms in Dart & Flutter with Bloc description: Manage forms in Dart & Flutter with Bloc
repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_form_bloc repository: https://git.wyatt-studio.fr/Wyatt-FOSS/wyatt-packages/src/branch/master/packages/wyatt_form_bloc
version: 0.2.0 version: 0.2.0+2
publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub publish_to: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub
@@ -17,11 +17,11 @@ dependencies:
wyatt_architecture: wyatt_architecture:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/ hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^0.0.2 version: ^0.1.0+1
wyatt_type_utils: wyatt_type_utils:
hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/ hosted: https://git.wyatt-studio.fr/api/packages/Wyatt-FOSS/pub/
version: ^0.0.3+1 version: ^0.0.4
dev_dependencies: dev_dependencies:
@@ -0,0 +1,10 @@
# Files and directories created by pub.
.dart_tool/
.packages
# Conventional directory for build outputs.
build/
# Omit committing pubspec.lock for library packages; see
# https://dart.dev/guides/libraries/private-files#pubspeclock.
pubspec.lock
@@ -0,0 +1,3 @@
## 1.0.0
- Initial version.
@@ -0,0 +1,39 @@
<!--
This README describes the package. If you publish this package to pub.dev,
this README's contents appear on the landing page for your package.
For information about how to write a good package README, see the guide for
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages).
For general information about developing packages, see the Dart guide for
[creating packages](https://dart.dev/guides/libraries/create-library-packages)
and the Flutter guide for
[developing packages and plugins](https://flutter.dev/developing-packages).
-->
TODO: Put a short description of the package here that helps potential users
know whether this package might be useful for them.
## Features
TODO: List what your package can do. Maybe include images, gifs, or videos.
## Getting started
TODO: List prerequisites and provide or point to information on how to
start using the package.
## Usage
TODO: Include short and useful examples for package users. Add longer examples
to `/example` folder.
```dart
const like = 'sample';
```
## Additional information
TODO: Tell users more about the package: where to find more information, how to
contribute to the package, how to file issues, what response they can expect
from the package authors, and more.
@@ -0,0 +1,30 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.
include: package:lints/recommended.yaml
# Uncomment the following section to specify additional rules.
# linter:
# rules:
# - camel_case_types
# analyzer:
# exclude:
# - path/to/excluded/files/**
# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints
# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options
@@ -0,0 +1,44 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/
# Symbolication related
app.*.symbols
# Obfuscation related
app.*.map.json
# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
@@ -0,0 +1,33 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.
version:
revision: eb6d86ee27deecba4a83536aa20f366a6044895c
channel: stable
project_type: app
# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c
base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c
- platform: android
create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c
base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c
- platform: ios
create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c
base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c
# User provided section
# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
@@ -0,0 +1,16 @@
# notification_bloc_example
A new Flutter project.
## Getting Started
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
@@ -0,0 +1,29 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.
# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml
linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
@@ -0,0 +1,13 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java
# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
**/*.keystore
**/*.jks
@@ -0,0 +1,71 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.notification_bloc_example"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
@@ -0,0 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.notification_bloc_example">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
@@ -0,0 +1,34 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.notification_bloc_example">
<application
android:label="notification_bloc_example"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
@@ -0,0 +1,6 @@
package com.example.notification_bloc_example
import io.flutter.embedding.android.FlutterActivity
class MainActivity: FlutterActivity() {
}
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="?android:colorBackground" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@android:color/white" />
<!-- You can insert your own image assets here -->
<!-- <item>
<bitmap
android:gravity="center"
android:src="@mipmap/launch_image" />
</item> -->
</layer-list>
Binary file not shown.

After

Width:  |  Height:  |  Size: 544 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 442 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 721 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is on -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting when the OS's Dark Mode setting is off -->
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
the Flutter engine draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
</style>
</resources>
@@ -0,0 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.notification_bloc_example">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
</manifest>
@@ -0,0 +1,31 @@
buildscript {
ext.kotlin_version = '1.6.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
@@ -0,0 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
@@ -0,0 +1,11 @@
include ':app'
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
@@ -0,0 +1,34 @@
**/dgph
*.mode1v3
*.mode2v3
*.moved-aside
*.pbxuser
*.perspectivev3
**/*sync/
.sconsign.dblite
.tags*
**/.vagrant/
**/DerivedData/
Icon?
**/Pods/
**/.symlinks/
profile
xcuserdata
**/.generated/
Flutter/App.framework
Flutter/Flutter.framework
Flutter/Flutter.podspec
Flutter/Generated.xcconfig
Flutter/ephemeral/
Flutter/app.flx
Flutter/app.zip
Flutter/flutter_assets/
Flutter/flutter_export_environment.sh
ServiceDefinitions.json
Runner/GeneratedPluginRegistrant.*
# Exceptions to above rules.
!default.mode1v3
!default.mode2v3
!default.pbxuser
!default.perspectivev3
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>App</string>
<key>CFBundleIdentifier</key>
<string>io.flutter.flutter.app</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>App</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
</dict>
</plist>
@@ -0,0 +1 @@
#include "Generated.xcconfig"

Some files were not shown because too many files have changed in this diff Show More