feat(profile): show other people's avatars in chat, chat list, your people
Follow-up to the avatar feature: peers' published photos/illustrations now actually render where people appear. - CachedAvatar: a PeerAvatar that resolves the person's picture from the ProfileCache (FutureBuilder), falling back to the coloured-initial disc. For list/row sites — one avatar each. - Chat bubbles: the peer's and my own avatar are resolved once into state (_peerPicture/_selfPicture — from the cache / ProfileStore, freshened from the peer's published profile) and threaded to each bubble, so many bubbles of two people don't each hit the cache. - Chat list + your-people rows: swapped the static person-icon disc for CachedAvatar, so photos/illustrations show there too. - Tests: CachedAvatar render modes (cached illustration / initial / no cache). analyze clean; chat + your-people suites green. Market offers show no author avatar today (would be a new element, not a swap) — left out of scope.
This commit is contained in:
parent
ec56819fbf
commit
51d6924464
5 changed files with 150 additions and 16 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../services/offer_thumbnail.dart' show decodeDataUri;
|
||||
import '../services/profile_cache.dart';
|
||||
import 'avatar.dart';
|
||||
import 'seed_glyph.dart';
|
||||
|
||||
|
|
@ -71,6 +72,43 @@ class PeerAvatar extends StatelessWidget {
|
|||
}
|
||||
}
|
||||
|
||||
/// A [PeerAvatar] that looks the person's published avatar up from the
|
||||
/// [ProfileCache] (their kind:0 `picture`), falling back to the coloured-initial
|
||||
/// disc while it loads or when none is cached / no cache is available. Use at
|
||||
/// list/row sites (one avatar each); for many avatars of the same few people
|
||||
/// (chat bubbles) resolve the picture once into state instead.
|
||||
class CachedAvatar extends StatelessWidget {
|
||||
const CachedAvatar({
|
||||
required this.pubkey,
|
||||
this.name,
|
||||
this.cache,
|
||||
this.radius = 14,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final String pubkey;
|
||||
final String? name;
|
||||
final ProfileCache? cache;
|
||||
final double radius;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final c = cache;
|
||||
if (c == null) {
|
||||
return PeerAvatar(pubkey: pubkey, name: name, radius: radius);
|
||||
}
|
||||
return FutureBuilder<String?>(
|
||||
future: c.picture(pubkey),
|
||||
builder: (context, snap) => PeerAvatar(
|
||||
pubkey: pubkey,
|
||||
name: name,
|
||||
picture: snap.data,
|
||||
radius: radius,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A deterministic, readable avatar colour derived from [pubkey]. Hashes the
|
||||
/// key to a hue, then fixes saturation/lightness so white text stays legible on
|
||||
/// top. Pure and stable — exposed for testing.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue