nc-photos/app/lib/mobile/notification.dart

73 lines
1.7 KiB
Dart
Raw Normal View History

2021-10-02 17:12:54 +08:00
import 'package:flutter/foundation.dart';
import 'package:nc_photos/platform/notification.dart' as itf;
2022-03-11 22:44:43 +08:00
import 'package:nc_photos_plugin/nc_photos_plugin.dart' as plugin;
2021-10-02 17:12:54 +08:00
class AndroidDownloadSuccessfulNotification extends _AndroidNotification {
AndroidDownloadSuccessfulNotification(
this.fileUris,
this.mimeTypes, {
int? notificationId,
}) : replaceId = notificationId;
@override
2022-03-11 22:44:43 +08:00
doNotify() => plugin.Notification.notifyDownloadSuccessful(
fileUris, mimeTypes, replaceId);
final List<String> fileUris;
2021-07-24 04:05:57 +08:00
final List<String?> mimeTypes;
2021-10-02 17:12:54 +08:00
final int? replaceId;
}
2021-10-02 17:12:54 +08:00
class AndroidDownloadProgressNotification extends _AndroidNotification {
AndroidDownloadProgressNotification(
this.progress,
this.max, {
this.currentItemTitle,
});
@override
2022-03-11 22:44:43 +08:00
doNotify() => plugin.Notification.notifyDownloadProgress(
2021-10-02 17:12:54 +08:00
progress, max, currentItemTitle, notificationId);
Future<void> update(
int progress, {
String? currentItemTitle,
}) async {
this.progress = progress;
this.currentItemTitle = currentItemTitle;
await doNotify();
}
2021-10-02 17:12:54 +08:00
int progress;
final int max;
String? currentItemTitle;
}
class AndroidLogSaveSuccessfulNotification extends _AndroidNotification {
AndroidLogSaveSuccessfulNotification(this.fileUri);
@override
2022-03-11 22:44:43 +08:00
doNotify() => plugin.Notification.notifyLogSaveSuccessful(fileUri);
2021-10-02 17:12:54 +08:00
final String fileUri;
}
2021-10-02 17:12:54 +08:00
abstract class _AndroidNotification extends itf.Notification {
@override
notify() async {
notificationId = await doNotify();
}
@override
dismiss() async {
if (notificationId != null) {
2022-03-11 22:44:43 +08:00
await plugin.Notification.dismiss(notificationId!);
2021-10-02 17:12:54 +08:00
}
}
@protected
Future<int?> doNotify();
int? notificationId;
}