mirror of
https://github.com/haorendashu/nowser.git
synced 2025-12-17 01:44:19 +01:00
user name component add show both support
This commit is contained in:
@@ -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,
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -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!;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:nostr_sdk/nip19/nip19.dart';
|
||||
import 'package:nostr_sdk/utils/string_util.dart';
|
||||
import 'package:nowser/component/app/app_type_component.dart';
|
||||
import 'package:nowser/component/image_component.dart';
|
||||
import 'package:nowser/component/user/user_name_component.dart';
|
||||
import 'package:nowser/const/connect_type.dart';
|
||||
import 'package:nowser/data/app.dart';
|
||||
import 'package:nowser/main.dart';
|
||||
@@ -120,10 +121,10 @@ class _AppDetailRouter extends State<AppDetailRouter> {
|
||||
for (var pubkey in pubkeys) {
|
||||
items.add(DropdownMenuItem(
|
||||
value: pubkey,
|
||||
child: Text(
|
||||
Nip19.encodePubKey(pubkey),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
child: UserNameComponent(
|
||||
pubkey,
|
||||
fullNpubName: true,
|
||||
showBoth: true,
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -74,7 +74,11 @@ class _AddRemoteAppRouter extends CustState<AddRemoteAppRouter> {
|
||||
for (var pubkey in pubkeys) {
|
||||
items.add(DropdownMenuItem(
|
||||
value: pubkey,
|
||||
child: UserNameComponent(pubkey),
|
||||
child: UserNameComponent(
|
||||
pubkey,
|
||||
showBoth: true,
|
||||
fullNpubName: true,
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -36,10 +36,15 @@ class _KeysItemComponent extends State<KeysItemComponent> {
|
||||
),
|
||||
));
|
||||
list.add(Expanded(
|
||||
child: Container(
|
||||
margin: const EdgeInsets.only(left: Base.BASE_PADDING_HALF),
|
||||
child: UserNameComponent(
|
||||
widget.pubkey,
|
||||
fullNpubName: true,
|
||||
)));
|
||||
showBoth: true,
|
||||
),
|
||||
),
|
||||
));
|
||||
list.add(GestureDetector(
|
||||
onTap: () {
|
||||
keyProvider.removeKey(widget.pubkey);
|
||||
|
||||
Reference in New Issue
Block a user