From a3d41da047a995fb0d0cbdb0fb9b1a82af5a03f1 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Wed, 15 Jun 2022 13:00:12 +0200 Subject: [PATCH] fix: Sharing on iOS and iPad --- lib/pages/bootstrap/bootstrap_dialog.dart | 7 ++++++- lib/utils/fluffy_share.dart | 6 +++++- .../matrix_sdk_extensions.dart/matrix_file_extension.dart | 6 +++++- pubspec.lock | 2 +- pubspec.yaml | 2 +- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/pages/bootstrap/bootstrap_dialog.dart b/lib/pages/bootstrap/bootstrap_dialog.dart index bace36c9..6e35e62e 100644 --- a/lib/pages/bootstrap/bootstrap_dialog.dart +++ b/lib/pages/bootstrap/bootstrap_dialog.dart @@ -121,7 +121,12 @@ class _BootstrapDialogState extends State { icon: const Icon(Icons.save_alt_outlined), label: Text(L10n.of(context)!.saveTheSecurityKeyNow), onPressed: () { - Share.share(key!); + final box = context.findRenderObject() as RenderBox; + Share.share( + key!, + sharePositionOrigin: + box.localToGlobal(Offset.zero) & box.size, + ); setState(() => _recoveryKeyCopied = true); }, ), diff --git a/lib/utils/fluffy_share.dart b/lib/utils/fluffy_share.dart index 052198cc..630803b3 100644 --- a/lib/utils/fluffy_share.dart +++ b/lib/utils/fluffy_share.dart @@ -9,7 +9,11 @@ import 'package:fluffychat/utils/platform_infos.dart'; abstract class FluffyShare { static Future share(String text, BuildContext context) async { if (PlatformInfos.isMobile) { - return Share.share(text); + final box = context.findRenderObject() as RenderBox; + return Share.share( + text, + sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size, + ); } await Clipboard.setData( ClipboardData(text: text), diff --git a/lib/utils/matrix_sdk_extensions.dart/matrix_file_extension.dart b/lib/utils/matrix_sdk_extensions.dart/matrix_file_extension.dart index bfeefe8a..17ebd339 100644 --- a/lib/utils/matrix_sdk_extensions.dart/matrix_file_extension.dart +++ b/lib/utils/matrix_sdk_extensions.dart/matrix_file_extension.dart @@ -25,7 +25,11 @@ extension MatrixFileExtension on MatrixFile { final tmpDirectory = await getTemporaryDirectory(); final path = '${tmpDirectory.path}$fileName'; await File(path).writeAsBytes(bytes); - await Share.shareFiles([path]); + final box = context.findRenderObject() as RenderBox; + await Share.shareFiles( + [path], + sharePositionOrigin: box.localToGlobal(Offset.zero) & box.size, + ); return; } diff --git a/pubspec.lock b/pubspec.lock index e5986b1b..53abc989 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1464,7 +1464,7 @@ packages: name: share_plus url: "https://pub.dartlang.org" source: hosted - version: "4.0.6" + version: "4.0.8" share_plus_linux: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 4dc1542d..a8cc2d59 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -75,7 +75,7 @@ dependencies: salomon_bottom_bar: ^3.2.0 scroll_to_index: ^2.1.1 sentry: ^6.3.0 - share_plus: ^4.0.6 + share_plus: ^4.0.8 shared_preferences: ^2.0.13 slugify: ^2.0.0 snapping_sheet: ^3.1.0