fix(mobile): native share functionality on iPad (#11294)

* pass context to share method

* use correct context

* fix: multiselection and logs sharing

* fix: lint
This commit is contained in:
Saschl
2024-07-26 15:43:59 +02:00
committed by GitHub
parent 86a658b891
commit 62ac9bb7cd
5 changed files with 27 additions and 17 deletions
@@ -85,7 +85,7 @@ class ImmichLogger {
_db.writeTxn(() => _db.loggerMessages.clear());
}
Future<void> shareLogs() async {
Future<void> shareLogs(BuildContext context) async {
final tempDir = await getTemporaryDirectory();
final dateTime = DateTime.now().toIso8601String();
final filePath = '${tempDir.path}/Immich_log_$dateTime.log';
@@ -107,11 +107,13 @@ class ImmichLogger {
await io.close();
}
final box = context.findRenderObject() as RenderBox?;
// Share file
await Share.shareXFiles(
[XFile(filePath)],
subject: "Immich logs $dateTime",
sharePositionOrigin: Rect.zero,
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
).then(
(value) => logFile.delete(),
);
+5 -4
View File
@@ -19,11 +19,11 @@ class ShareService {
ShareService(this._apiService);
Future<bool> shareAsset(Asset asset) async {
return await shareAssets([asset]);
Future<bool> shareAsset(Asset asset, BuildContext context) async {
return await shareAssets([asset], context);
}
Future<bool> shareAssets(List<Asset> assets) async {
Future<bool> shareAssets(List<Asset> assets, BuildContext context) async {
try {
final downloadedXFiles = <XFile>[];
@@ -64,9 +64,10 @@ class ShareService {
);
}
final box = context.findRenderObject() as RenderBox?;
Share.shareXFiles(
downloadedXFiles,
sharePositionOrigin: Rect.zero,
sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size,
);
return true;
} catch (error) {