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,120 @@
// Health ▸ Overview: today at a glance — the food eaten today (the Food page's day card), last night's
// sleep (Sleep's night card, or that it isn't in yet), then steps today | the next period. Each part's
// heading opens its page.
import 'package:flutter/material.dart';
import '../app/sync_service.dart';
import '../app/theme.dart';
import 'activity_page.dart' show thousands;
import 'cycle_model.dart' show CycleSettings, CycleView, Status, iso, parseDay, plus, today;
import 'cycle_page.dart' show cycleStatus;
import 'food_model.dart' show FoodDb;
import 'food_page.dart' show FoodDayCard;
import 'body_page.dart' show dm;
import 'sleep_page.dart' show Night, NightCard;
import 'summaries.dart';
class OverviewPage extends StatefulWidget {
const OverviewPage({super.key, required this.sync, required this.onFood});
final SyncService sync;
final VoidCallback onFood; // → the Food section
@override
State<OverviewPage> createState() => _OverviewPageState();
}
class _OverviewPageState extends State<OverviewPage> {
FoodDb? fdb;
@override
void initState() {
super.initState();
FoodDb.open().then((x) => mounted ? setState(() => fdb = x) : null);
}
void _tab(String name) {
const tabs = ['Overview', 'Cycle', 'Body', 'Sleep', 'Heart', 'Activity'];
DefaultTabController.of(context).animateTo(tabs.indexOf(name));
}
@override
Widget build(BuildContext context) => ListenableBuilder(
listenable: widget.sync,
builder: (context, _) {
final sm = Summaries(widget.sync.store);
final now = today();
final nights = [for (final x in sm.all('night', a: iso(plus(now, -400)))) Night(parseDay(x['_day'] as String), x)];
final goal = (((sm.meta('sleep') ?? {})['goal'] as num?) ?? 8).toDouble();
final last = nights.isNotEmpty && nights.last.day == now;
final steps = sm.day(iso(now))?['steps'] as num?;
final week = [for (var k = 1; k <= 7; k++) sm.day(iso(plus(now, -k)))?['steps'] as num?].whereType<num>().toList();
final cv = CycleView(widget.sync.store, const CycleSettings());
var (head, sub) = cycleStatus(cv);
if (cv.status == Status.wait) head = cv.daysToNext == 0 ? 'today' : 'in ${cv.daysToNext} ${cv.daysToNext == 1 ? 'day' : 'days'}';
if (cv.status == Status.period) head = 'day ${cv.cycleDay}';
final wide = MediaQuery.of(context).size.width >= 700;
final food = Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
_heading('Food today', widget.onFood),
FoodDayCard(sync: widget.sync, day: now, fdb: fdb),
]);
final sleep = Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
_heading('Sleep', () => _tab('Sleep')),
if (last)
NightCard(all: nights, i: nights.length - 1, goal: goal)
else
Card(child: Padding(
padding: const EdgeInsets.all(16),
child: Text(
'Last night isn\'t logged yet${nights.isEmpty ? '' : ' — the latest is the night to ${dm(nights.last.day)}'}. '
'It comes from the band once Gadgetbridge has exported and the dashboard has synced.',
style: const TextStyle(color: muted)),
)),
]);
final tiles = Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
Expanded(child: _tile('Steps today', steps == null ? '—' : thousands(steps),
week.isEmpty ? 'nothing from the band yet' : 'last 7 days: ${thousands(week.reduce((a, b) => a + b) / week.length)} a day',
() => _tab('Activity'))),
const SizedBox(width: 10),
Expanded(child: _tile(cv.status == Status.period ? 'Period' : 'Next period', head, sub, () => _tab('Cycle'),
color: cv.status == Status.late ? bad : cv.status == Status.period ? const Color(0xFFFF6B7A) : null)),
]);
return ListView(padding: const EdgeInsets.fromLTRB(12, 4, 12, 24), children: [
if (wide)
Row(crossAxisAlignment: CrossAxisAlignment.start, children: [
Expanded(child: food),
const SizedBox(width: 12),
Expanded(child: Column(children: [sleep, const SizedBox(height: 12), tiles])),
])
else ...[food, const SizedBox(height: 4), sleep, const SizedBox(height: 12), tiles],
]);
},
);
Widget _heading(String title, VoidCallback go) => InkWell(
onTap: go,
child: Padding(
padding: const EdgeInsets.fromLTRB(4, 8, 4, 8),
child: Row(children: [
Text(title, style: const TextStyle(color: muted, fontSize: 13, fontWeight: FontWeight.bold, letterSpacing: .5)),
const Icon(Icons.chevron_right, size: 18, color: muted),
]),
),
);
Widget _tile(String label, String value, String sub, VoidCallback go, {Color? color}) => Card(
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: go,
child: Padding(
padding: const EdgeInsets.all(12),
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Text(label.toUpperCase(), style: const TextStyle(color: muted, fontSize: 11.5)),
const SizedBox(height: 2),
Text(value, style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: color)),
const SizedBox(height: 2),
Text(sub, style: const TextStyle(color: muted, fontSize: 12)),
]),
),
),
);
}