mirror of
https://github.com/haorendashu/nowser.git
synced 2025-12-17 09:54: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) {
|
for (var pubkey in pubkeys) {
|
||||||
items.add(DropdownMenuItem(
|
items.add(DropdownMenuItem(
|
||||||
value: pubkey,
|
value: pubkey,
|
||||||
child: UserNameComponent(pubkey),
|
child: UserNameComponent(
|
||||||
|
pubkey,
|
||||||
|
showBoth: true,
|
||||||
|
fullNpubName: true,
|
||||||
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ class UserNameComponent extends StatefulWidget {
|
|||||||
|
|
||||||
bool fullNpubName;
|
bool fullNpubName;
|
||||||
|
|
||||||
UserNameComponent(this.pubkey, {this.fullNpubName = false});
|
bool showBoth;
|
||||||
|
|
||||||
|
UserNameComponent(this.pubkey,
|
||||||
|
{this.fullNpubName = false, this.showBoth = false});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() {
|
State<StatefulWidget> createState() {
|
||||||
@@ -30,10 +33,19 @@ class _UserNameComponent extends State<UserNameComponent> {
|
|||||||
var name = npub;
|
var name = npub;
|
||||||
|
|
||||||
if (metadata != null) {
|
if (metadata != null) {
|
||||||
|
String? niceName;
|
||||||
if (StringUtil.isNotBlank(metadata.displayName)) {
|
if (StringUtil.isNotBlank(metadata.displayName)) {
|
||||||
name = metadata.displayName!;
|
niceName = metadata.displayName!;
|
||||||
} else if (StringUtil.isNotBlank(metadata.name)) {
|
} 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:nostr_sdk/utils/string_util.dart';
|
||||||
import 'package:nowser/component/app/app_type_component.dart';
|
import 'package:nowser/component/app/app_type_component.dart';
|
||||||
import 'package:nowser/component/image_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/const/connect_type.dart';
|
||||||
import 'package:nowser/data/app.dart';
|
import 'package:nowser/data/app.dart';
|
||||||
import 'package:nowser/main.dart';
|
import 'package:nowser/main.dart';
|
||||||
@@ -120,10 +121,10 @@ class _AppDetailRouter extends State<AppDetailRouter> {
|
|||||||
for (var pubkey in pubkeys) {
|
for (var pubkey in pubkeys) {
|
||||||
items.add(DropdownMenuItem(
|
items.add(DropdownMenuItem(
|
||||||
value: pubkey,
|
value: pubkey,
|
||||||
child: Text(
|
child: UserNameComponent(
|
||||||
Nip19.encodePubKey(pubkey),
|
pubkey,
|
||||||
maxLines: 1,
|
fullNpubName: true,
|
||||||
overflow: TextOverflow.ellipsis,
|
showBoth: true,
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,11 @@ class _AddRemoteAppRouter extends CustState<AddRemoteAppRouter> {
|
|||||||
for (var pubkey in pubkeys) {
|
for (var pubkey in pubkeys) {
|
||||||
items.add(DropdownMenuItem(
|
items.add(DropdownMenuItem(
|
||||||
value: pubkey,
|
value: pubkey,
|
||||||
child: UserNameComponent(pubkey),
|
child: UserNameComponent(
|
||||||
|
pubkey,
|
||||||
|
showBoth: true,
|
||||||
|
fullNpubName: true,
|
||||||
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,10 +36,15 @@ class _KeysItemComponent extends State<KeysItemComponent> {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
list.add(Expanded(
|
list.add(Expanded(
|
||||||
|
child: Container(
|
||||||
|
margin: const EdgeInsets.only(left: Base.BASE_PADDING_HALF),
|
||||||
child: UserNameComponent(
|
child: UserNameComponent(
|
||||||
widget.pubkey,
|
widget.pubkey,
|
||||||
fullNpubName: true,
|
fullNpubName: true,
|
||||||
)));
|
showBoth: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
list.add(GestureDetector(
|
list.add(GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
keyProvider.removeKey(widget.pubkey);
|
keyProvider.removeKey(widget.pubkey);
|
||||||
|
|||||||
Reference in New Issue
Block a user