💄 Optimize publisher name display

This commit is contained in:
2025-10-23 00:38:37 +08:00
parent 1ae81794b1
commit 8bec18813d
7 changed files with 31 additions and 15 deletions

View File

@@ -203,7 +203,7 @@ class AccountScreen extends HookConsumerWidget {
], ],
).padding(horizontal: 16, vertical: 12), ).padding(horizontal: 16, vertical: 12),
onTap: () { onTap: () {
context.pushNamed('developerHub'); context.goNamed('developerHub');
}, },
), ),
).height(140), ).height(140),

View File

@@ -522,7 +522,7 @@ class CreatorHubScreen extends HookConsumerWidget {
return AppScaffold( return AppScaffold(
isNoBackground: false, isNoBackground: false,
appBar: AppBar( appBar: AppBar(
leading: const PageBackButton(), leading: const PageBackButton(backTo: '/account'),
title: Text('creatorHub').tr(), title: Text('creatorHub').tr(),
actions: [ actions: [
if (!isWideScreen(context)) if (!isWideScreen(context))

View File

@@ -181,7 +181,7 @@ class _ConsoleAppBar extends StatelessWidget implements PreferredSizeWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AppBar( return AppBar(
leading: const PageBackButton(), leading: const PageBackButton(backTo: '/account'),
title: Text('developerHub').tr(), title: Text('developerHub').tr(),
actions: [ actions: [
if (currentProject != null) if (currentProject != null)

View File

@@ -276,7 +276,7 @@ class _RealmIdentityProviderElement
String get realmSlug => (origin as RealmIdentityProvider).realmSlug; String get realmSlug => (origin as RealmIdentityProvider).realmSlug;
} }
String _$realmChatRoomsHash() => r'54d36010221cd298f5ee0059259059f8b8aaff7b'; String _$realmChatRoomsHash() => r'5f199906fb287b109e2a2d2a81dcb6675bdcb816';
/// See also [realmChatRooms]. /// See also [realmChatRooms].
@ProviderFor(realmChatRooms) @ProviderFor(realmChatRooms)

View File

@@ -36,11 +36,13 @@ const kVerificationMarkColors = [
class AccountName extends StatelessWidget { class AccountName extends StatelessWidget {
final SnAccount account; final SnAccount account;
final TextStyle? style; final TextStyle? style;
final String? textOverride;
final bool ignorePermissions; final bool ignorePermissions;
const AccountName({ const AccountName({
super.key, super.key,
required this.account, required this.account,
this.style, this.style,
this.textOverride,
this.ignorePermissions = false, this.ignorePermissions = false,
}); });
@@ -177,7 +179,7 @@ class AccountName extends StatelessWidget {
child: ShaderMask( child: ShaderMask(
shaderCallback: (bounds) => gradient.createShader(bounds), shaderCallback: (bounds) => gradient.createShader(bounds),
child: Text( child: Text(
account.nick, textOverride ?? account.nick,
style: nameStyle.copyWith(color: Colors.white), style: nameStyle.copyWith(color: Colors.white),
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,

View File

@@ -370,12 +370,18 @@ class PageBackButton extends StatelessWidget {
final Color? color; final Color? color;
final List<Shadow>? shadows; final List<Shadow>? shadows;
final VoidCallback? onWillPop; final VoidCallback? onWillPop;
const PageBackButton({super.key, this.shadows, this.onWillPop, this.color}); final String? backTo;
const PageBackButton({
super.key,
this.shadows,
this.onWillPop,
this.color,
this.backTo,
});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final hasPageAction = final hasPageAction = !kIsWeb && Platform.isMacOS;
!kIsWeb && Platform.isMacOS;
if (hasPageAction && isWideScreen(context)) return const SizedBox.shrink(); if (hasPageAction && isWideScreen(context)) return const SizedBox.shrink();
@@ -385,7 +391,7 @@ class PageBackButton extends StatelessWidget {
if (context.canPop()) { if (context.canPop()) {
context.pop(); context.pop();
} else { } else {
context.go('/'); context.go(backTo ?? '/');
} }
}, },
icon: Icon( icon: Icon(

View File

@@ -570,7 +570,9 @@ class PostHeader extends StatelessWidget {
} }
: null, : null,
child: ProfilePictureWidget( child: ProfilePictureWidget(
file: item.publisher.picture, file:
item.publisher.picture ??
item.publisher.account?.profile.picture,
radius: 16, radius: 16,
borderRadius: item.publisher.type == 0 ? null : 6, borderRadius: item.publisher.type == 0 ? null : 6,
), ),
@@ -586,11 +588,17 @@ class PostHeader extends StatelessWidget {
children: [ children: [
Flexible( Flexible(
child: child:
Text( item.publisher.account != null
item.publisher.nick, ? AccountName(
maxLines: 1, account: item.publisher.account!,
overflow: TextOverflow.ellipsis, textOverride: item.publisher.nick,
).bold(), style: TextStyle(fontWeight: FontWeight.bold),
)
: Text(
item.publisher.nick,
maxLines: 1,
overflow: TextOverflow.ellipsis,
).bold(),
), ),
if (item.publisher.verification != null) if (item.publisher.verification != null)
VerificationMark(mark: item.publisher.verification!), VerificationMark(mark: item.publisher.verification!),