🐛 Fix missing sharePositionOrigin in share

This commit is contained in:
2025-08-17 11:56:34 +08:00
parent ff871943cf
commit a04dffdfe8
2 changed files with 21 additions and 6 deletions

View File

@@ -117,8 +117,12 @@ class PostActionableItem extends HookConsumerWidget {
await File('${directory.path}/image.png').create(); await File('${directory.path}/image.png').create();
await imagePath.writeAsBytes(image); await imagePath.writeAsBytes(image);
if (context.mounted) hideLoadingModal(context); if (!context.mounted) return;
await Share.shareXFiles([XFile(imagePath.path)]); hideLoadingModal(context);
final box = context.findRenderObject() as RenderBox?;
await Share.shareXFiles([
XFile(imagePath.path),
], sharePositionOrigin: box!.localToGlobal(Offset.zero) & box.size);
}) })
.catchError((err) { .catchError((err) {
if (context.mounted) hideLoadingModal(context); if (context.mounted) hideLoadingModal(context);
@@ -174,7 +178,7 @@ class PostActionableItem extends HookConsumerWidget {
image: MenuImage.icon(Symbols.link), image: MenuImage.icon(Symbols.link),
callback: () { callback: () {
Clipboard.setData( Clipboard.setData(
ClipboardData(text: 'https://solsynth.dev/posts/${item.id}'), ClipboardData(text: 'https://solian.app/posts/${item.id}'),
); );
}, },
), ),

View File

@@ -340,22 +340,33 @@ class _ShareSheetState extends ConsumerState<ShareSheet> {
Future<void> _shareToSystem() async { Future<void> _shareToSystem() async {
if (!widget.toSystem) return; if (!widget.toSystem) return;
final box = context.findRenderObject() as RenderBox?;
setState(() => _isLoading = true); setState(() => _isLoading = true);
try { try {
switch (widget.content.type) { switch (widget.content.type) {
case ShareContentType.text: case ShareContentType.text:
if (widget.content.text?.isNotEmpty == true) { 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; break;
case ShareContentType.link: case ShareContentType.link:
if (widget.content.link?.isNotEmpty == true) { 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; break;
case ShareContentType.file: case ShareContentType.file:
if (widget.content.files?.isNotEmpty == true) { 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; break;
} }