Add Progress over time and a targets and reminders setup

Progress gives a Day/Week/Month view of routines held against a weekly
target, compared with the same point of the previous period, with active
time and the daily streak. Targets & reminders sets routines and minutes
per week and schedules a heads-up before each routine. The runner's summary
now shows today's held count and streak. Finished runs are mirrored to a
device run log that feeds both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KhQh614DMeYoQEH9SoMRUw
This commit is contained in:
alvocool
2026-11-08 20:17:58 +03:00
parent 4b71257429
commit add94f621c
26 changed files with 1590 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
import '../../about/external/data/LiveSession.dart';
import '../../about/external/initial/RoutineLogRequest.dart';
import '../../about/internal/application/RoutineRun.dart';
import '../../about/internal/application/RoutineRunRecord.dart';
import '../../configs/NotificationServiceConfig.dart';
import '../parent/ParentViewModel.dart';
import 'ConnectRoutineRunner.dart';
@@ -25,6 +26,30 @@ class ViewRoutineRunner extends ParentViewModel {
));
}
void loadHistory() async {
connection.onHistoryLoaded(await getDataManager().getRunLog());
}
/// The local mirror Progress reads. Capped so the device log stays small.
Future<void> _remember(RoutineRun run) async {
final List<RoutineRunRecord> records = await getDataManager().getRunLog();
records.add(RoutineRunRecord(
routineId: run.chain.id ?? "",
title: run.chain.title,
kind: run.chain.kind.name,
startedAt: run.startedAt,
seconds: run.elapsedSeconds(),
completedSteps: run.chain.completedSteps,
totalSteps: run.chain.steps.length,
));
const int cap = 500;
await getDataManager().setRunLog(records.length > cap
? records.sublist(records.length - cap)
: records);
}
void clearRun() {
LocalNotificationEngine.cancelSessionNotification();
}
@@ -48,6 +73,8 @@ class ViewRoutineRunner extends ParentViewModel {
skippedCount: run.skippedCount,
).toJson());
await _remember(run);
clearRun();
closeLoading();