💄 Changes to the showing of realm post

This commit is contained in:
LittleSheep 2025-03-09 00:11:01 +08:00
parent 3defd3a593
commit 25550ba197
2 changed files with 58 additions and 24 deletions

View File

@ -13,6 +13,7 @@ class AccountImage extends StatelessWidget {
final double? borderRadius; final double? borderRadius;
final Widget? fallbackWidget; final Widget? fallbackWidget;
final Widget? badge; final Widget? badge;
final Offset? badgeOffset;
const AccountImage({ const AccountImage({
super.key, super.key,
@ -23,6 +24,7 @@ class AccountImage extends StatelessWidget {
this.borderRadius, this.borderRadius,
this.fallbackWidget, this.fallbackWidget,
this.badge, this.badge,
this.badgeOffset,
}); });
@override @override
@ -40,7 +42,8 @@ class AccountImage extends StatelessWidget {
borderRadius: BorderRadius.circular(borderRadius ?? radius ?? 20), borderRadius: BorderRadius.circular(borderRadius ?? radius ?? 20),
child: (content?.isEmpty ?? true) child: (content?.isEmpty ?? true)
? Container( ? Container(
color: backgroundColor ?? Theme.of(context).colorScheme.primaryContainer, color: backgroundColor ??
Theme.of(context).colorScheme.primaryContainer,
child: (fallbackWidget ?? child: (fallbackWidget ??
Icon( Icon(
Symbols.account_circle, Symbols.account_circle,
@ -58,8 +61,8 @@ class AccountImage extends StatelessWidget {
), ),
if (badge != null) if (badge != null)
Positioned( Positioned(
right: -4, right: badgeOffset?.dx ?? -4,
bottom: -2, bottom: badgeOffset?.dy ?? -2,
child: badge!, child: badge!,
), ),
], ],

View File

@ -923,10 +923,12 @@ class _PostContentHeader extends StatelessWidget {
return Row( return Row(
children: [ children: [
GestureDetector( GestureDetector(
child: AccountImage( child: data.preload?.realm == null
? AccountImage(
content: data.publisher.avatar, content: data.publisher.avatar,
radius: isCompact ? 12 : 20, radius: isCompact ? 12 : 20,
borderRadius: data.publisher.type == 1 ? (isCompact ? 4 : 8) : 20, borderRadius:
data.publisher.type == 1 ? (isCompact ? 4 : 8) : 20,
badge: (user?.badges.isNotEmpty ?? false) badge: (user?.badges.isNotEmpty ?? false)
? Icon( ? Icon(
kBadgesMeta[user!.badges.first.type]?.$2 ?? kBadgesMeta[user!.badges.first.type]?.$2 ??
@ -943,6 +945,25 @@ class _PostContentHeader extends StatelessWidget {
], ],
) )
: null, : null,
)
: AccountImage(
content: data.preload!.realm!.avatar,
radius: isCompact ? 12 : 20,
borderRadius: isCompact ? 4 : 8,
badgeOffset: Offset(-6, -4),
badge: Container(
decoration: BoxDecoration(
border: Border.all(
color: Theme.of(context).colorScheme.surface,
width: 2,
),
borderRadius: BorderRadius.circular(10),
),
child: AccountImage(
content: data.publisher.avatar,
radius: 10,
),
),
), ),
onTap: () { onTap: () {
showPopover( showPopover(
@ -987,8 +1008,18 @@ class _PostContentHeader extends StatelessWidget {
Expanded( Expanded(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [ children: [
Text(data.publisher.nick).bold(), Text(data.publisher.nick).bold(),
if (data.preload?.realm != null)
const Icon(Symbols.arrow_right, size: 16)
.padding(horizontal: 2)
.opacity(0.5),
if (data.preload?.realm != null)
Text(data.preload!.realm!.name),
],
),
Row( Row(
children: [ children: [
Text('@${data.publisher.name}').fontSize(13), Text('@${data.publisher.name}').fontSize(13),