-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f174fa4
commit bc5d9fc
Showing
46 changed files
with
2,759 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule a2f_sdk
updated
16 files
1 change: 0 additions & 1 deletion
1
packages/items_repository/lib/src/data/models/pantry_item_model.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
packages/items_repository/lib/src/data/models/shelf_item_model.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/items_repository/lib/src/domain/repositories/items_repository.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
migrate_working_dir/ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
# VSCode related | ||
.vscode/* | ||
|
||
# Flutter/Dart/Pub related | ||
**/doc/api/ | ||
**/ios/Flutter/.last_build_id | ||
.dart_tool/ | ||
.flutter-plugins | ||
.flutter-plugins-dependencies | ||
.packages | ||
.pub-cache/ | ||
.pub/ | ||
/build/ | ||
pubspec.lock | ||
|
||
# Web related | ||
lib/generated_plugin_registrant.dart | ||
|
||
# Symbolication related | ||
app.*.symbols | ||
|
||
# Obfuscation related | ||
app.*.map.json | ||
|
||
# Test related | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Notifications Repository | ||
|
||
[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link] | ||
[![Powered by Mason](https://img.shields.io/endpoint?url=https%3A%2F%2Ftinyurl.com%2Fmason-badge)](https://github.com/felangel/mason) | ||
[![License: MIT][license_badge]][license_link] | ||
|
||
The notifications package | ||
|
||
## Installation 💻 | ||
|
||
**❗ In order to start using Notifications Repository you must have the [Flutter SDK][flutter_install_link] installed on your machine.** | ||
|
||
Install via `flutter pub add`: | ||
|
||
```sh | ||
dart pub add notifications_repository | ||
``` | ||
|
||
--- | ||
|
||
## Continuous Integration 🤖 | ||
|
||
Notifications Repository comes with a built-in [GitHub Actions workflow][github_actions_link] powered by [Very Good Workflows][very_good_workflows_link] but you can also add your preferred CI/CD solution. | ||
|
||
Out of the box, on each pull request and push, the CI `formats`, `lints`, and `tests` the code. This ensures the code remains consistent and behaves correctly as you add functionality or make changes. The project uses [Very Good Analysis][very_good_analysis_link] for a strict set of analysis options used by our team. Code coverage is enforced using the [Very Good Workflows][very_good_coverage_link]. | ||
|
||
--- | ||
|
||
## Running Tests 🧪 | ||
|
||
For first time users, install the [very_good_cli][very_good_cli_link]: | ||
|
||
```sh | ||
dart pub global activate very_good_cli | ||
``` | ||
|
||
To run all unit tests: | ||
|
||
```sh | ||
very_good test --coverage | ||
``` | ||
|
||
To view the generated coverage report you can use [lcov](https://github.com/linux-test-project/lcov). | ||
|
||
```sh | ||
# Generate Coverage Report | ||
genhtml coverage/lcov.info -o coverage/ | ||
|
||
# Open Coverage Report | ||
open coverage/index.html | ||
``` | ||
|
||
[flutter_install_link]: https://docs.flutter.dev/get-started/install | ||
[github_actions_link]: https://docs.github.com/en/actions/learn-github-actions | ||
[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg | ||
[license_link]: https://opensource.org/licenses/MIT | ||
[logo_black]: https://raw.githubusercontent.com/VGVentures/very_good_brand/main/styles/README/vgv_logo_black.png#gh-light-mode-only | ||
[logo_white]: https://raw.githubusercontent.com/VGVentures/very_good_brand/main/styles/README/vgv_logo_white.png#gh-dark-mode-only | ||
[mason_link]: https://github.com/felangel/mason | ||
[very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg | ||
[very_good_analysis_link]: https://pub.dev/packages/very_good_analysis | ||
[very_good_cli_link]: https://pub.dev/packages/very_good_cli | ||
[very_good_coverage_link]: https://github.com/marketplace/actions/very-good-coverage | ||
[very_good_ventures_link]: https://verygood.ventures | ||
[very_good_ventures_link_light]: https://verygood.ventures#gh-light-mode-only | ||
[very_good_ventures_link_dark]: https://verygood.ventures#gh-dark-mode-only | ||
[very_good_workflows_link]: https://github.com/VeryGoodOpenSource/very_good_workflows |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions
4
packages/notifications_repository/lib/notifications_repository.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/// The notifications package | ||
library notifications_repository; | ||
|
||
export 'src/notifications_repository.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export 'data_source/data_source.dart'; | ||
export 'models/models.dart'; | ||
export 'repository/notifications_repository_impl.dart'; |
2 changes: 2 additions & 0 deletions
2
packages/notifications_repository/lib/src/data/data_source/data_source.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export 'notifications_db_provider.dart'; | ||
export 'notifications_provider.dart'; |
93 changes: 93 additions & 0 deletions
93
packages/notifications_repository/lib/src/data/data_source/notifications_db_provider.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import 'package:a2f_sdk/a2f_sdk.dart'; | ||
|
||
import '../../../notifications_repository.dart'; | ||
|
||
class NotificationsDbProvider implements NotificationsProvider { | ||
const NotificationsDbProvider(this._dbService); | ||
|
||
final IsarService _dbService; | ||
|
||
@override | ||
Future<NotificationModel> add(NotificationInput input) async { | ||
final isar = await _dbService.db; | ||
final createdAt = DateTime.now(); | ||
|
||
final notification = NotificationIsarModel() | ||
..type = input.type | ||
..createdAt = createdAt //.toUtc() | ||
..scheduledAt = input.scheduledAt //.toUtc() | ||
..intVal = input.intVal | ||
..stringVal = input.stringVal | ||
..boolVal = input.boolVal | ||
..dateTimeVal = input.dateTimeVal | ||
..location = input.location.name | ||
..uuid = null | ||
..readAt = null; | ||
|
||
final id = await isar.writeTxn( | ||
() async => isar.notificationIsarModels.put(notification), | ||
); | ||
|
||
final data = | ||
await isar.notificationIsarModels.where().idEqualTo(id).findFirst(); | ||
|
||
return NotificationModel.fromData(data!); | ||
} | ||
|
||
@override | ||
Future<List<NotificationModel>> fetch() async { | ||
final isar = await _dbService.db; | ||
final items = await isar.notificationIsarModels | ||
.where() | ||
.sortByScheduledAtDesc() | ||
.findAll(); | ||
return items.map(NotificationModel.fromData).toList(); | ||
} | ||
|
||
@override | ||
Future<NotificationModel> read(int id) async { | ||
final isar = await _dbService.db; | ||
|
||
return isar.writeTxn(() async { | ||
final notification = | ||
await isar.notificationIsarModels.where().idEqualTo(id).findFirst(); | ||
|
||
if (notification == null) { | ||
throw AssertionError('Notification must exist'); | ||
} | ||
|
||
final updated = notification.copyWith(readAt: DateTime.now()); | ||
await isar.notificationIsarModels.put(updated); | ||
|
||
return NotificationModel.fromData(updated); | ||
}); | ||
} | ||
|
||
@override | ||
Future<bool> exists({ | ||
int? id, | ||
NotificationType? type, | ||
DateTime? scheduledAt, | ||
}) async { | ||
if (id == null && type == null && scheduledAt == null) { | ||
throw AssertionError('At least one parameter must be provided.'); | ||
} | ||
final isar = await _dbService.db; | ||
if (id != null) { | ||
final count = | ||
await isar.notificationIsarModels.where().idEqualTo(id!).count(); | ||
return count > 0; | ||
} | ||
assert(type != null && scheduledAt != null, ''); | ||
final date = scheduledAt!; | ||
final dateStart = DateTime.utc(date.year, date.month, date.day, 0, 0, 0); | ||
final dateEnd = DateTime.utc(date.year, date.month, date.day, 23, 59, 59); | ||
final count = await isar.notificationIsarModels | ||
.filter() | ||
.typeEqualTo(type!) | ||
.and() | ||
.scheduledAtBetween(dateStart, dateEnd) | ||
.count(); | ||
return count > 0; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/notifications_repository/lib/src/data/data_source/notifications_provider.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import '../../../notifications_repository.dart'; | ||
|
||
/// This provider return [NotificationEntity] object because does not exist a | ||
/// concrete implementation of model that extends [NotificationEntity]. | ||
abstract class NotificationsProvider { | ||
Future<NotificationModel> add(NotificationInput input); | ||
|
||
Future<List<NotificationModel>> fetch(); | ||
|
||
Future<NotificationModel> read(int id); | ||
|
||
Future<bool> exists({ | ||
int? id, | ||
NotificationType? type, | ||
DateTime? scheduledAt, | ||
}); | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/notifications_repository/lib/src/data/models/models.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export 'notification_isar_model.dart'; | ||
export 'notification_model.dart'; |
Oops, something went wrong.