dashPi: a self-hosted home dashboard, its sync server and phone app

The dashboard (Raspberry Pi 3.5" screen + web pages), the end-to-end
encrypted sync mailbox (PHP + SQLite) and the Android companion app
(Flutter), with docs, clean-install checks and screenshots made from
demo data.

Built mostly with an AI coding assistant; not yet reviewed line by line
by a human (see README and SECURITY.md).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Bashy 2026-10-24 09:35:12 +02:00
commit fb3c01cdd7
333 changed files with 45151 additions and 0 deletions

View file

@ -0,0 +1,144 @@
// The Work timeline's gestures on a phone-sized screen: hold an empty spot and drag = a new span; a block's
// grips = an earlier start / later end (never under 15 minutes); hold the block = move it. Holds start after
// holdDelay (250 ms — Flutter's long press would need 500). The Undo messages time out by themselves.
import 'dart:io';
import 'dart:typed_data';
import 'package:dash_app/app/sync_service.dart';
import 'package:dash_app/sync/client.dart';
import 'package:dash_app/sync/store.dart';
import 'package:dash_app/work/work_model.dart';
import 'package:dash_app/work/work_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('span, resize, move', (tester) async {
tester.view.physicalSize = const Size(1200, 2700); // a 400 × 900 phone at 3×
tester.view.devicePixelRatio = 3;
addTearDown(tester.view.reset);
final dir = Directory.systemTemp.createTempSync('resize');
final store = SyncStore('${dir.path}/d.db', 'test00000000');
final node = SyncStore.randomId(), id = SyncStore.randomId();
store.put(tNode, node, {'kind': 'client', 'name': 'Acme', 'created': '2026-10-01 00:00:00'});
final now = DateTime.now(), d = DateTime.utc(now.year, now.month, now.day);
store.put(tEntry, id, {'node_id': node, 'start': fmtMin(d.add(const Duration(hours: 10))),
'end': fmtMin(d.add(const Duration(hours: 11))), 'billable': 1, 'note': '', 'created': '2026-10-01 00:00:00'});
final sync = SyncService(SyncSettings(server: 'http://x.invalid', token: 't', account: 'a', name: 'n', device: 'test00000000',
key: Uint8List(32)), store);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: WorkPage(sync: sync))));
await tester.pump(const Duration(milliseconds: 300));
// hold an empty spot at 14:00 and drag down to 16:00 → the sheet opens with 14:00–16:00
final two = tester.getTopLeft(find.text('14'));
var s = await tester.startGesture(Offset(two.dx + 200, two.dy + 7 + 10));
await tester.pump(const Duration(milliseconds: 300));
await s.moveBy(const Offset(0, 20));
await tester.pump();
await s.moveBy(const Offset(0, 2 * hourH - 30));
await tester.pump();
expect(find.textContaining('14:00–16:00'), findsOneWidget);
await s.up();
await tester.pumpAndSettle();
expect(find.text('14:00'), findsWidgets);
expect(find.text('16:00'), findsWidgets);
Navigator.of(tester.element(find.text('16:00').first)).pop();
await tester.pumpAndSettle();
String end() => (store.row(tEntry, id)!['end'] as String).split(' ').last;
String start() => (store.row(tEntry, id)!['start'] as String).split(' ').last;
Rect block() => tester.getRect(find.ancestor(of: find.textContaining(RegExp(r'\d\d:\d\d–\d\d:\d\d')), matching: find.byType(Stack)).first);
// bottom grip: hold 300 ms, drag down an hour → ends 12:00
var g = await tester.startGesture(block().bottomCenter - const Offset(0, 5));
await tester.pump(const Duration(milliseconds: 300));
await g.moveBy(const Offset(0, 20));
await tester.pump();
await g.moveBy(const Offset(0, hourH - 20));
await tester.pump();
expect(find.textContaining('10:00–12:00'), findsOneWidget);
await g.up();
await tester.pumpAndSettle();
expect(end(), '12:00');
await tester.pump(const Duration(seconds: 5)); // the Undo message times out
await tester.pumpAndSettle();
expect(find.text('Undo'), findsNothing);
// top grip: drag up half an hour → starts 09:30
g = await tester.startGesture(block().topCenter + const Offset(0, 5));
await tester.pump(const Duration(milliseconds: 300));
await g.moveBy(const Offset(0, -20));
await tester.pump();
await g.moveBy(const Offset(0, -hourH / 2 + 20));
await tester.pump();
await g.up();
await tester.pumpAndSettle();
expect(start(), '09:30');
expect(end(), '12:00');
await tester.pump(const Duration(seconds: 5));
await tester.pumpAndSettle();
// never shorter than 15 minutes: bottom grip dragged far up
g = await tester.startGesture(block().bottomCenter - const Offset(0, 5));
await tester.pump(const Duration(milliseconds: 300));
await g.moveBy(const Offset(0, -20));
await tester.pump();
await g.moveBy(const Offset(0, -5 * hourH));
await tester.pump();
await g.up();
await tester.pumpAndSettle();
expect(end(), '09:45');
await tester.pump(const Duration(seconds: 5));
await tester.pumpAndSettle();
// the middle: a 300 ms hold moves it (Flutter's long press would need 500)
g = await tester.startGesture(block().center);
await tester.pump(const Duration(milliseconds: 300));
await g.moveBy(const Offset(0, 20));
await g.moveBy(const Offset(0, hourH - 20));
await tester.pump();
await g.up();
await tester.pumpAndSettle();
expect((start(), end()), ('10:30', '10:45'));
// a tap on the block opens it
await tester.tap(find.text('Acme · 10:30–10:45'));
await tester.pumpAndSettle();
expect(find.text('10:30'), findsWidgets);
// drawing to the screen's bottom edge and holding there scrolls the day: the span reaches past what was showing
Navigator.of(tester.element(find.text('10:30').first)).pop();
await tester.pumpAndSettle();
await tester.pump(const Duration(seconds: 5));
await tester.pumpAndSettle();
final h14 = tester.getTopLeft(find.text('14'));
final bottom = tester.view.physicalSize.height / tester.view.devicePixelRatio;
final shown = (14 + (bottom - h14.dy) / hourH).floor(); // the last hour on screen when it starts
s = await tester.startGesture(Offset(h14.dx + 200, h14.dy + 7 + 10));
await tester.pump(const Duration(milliseconds: 300));
await s.moveTo(Offset(h14.dx + 200, bottom - 30));
await tester.pump();
for (var i = 0; i < 20; i++) {
await tester.pump(const Duration(milliseconds: 16));
}
final label = tester.widgetList<Text>(find.textContaining(RegExp(r'^14:00–'))).first.data!;
final to = int.parse(label.substring(6, 8));
expect(to, greaterThan(shown), reason: '$label, $shown:00 was the last hour showing');
await s.up();
await tester.pumpAndSettle();
expect(find.text(label.substring(6, 11)), findsWidgets); // the sheet has that end
// a block held at the bottom edge rides along: it lands beyond the last hour that was showing
Navigator.of(tester.element(find.text(label.substring(6, 11)).first)).pop();
await tester.pumpAndSettle();
await tester.pump(const Duration(seconds: 5));
await tester.pumpAndSettle();
final blk = tester.getCenter(find.text('Acme · 10:30–10:45'));
final lastShown = (10.5 + (bottom - blk.dy) / hourH).floor();
s = await tester.startGesture(blk);
await tester.pump(const Duration(milliseconds: 300));
await s.moveTo(Offset(blk.dx, bottom - 30));
await tester.pump();
for (var i = 0; i < 20; i++) {
await tester.pump(const Duration(milliseconds: 16));
}
await s.up();
await tester.pumpAndSettle();
expect(int.parse(start().substring(0, 2)), greaterThan(lastShown), reason: 'moved to ${start()}, $lastShown:00 was showing');
expect(end(), isNot('10:45'));
sync.dispose();
});
}