feat(profile): profile photo or seed-illustration avatar
Profiles had only a coloured-initial disc. Now each person can set an avatar — a real photo OR one of our own seed illustrations (so pseudonymity stays the default; no photo required). - ui/avatar.dart: the one-string value scheme carried in the kind:0 'picture' — a 'data:' photo thumbnail, a 'tane:seed:<glyph>' token, or empty. The Nostr ProfileTransport already published 'picture'. - Photos ride inline as a tiny thumbnail (reuses offerThumbnailDataUri, 24 KB cap) — no media server, like offer photos. - avatar_edit.dart: pick/take a photo, choose a seed illustration, or remove; ProfileStore stores it; ProfileScreen shows a big editable avatar and publishes it. - PeerAvatar renders photo / illustration / initial fallback. - ProfileCache gains picture/setPicture; the inbox caches peers' avatars alongside their names. - i18n avatar block (en/es/pt/ast). Tests: value scheme + PeerAvatar render modes, store + cache round-trips. Follow-up: render peers' avatars in chat/market/your-people (thread the cached picture into PeerAvatar at each call site).
This commit is contained in:
parent
74c7edaecd
commit
ec56819fbf
19 changed files with 375 additions and 12 deletions
|
|
@ -1,23 +1,50 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
/// A small round avatar for a chat peer. We have no profile photos yet, so it's
|
||||
/// a deterministic disc coloured from the peer's pubkey, showing the first
|
||||
/// letter of their [name] when known (else a person glyph). Same pubkey → same
|
||||
/// colour on every device, so the peer is visually recognizable.
|
||||
import '../services/offer_thumbnail.dart' show decodeDataUri;
|
||||
import 'avatar.dart';
|
||||
import 'seed_glyph.dart';
|
||||
|
||||
/// A small round avatar for a person. When they've set an avatar ([picture] — a
|
||||
/// `data:` photo thumbnail or a `tane:seed:<glyph>` illustration) it's shown;
|
||||
/// otherwise it falls back to a deterministic disc coloured from their [pubkey],
|
||||
/// with the first letter of their [name] (else a person glyph). Same pubkey →
|
||||
/// same colour on every device, so a person stays visually recognizable.
|
||||
class PeerAvatar extends StatelessWidget {
|
||||
const PeerAvatar({
|
||||
required this.pubkey,
|
||||
this.name,
|
||||
this.picture,
|
||||
this.radius = 14,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String pubkey;
|
||||
final String? name;
|
||||
|
||||
/// The person's chosen avatar value; null/empty → the coloured-initial disc.
|
||||
final String? picture;
|
||||
final double radius;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final pic = picture?.trim() ?? '';
|
||||
|
||||
if (pic.startsWith('data:')) {
|
||||
final bytes = decodeDataUri(pic);
|
||||
if (bytes != null) {
|
||||
return CircleAvatar(radius: radius, backgroundImage: MemoryImage(bytes));
|
||||
}
|
||||
} else if (pic.startsWith(avatarGlyphPrefix)) {
|
||||
final glyph = avatarGlyphChar(pic.substring(avatarGlyphPrefix.length));
|
||||
if (glyph != null) {
|
||||
return CircleAvatar(
|
||||
radius: radius,
|
||||
backgroundColor: peerAvatarColor(pubkey),
|
||||
child: SeedGlyph(glyph, size: radius * 1.15, color: Colors.white),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final letter = _initial(name);
|
||||
return CircleAvatar(
|
||||
radius: radius,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue