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>
74 lines
3.9 KiB
Dart
74 lines
3.9 KiB
Dart
// Cycle ▸ For your doctor: the last 12 months as on the web page's History (cycle.views.history's
|
||
// doctor part): last period, cycle / period length (average + range), periods logged, pain,
|
||
// most common symptoms + moods, and what's worth mentioning by the common guidelines.
|
||
import 'package:flutter/material.dart';
|
||
|
||
import '../app/sync_service.dart';
|
||
import '../app/theme.dart';
|
||
import 'cycle_model.dart';
|
||
|
||
const _mon = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
||
String dmy(DateTime d) => '${d.day} ${_mon[d.month - 1]} ${d.year}';
|
||
String _range((int, int)? r) => r == null ? '—' : r.$1 == r.$2 ? '${r.$1} days' : '${r.$1}–${r.$2} days';
|
||
|
||
class DoctorPage extends StatelessWidget {
|
||
const DoctorPage({super.key, required this.sync, required this.settings});
|
||
final SyncService sync;
|
||
final CycleSettings settings;
|
||
|
||
@override
|
||
Widget build(BuildContext context) => Scaffold(
|
||
appBar: AppBar(title: const Text('For your doctor')),
|
||
body: ListenableBuilder(
|
||
listenable: sync,
|
||
builder: (context, _) {
|
||
final v = CycleView(sync.store, settings);
|
||
if (v.periods.isEmpty) {
|
||
return const Center(child: Text('Nothing logged yet.', style: TextStyle(color: muted)));
|
||
}
|
||
final d = doctor(v);
|
||
final rows = <(String, String)>[
|
||
('First day of last period', d.last == null ? '—' : dmy(d.last!)),
|
||
('Cycle length', d.cycle == null ? 'not enough data yet' : '${d.cycle} days on average · ${_range(d.cycleRange)}'),
|
||
('Period length', d.period == null ? 'not enough data yet' : '${d.period} days on average · ${_range(d.periodRange)}'),
|
||
('Periods logged', '${d.periods}'),
|
||
('Pain', d.painDays == 0 ? 'none logged' : 'on ${d.painDays} day${d.painDays != 1 ? 's' : ''}, ${d.painAvg} / 5 on average'),
|
||
('Most common', d.symptoms.isEmpty ? 'no symptoms logged' : d.symptoms.map((s) => '${s.$1} (${s.$2}×)').join(', ')),
|
||
];
|
||
return ListView(padding: const EdgeInsets.all(12), children: [
|
||
Card(
|
||
child: Padding(
|
||
padding: const EdgeInsets.all(16),
|
||
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||
Row(children: [
|
||
Expanded(child: Text('${dmy(d.since)} – ${dmy(d.now)}', style: const TextStyle(color: muted))),
|
||
const Tooltip(
|
||
triggerMode: TooltipTriggerMode.tap,
|
||
message: 'From self-logged data; general guidance, not a diagnosis.',
|
||
child: Icon(Icons.info_outline, size: 18, color: muted),
|
||
),
|
||
]),
|
||
const SizedBox(height: 12),
|
||
for (final (k, val) in rows) ...[
|
||
Text(k, style: const TextStyle(color: muted, fontSize: 13)),
|
||
Padding(padding: const EdgeInsets.only(top: 2, bottom: 12), child: Text(val, style: const TextStyle(fontSize: 16))),
|
||
],
|
||
const Divider(color: card2),
|
||
const SizedBox(height: 6),
|
||
if (d.flags.isEmpty)
|
||
const Text('Nothing unusual by the common guidelines (cycles 21–35 days, periods up to 7 days, '
|
||
'no spotting between periods, …).', style: TextStyle(color: good))
|
||
else ...[
|
||
const Text('Worth mentioning', style: TextStyle(fontWeight: FontWeight.bold, color: accent)),
|
||
const SizedBox(height: 6),
|
||
for (final f in d.flags)
|
||
Padding(padding: const EdgeInsets.only(bottom: 4), child: Text('• $f')),
|
||
],
|
||
]),
|
||
),
|
||
),
|
||
]);
|
||
},
|
||
),
|
||
);
|
||
}
|