mirror of
https://github.com/haorendashu/nowser.git
synced 2025-12-17 18:04:18 +01:00
init nostr and add userinfo provider
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:nostr_sdk/nip19/nip19.dart';
|
||||
import 'package:nostr_sdk/utils/string_util.dart';
|
||||
import 'package:nowser/data/metadata.dart';
|
||||
import 'package:nowser/provider/userinfo_provider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class UserNameComponent extends StatefulWidget {
|
||||
String pubkey;
|
||||
@@ -17,15 +21,29 @@ class UserNameComponent extends StatefulWidget {
|
||||
class _UserNameComponent extends State<UserNameComponent> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var npub = Nip19.encodePubKey(widget.pubkey);
|
||||
if (!widget.fullNpubName) {
|
||||
npub = Nip19.encodeSimplePubKey(widget.pubkey);
|
||||
}
|
||||
return Selector<UserinfoProvider, Metadata?>(
|
||||
builder: (context, metadata, child) {
|
||||
var npub = Nip19.encodePubKey(widget.pubkey);
|
||||
if (!widget.fullNpubName) {
|
||||
npub = Nip19.encodeSimplePubKey(widget.pubkey);
|
||||
}
|
||||
var name = npub;
|
||||
|
||||
return Text(
|
||||
npub,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
);
|
||||
if (metadata != null) {
|
||||
if (StringUtil.isNotBlank(metadata.displayName)) {
|
||||
name = metadata.displayName!;
|
||||
} else if (StringUtil.isNotBlank(metadata.name)) {
|
||||
name = metadata.name!;
|
||||
}
|
||||
}
|
||||
|
||||
return Text(
|
||||
name,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
);
|
||||
}, selector: (context, _provider) {
|
||||
return _provider.getMetadata(widget.pubkey);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user