From a04dffdfe8974e58a7b31e228121e57e85f86b24 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 17 Aug 2025 11:56:34 +0800 Subject: [PATCH] :bug: Fix missing sharePositionOrigin in share --- lib/widgets/post/post_item.dart | 10 +++++++--- lib/widgets/share/share_sheet.dart | 17 ++++++++++++++--- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/widgets/post/post_item.dart b/lib/widgets/post/post_item.dart index 07a0f03c..7f79a849 100644 --- a/lib/widgets/post/post_item.dart +++ b/lib/widgets/post/post_item.dart @@ -117,8 +117,12 @@ class PostActionableItem extends HookConsumerWidget { await File('${directory.path}/image.png').create(); await imagePath.writeAsBytes(image); - if (context.mounted) hideLoadingModal(context); - await Share.shareXFiles([XFile(imagePath.path)]); + if (!context.mounted) return; + hideLoadingModal(context); + final box = context.findRenderObject() as RenderBox?; + await Share.shareXFiles([ + XFile(imagePath.path), + ], sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size); }) .catchError((err) { if (context.mounted) hideLoadingModal(context); @@ -174,7 +178,7 @@ class PostActionableItem extends HookConsumerWidget { image: MenuImage.icon(Symbols.link), callback: () { Clipboard.setData( - ClipboardData(text: 'https://solsynth.dev/posts/${item.id}'), + ClipboardData(text: 'https://solian.app/posts/${item.id}'), ); }, ), diff --git a/lib/widgets/share/share_sheet.dart b/lib/widgets/share/share_sheet.dart index 82b58b37..037f8203 100644 --- a/lib/widgets/share/share_sheet.dart +++ b/lib/widgets/share/share_sheet.dart @@ -340,22 +340,33 @@ class _ShareSheetState extends ConsumerState { Future _shareToSystem() async { if (!widget.toSystem) return; + final box = context.findRenderObject() as RenderBox?; + setState(() => _isLoading = true); try { switch (widget.content.type) { case ShareContentType.text: if (widget.content.text?.isNotEmpty == true) { - await Share.share(widget.content.text!); + await Share.share( + widget.content.text!, + sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, + ); } break; case ShareContentType.link: if (widget.content.link?.isNotEmpty == true) { - await Share.share(widget.content.link!); + await Share.share( + widget.content.link!, + sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, + ); } break; case ShareContentType.file: if (widget.content.files?.isNotEmpty == true) { - await Share.shareXFiles(widget.content.files!); + await Share.shareXFiles( + widget.content.files!, + sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size, + ); } break; }