The public profile was already one per person for every service of an instance (the register, ADR 0016); its app side was Learn's alone. It moves into halkyon_app: the model, the repository on the module's endpoints, the form, the avatar drawn on the device and the sheet with someone's profile. They take the Public prefix (PublicProfileRepository, BasePublicProfileGateway), as Train's own ProfileRepository holds the body's figures. AppDependencies gains profiles and files, the picker the avatar is chosen with, which moves out of Learn too. HalkyonProfile is every app's Profile screen: the person's own tab first, the same in every app (the account and the ways they sign in, the app's own cards, then the public profile), then the app's own tabs, folding into the title. Learn adds its inbox and Statistics. Train adds Progress, Days and, where nothing records, Plans, and so opens on the person's tab, no longer on Progress. Todo, which has no Profile tab, opens it from a row at the top of Browse, where Todoist keeps the account. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
66 lines
2 KiB
Dart
66 lines
2 KiB
Dart
import 'dart:typed_data';
|
||
import 'dart:ui' as ui;
|
||
|
||
import 'package:flutter_test/flutter_test.dart';
|
||
import 'package:halkyon_app/halkyon_app.dart';
|
||
|
||
/// A PNG [width] × [height], red on its left half, blue on its right.
|
||
Future<Uint8List> picture(int width, int height) async {
|
||
final recorder = ui.PictureRecorder();
|
||
ui.Canvas(recorder)
|
||
..drawRect(
|
||
ui.Rect.fromLTWH(0, 0, width / 2, height.toDouble()),
|
||
ui.Paint()..color = const ui.Color(0xFFFF0000),
|
||
)
|
||
..drawRect(
|
||
ui.Rect.fromLTWH(width / 2, 0, width / 2, height.toDouble()),
|
||
ui.Paint()..color = const ui.Color(0xFF0000FF),
|
||
);
|
||
final image = await recorder.endRecording().toImage(width, height);
|
||
final png = await image.toByteData(format: ui.ImageByteFormat.png);
|
||
return png!.buffer.asUint8List();
|
||
}
|
||
|
||
Future<ui.Image> decoded(Uint8List png) async {
|
||
final codec = await ui.instantiateImageCodec(png);
|
||
return (await codec.getNextFrame()).image;
|
||
}
|
||
|
||
void main() {
|
||
TestWidgetsFlutterBinding.ensureInitialized();
|
||
|
||
test('a picture becomes its middle square, at most 400 pixels a side, as '
|
||
'a PNG', () async {
|
||
final wide = await avatarPng(await picture(1200, 600));
|
||
final image = await decoded(wide);
|
||
|
||
expect((image.width, image.height), (400, 400));
|
||
expect(wide.sublist(0, 8), [
|
||
0x89,
|
||
0x50,
|
||
0x4e,
|
||
0x47,
|
||
0x0d,
|
||
0x0a,
|
||
0x1a,
|
||
0x0a,
|
||
]);
|
||
// The middle square of a picture red and blue side by side holds both.
|
||
final pixels = (await image.toByteData())!;
|
||
expect(pixels.getUint8(0), greaterThan(200));
|
||
expect(pixels.getUint8(399 * 4 + 2), greaterThan(200));
|
||
});
|
||
|
||
test('a small picture keeps its size', () async {
|
||
final image = await decoded(await avatarPng(await picture(100, 160)));
|
||
|
||
expect((image.width, image.height), (100, 100));
|
||
});
|
||
|
||
test('what is no picture is refused', () async {
|
||
await expectLater(
|
||
avatarPng(Uint8List.fromList([1, 2, 3])),
|
||
throwsA(anything),
|
||
);
|
||
});
|
||
}
|