nc-photos/app/lib/mobile/share.dart
Ming Ming d5de52a789 Support ATTACH_DATA intent on android
This is typically used to set wallpaper or contact photos
2023-08-04 01:24:25 +08:00

42 lines
969 B
Dart

import 'package:nc_photos/mobile/android/share.dart';
import 'package:nc_photos/platform/share.dart' as itf;
class AndroidFileShareFile {
const AndroidFileShareFile(this.fileUri, this.mimeType);
final String fileUri;
final String? mimeType;
}
class AndroidFileShare implements itf.FileShare {
const AndroidFileShare(this.files);
@override
Future<void> share() {
final uris = files.map((e) => e.fileUri).toList();
final mimes = files.map((e) => e.mimeType).toList();
return Share.shareItems(uris, mimes);
}
Future<void> setAs() {
assert(files.length == 1);
return Share.shareAsAttachData(files.first.fileUri, files.first.mimeType);
}
final List<AndroidFileShareFile> files;
}
class AndroidTextShare extends itf.TextShare {
AndroidTextShare(
this.text, {
this.mimeType = "text/plain",
});
@override
share() {
return Share.shareText(text, mimeType);
}
final String text;
final String? mimeType;
}