🐛 Fix share post via screenshot entirely broke

This commit is contained in:
2025-11-19 22:49:47 +08:00
parent 96a2c8182e
commit 9c5e50c16a
3 changed files with 135 additions and 75 deletions

View File

@@ -39,6 +39,7 @@ class AccountName extends StatelessWidget {
final String? textOverride; final String? textOverride;
final bool ignorePermissions; final bool ignorePermissions;
final bool hideVerificationMark; final bool hideVerificationMark;
final bool hideOverlay;
const AccountName({ const AccountName({
super.key, super.key,
required this.account, required this.account,
@@ -46,6 +47,7 @@ class AccountName extends StatelessWidget {
this.textOverride, this.textOverride,
this.ignorePermissions = false, this.ignorePermissions = false,
this.hideVerificationMark = false, this.hideVerificationMark = false,
this.hideOverlay = false,
}); });
Alignment _parseGradientDirection(String direction) { Alignment _parseGradientDirection(String direction) {
@@ -189,12 +191,25 @@ class AccountName extends StatelessWidget {
), ),
), ),
if (account.perkSubscription != null) if (account.perkSubscription != null)
StellarMembershipMark(membership: account.perkSubscription!), StellarMembershipMark(
membership: account.perkSubscription!,
hideOverlay: hideOverlay,
),
if (account.profile.verification != null && if (account.profile.verification != null &&
!hideVerificationMark) !hideVerificationMark)
VerificationMark(mark: account.profile.verification!), VerificationMark(
mark: account.profile.verification!,
hideOverlay: hideOverlay,
),
if (account.automatedId != null) if (account.automatedId != null)
Tooltip( hideOverlay
? Icon(
Symbols.smart_toy,
size: 16,
color: nameStyle.color,
fill: 1,
)
: Tooltip(
message: 'accountAutomated'.tr(), message: 'accountAutomated'.tr(),
child: Icon( child: Icon(
Symbols.smart_toy, Symbols.smart_toy,
@@ -233,11 +248,24 @@ class AccountName extends StatelessWidget {
), ),
), ),
if (account.perkSubscription != null) if (account.perkSubscription != null)
StellarMembershipMark(membership: account.perkSubscription!), StellarMembershipMark(
membership: account.perkSubscription!,
hideOverlay: hideOverlay,
),
if (account.profile.verification != null) if (account.profile.verification != null)
VerificationMark(mark: account.profile.verification!), VerificationMark(
mark: account.profile.verification!,
hideOverlay: hideOverlay,
),
if (account.automatedId != null) if (account.automatedId != null)
Tooltip( hideOverlay
? Icon(
Symbols.smart_toy,
size: 16,
color: nameStyle.color,
fill: 1,
)
: Tooltip(
message: 'accountAutomated'.tr(), message: 'accountAutomated'.tr(),
child: Icon( child: Icon(
Symbols.smart_toy, Symbols.smart_toy,
@@ -253,11 +281,29 @@ class AccountName extends StatelessWidget {
class VerificationMark extends StatelessWidget { class VerificationMark extends StatelessWidget {
final SnVerificationMark mark; final SnVerificationMark mark;
const VerificationMark({super.key, required this.mark}); final bool hideOverlay;
const VerificationMark({
super.key,
required this.mark,
this.hideOverlay = false,
});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Tooltip( 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( richMessage: TextSpan(
text: mark.title ?? 'No title', text: mark.title ?? 'No title',
children: [ children: [
@@ -269,23 +315,19 @@ class VerificationMark extends StatelessWidget {
], ],
style: TextStyle(fontWeight: FontWeight.bold), style: TextStyle(fontWeight: FontWeight.bold),
), ),
child: Icon( child: icon,
mark.type == 4
? Symbols.play_circle
: mark.type == 0
? Symbols.build_circle
: Symbols.verified,
size: 16,
color: kVerificationMarkColors[mark.type],
fill: 1,
),
); );
} }
} }
class StellarMembershipMark extends StatelessWidget { class StellarMembershipMark extends StatelessWidget {
final SnWalletSubscriptionRef membership; 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) { String _getMembershipTierName(String identifier) {
switch (identifier) { switch (identifier) {
@@ -321,7 +363,11 @@ class StellarMembershipMark extends StatelessWidget {
final tierColor = _getMembershipTierColor(membership.identifier); final tierColor = _getMembershipTierColor(membership.identifier);
final tierIcon = Symbols.kid_star; final tierIcon = Symbols.kid_star;
return Tooltip( final icon = Icon(tierIcon, size: 16, color: tierColor, fill: 1);
return hideOverlay
? icon
: Tooltip(
richMessage: TextSpan( richMessage: TextSpan(
text: 'stellarMembership'.tr(), text: 'stellarMembership'.tr(),
children: [ children: [
@@ -333,7 +379,7 @@ class StellarMembershipMark extends StatelessWidget {
], ],
style: TextStyle(fontWeight: FontWeight.bold), style: TextStyle(fontWeight: FontWeight.bold),
), ),
child: Icon(tierIcon, size: 16, color: tierColor, fill: 1), child: icon,
); );
} }
} }

View File

@@ -45,6 +45,7 @@ class PostItemScreenshot extends ConsumerWidget {
children: [ children: [
Gap(renderingPadding.vertical), Gap(renderingPadding.vertical),
PostHeader( PostHeader(
hideOverlay: true,
item: item, item: item,
isFullPost: isFullPost, isFullPost: isFullPost,
isInteractive: false, isInteractive: false,
@@ -73,6 +74,7 @@ class PostItemScreenshot extends ConsumerWidget {
isFullPost: isFullPost, isFullPost: isFullPost,
isTextSelectable: false, isTextSelectable: false,
isInteractive: false, isInteractive: false,
hideOverlay: true,
), ),
if (isShowReference) if (isShowReference)
ReferencedPostWidget( ReferencedPostWidget(

View File

@@ -554,6 +554,7 @@ class PostHeader extends StatelessWidget {
final EdgeInsets renderingPadding; final EdgeInsets renderingPadding;
final bool isRelativeTime; final bool isRelativeTime;
final bool isCompact; final bool isCompact;
final bool hideOverlay;
const PostHeader({ const PostHeader({
super.key, super.key,
@@ -564,6 +565,7 @@ class PostHeader extends StatelessWidget {
this.renderingPadding = EdgeInsets.zero, this.renderingPadding = EdgeInsets.zero,
this.isRelativeTime = true, this.isRelativeTime = true,
this.isCompact = false, this.isCompact = false,
this.hideOverlay = false,
}); });
@override @override
@@ -606,6 +608,7 @@ class PostHeader extends StatelessWidget {
(item.publisher.account != null && (item.publisher.account != null &&
item.publisher.type == 0) item.publisher.type == 0)
? AccountName( ? AccountName(
hideOverlay: hideOverlay,
account: item.publisher.account!, account: item.publisher.account!,
textOverride: item.publisher.nick, textOverride: item.publisher.nick,
style: TextStyle(fontWeight: FontWeight.bold), style: TextStyle(fontWeight: FontWeight.bold),
@@ -618,7 +621,10 @@ class PostHeader extends StatelessWidget {
).bold(), ).bold(),
), ),
if (item.publisher.verification != null) if (item.publisher.verification != null)
VerificationMark(mark: item.publisher.verification!), VerificationMark(
mark: item.publisher.verification!,
hideOverlay: hideOverlay,
),
if (item.realm == null) if (item.realm == null)
Flexible( Flexible(
child: child:
@@ -690,6 +696,7 @@ class PostBody extends ConsumerWidget {
final bool isInteractive; final bool isInteractive;
final EdgeInsets renderingPadding; final EdgeInsets renderingPadding;
final bool isRelativeTime; final bool isRelativeTime;
final bool hideOverlay;
const PostBody({ const PostBody({
super.key, super.key,
@@ -700,6 +707,7 @@ class PostBody extends ConsumerWidget {
this.isInteractive = true, this.isInteractive = true,
this.renderingPadding = EdgeInsets.zero, this.renderingPadding = EdgeInsets.zero,
this.isRelativeTime = true, this.isRelativeTime = true,
this.hideOverlay = false,
}); });
@override @override
@@ -771,18 +779,7 @@ class PostBody extends ConsumerWidget {
); );
} }
if (item.editedAt != null) { if (item.editedAt != null) {
metadataChildren.add( final text = Text(
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( 'editedAt'.tr(
args: [ args: [
!isFullPost && isRelativeTime !isFullPost && isRelativeTime
@@ -790,7 +787,22 @@ class PostBody extends ConsumerWidget {
: item.editedAt!.formatSystem(), : item.editedAt!.formatSystem(),
], ],
), ),
).fontSize(13), ).fontSize(13);
metadataChildren.add(
Row(
spacing: 8,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Icon(Symbols.edit, size: 16),
hideOverlay
? text
: Tooltip(
message:
!isFullPost && isRelativeTime
? item.editedAt!.formatSystem()
: item.editedAt!.formatRelative(context),
child: text,
), ),
], ],
), ),