feat(profile): Material default avatar + square photo crop
Drop the DiceBear generated avatar (and dicebear_core/dicebear_styles/ flutter_svg): the default is again a Material coloured-initial disc from the pubkey. Picking a photo now goes through a square crop step (crop_your_image — pure Flutter, all platforms incl. desktop, Apache-2.0, only pulls the image package we already had) before the 24 KB thumbnail.
This commit is contained in:
parent
17612b8147
commit
f6967e8cbb
8 changed files with 200 additions and 175 deletions
|
|
@ -36,19 +36,17 @@ void main() {
|
|||
home: Scaffold(body: Center(child: child)),
|
||||
);
|
||||
|
||||
testWidgets('falls back to a generated avatar keyed by pubkey', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('shows the name initial when known', (tester) async {
|
||||
await tester.pumpWidget(host(PeerAvatar(pubkey: 'aa', name: 'rosa')));
|
||||
final generated =
|
||||
tester.widget<GeneratedAvatar>(find.byType(GeneratedAvatar));
|
||||
expect(generated.pubkey, 'aa'); // pubkey, not name → stable across renames
|
||||
expect(find.byType(Text), findsNothing);
|
||||
expect(find.text('R'), findsOneWidget); // uppercased first letter
|
||||
});
|
||||
|
||||
testWidgets('generates it even when the name is unknown', (tester) async {
|
||||
testWidgets('falls back to a person icon when the name is unknown', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(host(const PeerAvatar(pubkey: 'aa')));
|
||||
expect(find.byType(GeneratedAvatar), findsOneWidget);
|
||||
expect(find.byIcon(Icons.person_outline), findsOneWidget);
|
||||
expect(find.byType(Text), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('renders a seed illustration when the avatar is a token', (
|
||||
|
|
@ -75,19 +73,19 @@ void main() {
|
|||
expect(find.byType(SeedGlyph), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('falls back to the generated avatar when nothing is cached', (
|
||||
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.byType(GeneratedAvatar), findsOneWidget);
|
||||
expect(find.text('B'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('no cache → the generated avatar', (tester) async {
|
||||
testWidgets('no cache → the coloured-initial disc', (tester) async {
|
||||
await tester.pumpWidget(host(const CachedAvatar(pubkey: 'x', name: 'Bea')));
|
||||
expect(find.byType(GeneratedAvatar), findsOneWidget);
|
||||
expect(find.text('B'), findsOneWidget);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue