2026-04-14 08:42:29 -07:00
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
|
|
|
|
|
|
@immutable
|
|
|
|
|
class UserProfile {
|
|
|
|
|
final String pubkey;
|
|
|
|
|
final String? displayName;
|
|
|
|
|
final String? avatarUrl;
|
|
|
|
|
final String? about;
|
2026-05-02 10:54:21 -06:00
|
|
|
final String? nip05Handle;
|
2026-04-14 08:42:29 -07:00
|
|
|
|
2026-07-03 09:55:27 -06:00
|
|
|
/// NIP-OA verified owner pubkey from the profile's `auth` tag; non-null
|
|
|
|
|
/// means this identity is an agent (mirrors desktop's `ownerPubkey`).
|
|
|
|
|
final String? ownerPubkey;
|
|
|
|
|
|
2026-04-14 08:42:29 -07:00
|
|
|
const UserProfile({
|
|
|
|
|
required this.pubkey,
|
|
|
|
|
this.displayName,
|
|
|
|
|
this.avatarUrl,
|
|
|
|
|
this.about,
|
2026-05-02 10:54:21 -06:00
|
|
|
this.nip05Handle,
|
2026-07-03 09:55:27 -06:00
|
|
|
this.ownerPubkey,
|
2026-04-14 08:42:29 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
factory UserProfile.fromJson(Map<String, dynamic> json) => UserProfile(
|
|
|
|
|
pubkey: json['pubkey'] as String,
|
|
|
|
|
displayName: json['display_name'] as String?,
|
|
|
|
|
avatarUrl: json['avatar_url'] as String?,
|
|
|
|
|
about: json['about'] as String?,
|
2026-05-02 10:54:21 -06:00
|
|
|
nip05Handle: json['nip05_handle'] as String?,
|
2026-04-14 08:42:29 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
/// Short label: display name, or first 8 chars of pubkey.
|
|
|
|
|
String get label =>
|
|
|
|
|
displayName ??
|
|
|
|
|
'${pubkey.length >= 8 ? pubkey.substring(0, 8) : pubkey}...';
|
|
|
|
|
|
|
|
|
|
/// First letter for fallback avatar.
|
|
|
|
|
String get initial =>
|
|
|
|
|
(displayName?.isNotEmpty == true ? displayName! : pubkey)[0]
|
|
|
|
|
.toUpperCase();
|
|
|
|
|
}
|