🐛 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,20 +191,33 @@ 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(
if (account.automatedId != null) mark: account.profile.verification!,
Tooltip( hideOverlay: hideOverlay,
message: 'accountAutomated'.tr(),
child: Icon(
Symbols.smart_toy,
size: 16,
color: nameStyle.color,
fill: 1,
),
), ),
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) if (account.perkSubscription != null)
StellarMembershipMark(membership: account.perkSubscription!), StellarMembershipMark(
if (account.profile.verification != null) membership: account.perkSubscription!,
VerificationMark(mark: account.profile.verification!), hideOverlay: hideOverlay,
if (account.automatedId != null)
Tooltip(
message: 'accountAutomated'.tr(),
child: Icon(
Symbols.smart_toy,
size: 16,
color: nameStyle.color,
fill: 1,
),
), ),
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 { 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(
richMessage: TextSpan( mark.type == 4
text: mark.title ?? 'No title', ? Symbols.play_circle
children: [ : mark.type == 0
TextSpan(text: '\n'), ? Symbols.build_circle
TextSpan( : Symbols.verified,
text: mark.description ?? 'descriptionNone'.tr(), size: 16,
style: TextStyle(fontWeight: FontWeight.normal), color: kVerificationMarkColors[mark.type],
), fill: 1,
],
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,
),
); );
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 { 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,20 +363,24 @@ 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);
richMessage: TextSpan(
text: 'stellarMembership'.tr(), return hideOverlay
children: [ ? icon
TextSpan(text: '\n'), : Tooltip(
TextSpan( richMessage: TextSpan(
text: 'currentMembershipMember'.tr(args: [tierName]), text: 'stellarMembership'.tr(),
style: TextStyle(fontWeight: FontWeight.normal), children: [
TextSpan(text: '\n'),
TextSpan(
text: 'currentMembershipMember'.tr(args: [tierName]),
style: TextStyle(fontWeight: FontWeight.normal),
),
],
style: TextStyle(fontWeight: FontWeight.bold),
), ),
], child: icon,
style: TextStyle(fontWeight: FontWeight.bold), );
),
child: Icon(tierIcon, size: 16, color: tierColor, fill: 1),
);
} }
} }

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,27 +779,31 @@ class PostBody extends ConsumerWidget {
); );
} }
if (item.editedAt != null) { if (item.editedAt != null) {
final text = Text(
'editedAt'.tr(
args: [
!isFullPost && isRelativeTime
? item.editedAt!.formatRelative(context)
: item.editedAt!.formatSystem(),
],
),
).fontSize(13);
metadataChildren.add( metadataChildren.add(
Row( Row(
spacing: 8, spacing: 8,
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
const Icon(Symbols.edit, size: 16), const Icon(Symbols.edit, size: 16),
Tooltip( hideOverlay
message: ? text
!isFullPost && isRelativeTime : Tooltip(
? item.editedAt!.formatSystem() message:
: item.editedAt!.formatRelative(context), !isFullPost && isRelativeTime
child: Text( ? item.editedAt!.formatSystem()
'editedAt'.tr( : item.editedAt!.formatRelative(context),
args: [ child: text,
!isFullPost && isRelativeTime
? item.editedAt!.formatRelative(context)
: item.editedAt!.formatSystem(),
],
), ),
).fontSize(13),
),
], ],
), ),
); );