Settings sync between the dashboard and the app
- Dashboard (settingsync.py): the plugins' settings go into a synced settings.db, one row per setting (the row id is the setting's key, so the phone and the dashboard edit the same row; the later change wins) plus each field as the plugin declares it. Fields marked "local" (addresses, paths on one machine) and the plugins' on / off stay out. Values set on another device are checked as the Settings page does before they're saved; a refused one is written back with the dashboard's value. - App 1.1.7: a Settings page (the gear on every tab) built from those fields, synced both ways. Food targets, the cycle, the work day and the body profile read the synced values; with a dashboard that doesn't sync settings yet, they still come from its Health summaries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
98b110dd56
commit
820aca7d92
25 changed files with 606 additions and 41 deletions
|
|
@ -5,6 +5,7 @@
|
|||
// pain_len, tags "a,b", note, source, updated}. Days are UTC dates here (no DST surprises).
|
||||
import 'dart:math';
|
||||
|
||||
import '../app/prefs.dart';
|
||||
import '../sync/store.dart';
|
||||
|
||||
const history = 12; // cycles averaged (at most)
|
||||
|
|
@ -58,10 +59,17 @@ String iso(DateTime d) => d.toIso8601String().substring(0, 10);
|
|||
int daysBetween(DateTime a, DateTime b) => b.difference(a).inDays; // b - a
|
||||
DateTime plus(DateTime d, int n) => d.add(Duration(days: n));
|
||||
|
||||
/// The dashboard's Settings ▸ Cycle (synced: prefs.dart); its defaults until they've come.
|
||||
class CycleSettings {
|
||||
const CycleSettings({this.cycleLength = 28, this.periodLength = 5, this.showFertile = true});
|
||||
const CycleSettings({this.cycleLength = 28, this.periodLength = 5, this.showFertile = false});
|
||||
final int cycleLength, periodLength;
|
||||
final bool showFertile;
|
||||
|
||||
static CycleSettings of(SyncStore store) {
|
||||
final p = Prefs(store);
|
||||
return CycleSettings(cycleLength: p.number('cycle.cycle_length', 28).round(),
|
||||
periodLength: p.number('cycle.period_length', 5).round(), showFertile: p.get<bool>('cycle.show_fertile', false));
|
||||
}
|
||||
}
|
||||
|
||||
class DayLog {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue