user name component add show both support

This commit is contained in:
DASHU
2025-07-22 21:48:14 +08:00
parent d09c35f778
commit dafbf08115
5 changed files with 38 additions and 12 deletions

View File

@@ -64,7 +64,11 @@ class _AuthDialog extends State<AuthDialogBaseComponnet> {
for (var pubkey in pubkeys) {
items.add(DropdownMenuItem(
value: pubkey,
child: UserNameComponent(pubkey),
child: UserNameComponent(
pubkey,
showBoth: true,
fullNpubName: true,
),
));
}

View File

@@ -10,7 +10,10 @@ class UserNameComponent extends StatefulWidget {
bool fullNpubName;
UserNameComponent(this.pubkey, {this.fullNpubName = false});
bool showBoth;
UserNameComponent(this.pubkey,
{this.fullNpubName = false, this.showBoth = false});
@override
State<StatefulWidget> createState() {
@@ -30,10 +33,19 @@ class _UserNameComponent extends State<UserNameComponent> {
var name = npub;
if (metadata != null) {
String? niceName;
if (StringUtil.isNotBlank(metadata.displayName)) {
name = metadata.displayName!;
niceName = metadata.displayName!;
} else if (StringUtil.isNotBlank(metadata.name)) {
name = metadata.name!;
niceName = metadata.name!;
}
if (StringUtil.isNotBlank(niceName)) {
if (widget.showBoth) {
name = "$niceName / $npub";
} else {
name = niceName!;
}
}
}