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
48
apps/app_seeds/test/ui/photo_crop_test.dart
Normal file
48
apps/app_seeds/test/ui/photo_crop_test.dart
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:image/image.dart' as img;
|
||||
import 'package:tane/ui/photo_crop.dart';
|
||||
|
||||
void main() {
|
||||
// A small but real PNG the cropper can decode.
|
||||
final bytes = Uint8List.fromList(
|
||||
img.encodePng(img.Image(width: 32, height: 32)),
|
||||
);
|
||||
|
||||
testWidgets('cropToSquare shows a cancel/confirm UI and cancel returns null', (
|
||||
tester,
|
||||
) async {
|
||||
Uint8List? result;
|
||||
var returned = false;
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Builder(
|
||||
builder: (context) => Scaffold(
|
||||
body: Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: () async {
|
||||
result = await cropToSquare(context, bytes);
|
||||
returned = true;
|
||||
},
|
||||
child: const Text('open'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
await tester.tap(find.text('open'));
|
||||
await tester.pump(); // push the crop route
|
||||
await tester.pump(const Duration(milliseconds: 100));
|
||||
|
||||
expect(find.byKey(const Key('crop.confirm')), findsOneWidget);
|
||||
expect(find.byKey(const Key('crop.cancel')), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('crop.cancel')));
|
||||
await tester.pump(); // pop the crop route
|
||||
|
||||
expect(returned, isTrue);
|
||||
expect(result, isNull); // cancelling yields no image
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue