Add routines module and full goal management

Routines: workout, meditation and must-do routines with timed, rep and
tick steps, sets and rest. A library screen, a builder with templates
and drag-to-reorder steps, and a full-screen player that auto-advances
timed phases, counts backgrounding and logs broken chains as partial.

Goals: a goal editor (deadline, colour, category, default class, archive),
routines linked to goals, and a goal field on tasks and routines. Tasks
added from inside a goal are now actually attached to it via parentId.

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-02 08:45:41 +03:00
parent c88887b639
commit 1a5867a98f
49 changed files with 5384 additions and 220 deletions

View File

@@ -2,6 +2,9 @@
class CommitmentRequest {
String? id;
/// The goal this task belongs to; null for a loose task.
String? parentId;
String type;
String commitmentClass;
@@ -26,6 +29,7 @@ class CommitmentRequest {
CommitmentRequest({
this.id,
this.parentId,
this.type = "TASK",
this.commitmentClass = "Standard",
this.title = "",
@@ -42,6 +46,7 @@ class CommitmentRequest {
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['id'] = id;
data['parentId'] = parentId;
data['type'] = type;
data['commitmentClass'] = commitmentClass;
data['title'] = title;

View File

@@ -0,0 +1,45 @@
/// One run of a routine. Sent whether the chain held or broke — a broken
/// chain is logged as partial, never silently dropped.
class RoutineLogRequest {
String routineId;
String startedAt;
/// Foreground seconds only. Backgrounding pauses the run.
int elapsedSeconds;
int completedSteps;
int totalSteps;
/// Step index the chain broke at; -1 when it held.
int breakIndex;
int backgroundedCount;
int skippedCount;
RoutineLogRequest({
this.routineId = "",
this.startedAt = "",
this.elapsedSeconds = 0,
this.completedSteps = 0,
this.totalSteps = 0,
this.breakIndex = -1,
this.backgroundedCount = 0,
this.skippedCount = 0,
});
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = <String, dynamic>{};
data['routineId'] = routineId;
data['startedAt'] = startedAt;
data['elapsedSeconds'] = elapsedSeconds;
data['completedSteps'] = completedSteps;
data['totalSteps'] = totalSteps;
data['breakIndex'] = breakIndex;
data['backgroundedCount'] = backgroundedCount;
data['skippedCount'] = skippedCount;
return data;
}
}