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,9 +1,12 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:tane/services/profile_cache.dart';
|
||||
import 'package:tane/ui/avatar.dart';
|
||||
import 'package:tane/ui/peer_avatar.dart';
|
||||
import 'package:tane/ui/seed_glyph.dart';
|
||||
|
||||
import '../support/test_support.dart';
|
||||
|
||||
void main() {
|
||||
group('avatar value scheme', () {
|
||||
test('every offered illustration maps to a glyph; unknown → null', () {
|
||||
|
|
@ -56,4 +59,34 @@ void main() {
|
|||
expect(find.text('R'), findsNothing); // the initial isn't used
|
||||
});
|
||||
});
|
||||
|
||||
group('CachedAvatar', () {
|
||||
Widget host(Widget child) => MaterialApp(
|
||||
home: Scaffold(body: Center(child: child)),
|
||||
);
|
||||
|
||||
testWidgets('paints the cached illustration for the peer', (tester) async {
|
||||
final cache = ProfileCache(InMemorySecretStore());
|
||||
await cache.setPicture('peer1', 'tane:seed:sack');
|
||||
await tester.pumpWidget(host(
|
||||
CachedAvatar(pubkey: 'peer1', name: 'Bea', cache: cache)));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(SeedGlyph), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('falls back to the initial when nothing is cached', (
|
||||
tester,
|
||||
) async {
|
||||
final cache = ProfileCache(InMemorySecretStore());
|
||||
await tester.pumpWidget(host(
|
||||
CachedAvatar(pubkey: 'peer2', name: 'Bea', cache: cache)));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('B'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('no cache → the coloured-initial disc', (tester) async {
|
||||
await tester.pumpWidget(host(const CachedAvatar(pubkey: 'x', name: 'Bea')));
|
||||
expect(find.text('B'), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue