mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
Break plugin classes into separated files
This commit is contained in:
parent
4c0fbb49b1
commit
46b90cadfe
4 changed files with 54 additions and 49 deletions
|
@ -1,50 +1,4 @@
|
|||
import 'dart:async';
|
||||
library nc_photos_plugin;
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
class Lock {
|
||||
static Future<bool> tryLock(int lockId) async {
|
||||
return (await _channel.invokeMethod<bool>("tryLock", <String, dynamic>{
|
||||
"lockId": lockId,
|
||||
}))!;
|
||||
}
|
||||
|
||||
static Future<void> unlock(int lockId) =>
|
||||
_channel.invokeMethod("unlock", <String, dynamic>{
|
||||
"lockId": lockId,
|
||||
});
|
||||
|
||||
static const _channel = MethodChannel("com.nkming.nc_photos.plugin/lock");
|
||||
}
|
||||
|
||||
class Notification {
|
||||
static Future<int?> notifyDownloadSuccessful(List<String> fileUris,
|
||||
List<String?> mimeTypes, int? notificationId) =>
|
||||
_channel.invokeMethod("notifyDownloadSuccessful", <String, dynamic>{
|
||||
"fileUris": fileUris,
|
||||
"mimeTypes": mimeTypes,
|
||||
"notificationId": notificationId,
|
||||
});
|
||||
|
||||
static Future<int?> notifyDownloadProgress(int progress, int max,
|
||||
String? currentItemTitle, int? notificationId) =>
|
||||
_channel.invokeMethod("notifyDownloadProgress", <String, dynamic>{
|
||||
"progress": progress,
|
||||
"max": max,
|
||||
"currentItemTitle": currentItemTitle,
|
||||
"notificationId": notificationId,
|
||||
});
|
||||
|
||||
static Future<int?> notifyLogSaveSuccessful(String fileUri) =>
|
||||
_channel.invokeMethod("notifyLogSaveSuccessful", <String, dynamic>{
|
||||
"fileUri": fileUri,
|
||||
});
|
||||
|
||||
static Future<void> dismiss(int notificationId) =>
|
||||
_channel.invokeMethod("dismiss", <String, dynamic>{
|
||||
"notificationId": notificationId,
|
||||
});
|
||||
|
||||
static const _channel =
|
||||
MethodChannel("com.nkming.nc_photos.plugin/notification");
|
||||
}
|
||||
export 'src/lock.dart';
|
||||
export 'src/notification.dart';
|
||||
|
|
1
plugin/lib/src/k.dart
Normal file
1
plugin/lib/src/k.dart
Normal file
|
@ -0,0 +1 @@
|
|||
const libId = "com.nkming.nc_photos.plugin";
|
17
plugin/lib/src/lock.dart
Normal file
17
plugin/lib/src/lock.dart
Normal file
|
@ -0,0 +1,17 @@
|
|||
import 'package:flutter/services.dart';
|
||||
import 'package:nc_photos_plugin/src/k.dart' as k;
|
||||
|
||||
class Lock {
|
||||
static Future<bool> tryLock(int lockId) async {
|
||||
return (await _channel.invokeMethod<bool>("tryLock", <String, dynamic>{
|
||||
"lockId": lockId,
|
||||
}))!;
|
||||
}
|
||||
|
||||
static Future<void> unlock(int lockId) =>
|
||||
_channel.invokeMethod("unlock", <String, dynamic>{
|
||||
"lockId": lockId,
|
||||
});
|
||||
|
||||
static const _channel = MethodChannel("${k.libId}/lock");
|
||||
}
|
33
plugin/lib/src/notification.dart
Normal file
33
plugin/lib/src/notification.dart
Normal file
|
@ -0,0 +1,33 @@
|
|||
import 'package:flutter/services.dart';
|
||||
import 'package:nc_photos_plugin/src/k.dart' as k;
|
||||
|
||||
class Notification {
|
||||
static Future<int?> notifyDownloadSuccessful(List<String> fileUris,
|
||||
List<String?> mimeTypes, int? notificationId) =>
|
||||
_channel.invokeMethod("notifyDownloadSuccessful", <String, dynamic>{
|
||||
"fileUris": fileUris,
|
||||
"mimeTypes": mimeTypes,
|
||||
"notificationId": notificationId,
|
||||
});
|
||||
|
||||
static Future<int?> notifyDownloadProgress(int progress, int max,
|
||||
String? currentItemTitle, int? notificationId) =>
|
||||
_channel.invokeMethod("notifyDownloadProgress", <String, dynamic>{
|
||||
"progress": progress,
|
||||
"max": max,
|
||||
"currentItemTitle": currentItemTitle,
|
||||
"notificationId": notificationId,
|
||||
});
|
||||
|
||||
static Future<int?> notifyLogSaveSuccessful(String fileUri) =>
|
||||
_channel.invokeMethod("notifyLogSaveSuccessful", <String, dynamic>{
|
||||
"fileUri": fileUri,
|
||||
});
|
||||
|
||||
static Future<void> dismiss(int notificationId) =>
|
||||
_channel.invokeMethod("dismiss", <String, dynamic>{
|
||||
"notificationId": notificationId,
|
||||
});
|
||||
|
||||
static const _channel = MethodChannel("${k.libId}/notification");
|
||||
}
|
Loading…
Reference in a new issue