feat(profile): default avatars via DiceBear "thumbs" (CC0), drop boring_avatars
Replace the flutter_boring_avatars fallback with a friendly DiceBear "thumbs" face, generated offline (dicebear_core) and deterministically from the pubkey, rendered as SVG (flutter_svg). The thumbs style is CC0 1.0 (public domain) — no attribution, AGPL-clean — unlike Multiavatar whose custom licence restricts use. Style parsed once and per-pubkey SVG memoized; the CC0 <metadata> block is stripped to keep flutter_svg quiet.
This commit is contained in:
parent
d85b557f1e
commit
d4a9142ee2
6 changed files with 153 additions and 45 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_boring_avatars/flutter_boring_avatars.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:tane/services/profile_cache.dart';
|
||||
import 'package:tane/ui/avatar.dart';
|
||||
|
|
@ -38,18 +37,19 @@ void main() {
|
|||
home: Scaffold(body: Center(child: child)),
|
||||
);
|
||||
|
||||
testWidgets('falls back to a generated pattern keyed by pubkey', (
|
||||
testWidgets('falls back to a generated avatar keyed by pubkey', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(host(PeerAvatar(pubkey: 'aa', name: 'rosa')));
|
||||
final generated = tester.widget<BoringAvatar>(find.byType(BoringAvatar));
|
||||
expect(generated.name, 'aa'); // pubkey, not name → stable across renames
|
||||
final generated =
|
||||
tester.widget<GeneratedAvatar>(find.byType(GeneratedAvatar));
|
||||
expect(generated.pubkey, 'aa'); // pubkey, not name → stable across renames
|
||||
expect(find.byType(Text), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('generates it even when the name is unknown', (tester) async {
|
||||
await tester.pumpWidget(host(const PeerAvatar(pubkey: 'aa')));
|
||||
expect(find.byType(BoringAvatar), findsOneWidget);
|
||||
expect(find.byType(GeneratedAvatar), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('renders a seed illustration when the avatar is a token', (
|
||||
|
|
@ -76,19 +76,19 @@ void main() {
|
|||
expect(find.byType(SeedGlyph), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('falls back to the generated pattern when nothing is cached', (
|
||||
testWidgets('falls back to the generated avatar 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.byType(BoringAvatar), findsOneWidget);
|
||||
expect(find.byType(GeneratedAvatar), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('no cache → the generated pattern', (tester) async {
|
||||
testWidgets('no cache → the generated avatar', (tester) async {
|
||||
await tester.pumpWidget(host(const CachedAvatar(pubkey: 'x', name: 'Bea')));
|
||||
expect(find.byType(BoringAvatar), findsOneWidget);
|
||||
expect(find.byType(GeneratedAvatar), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue