From 9c5e50c16a3dc4a2cf9bb4be6b710822a1d6484d Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Wed, 19 Nov 2025 22:49:47 +0800 Subject: [PATCH] :bug: Fix share post via screenshot entirely broke --- lib/widgets/account/account_name.dart | 166 +++++++++++++-------- lib/widgets/post/post_item_screenshot.dart | 2 + lib/widgets/post/post_shared.dart | 42 ++++-- 3 files changed, 135 insertions(+), 75 deletions(-) diff --git a/lib/widgets/account/account_name.dart b/lib/widgets/account/account_name.dart index 55db6933..a429bb69 100644 --- a/lib/widgets/account/account_name.dart +++ b/lib/widgets/account/account_name.dart @@ -39,6 +39,7 @@ class AccountName extends StatelessWidget { final String? textOverride; final bool ignorePermissions; final bool hideVerificationMark; + final bool hideOverlay; const AccountName({ super.key, required this.account, @@ -46,6 +47,7 @@ class AccountName extends StatelessWidget { this.textOverride, this.ignorePermissions = false, this.hideVerificationMark = false, + this.hideOverlay = false, }); Alignment _parseGradientDirection(String direction) { @@ -189,20 +191,33 @@ class AccountName extends StatelessWidget { ), ), if (account.perkSubscription != null) - StellarMembershipMark(membership: account.perkSubscription!), + StellarMembershipMark( + membership: account.perkSubscription!, + hideOverlay: hideOverlay, + ), if (account.profile.verification != null && !hideVerificationMark) - VerificationMark(mark: account.profile.verification!), - if (account.automatedId != null) - Tooltip( - message: 'accountAutomated'.tr(), - child: Icon( - Symbols.smart_toy, - size: 16, - color: nameStyle.color, - fill: 1, - ), + VerificationMark( + mark: account.profile.verification!, + hideOverlay: hideOverlay, ), + if (account.automatedId != null) + hideOverlay + ? Icon( + Symbols.smart_toy, + size: 16, + color: nameStyle.color, + fill: 1, + ) + : Tooltip( + message: 'accountAutomated'.tr(), + child: Icon( + Symbols.smart_toy, + size: 16, + color: nameStyle.color, + fill: 1, + ), + ), ], ); } @@ -233,19 +248,32 @@ class AccountName extends StatelessWidget { ), ), if (account.perkSubscription != null) - StellarMembershipMark(membership: account.perkSubscription!), - if (account.profile.verification != null) - VerificationMark(mark: account.profile.verification!), - if (account.automatedId != null) - Tooltip( - message: 'accountAutomated'.tr(), - child: Icon( - Symbols.smart_toy, - size: 16, - color: nameStyle.color, - fill: 1, - ), + StellarMembershipMark( + membership: account.perkSubscription!, + hideOverlay: hideOverlay, ), + if (account.profile.verification != null) + VerificationMark( + mark: account.profile.verification!, + hideOverlay: hideOverlay, + ), + if (account.automatedId != null) + hideOverlay + ? Icon( + Symbols.smart_toy, + size: 16, + color: nameStyle.color, + fill: 1, + ) + : Tooltip( + message: 'accountAutomated'.tr(), + child: Icon( + Symbols.smart_toy, + size: 16, + color: nameStyle.color, + fill: 1, + ), + ), ], ); } @@ -253,39 +281,53 @@ class AccountName extends StatelessWidget { class VerificationMark extends StatelessWidget { final SnVerificationMark mark; - const VerificationMark({super.key, required this.mark}); + final bool hideOverlay; + const VerificationMark({ + super.key, + required this.mark, + this.hideOverlay = false, + }); @override Widget build(BuildContext context) { - return Tooltip( - richMessage: TextSpan( - text: mark.title ?? 'No title', - children: [ - TextSpan(text: '\n'), - TextSpan( - text: mark.description ?? 'descriptionNone'.tr(), - style: TextStyle(fontWeight: FontWeight.normal), - ), - ], - style: TextStyle(fontWeight: FontWeight.bold), - ), - child: Icon( - mark.type == 4 - ? Symbols.play_circle - : mark.type == 0 - ? Symbols.build_circle - : Symbols.verified, - size: 16, - color: kVerificationMarkColors[mark.type], - fill: 1, - ), + final icon = Icon( + mark.type == 4 + ? Symbols.play_circle + : mark.type == 0 + ? Symbols.build_circle + : Symbols.verified, + size: 16, + color: kVerificationMarkColors[mark.type], + fill: 1, ); + + return hideOverlay + ? icon + : Tooltip( + richMessage: TextSpan( + text: mark.title ?? 'No title', + children: [ + TextSpan(text: '\n'), + TextSpan( + text: mark.description ?? 'descriptionNone'.tr(), + style: TextStyle(fontWeight: FontWeight.normal), + ), + ], + style: TextStyle(fontWeight: FontWeight.bold), + ), + child: icon, + ); } } class StellarMembershipMark extends StatelessWidget { final SnWalletSubscriptionRef membership; - const StellarMembershipMark({super.key, required this.membership}); + final bool hideOverlay; + const StellarMembershipMark({ + super.key, + required this.membership, + this.hideOverlay = false, + }); String _getMembershipTierName(String identifier) { switch (identifier) { @@ -321,20 +363,24 @@ class StellarMembershipMark extends StatelessWidget { final tierColor = _getMembershipTierColor(membership.identifier); final tierIcon = Symbols.kid_star; - return Tooltip( - richMessage: TextSpan( - text: 'stellarMembership'.tr(), - children: [ - TextSpan(text: '\n'), - TextSpan( - text: 'currentMembershipMember'.tr(args: [tierName]), - style: TextStyle(fontWeight: FontWeight.normal), + final icon = Icon(tierIcon, size: 16, color: tierColor, fill: 1); + + return hideOverlay + ? icon + : Tooltip( + richMessage: TextSpan( + text: 'stellarMembership'.tr(), + children: [ + TextSpan(text: '\n'), + TextSpan( + text: 'currentMembershipMember'.tr(args: [tierName]), + style: TextStyle(fontWeight: FontWeight.normal), + ), + ], + style: TextStyle(fontWeight: FontWeight.bold), ), - ], - style: TextStyle(fontWeight: FontWeight.bold), - ), - child: Icon(tierIcon, size: 16, color: tierColor, fill: 1), - ); + child: icon, + ); } } diff --git a/lib/widgets/post/post_item_screenshot.dart b/lib/widgets/post/post_item_screenshot.dart index eeea50a9..01081b8d 100644 --- a/lib/widgets/post/post_item_screenshot.dart +++ b/lib/widgets/post/post_item_screenshot.dart @@ -45,6 +45,7 @@ class PostItemScreenshot extends ConsumerWidget { children: [ Gap(renderingPadding.vertical), PostHeader( + hideOverlay: true, item: item, isFullPost: isFullPost, isInteractive: false, @@ -73,6 +74,7 @@ class PostItemScreenshot extends ConsumerWidget { isFullPost: isFullPost, isTextSelectable: false, isInteractive: false, + hideOverlay: true, ), if (isShowReference) ReferencedPostWidget( diff --git a/lib/widgets/post/post_shared.dart b/lib/widgets/post/post_shared.dart index ab72af44..e8c85531 100644 --- a/lib/widgets/post/post_shared.dart +++ b/lib/widgets/post/post_shared.dart @@ -554,6 +554,7 @@ class PostHeader extends StatelessWidget { final EdgeInsets renderingPadding; final bool isRelativeTime; final bool isCompact; + final bool hideOverlay; const PostHeader({ super.key, @@ -564,6 +565,7 @@ class PostHeader extends StatelessWidget { this.renderingPadding = EdgeInsets.zero, this.isRelativeTime = true, this.isCompact = false, + this.hideOverlay = false, }); @override @@ -606,6 +608,7 @@ class PostHeader extends StatelessWidget { (item.publisher.account != null && item.publisher.type == 0) ? AccountName( + hideOverlay: hideOverlay, account: item.publisher.account!, textOverride: item.publisher.nick, style: TextStyle(fontWeight: FontWeight.bold), @@ -618,7 +621,10 @@ class PostHeader extends StatelessWidget { ).bold(), ), if (item.publisher.verification != null) - VerificationMark(mark: item.publisher.verification!), + VerificationMark( + mark: item.publisher.verification!, + hideOverlay: hideOverlay, + ), if (item.realm == null) Flexible( child: @@ -690,6 +696,7 @@ class PostBody extends ConsumerWidget { final bool isInteractive; final EdgeInsets renderingPadding; final bool isRelativeTime; + final bool hideOverlay; const PostBody({ super.key, @@ -700,6 +707,7 @@ class PostBody extends ConsumerWidget { this.isInteractive = true, this.renderingPadding = EdgeInsets.zero, this.isRelativeTime = true, + this.hideOverlay = false, }); @override @@ -771,27 +779,31 @@ class PostBody extends ConsumerWidget { ); } if (item.editedAt != null) { + final text = Text( + 'editedAt'.tr( + args: [ + !isFullPost && isRelativeTime + ? item.editedAt!.formatRelative(context) + : item.editedAt!.formatSystem(), + ], + ), + ).fontSize(13); + metadataChildren.add( Row( spacing: 8, crossAxisAlignment: CrossAxisAlignment.center, children: [ const Icon(Symbols.edit, size: 16), - Tooltip( - message: - !isFullPost && isRelativeTime - ? item.editedAt!.formatSystem() - : item.editedAt!.formatRelative(context), - child: Text( - 'editedAt'.tr( - args: [ - !isFullPost && isRelativeTime - ? item.editedAt!.formatRelative(context) - : item.editedAt!.formatSystem(), - ], + hideOverlay + ? text + : Tooltip( + message: + !isFullPost && isRelativeTime + ? item.editedAt!.formatSystem() + : item.editedAt!.formatRelative(context), + child: text, ), - ).fontSize(13), - ), ], ), );