feat(app): one Profile for every app, the person's own tab first, then each app's (ADR 0014)
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>
This commit is contained in:
parent
a0bb75f1ad
commit
b7b0b937fe
2 changed files with 1668 additions and 1293 deletions
|
|
@ -0,0 +1,66 @@
|
|||
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),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:halkyon_app/halkyon_app.dart';
|
||||
import 'package:halkyon_app/testing.dart';
|
||||
import 'package:halkyon_ui/halkyon_ui.dart';
|
||||
import 'package:material_ui/material_ui.dart';
|
||||
|
||||
void main() {
|
||||
/// Shows [profile] for someone signed in.
|
||||
Future<void> show(WidgetTester tester, HalkyonProfile profile) async {
|
||||
tester.view.physicalSize = const Size(1000, 1800);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
await tester.pumpWidget(
|
||||
testApp(profile, dependencies: TestAppDependencies()),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
testWidgets("the person's own tab first: the account and how they sign "
|
||||
"in, the app's sections, then the public profile", (tester) async {
|
||||
await show(
|
||||
tester,
|
||||
const HalkyonProfile(sections: [Text('Inbox of the app')]),
|
||||
);
|
||||
|
||||
expect(find.widgetWithText(AppBar, 'Profile'), findsOneWidget);
|
||||
expect(find.text('Account'), findsOneWidget);
|
||||
expect(find.text('Ways to sign in'), findsOneWidget);
|
||||
expect(
|
||||
tester.getTopLeft(find.text('Ways to sign in')).dy,
|
||||
lessThan(tester.getTopLeft(find.text('Inbox of the app')).dy),
|
||||
);
|
||||
expect(
|
||||
tester.getTopLeft(find.text('Inbox of the app')).dy,
|
||||
lessThan(tester.getTopLeft(find.text('Public profile')).dy),
|
||||
);
|
||||
// With no tabs of the app's, no tab row.
|
||||
expect(find.byType(FoldingTabs), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets("the app's tabs follow the person's own, which folds with "
|
||||
'them', (tester) async {
|
||||
await show(
|
||||
tester,
|
||||
const HalkyonProfile(
|
||||
tabs: [FoldingTab(label: 'Statistics', body: Text('Charts'))],
|
||||
),
|
||||
);
|
||||
|
||||
expect(
|
||||
[
|
||||
for (final tab in tester.widgetList<Tab>(find.byType(Tab))) tab.text,
|
||||
],
|
||||
['Profile', 'Statistics'],
|
||||
);
|
||||
expect(find.text('Public profile'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.widgetWithText(Tab, 'Statistics'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Charts'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
Loading…
Reference in a new issue