fix: Sharing on iOS and iPad

This commit is contained in:
Christian Pauly 2022-06-15 13:00:12 +02:00
parent a38da5cf69
commit a3d41da047
5 changed files with 18 additions and 5 deletions

View File

@ -121,7 +121,12 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
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);
},
),

View File

@ -9,7 +9,11 @@ import 'package:fluffychat/utils/platform_infos.dart';
abstract class FluffyShare {
static Future<void> 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),

View File

@ -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;
}

View File

@ -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:

View File

@ -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