From a3a0e8c7a2494fa5a555d780b0d46786b6c1ba24 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 13 Dec 2024 18:49:46 +0800 Subject: [PATCH] :bug: Bug fixes :bug: Fix cannot scan QR code from share post via image --- assets/translations/en-US.json | 1 + assets/translations/zh-CN.json | 1 + assets/translations/zh-HK.json | 1 + assets/translations/zh-TW.json | 1 + lib/providers/post.dart | 2 +- lib/widgets/post/post_item.dart | 18 ++++++++++++------ macos/Runner/DebugProfile.entitlements | 4 ---- macos/Runner/Release.entitlements | 4 ---- 8 files changed, 17 insertions(+), 15 deletions(-) diff --git a/assets/translations/en-US.json b/assets/translations/en-US.json index cf334fe..9db98b8 100644 --- a/assets/translations/en-US.json +++ b/assets/translations/en-US.json @@ -439,6 +439,7 @@ "userUnblocked": "{} has been unblocked.", "userBlocked": "{} has been blocked.", "postSharingViaPicture": "Capturing post as picture, please stand by...", + "postImageShareReadMore": "Scan the QR code to read full post", "postImageShareAds": "Explore posts on the Solar Network", "postShare": "Share", "postShareImage": "Share via Image" diff --git a/assets/translations/zh-CN.json b/assets/translations/zh-CN.json index 348db5c..2ba265b 100644 --- a/assets/translations/zh-CN.json +++ b/assets/translations/zh-CN.json @@ -437,6 +437,7 @@ "userUnblocked": "已解除屏蔽用户 {}", "userBlocked": "已屏蔽用户 {}", "postSharingViaPicture": "正在生成帖子截图,请稍等片刻……", + "postImageShareReadMore": "扫描坐车 QRCode 查看全文", "postImageShareAds": "来 Solar Network 探索更多有趣帖子", "postShare": "分享", "postShareImage": "分享帖图" diff --git a/assets/translations/zh-HK.json b/assets/translations/zh-HK.json index 5c6ba34..28b3e5e 100644 --- a/assets/translations/zh-HK.json +++ b/assets/translations/zh-HK.json @@ -437,6 +437,7 @@ "userUnblocked": "已解除屏蔽用户 {}", "userBlocked": "已屏蔽用户 {}", "postSharingViaPicture": "正在生成帖子截圖,請稍等片刻……", + "postImageShareReadMore": "掃描坐車 QRCode 查看全文", "postImageShareAds": "來 Solar Network 探索更多有趣帖子", "postShare": "分享", "postShareImage": "分享帖圖" diff --git a/assets/translations/zh-TW.json b/assets/translations/zh-TW.json index 3944875..1f0a7bc 100644 --- a/assets/translations/zh-TW.json +++ b/assets/translations/zh-TW.json @@ -437,6 +437,7 @@ "userUnblocked": "已解除遮蔽使用者 {}", "userBlocked": "已遮蔽使用者 {}", "postSharingViaPicture": "正在生成帖子截圖,請稍等片刻……", + "postImageShareReadMore": "掃描坐車 QRCode 檢視全文", "postImageShareAds": "來 Solar Network 探索更多有趣帖子", "postShare": "分享", "postShareImage": "分享帖圖" diff --git a/lib/providers/post.dart b/lib/providers/post.dart index 74466bb..58dae80 100644 --- a/lib/providers/post.dart +++ b/lib/providers/post.dart @@ -53,7 +53,7 @@ class SnPostContentProvider { if (out.body['thumbnail'] != null) { rids.add(out.body['thumbnail']); } - if (out.repostId != null) { + if (out.repostTo != null) { out = out.copyWith( repostTo: await _preloadRelatedDataSingle(out.repostTo!), ); diff --git a/lib/widgets/post/post_item.dart b/lib/widgets/post/post_item.dart index 1e9143b..7b7f795 100644 --- a/lib/widgets/post/post_item.dart +++ b/lib/widgets/post/post_item.dart @@ -84,7 +84,7 @@ class PostItem extends StatelessWidget { ], child: ResponsiveBreakpoints.builder( breakpoints: ResponsiveBreakpoints.of(context).breakpoints, - child: PostShareImage(data: data), + child: PostShareImageWidget(data: data), ), ), ), @@ -115,7 +115,7 @@ class PostItem extends StatelessWidget { final sn = context.read(); final ua = context.read(); - final isAuthor = ua.isAuthorized && data.publisher.accountId == ua.user!.id; + final isAuthor = ua.isAuthorized && data.publisher.accountId == ua.user?.id; // Article headline preview if (!showFullPost && data.type == 'article') { @@ -261,8 +261,8 @@ class PostItem extends StatelessWidget { } } -class PostShareImage extends StatelessWidget { - const PostShareImage({ +class PostShareImageWidget extends StatelessWidget { + const PostShareImageWidget({ super.key, required this.data, }); @@ -349,6 +349,11 @@ class PostShareImage extends StatelessWidget { ], ), ), + if(data.body['content_truncated'] == true) + Text( + 'postImageShareReadMore'.tr(), + style: GoogleFonts.robotoMono(fontSize: 11), + ), Text( 'postImageShareAds', style: GoogleFonts.robotoMono(fontSize: 13), @@ -359,15 +364,16 @@ class PostShareImage extends StatelessWidget { QrImageView( padding: EdgeInsets.zero, data: 'https://solsynth.dev/posts/${data.id}', + errorCorrectionLevel: QrErrorCorrectLevel.H, version: QrVersions.auto, size: 100, gapless: true, embeddedImage: AssetImage('assets/icon/icon-light-radius.png'), embeddedImageStyle: QrEmbeddedImageStyle( - size: Size(32, 32), + size: Size(24, 24), ), eyeStyle: QrEyeStyle( - eyeShape: QrEyeShape.circle, + eyeShape: QrEyeShape.square, color: Theme.of(context).colorScheme.onSurface, ), dataModuleStyle: QrDataModuleStyle( diff --git a/macos/Runner/DebugProfile.entitlements b/macos/Runner/DebugProfile.entitlements index 31f36d7..46e6f68 100644 --- a/macos/Runner/DebugProfile.entitlements +++ b/macos/Runner/DebugProfile.entitlements @@ -10,12 +10,8 @@ com.apple.security.device.audio-input - com.apple.security.device.bluetooth - com.apple.security.device.camera - com.apple.security.files.downloads.read-write - com.apple.security.files.user-selected.read-write com.apple.security.network.client diff --git a/macos/Runner/Release.entitlements b/macos/Runner/Release.entitlements index 762b4c9..c7edc19 100644 --- a/macos/Runner/Release.entitlements +++ b/macos/Runner/Release.entitlements @@ -8,12 +8,8 @@ com.apple.security.device.audio-input - com.apple.security.device.bluetooth - com.apple.security.device.camera - com.apple.security.files.downloads.read-write - com.apple.security.files.user-selected.read-write com.apple.security.network.client