Skip to content

Commit

Permalink
feat: Added NotificationSchedule functionality.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Aug 28, 2023
1 parent d371765 commit 819d2a6
Show file tree
Hide file tree
Showing 10 changed files with 1,059 additions and 23 deletions.
18 changes: 9 additions & 9 deletions packages/masamune_notification_firebase/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ packages:
dependency: transitive
description:
name: built_value
sha256: "598a2a682e2a7a90f08ba39c0aaa9374c5112340f0a2e275f61b59389543d166"
sha256: ff627b645b28fb8bdb69e645f910c2458fd6b65f6585c3a53e0626024897dedf
url: "https://pub.dev"
source: hosted
version: "8.6.1"
version: "8.6.2"
characters:
dependency: transitive
description:
Expand Down Expand Up @@ -523,7 +523,7 @@ packages:
path: "../../katana_form"
relative: true
source: path
version: "2.7.5"
version: "2.7.6"
katana_functions:
dependency: "direct overridden"
description:
Expand Down Expand Up @@ -607,14 +607,14 @@ packages:
path: "../../katana_router"
relative: true
source: path
version: "2.0.33"
version: "2.0.34"
katana_router_annotation:
dependency: "direct overridden"
description:
path: "../../katana_router_annotation"
relative: true
source: path
version: "2.0.18"
version: "2.0.19"
katana_scoped:
dependency: "direct overridden"
description:
Expand Down Expand Up @@ -679,7 +679,7 @@ packages:
path: "../../masamune"
relative: true
source: path
version: "2.4.40"
version: "2.4.41"
masamune_annotation:
dependency: "direct overridden"
description:
Expand All @@ -693,7 +693,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.1.94"
version: "2.1.96"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -1119,10 +1119,10 @@ packages:
dependency: transitive
description:
name: win32
sha256: f2add6fa510d3ae152903412227bda57d0d5a8da61d2c39c1fb022c9429a41c0
sha256: "9e82a402b7f3d518fb9c02d0e9ae45952df31b9bf34d77baf19da2de03fc2aaa"
url: "https://pub.dev"
source: hosted
version: "5.0.6"
version: "5.0.7"
xdg_directories:
dependency: transitive
description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class PushNotificationMasamuneAdapter extends MasamuneAdapter {
///
/// PUSH通知を受信するための[MasamuneAdapter]です。
const PushNotificationMasamuneAdapter({
this.functions,
this.functionsAdapter,
this.modelAdapter,
required this.androidNotificationChannelId,
required this.androidNotificationChannelTitle,
required this.androidNotificationChannelDescription,
Expand Down Expand Up @@ -150,10 +151,15 @@ class PushNotificationMasamuneAdapter extends MasamuneAdapter {
/// [options]が指定されている場合はこちらが優先されます。
final FirebaseOptions? linuxOptions;

/// Specify if there are functions to be executed on the server side.
/// Specify [FunctionsAdapter] if there are functions to be executed on the server side.
///
/// サーバー側で実行する関数がある場合指定します。
final Functions? functions;
/// サーバー側で実行する関数がある場合[FunctionsAdapter]を指定します。
final FunctionsAdapter? functionsAdapter;

/// Specify a [ModelAdapter] to register the PUSH notification schedule.
///
/// PUSH通知のスケジュールを登録するための[ModelAdapter]を指定します。
final ModelAdapter? modelAdapter;

/// Notification channel IDs supported only by **Android**.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import 'package:katana_firebase/katana_firebase.dart';
import 'package:masamune/masamune.dart';
import 'package:universal_platform/universal_platform.dart';

import 'models/push_notification_schedule.dart';

part 'adapter/push_notification_masamune_adapter.dart';
part 'functions/send_notification_functions_action.dart';

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
// ignore: unused_import, unnecessary_import
import 'package:flutter/material.dart';
// ignore: unused_import, unnecessary_import
import 'package:masamune/masamune.dart';

import 'package:freezed_annotation/freezed_annotation.dart';

part 'push_notification_schedule.m.dart';
part 'push_notification_schedule.g.dart';
part 'push_notification_schedule.freezed.dart';

/// This model is for scheduling and registering notifications.
///
/// Specify the date and time to send the notification in [time].
///
/// Specify the title of the notification in [title]. Specify the body of the notification in [text].
///
/// 通知をスケジュールして登録するためのモデルです。
///
/// [time]に通知を送信する日時を指定します。
///
/// [title]に通知のタイトルを指定します。[text]に通知の本文を指定します。
@freezed
@formValue
@immutable
@CollectionModelPath("plugins/notification/schedule")
class PushNotificationScheduleModel with _$PushNotificationScheduleModel {
/// This model is for scheduling and registering notifications.
///
/// Specify the date and time to send the notification in [time].
///
/// Specify the title of the notification in [title]. Specify the body of the notification in [text].
///
/// 通知をスケジュールして登録するためのモデルです。
///
/// [time]に通知を送信する日時を指定します。
///
/// [title]に通知のタイトルを指定します。[text]に通知の本文を指定します。
const factory PushNotificationScheduleModel({
required ModelTimestamp time,
required String title,
required String text,
String? channelId,
DynamicMap? data,
String? token,
String? topic,
}) = _PushNotificationScheduleModel;
const PushNotificationScheduleModel._();

factory PushNotificationScheduleModel.fromJson(Map<String, Object?> json) =>
_$PushNotificationScheduleModelFromJson(json);

/// Query for document.
///
/// ```dart
/// appRef.model(PushNotificationScheduleModel.document(id)); // Get the document.
/// ref.model(PushNotificationScheduleModel.document(id))..load(); // Load the document.
/// ```
static const document = _$PushNotificationScheduleModelDocumentQuery();

/// Query for collection.
///
/// ```dart
/// appRef.model(PushNotificationScheduleModel.collection()); // Get the collection.
/// ref.model(PushNotificationScheduleModel.collection())..load(); // Load the collection.
/// ref.model(
/// PushNotificationScheduleModel.collection().data.equal(
/// "data",
/// )
/// )..load(); // Load the collection with filter.
/// ```
static const collection = _$PushNotificationScheduleModelCollectionQuery();

/// Query for form value.
///
/// ```dart
/// ref.page.controller(PushNotificationScheduleModel.form(PushNotificationScheduleModel())); // Get the form controller.
/// ```
static const form = _$PushNotificationScheduleModelFormQuery();
}

/// [Enum] of the name of the value defined in PushNotificationScheduleModel.
typedef PushNotificationScheduleModelKeys = _$PushNotificationScheduleModelKeys;

/// Alias for ModelRef<PushNotificationScheduleModel>.
///
/// When defining parameters for other Models, you can define them as follows
///
/// ```dart
/// @RefParam(PushNotificationScheduleModelDocument) PushNotificationScheduleModelRef push_notification_schedule
/// ```
typedef PushNotificationScheduleModelRef
= ModelRef<PushNotificationScheduleModel>?;

/// It can be defined as an empty ModelRef<PushNotificationScheduleModel>.
///
/// ```dart
/// PushNotificationScheduleModelRefPath("xxx") // Define as a path.
/// ```
typedef PushNotificationScheduleModelRefPath
= _$PushNotificationScheduleModelRefPath;

/// Class for defining initial values to be passed to `initialValue` of [RuntimeModelAdapter].
///
/// ```dart
/// RuntimeModelAdapter(
/// initialValue: [
/// PushNotificationScheduleModelInitialCollection(
/// "xxx": PushNotificationScheduleModel(...),
/// ),
/// ],
/// );
/// ```
typedef PushNotificationScheduleModelInitialCollection
= _$PushNotificationScheduleModelInitialCollection;

/// Document class for storing PushNotificationScheduleModel.
typedef PushNotificationScheduleModelDocument
= _$PushNotificationScheduleModelDocument;

/// Collection class for storing PushNotificationScheduleModel.
typedef PushNotificationScheduleModelCollection
= _$PushNotificationScheduleModelCollection;

/// It can be defined as an empty ModelRef<PushNotificationScheduleModel>.
///
/// ```dart
/// PushNotificationScheduleModelMirrorRefPath("xxx") // Define as a path.
/// ```
typedef PushNotificationScheduleModelMirrorRefPath
= _$PushNotificationScheduleModelMirrorRefPath;

/// Class for defining initial values to be passed to `initialValue` of [RuntimeModelAdapter].
///
/// ```dart
/// RuntimeModelAdapter(
/// initialValue: [
/// PushNotificationScheduleModelMirrorInitialCollection(
/// "xxx": PushNotificationScheduleModel(...),
/// ),
/// ],
/// );
/// ```
typedef PushNotificationScheduleModelMirrorInitialCollection
= _$PushNotificationScheduleModelMirrorInitialCollection;

/// Document class for storing PushNotificationScheduleModel.
typedef PushNotificationScheduleModelMirrorDocument
= _$PushNotificationScheduleModelMirrorDocument;

/// Collection class for storing PushNotificationScheduleModel.
typedef PushNotificationScheduleModelMirrorCollection
= _$PushNotificationScheduleModelMirrorCollection;

0 comments on commit 819d2a6

Please sign in to comment.