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
1c2b3d5e8d
commit
109c85298c
6 changed files with 153 additions and 45 deletions
|
|
@ -3,7 +3,6 @@ import 'dart:async';
|
|||
import 'package:commons_core/commons_core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_boring_avatars/flutter_boring_avatars.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:tane/domain/chat_timeline.dart';
|
||||
|
|
@ -129,10 +128,10 @@ void main() {
|
|||
// so you can tell who said what at a glance.
|
||||
expect(find.byType(PeerAvatar), findsNWidgets(2));
|
||||
final generated = tester
|
||||
.widgetList<BoringAvatar>(find.byType(BoringAvatar))
|
||||
.widgetList<GeneratedAvatar>(find.byType(GeneratedAvatar))
|
||||
.toList();
|
||||
expect(generated, hasLength(2));
|
||||
expect(generated.first.name, isNot(generated.last.name));
|
||||
expect(generated.first.pubkey, isNot(generated.last.pubkey));
|
||||
});
|
||||
|
||||
testWidgets('a new message lands in view at the bottom, not below the fold', (
|
||||
|
|
|
|||
|
|
@ -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