Compare commits
28 Commits
588f215078
...
v1.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 0ea79e0853 | |||
| 772034cba1 | |||
| a3e4d0224b | |||
| e5eccb74e5 | |||
| 9398193c1e | |||
| 3697e4efc4 | |||
| 13c7d623ba | |||
| a9f298350e | |||
| a44f2b80b5 | |||
| 27f18d4f39 | |||
| a94d41b7f7 | |||
| 99358ed704 | |||
| 2a4b14cb43 | |||
| 7a2c1b81de | |||
| 7344933278 | |||
| 9f902ff2c7 | |||
| ceae7d7d61 | |||
| 2687f5e31e | |||
| 97eaa6dacc | |||
| 03ebaac5a8 | |||
| dec15204de | |||
| adb46d847e | |||
| b674497003 | |||
| 7536f2f759 | |||
| 27b1a80f29 | |||
| 88ef248a33 | |||
| f718ee8483 | |||
| 01de2d0f9c |
@@ -114,7 +114,7 @@ jobs:
|
||||
$SUDO apt-get update
|
||||
# sshpass from apt, fdroidserver via pip to get a newer androguard that
|
||||
# can parse modern Flutter/AGP APKs (apt ships fdroidserver 2.2.1 which crashes)
|
||||
$SUDO apt-get install -y sshpass rsync python3-pip
|
||||
$SUDO apt-get install -y sshpass python3-pip
|
||||
pip3 install --break-system-packages --upgrade fdroidserver
|
||||
|
||||
- name: Initialize or fetch F-Droid Repository
|
||||
@@ -124,11 +124,35 @@ jobs:
|
||||
PASS: ${{ secrets.HETZNER_PASS }}
|
||||
run: |
|
||||
mkdir -p fdroid
|
||||
|
||||
# Ensure remote path exists (sftp mkdir, ignoring errors if already present).
|
||||
sshpass -p "$PASS" sftp -o StrictHostKeyChecking=no "$USER@$HOST" <<'SFTP'
|
||||
-mkdir dev
|
||||
-mkdir dev/fdroid
|
||||
-mkdir dev/fdroid/repo
|
||||
SFTP
|
||||
|
||||
# Try to download the entire fdroid/ directory from Hetzner to keep
|
||||
# older APKs, the repo keystore, and config.yml across runs.
|
||||
# If it fails (first time), initialize a new local repo.
|
||||
sshpass -p "$PASS" scp -o StrictHostKeyChecking=no -r "$USER@$HOST:dev/fdroid/." fdroid/ || (cd fdroid && fdroid init)
|
||||
|
||||
- name: Ensure F-Droid repo signing key and icon
|
||||
run: |
|
||||
cd fdroid
|
||||
|
||||
# Try to download the existing repo/ folder from Hetzner to keep older versions and the keystore
|
||||
# If it fails (first time), we just initialize a new one
|
||||
sshpass -p "$PASS" scp -o StrictHostKeyChecking=no -r $USER@$HOST:dev/fdroid/repo . || fdroid init
|
||||
|
||||
# Ensure repo icon exists (use app launcher icon)
|
||||
mkdir -p repo/icons
|
||||
if [ ! -f repo/icons/icon.png ]; then
|
||||
cp ../android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png repo/icons/icon.png
|
||||
fi
|
||||
|
||||
# If keystore doesn't exist, create the signing key.
|
||||
# This only runs on the very first deployment; subsequent runs
|
||||
# download the keystore from Hetzner via the scp step above.
|
||||
if [ ! -f keystore.p12 ]; then
|
||||
fdroid update --create-key
|
||||
fi
|
||||
|
||||
- name: Copy new APK to repo
|
||||
run: |
|
||||
@@ -156,25 +180,16 @@ jobs:
|
||||
PASS: ${{ secrets.HETZNER_PASS }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
REMOTE_REPO_DIR="dev/fdroid/repo"
|
||||
SSH_OPTS="-o StrictHostKeyChecking=no -o ConnectTimeout=20 -o ServerAliveInterval=30 -o ServerAliveCountMax=5"
|
||||
SSH_OPTS="-o StrictHostKeyChecking=no -o ConnectTimeout=20"
|
||||
|
||||
# Ensure target directory exists before upload.
|
||||
sshpass -p "$PASS" ssh $SSH_OPTS "$USER@$HOST" "mkdir -p '$REMOTE_REPO_DIR'"
|
||||
# Create remote directory tree via SFTP batch (no exec channel needed).
|
||||
# Leading '-' on each mkdir means "ignore error if already exists".
|
||||
sshpass -p "$PASS" sftp $SSH_OPTS "$USER@$HOST" <<'SFTP'
|
||||
-mkdir dev
|
||||
-mkdir dev/fdroid
|
||||
-mkdir dev/fdroid/repo
|
||||
SFTP
|
||||
|
||||
if sshpass -p "$PASS" ssh $SSH_OPTS "$USER@$HOST" "command -v rsync >/dev/null 2>&1"; then
|
||||
ATTEMPT=1
|
||||
until [ "$ATTEMPT" -gt 3 ]; do
|
||||
echo "Rsync upload attempt $ATTEMPT/3"
|
||||
if sshpass -p "$PASS" rsync -avz --timeout=60 -e "ssh $SSH_OPTS" fdroid/repo/ "$USER@$HOST:$REMOTE_REPO_DIR/"; then
|
||||
exit 0
|
||||
fi
|
||||
sleep $((ATTEMPT * 5))
|
||||
ATTEMPT=$((ATTEMPT + 1))
|
||||
done
|
||||
echo "Rsync failed after retries, falling back to scp"
|
||||
else
|
||||
echo "Remote rsync not found, using scp fallback"
|
||||
fi
|
||||
|
||||
sshpass -p "$PASS" scp $SSH_OPTS -r fdroid/repo/. "$USER@$HOST:$REMOTE_REPO_DIR/"
|
||||
# Upload the entire fdroid/ directory (repo + keystore + config)
|
||||
# so the signing key persists across runs.
|
||||
sshpass -p "$PASS" scp $SSH_OPTS -r fdroid/. "$USER@$HOST:dev/fdroid/"
|
||||
|
||||
@@ -9,22 +9,22 @@ Requirements for milestone v1.1 Calendar & Polish. Each maps to roadmap phases.
|
||||
|
||||
### Calendar UI
|
||||
|
||||
- [ ] **CAL-01**: User sees a horizontal scrollable date-strip with day abbreviation (Mo, Di...) and date number per card
|
||||
- [ ] **CAL-02**: User can tap a day card to see that day's tasks in a list below the strip
|
||||
- [ ] **CAL-03**: User sees a subtle color shift at month boundaries for visual orientation
|
||||
- [ ] **CAL-04**: Calendar strip auto-scrolls to today on app launch
|
||||
- [ ] **CAL-05**: Undone tasks carry over to the next day with a red/orange color accent marking them as overdue
|
||||
- [x] **CAL-01**: User sees a horizontal scrollable date-strip with day abbreviation (Mo, Di...) and date number per card
|
||||
- [x] **CAL-02**: User can tap a day card to see that day's tasks in a list below the strip
|
||||
- [x] **CAL-03**: User sees a subtle color shift at month boundaries for visual orientation
|
||||
- [x] **CAL-04**: Calendar strip auto-scrolls to today on app launch
|
||||
- [x] **CAL-05**: Undone tasks carry over to the next day with a red/orange color accent marking them as overdue
|
||||
|
||||
### Task History
|
||||
|
||||
- [ ] **HIST-01**: Each task completion is recorded with a timestamp
|
||||
- [ ] **HIST-02**: User can view past completion dates for any individual task
|
||||
- [x] **HIST-01**: Each task completion is recorded with a timestamp
|
||||
- [x] **HIST-02**: User can view past completion dates for any individual task
|
||||
|
||||
### Task Sorting
|
||||
|
||||
- [ ] **SORT-01**: User can sort tasks alphabetically
|
||||
- [ ] **SORT-02**: User can sort tasks by frequency interval
|
||||
- [ ] **SORT-03**: User can sort tasks by effort level
|
||||
- [x] **SORT-01**: User can sort tasks alphabetically
|
||||
- [x] **SORT-02**: User can sort tasks by frequency interval
|
||||
- [x] **SORT-03**: User can sort tasks by effort level
|
||||
|
||||
## Future Requirements
|
||||
|
||||
@@ -60,16 +60,16 @@ Which phases cover which requirements. Updated during roadmap creation.
|
||||
|
||||
| Requirement | Phase | Status |
|
||||
|-------------|-------|--------|
|
||||
| CAL-01 | Phase 5 | Pending |
|
||||
| CAL-02 | Phase 5 | Pending |
|
||||
| CAL-03 | Phase 5 | Pending |
|
||||
| CAL-04 | Phase 5 | Pending |
|
||||
| CAL-05 | Phase 5 | Pending |
|
||||
| HIST-01 | Phase 6 | Pending |
|
||||
| HIST-02 | Phase 6 | Pending |
|
||||
| SORT-01 | Phase 7 | Pending |
|
||||
| SORT-02 | Phase 7 | Pending |
|
||||
| SORT-03 | Phase 7 | Pending |
|
||||
| CAL-01 | Phase 5 | Complete |
|
||||
| CAL-02 | Phase 5 | Complete |
|
||||
| CAL-03 | Phase 5 | Complete |
|
||||
| CAL-04 | Phase 5 | Complete |
|
||||
| CAL-05 | Phase 5 | Complete |
|
||||
| HIST-01 | Phase 6 | Complete |
|
||||
| HIST-02 | Phase 6 | Complete |
|
||||
| SORT-01 | Phase 7 | Complete |
|
||||
| SORT-02 | Phase 7 | Complete |
|
||||
| SORT-03 | Phase 7 | Complete |
|
||||
|
||||
**Coverage:**
|
||||
- v1.1 requirements: 10 total
|
||||
|
||||
@@ -21,9 +21,9 @@ See `milestones/v1.0-ROADMAP.md` for full phase details.
|
||||
|
||||
**v1.1 Calendar & Polish (Phases 5-7):**
|
||||
|
||||
- [ ] **Phase 5: Calendar Strip** - Replace the stacked daily plan home screen with a horizontal scrollable date-strip and day-task list
|
||||
- [ ] **Phase 6: Task History** - Record every task completion with a timestamp and expose a per-task history view
|
||||
- [ ] **Phase 7: Task Sorting** - Add alphabetical, interval, and effort sort options to task lists
|
||||
- [x] **Phase 5: Calendar Strip** - Replace the stacked daily plan home screen with a horizontal scrollable date-strip and day-task list (completed 2026-03-16)
|
||||
- [x] **Phase 6: Task History** - Record every task completion with a timestamp and expose a per-task history view (completed 2026-03-16)
|
||||
- [x] **Phase 7: Task Sorting** - Add alphabetical, interval, and effort sort options to task lists (completed 2026-03-16)
|
||||
|
||||
## Phase Details
|
||||
|
||||
@@ -37,7 +37,7 @@ See `milestones/v1.0-ROADMAP.md` for full phase details.
|
||||
3. On app launch the strip auto-scrolls so today's card is centered and selected by default
|
||||
4. When two adjacent day cards span a month boundary, a subtle color shift or divider makes the boundary visible without extra chrome
|
||||
5. Tasks that were not completed on their due date appear in subsequent days' lists with a red/orange accent marking them as overdue
|
||||
**Plans:** 2 plans
|
||||
**Plans:** 2/2 plans complete
|
||||
Plans:
|
||||
- [ ] 05-01-PLAN.md — Data layer: CalendarDao, CalendarDayState model, Riverpod providers, localization, DAO tests
|
||||
- [ ] 05-02-PLAN.md — UI: CalendarStrip, CalendarDayList, CalendarTaskRow widgets, HomeScreen replacement
|
||||
@@ -50,7 +50,9 @@ Plans:
|
||||
1. Every task completion (tap done in any view) is recorded in the database with a precise timestamp — data persists across app restarts
|
||||
2. From a task's detail or context menu the user can open a history view listing all past completion dates for that task in reverse-chronological order
|
||||
3. The history view shows a meaningful empty state if the task has never been completed
|
||||
**Plans**: TBD
|
||||
**Plans:** 1/1 plans complete
|
||||
Plans:
|
||||
- [ ] 06-01-PLAN.md — DAO query + history bottom sheet + TaskFormScreen integration + CalendarTaskRow navigation
|
||||
|
||||
### Phase 7: Task Sorting
|
||||
**Goal**: Users can reorder task lists by the dimension most useful to them — name, how often the task recurs, or how much effort it requires
|
||||
@@ -61,7 +63,10 @@ Plans:
|
||||
2. Selecting alphabetical sort orders tasks A-Z by name within the visible list
|
||||
3. Selecting interval sort orders tasks from most-frequent (daily) to least-frequent (yearly/custom) intervals
|
||||
4. Selecting effort sort orders tasks from lowest effort to highest effort level
|
||||
**Plans**: TBD
|
||||
**Plans:** 2/2 plans complete
|
||||
Plans:
|
||||
- [ ] 07-01-PLAN.md — Sort model, persistence notifier, localization, provider integration
|
||||
- [ ] 07-02-PLAN.md — Sort dropdown widget, HomeScreen AppBar, TaskListScreen integration, tests
|
||||
|
||||
## Progress
|
||||
|
||||
@@ -71,6 +76,6 @@ Plans:
|
||||
| 2. Rooms and Tasks | v1.0 | 5/5 | Complete | 2026-03-15 |
|
||||
| 3. Daily Plan and Cleanliness | v1.0 | 3/3 | Complete | 2026-03-16 |
|
||||
| 4. Notifications | v1.0 | 3/3 | Complete | 2026-03-16 |
|
||||
| 5. Calendar Strip | v1.1 | 0/2 | Planned | - |
|
||||
| 6. Task History | v1.1 | 0/? | Not started | - |
|
||||
| 7. Task Sorting | v1.1 | 0/? | Not started | - |
|
||||
| 5. Calendar Strip | 2/2 | Complete | 2026-03-16 | - |
|
||||
| 6. Task History | 1/1 | Complete | 2026-03-16 | - |
|
||||
| 7. Task Sorting | 2/2 | Complete | 2026-03-16 | - |
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
---
|
||||
gsd_state_version: 1.0
|
||||
milestone: v1.1
|
||||
milestone_name: Calendar & Polish
|
||||
status: ready
|
||||
stopped_at: Roadmap created — ready for Phase 5
|
||||
last_updated: "2026-03-16T21:00:00.000Z"
|
||||
last_activity: 2026-03-16 — Roadmap created for v1.1 (phases 5-7)
|
||||
milestone: v1.0
|
||||
milestone_name: milestone
|
||||
status: completed
|
||||
stopped_at: Completed 07-task-sorting/07-02-PLAN.md
|
||||
last_updated: "2026-03-16T21:43:23.009Z"
|
||||
last_activity: 2026-03-16 — Completed Phase 6 Plan 01 (task completion history)
|
||||
progress:
|
||||
total_phases: 3
|
||||
completed_phases: 0
|
||||
total_plans: 0
|
||||
completed_plans: 0
|
||||
percent: 0
|
||||
completed_phases: 3
|
||||
total_plans: 5
|
||||
completed_plans: 5
|
||||
percent: 100
|
||||
---
|
||||
|
||||
# Project State
|
||||
@@ -21,17 +21,17 @@ progress:
|
||||
See: .planning/PROJECT.md (updated 2026-03-16)
|
||||
|
||||
**Core value:** Users can see what needs doing today, mark it done, and trust the app to schedule the next occurrence — without thinking about it.
|
||||
**Current focus:** v1.1 Calendar & Polish — Phase 5: Calendar Strip
|
||||
**Current focus:** v1.1 Calendar & Polish — Phase 6: Task History
|
||||
|
||||
## Current Position
|
||||
|
||||
Phase: 5 — Calendar Strip
|
||||
Plan: Not started
|
||||
Status: Ready to plan Phase 5
|
||||
Last activity: 2026-03-16 — Roadmap for v1.1 written (phases 5-7)
|
||||
Phase: 6 — Task History
|
||||
Plan: 1/1 complete (Phase 6 done)
|
||||
Status: Phase Complete
|
||||
Last activity: 2026-03-16 — Completed Phase 6 Plan 01 (task completion history)
|
||||
|
||||
```
|
||||
Progress: [ ░░░░░░░░░░░░░░░░░░░░ ] 0% (0/3 phases)
|
||||
Progress: [██████████] 100% (1/1 plans in Phase 6)
|
||||
```
|
||||
|
||||
## Performance Metrics
|
||||
@@ -42,6 +42,11 @@ Progress: [ ░░░░░░░░░░░░░░░░░░░░ ] 0% (0
|
||||
| Plans | 13 | TBD |
|
||||
| LOC (lib) | 7,773 | TBD |
|
||||
| Tests | 89 | TBD |
|
||||
| Phase 05-calendar-strip P01 | 5 | 2 tasks | 10 files |
|
||||
| Phase 05-calendar-strip P02 | 8 | 3 tasks | 9 files |
|
||||
| Phase 06-task-history P01 | 5 | 2 tasks | 9 files |
|
||||
| Phase 07-task-sorting P01 | 4 | 2 tasks | 9 files |
|
||||
| Phase 07-task-sorting P02 | 4 | 2 tasks | 5 files |
|
||||
|
||||
## Accumulated Context
|
||||
|
||||
@@ -53,6 +58,18 @@ Progress: [ ░░░░░░░░░░░░░░░░░░░░ ] 0% (0
|
||||
| Phase 5 before Phase 6 and 7 | Calendar strip is the primary UI surface; history and sorting operate within or alongside it |
|
||||
| Phase 6 and 7 both depend on Phase 5 only | History and sorting are independent of each other — could execute in either order |
|
||||
| HIST-01 and HIST-02 in same phase | Data layer (HIST-01) is only 1-2 DAO additions; grouping with the UI (HIST-02) keeps the phase coherent |
|
||||
| Used NotifierProvider<SelectedDateNotifier> instead of deprecated StateProvider | Riverpod 3.x removed StateProvider; NotifierProvider is the correct replacement |
|
||||
| calendarDayProvider fetches overdue tasks with .first in asyncMap when isToday | Consistent with dailyPlanProvider pattern; avoids combining two streams |
|
||||
| watchTasksForDate sorts alphabetically by task name | Same-day tasks have no meaningful time-based order; alpha sort is deterministic and user-friendly |
|
||||
| CalendarStripController as VoidCallback holder | Avoids GlobalKey for single imperative scroll-to-today action — simpler |
|
||||
| Tests use pump()+pump(Duration) instead of pumpAndSettle() | CalendarStrip animation controllers cause pumpAndSettle timeout — fixed-duration pump steps are reliable |
|
||||
| No separate Riverpod provider for history sheet | ref.read(appDatabaseProvider) directly in ConsumerWidget — one-shot modals do not need a dedicated provider |
|
||||
| CalendarTaskRow onTap navigates to task edit form | Makes history accessible in one tap from home screen, consistent with GoRouter route patterns |
|
||||
- [Phase 07-task-sorting]: Default sort is alphabetical — continuity with existing A-Z SQL sort in CalendarDayList
|
||||
- [Phase 07-task-sorting]: overdueTasks are NOT sorted — pinned at top in existing order per design decision
|
||||
- [Phase 07-task-sorting]: Sort preference stored as enum.name string in SharedPreferences (not intEnum) — enum reordering safe
|
||||
- [Phase 07-task-sorting]: Used PopupMenuButton for SortDropdown in AppBar — menu overlay vs inline expansion, Material 3 pattern
|
||||
- [Phase 07-task-sorting]: HomeScreen uses nested Scaffold for AppBar — standard StatefulShellRoute.indexedStack per-tab AppBar pattern
|
||||
|
||||
### Pending Todos
|
||||
|
||||
@@ -60,12 +77,11 @@ None.
|
||||
|
||||
### Blockers/Concerns
|
||||
|
||||
- The existing HomeScreen (daily plan with overdue/today/upcoming) will be replaced entirely in Phase 5. Verify no other screen references the daily plan provider before deleting it, or migrate references.
|
||||
- CAL-05 (overdue carry-over with color accent) requires a query that returns tasks by their original due date relative to a selected day — confirm the existing DailyPlanDao can be adapted or a new CalendarDao is needed.
|
||||
- Phase 5 complete. daily_plan_providers.dart, daily_plan_task_row.dart, and progress_card.dart are now dead code (safe to clean up in a future phase). DailyPlanDao must NOT be deleted — still used by the notification service.
|
||||
|
||||
## Session Continuity
|
||||
|
||||
Last session: 2026-03-16
|
||||
Stopped at: Roadmap created, ready for Phase 5 planning
|
||||
Last session: 2026-03-16T21:40:24.556Z
|
||||
Stopped at: Completed 07-task-sorting/07-02-PLAN.md
|
||||
Resume file: None
|
||||
Next action: `/gsd:plan-phase 5`
|
||||
Next action: Phase 7 (task sorting) or release
|
||||
|
||||
142
.planning/phases/05-calendar-strip/05-01-SUMMARY.md
Normal file
142
.planning/phases/05-calendar-strip/05-01-SUMMARY.md
Normal file
@@ -0,0 +1,142 @@
|
||||
---
|
||||
phase: 05-calendar-strip
|
||||
plan: 01
|
||||
subsystem: database
|
||||
tags: [drift, riverpod, dart, flutter, localization, tdd]
|
||||
|
||||
# Dependency graph
|
||||
requires: []
|
||||
provides:
|
||||
- CalendarDao with watchTasksForDate and watchOverdueTasks date-parameterized queries
|
||||
- CalendarDayState domain model with selectedDate/dayTasks/overdueTasks
|
||||
- selectedDateProvider (NotifierProvider, persists while app is alive)
|
||||
- calendarDayProvider (StreamProvider.autoDispose, overdue only for today)
|
||||
- calendarTodayButton l10n string in ARB and generated dart files
|
||||
- 11 DAO unit tests covering all query behaviors
|
||||
affects:
|
||||
- 05-calendar-strip plan 02 (calendar strip UI uses these providers and state model)
|
||||
|
||||
# Tech tracking
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "CalendarDao follows @DriftAccessor pattern with DatabaseAccessor<AppDatabase>"
|
||||
- "Manual NotifierProvider<SelectedDateNotifier, DateTime> instead of @riverpod (Riverpod 3.x pattern)"
|
||||
- "StreamProvider.autoDispose with asyncMap for combining day + overdue streams"
|
||||
- "TDD: failing test commit, then implementation commit"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- lib/features/home/data/calendar_dao.dart
|
||||
- lib/features/home/data/calendar_dao.g.dart
|
||||
- lib/features/home/domain/calendar_models.dart
|
||||
- lib/features/home/presentation/calendar_providers.dart
|
||||
- test/features/home/data/calendar_dao_test.dart
|
||||
modified:
|
||||
- lib/core/database/database.dart
|
||||
- lib/core/database/database.g.dart
|
||||
- lib/l10n/app_de.arb
|
||||
- lib/l10n/app_localizations.dart
|
||||
- lib/l10n/app_localizations_de.dart
|
||||
|
||||
key-decisions:
|
||||
- "Used NotifierProvider<SelectedDateNotifier, DateTime> instead of deprecated StateProvider — Riverpod 3.x removed StateProvider in favour of Notifier-based providers"
|
||||
- "calendarDayProvider fetches overdue tasks with .first when isToday, keeping asyncMap pattern consistent with dailyPlanProvider"
|
||||
- "watchTasksForDate sorts alphabetically by name (not by due time) — arbitrary due time on same day has no meaningful sort order"
|
||||
|
||||
patterns-established:
|
||||
- "CalendarDao: @DriftAccessor with join + where filter + orderBy, mapped to TaskWithRoom — same shape as DailyPlanDao"
|
||||
- "Manual Notifier subclass for simple value-holding state provider (not @riverpod) to avoid code gen constraints"
|
||||
|
||||
requirements-completed: [CAL-02, CAL-05]
|
||||
|
||||
# Metrics
|
||||
duration: 5min
|
||||
completed: 2026-03-16
|
||||
---
|
||||
|
||||
# Phase 5 Plan 01: Calendar Data Layer Summary
|
||||
|
||||
**CalendarDao with date-exact and overdue-before-date Drift queries, CalendarDayState model, Riverpod providers for selected date and day state, and "Heute" l10n string — full data foundation for the calendar strip UI**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** 5 min
|
||||
- **Started:** 2026-03-16T20:18:55Z
|
||||
- **Completed:** 2026-03-16T20:24:12Z
|
||||
- **Tasks:** 2
|
||||
- **Files modified:** 10
|
||||
|
||||
## Accomplishments
|
||||
- CalendarDao registered in AppDatabase with two reactive Drift streams: `watchTasksForDate` (exact day, sorted by name) and `watchOverdueTasks` (strictly before reference date, sorted by due date)
|
||||
- CalendarDayState domain model separating dayTasks and overdueTasks with isEmpty helper
|
||||
- selectedDateProvider (NotifierProvider, keeps alive) + calendarDayProvider (StreamProvider.autoDispose) following existing Riverpod patterns
|
||||
- 11 unit tests passing via TDD red-green cycle; full 100-test suite passes with no regressions
|
||||
|
||||
## Task Commits
|
||||
|
||||
Each task was committed atomically:
|
||||
|
||||
1. **Task 1: RED - CalendarDao tests** - `f5c4b49` (test)
|
||||
2. **Task 1: GREEN - CalendarDao implementation** - `c666f9a` (feat)
|
||||
3. **Task 2: CalendarDayState, providers, l10n** - `68ba7c6` (feat)
|
||||
|
||||
## Files Created/Modified
|
||||
- `lib/features/home/data/calendar_dao.dart` - CalendarDao with watchTasksForDate and watchOverdueTasks
|
||||
- `lib/features/home/data/calendar_dao.g.dart` - Generated Drift mixin for CalendarDao
|
||||
- `lib/features/home/domain/calendar_models.dart` - CalendarDayState model
|
||||
- `lib/features/home/presentation/calendar_providers.dart` - selectedDateProvider and calendarDayProvider
|
||||
- `test/features/home/data/calendar_dao_test.dart` - 11 DAO unit tests (TDD RED phase)
|
||||
- `lib/core/database/database.dart` - Added CalendarDao import and registration in @DriftDatabase
|
||||
- `lib/core/database/database.g.dart` - Regenerated with CalendarDao accessor
|
||||
- `lib/l10n/app_de.arb` - Added calendarTodayButton: "Heute"
|
||||
- `lib/l10n/app_localizations.dart` - Regenerated with calendarTodayButton getter
|
||||
- `lib/l10n/app_localizations_de.dart` - Regenerated with calendarTodayButton implementation
|
||||
|
||||
## Decisions Made
|
||||
- **NotifierProvider instead of StateProvider:** Riverpod 3.x dropped `StateProvider` — replaced with `NotifierProvider<SelectedDateNotifier, DateTime>` pattern (manual, not @riverpod) to keep consistent with the codebase's non-generated providers.
|
||||
- **Overdue fetched with .first inside asyncMap:** When isToday, the overdue tasks stream's first emission is awaited inside asyncMap on the day tasks stream. This avoids combining two streams and stays consistent with the `dailyPlanProvider` pattern.
|
||||
- **watchTasksForDate sorts alphabetically by name:** Tasks due on the same calendar day have no meaningful relative order by time. Alphabetical name sort gives deterministic, user-friendly ordering.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 1 - Bug] StateProvider unavailable in Riverpod 3.x**
|
||||
- **Found during:** Task 2 (calendar providers)
|
||||
- **Issue:** Plan specified `StateProvider<DateTime>` but flutter_riverpod 3.3.1 removed StateProvider; analyzer reported `undefined_function`
|
||||
- **Fix:** Replaced with `NotifierProvider<SelectedDateNotifier, DateTime>` using a minimal `Notifier` subclass with a `selectDate(DateTime)` method
|
||||
- **Files modified:** lib/features/home/presentation/calendar_providers.dart
|
||||
- **Verification:** `flutter analyze --no-fatal-infos` reports no issues
|
||||
- **Committed in:** 68ba7c6 (Task 2 commit)
|
||||
|
||||
---
|
||||
|
||||
**Total deviations:** 1 auto-fixed (Rule 1 - Bug)
|
||||
**Impact on plan:** Fix was required for compilation. The API surface is equivalent — consumers call `ref.watch(selectedDateProvider)` to read the date and `ref.read(selectedDateProvider.notifier).selectDate(date)` to update it. No scope creep.
|
||||
|
||||
## Issues Encountered
|
||||
- None beyond the StateProvider API change documented above.
|
||||
|
||||
## User Setup Required
|
||||
None - no external service configuration required.
|
||||
|
||||
## Next Phase Readiness
|
||||
- CalendarDao, CalendarDayState, selectedDateProvider, and calendarDayProvider are all ready for consumption by Plan 02 (calendar strip UI)
|
||||
- The `selectDate` method on SelectedDateNotifier is the correct way to update the selected date from the UI
|
||||
- Existing dailyPlanProvider is unchanged — Plan 02 will decide whether to replace or retain it in the HomeScreen
|
||||
|
||||
---
|
||||
*Phase: 05-calendar-strip*
|
||||
*Completed: 2026-03-16*
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
- FOUND: lib/features/home/data/calendar_dao.dart
|
||||
- FOUND: lib/features/home/domain/calendar_models.dart
|
||||
- FOUND: lib/features/home/presentation/calendar_providers.dart
|
||||
- FOUND: test/features/home/data/calendar_dao_test.dart
|
||||
- FOUND: .planning/phases/05-calendar-strip/05-01-SUMMARY.md
|
||||
- FOUND: commit f5c4b49 (test RED phase)
|
||||
- FOUND: commit c666f9a (feat GREEN phase)
|
||||
- FOUND: commit 68ba7c6 (feat Task 2)
|
||||
148
.planning/phases/05-calendar-strip/05-02-SUMMARY.md
Normal file
148
.planning/phases/05-calendar-strip/05-02-SUMMARY.md
Normal file
@@ -0,0 +1,148 @@
|
||||
---
|
||||
phase: 05-calendar-strip
|
||||
plan: 02
|
||||
subsystem: ui
|
||||
tags: [flutter, riverpod, dart, intl, animation, calendar]
|
||||
|
||||
# Dependency graph
|
||||
requires:
|
||||
- phase: 05-calendar-strip plan 01
|
||||
provides: CalendarDao, CalendarDayState, selectedDateProvider, calendarDayProvider
|
||||
provides:
|
||||
- CalendarStrip widget (181-day horizontal scroll, German abbreviations, month boundary labels)
|
||||
- CalendarTaskRow widget (task name + room tag chip + checkbox, no relative date)
|
||||
- CalendarDayList widget (loading/empty/celebration/tasks states, overdue section today-only)
|
||||
- Rewritten HomeScreen composing strip + day list with floating Today button
|
||||
- totalTaskCount field on CalendarDayState and getTaskCount() on CalendarDao
|
||||
- Updated home screen and app shell tests for new calendar providers
|
||||
affects:
|
||||
- 06-task-history (uses CalendarStrip as the navigation surface)
|
||||
- 07-task-sorting (task display within CalendarDayList)
|
||||
|
||||
# Tech tracking
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "CalendarStrip uses CalendarStripController (simple VoidCallback holder) for parent-to-child imperative scrolling"
|
||||
- "CalendarDayList manages _completingTaskIds Set<int> for slide-out animation the same way as old HomeScreen"
|
||||
- "Tests use tester.pump() + pump(Duration) instead of pumpAndSettle() to avoid timeout from animation controllers"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- lib/features/home/presentation/calendar_strip.dart
|
||||
- lib/features/home/presentation/calendar_task_row.dart
|
||||
- lib/features/home/presentation/calendar_day_list.dart
|
||||
modified:
|
||||
- lib/features/home/presentation/home_screen.dart
|
||||
- lib/features/home/domain/calendar_models.dart
|
||||
- lib/features/home/data/calendar_dao.dart
|
||||
- lib/features/home/presentation/calendar_providers.dart
|
||||
- test/features/home/presentation/home_screen_test.dart
|
||||
- test/shell/app_shell_test.dart
|
||||
|
||||
key-decisions:
|
||||
- "CalendarStripController holds a VoidCallback instead of using GlobalKey — simpler for this one-direction imperative call"
|
||||
- "totalTaskCount fetched via getTaskCount() inside calendarDayProvider asyncMap — avoids a third stream, consistent with existing pattern"
|
||||
- "Tests use pump() + pump(Duration) instead of pumpAndSettle() — CalendarStrip's ScrollController postFrameCallback and animation controllers cause pumpAndSettle to timeout"
|
||||
- "month label height always reserved with SizedBox(height:16) on non-boundary cards — prevents strip height jitter as you scroll through months"
|
||||
|
||||
patterns-established:
|
||||
- "ImperativeController pattern: class with VoidCallback? _action; void action() => _action?.call(); widget sets _action in initState"
|
||||
- "CalendarDayList state machine: first-run (totalTaskCount==0) > celebration (isToday + isEmpty + totalTaskCount>0) > emptyDay (isEmpty) > hasTasks"
|
||||
|
||||
requirements-completed: [CAL-01, CAL-03, CAL-04, CAL-05]
|
||||
|
||||
# Metrics
|
||||
duration: 8min
|
||||
completed: 2026-03-16
|
||||
---
|
||||
|
||||
# Phase 5 Plan 02: Calendar Strip UI Summary
|
||||
|
||||
**Horizontal 181-day calendar strip with German day cards, month boundaries, floating Today button, and day task list with overdue section — replaces the stacked daily-plan HomeScreen**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** 8 min
|
||||
- **Started:** 2026-03-16T20:27:39Z
|
||||
- **Completed:** 2026-03-16T20:35:55Z
|
||||
- **Tasks:** 3 (Task 3 auto-approved in auto-advance mode)
|
||||
- **Files modified:** 9
|
||||
|
||||
## Accomplishments
|
||||
- CalendarStrip: horizontal ListView with 181 day cards (90 past + today + 90 future), German abbreviations via `DateFormat('E', 'de')`, selected card highlighted (stronger primaryContainer + border), today card with bold text + 2px accent underline, month boundary wider gap + month label, auto-scrolls to center today on init, CalendarStripController enables Today-button → strip communication
|
||||
- CalendarDayList: five-state machine (loading, first-run empty, celebration, empty day, has tasks) with overdue section when viewing today, slide-out completion animation reusing the same SizeTransition + SlideTransition pattern from the old HomeScreen
|
||||
- CalendarTaskRow: simplified from DailyPlanTaskRow — no relative date, name + room chip + checkbox, coral text when isOverdue
|
||||
- HomeScreen rewritten: Stack with Column(CalendarStrip + Expanded(CalendarDayList)) and conditionally-visible FloatingActionButton.extended for "Heute" navigation
|
||||
- Added totalTaskCount to CalendarDayState and getTaskCount() SELECT COUNT to CalendarDao for first-run vs. celebration disambiguation
|
||||
- Updated 2 test files (home_screen_test.dart, app_shell_test.dart) to test new providers; test count grew from 100 to 101
|
||||
|
||||
## Task Commits
|
||||
|
||||
Each task was committed atomically:
|
||||
|
||||
1. **Task 1: Build CalendarStrip, CalendarTaskRow, CalendarDayList widgets** - `f718ee8` (feat)
|
||||
2. **Task 2: Replace HomeScreen with calendar composition** - `88ef248` (feat)
|
||||
3. **Task 3: Verify calendar strip visually** - auto-approved (checkpoint:human-verify in auto-advance mode)
|
||||
|
||||
## Files Created/Modified
|
||||
- `lib/features/home/presentation/calendar_strip.dart` - 181-day horizontal scrollable strip with German abbreviations, today/selected highlights, month boundary labels
|
||||
- `lib/features/home/presentation/calendar_task_row.dart` - Task row: name + room chip + checkbox, isOverdue coral styling, no relative date
|
||||
- `lib/features/home/presentation/calendar_day_list.dart` - Day task list with 5-state machine, overdue section (today only), slide-out animation
|
||||
- `lib/features/home/presentation/home_screen.dart` - Rewritten: CalendarStrip + CalendarDayList + floating Today FAB
|
||||
- `lib/features/home/domain/calendar_models.dart` - Added totalTaskCount field
|
||||
- `lib/features/home/data/calendar_dao.dart` - Added getTaskCount() query
|
||||
- `lib/features/home/presentation/calendar_providers.dart` - calendarDayProvider now fetches and includes totalTaskCount
|
||||
- `test/features/home/presentation/home_screen_test.dart` - Rewritten for CalendarDayState / calendarDayProvider
|
||||
- `test/shell/app_shell_test.dart` - Updated from dailyPlanProvider to calendarDayProvider
|
||||
|
||||
## Decisions Made
|
||||
- **CalendarStripController as simple VoidCallback holder:** Avoids GlobalKey complexity for a single imperative scroll-to-today action; parent holds controller, widget registers its implementation in initState.
|
||||
- **totalTaskCount fetched in asyncMap:** Consistent with existing calendarDayProvider asyncMap pattern; avoids a third reactive stream just for a count.
|
||||
- **Tests use pump() + pump(Duration) instead of pumpAndSettle():** ScrollController's postFrameCallback animation and _completingTaskIds AnimationController keep the tester busy indefinitely; fixed-duration pump steps are reliable.
|
||||
- **Month label height always reserved:** Non-boundary cards get `SizedBox(height: 16)` to match the label row height — prevents strip height from changing as you scroll across month edges.
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 1 - Bug] Updated existing tests broken by the HomeScreen rewrite**
|
||||
- **Found during:** Task 2 verification (flutter test)
|
||||
- **Issue:** `home_screen_test.dart` and `app_shell_test.dart` both imported `dailyPlanProvider` and `DailyPlanState` and used `pumpAndSettle()`, which now times out because CalendarStrip animation controllers never settle
|
||||
- **Fix:** Rewrote both test files to use `calendarDayProvider`/`CalendarDayState` and replaced `pumpAndSettle()` with `pump() + pump(Duration(milliseconds: 500))`; updated all assertions to match new UI (removed progress card / tomorrow section assertions, added strip-visible assertion)
|
||||
- **Files modified:** test/features/home/presentation/home_screen_test.dart, test/shell/app_shell_test.dart
|
||||
- **Verification:** `flutter test` — 101 tests all pass; `flutter analyze --no-fatal-infos` — zero issues
|
||||
- **Committed in:** f718ee8 (Task 1 commit, as tests were fixed alongside widget creation)
|
||||
|
||||
---
|
||||
|
||||
**Total deviations:** 1 auto-fixed (Rule 1 - Bug)
|
||||
**Impact on plan:** Required to maintain working test suite. The new tests cover the same behaviors (empty state, overdue section, celebration, checkboxes) but against the calendar API. No scope creep.
|
||||
|
||||
## Issues Encountered
|
||||
- None beyond the test migration documented above.
|
||||
|
||||
## User Setup Required
|
||||
None - no external service configuration required.
|
||||
|
||||
## Next Phase Readiness
|
||||
- HomeScreen is fully replaced; CalendarStrip and CalendarDayList are composable widgets ready for Phase 6/7 integration
|
||||
- The old daily_plan_providers.dart, daily_plan_task_row.dart, and progress_card.dart are now dead code; safe to clean up in a future phase
|
||||
- DailyPlanDao is still used by the notification service and must NOT be deleted
|
||||
|
||||
---
|
||||
*Phase: 05-calendar-strip*
|
||||
*Completed: 2026-03-16*
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
- FOUND: lib/features/home/presentation/calendar_strip.dart
|
||||
- FOUND: lib/features/home/presentation/calendar_task_row.dart
|
||||
- FOUND: lib/features/home/presentation/calendar_day_list.dart
|
||||
- FOUND: lib/features/home/presentation/home_screen.dart (rewritten)
|
||||
- FOUND: lib/features/home/domain/calendar_models.dart (updated)
|
||||
- FOUND: lib/features/home/data/calendar_dao.dart (updated)
|
||||
- FOUND: lib/features/home/presentation/calendar_providers.dart (updated)
|
||||
- FOUND: .planning/phases/05-calendar-strip/05-02-SUMMARY.md
|
||||
- FOUND: commit f718ee8 (Task 1)
|
||||
- FOUND: commit 88ef248 (Task 2)
|
||||
202
.planning/phases/05-calendar-strip/05-VERIFICATION.md
Normal file
202
.planning/phases/05-calendar-strip/05-VERIFICATION.md
Normal file
@@ -0,0 +1,202 @@
|
||||
---
|
||||
phase: 05-calendar-strip
|
||||
verified: 2026-03-16T21:00:00Z
|
||||
status: human_needed
|
||||
score: 10/10 must-haves verified
|
||||
human_verification:
|
||||
- test: "Launch the app on a device or emulator and confirm the calendar strip renders correctly"
|
||||
expected: "Horizontal row of day cards with German abbreviations (Mo, Di, Mi...) and date number; today's card is bold with a 2px green underline accent; all cards have a light sage tint; selected card has stronger green background and border"
|
||||
why_human: "Visual appearance, color fidelity, and card proportions cannot be verified programmatically"
|
||||
- test: "Tap several day cards and verify the task list below updates"
|
||||
expected: "Tapping a card selects it (green highlight, centered), and the task list below immediately shows that day's tasks"
|
||||
why_human: "Interactive tap-to-select flow and reactive list update require a running device"
|
||||
- test: "Scroll the strip far from today, then tap the floating Today button"
|
||||
expected: "Floating 'Heute' FAB appears when today is scrolled out of view; tapping it re-centers today's card and resets the task list to today"
|
||||
why_human: "Visibility toggle of FAB and imperative scroll-back behavior require real scroll interaction"
|
||||
- test: "Verify month boundary treatment"
|
||||
expected: "At every month boundary a slightly wider gap appears between the last card of one month and the first card of the next, with a small month label (e.g. 'Mrz', 'Apr') in the gap"
|
||||
why_human: "Month label rendering and gap width are visual properties that require visual inspection"
|
||||
- test: "With tasks overdue (nextDueDate before today), view today in the strip"
|
||||
expected: "An 'Uberfaellig' section header in coral appears above the overdue tasks; switching to yesterday or tomorrow hides the overdue section entirely"
|
||||
why_human: "Requires a device with test data in the database and navigation between days"
|
||||
- test: "Complete a task via its checkbox"
|
||||
expected: "The task slides out with a SizeTransition + SlideTransition animation (300ms); it disappears from the list after the animation"
|
||||
why_human: "Animation quality and timing require visual observation on a running device"
|
||||
---
|
||||
|
||||
# Phase 5: Calendar Strip Verification Report
|
||||
|
||||
**Phase Goal:** Users navigate their tasks through a horizontal date-strip that replaces the stacked daily plan, seeing today's tasks by default and any day's tasks on tap
|
||||
**Verified:** 2026-03-16T21:00:00Z
|
||||
**Status:** human_needed — all automated checks pass; 6 visual/interactive behaviors need human confirmation
|
||||
**Re-verification:** No — initial verification
|
||||
|
||||
---
|
||||
|
||||
## Goal Achievement
|
||||
|
||||
### Observable Truths
|
||||
|
||||
| # | Truth | Status | Evidence |
|
||||
|----|-------|--------|---------|
|
||||
| 1 | Home screen shows a horizontal scrollable strip of day cards with German abbreviation (Mo, Di...) and date number | VERIFIED | `calendar_strip.dart` L265: `DateFormat('E', 'de').format(date)` produces German abbreviations; 181-card `ListView.builder` scroll direction horizontal |
|
||||
| 2 | Tapping a day card updates the task list below to show that day's tasks | VERIFIED | `_onCardTapped` calls `ref.read(selectedDateProvider.notifier).selectDate(tappedDate)`; `CalendarDayList` watches `calendarDayProvider` which watches `selectedDateProvider` |
|
||||
| 3 | On app launch the strip auto-scrolls so today's card is centered | VERIFIED | `initState` calls `WidgetsBinding.instance.addPostFrameCallback` → `_animateToToday()` which calls `_scrollController.animateTo(..., duration: 200ms, curve: Curves.easeOut)` |
|
||||
| 4 | A subtle wider gap and month label appears at month boundaries | VERIFIED | `_kMonthBoundaryGap = 16.0` vs `_kCardMargin = 4.0`; `_isFirstOfMonth` triggers `DateFormat('MMM', 'de').format(date)` text label; non-boundary cards reserve `SizedBox(height: 16)` to prevent jitter |
|
||||
| 5 | Overdue tasks appear in a separate coral-accented section when viewing today | VERIFIED | `calendarDayProvider` fetches `watchOverdueTasks` only when `isToday`; `_buildTaskList` renders a coral-colored "Uberfaellig" header via `_overdueColor = Color(0xFFE07A5F)` when `state.overdueTasks.isNotEmpty` |
|
||||
| 6 | Overdue tasks do NOT appear when viewing past or future days | VERIFIED | `calendarDayProvider`: `isToday` guard — past/future sets `overdueTasks = const []`; 101-test suite includes `does not show overdue section for non-today date` test passing |
|
||||
| 7 | Completing a task via checkbox triggers slide-out animation | VERIFIED | `_CompletingTaskRow` in `calendar_day_list.dart` implements `SizeTransition` + `SlideTransition` (300ms, `Curves.easeInOut`); `_onTaskCompleted` adds to `_completingTaskIds` and calls `taskActionsProvider.notifier.completeTask` |
|
||||
| 8 | Floating Today button appears when scrolled away from today, hidden when today is visible | VERIFIED | `CalendarStrip.onTodayVisibilityChanged` callback drives `_showTodayButton` in `HomeScreen`; `_onScroll` computes viewport bounds vs today card position |
|
||||
| 9 | First-run empty state (no rooms/tasks) still shows the create-room prompt | VERIFIED | `CalendarDayList._buildFirstRunEmpty` shows checklist icon + `l10n.dailyPlanNoTasks` + `l10n.homeEmptyAction` FilledButton.tonal navigating to `/rooms`; gated by `totalTaskCount == 0` |
|
||||
| 10 | Celebration state shows when all tasks for the selected day are done | VERIFIED | `_buildCelebration` renders `Icons.celebration_outlined` + `dailyPlanAllClearTitle` + `dailyPlanAllClearMessage`; triggered by `isToday && dayTasks.isEmpty && overdueTasks.isEmpty && totalTaskCount > 0` |
|
||||
|
||||
**Score: 10/10 truths verified**
|
||||
|
||||
---
|
||||
|
||||
## Required Artifacts
|
||||
|
||||
### Plan 01 Artifacts
|
||||
|
||||
| Artifact | Expected | Lines | Status | Details |
|
||||
|----------|----------|-------|--------|---------|
|
||||
| `lib/features/home/data/calendar_dao.dart` | Date-parameterized task queries | 87 | VERIFIED | `watchTasksForDate`, `watchOverdueTasks`, `getTaskCount` all implemented; `@DriftAccessor(tables: [Tasks, Rooms, TaskCompletions])` annotation present |
|
||||
| `lib/features/home/data/calendar_dao.g.dart` | Generated Drift mixin | 25 | VERIFIED | `_$CalendarDaoMixin` generated, part of `calendar_dao.dart` |
|
||||
| `lib/features/home/domain/calendar_models.dart` | CalendarDayState model | 25 | VERIFIED | `CalendarDayState` with `selectedDate`, `dayTasks`, `overdueTasks`, `totalTaskCount`, `isEmpty` getter |
|
||||
| `lib/features/home/presentation/calendar_providers.dart` | Riverpod providers | 69 | VERIFIED | `selectedDateProvider` (NotifierProvider), `calendarDayProvider` (StreamProvider.autoDispose) with overdue-today-only logic |
|
||||
| `test/features/home/data/calendar_dao_test.dart` | DAO unit tests (min 50 lines) | 286 | VERIFIED | 11 tests: 5 for `watchTasksForDate`, 6 for `watchOverdueTasks`; all pass |
|
||||
|
||||
### Plan 02 Artifacts
|
||||
|
||||
| Artifact | Expected | Lines | Status | Details |
|
||||
|----------|----------|-------|--------|---------|
|
||||
| `lib/features/home/presentation/calendar_strip.dart` | Horizontal scrollable date strip (min 100 lines) | 348 | VERIFIED | 181-card ListView, German abbreviations, CalendarStripController, today-visibility callback, month boundary labels |
|
||||
| `lib/features/home/presentation/calendar_day_list.dart` | Day task list with states (min 80 lines) | 310 | VERIFIED | 5-state machine (loading/first-run/celebration/empty/tasks), overdue section, `_CompletingTaskRow` animation |
|
||||
| `lib/features/home/presentation/calendar_task_row.dart` | Task row (min 30 lines) | 69 | VERIFIED | Name + room chip + checkbox; `isOverdue` coral styling; no relative date |
|
||||
| `lib/features/home/presentation/home_screen.dart` | Rewritten HomeScreen (min 40 lines) | 69 | VERIFIED | Stack with Column(CalendarStrip + CalendarDayList) + conditional floating FAB |
|
||||
|
||||
---
|
||||
|
||||
## Key Link Verification
|
||||
|
||||
### Plan 01 Links
|
||||
|
||||
| From | To | Via | Status | Details |
|
||||
|------|----|-----|--------|---------|
|
||||
| `calendar_dao.dart` | `database.dart` | CalendarDao registered in @DriftDatabase daos | WIRED | `database.dart` L49: `daos: [RoomsDao, TasksDao, DailyPlanDao, CalendarDao]`; `database.g.dart` L1249: `late final CalendarDao calendarDao = CalendarDao(this as AppDatabase)` |
|
||||
| `calendar_providers.dart` | `calendar_dao.dart` | Provider reads CalendarDao from AppDatabase via `db.calendarDao` | WIRED | `calendar_providers.dart` L46: `db.calendarDao.watchTasksForDate(selectedDate)`; L53–54: `db.calendarDao.watchOverdueTasks(selectedDate).first`; L60: `db.calendarDao.getTaskCount()` |
|
||||
|
||||
### Plan 02 Links
|
||||
|
||||
| From | To | Via | Status | Details |
|
||||
|------|----|-----|--------|---------|
|
||||
| `home_screen.dart` | `calendar_strip.dart` | HomeScreen composes CalendarStrip | WIRED | `home_screen.dart` L37: `CalendarStrip(controller: _stripController, ...)` |
|
||||
| `home_screen.dart` | `calendar_day_list.dart` | HomeScreen composes CalendarDayList | WIRED | `home_screen.dart` L43: `const Expanded(child: CalendarDayList())` |
|
||||
| `calendar_strip.dart` | `calendar_providers.dart` | Strip reads/writes selectedDateProvider | WIRED | `calendar_strip.dart` L193: `ref.read(selectedDateProvider.notifier).selectDate(tappedDate)`; L199: `ref.watch(selectedDateProvider)` |
|
||||
| `calendar_day_list.dart` | `calendar_providers.dart` | Day list watches calendarDayProvider | WIRED | `calendar_day_list.dart` L46: `final dayState = ref.watch(calendarDayProvider)` |
|
||||
| `calendar_day_list.dart` | `task_providers.dart` | Task completion via taskActionsProvider | WIRED | `calendar_day_list.dart` L39: `ref.read(taskActionsProvider.notifier).completeTask(taskId)` |
|
||||
|
||||
---
|
||||
|
||||
## Requirements Coverage
|
||||
|
||||
| Requirement | Source Plan | Description | Status | Evidence |
|
||||
|-------------|-------------|-------------|--------|---------|
|
||||
| CAL-01 | Plan 02 | User sees horizontal scrollable date-strip with day abbreviation (Mo, Di...) and date number per card | SATISFIED | `calendar_strip.dart`: 181-card horizontal ListView; `DateFormat('E', 'de')` for German abbreviations; `date.day.toString()` for date number |
|
||||
| CAL-02 | Plan 01 | User can tap a day card to see that day's tasks in a list below the strip | SATISFIED | `_onCardTapped` → `selectedDateProvider` → `calendarDayProvider` → `CalendarDayList` reactive update |
|
||||
| CAL-03 | Plan 02 | User sees a subtle color shift at month boundaries for visual orientation | SATISFIED | `_isFirstOfMonth` check triggers `_kMonthBoundaryGap = 16.0` (vs 4px normal) and `DateFormat('MMM', 'de')` month label in `theme.colorScheme.primary` |
|
||||
| CAL-04 | Plan 02 | Calendar strip auto-scrolls to today on app launch | SATISFIED | `addPostFrameCallback` → `_animateToToday()` → `animateTo(200ms, Curves.easeOut)` centered on today's index |
|
||||
| CAL-05 | Plans 01+02 | Undone tasks carry over to the next day with red/orange color accent | SATISFIED | `watchOverdueTasks` returns tasks with `nextDueDate < today`; `calendarDayProvider` includes them only for `isToday`; `_overdueColor = Color(0xFFE07A5F)` applied to section header and task name text |
|
||||
|
||||
**All 5 CAL requirements: SATISFIED**
|
||||
|
||||
No orphaned requirements — REQUIREMENTS.md maps CAL-01 through CAL-05 exclusively to Phase 5, all accounted for.
|
||||
|
||||
---
|
||||
|
||||
## Anti-Patterns Found
|
||||
|
||||
No anti-patterns detected. Scan of all 7 phase-created/modified files found:
|
||||
- No TODO/FIXME/XXX/HACK/PLACEHOLDER comments
|
||||
- No empty implementations (`return null`, `return {}`, `return []`)
|
||||
- No stub handlers (`() => {}` or `() => console.log(...)`)
|
||||
- No unimplemented API routes
|
||||
|
||||
---
|
||||
|
||||
## Test Results
|
||||
|
||||
| Suite | Result | Count |
|
||||
|-------|--------|-------|
|
||||
| `flutter test test/features/home/data/calendar_dao_test.dart` | All passed | 11/11 |
|
||||
| `flutter test` (full suite) | All passed | 101/101 |
|
||||
| `flutter analyze --no-fatal-infos` | No issues | 0 errors, 0 warnings |
|
||||
|
||||
---
|
||||
|
||||
## Commit Verification
|
||||
|
||||
All 5 commits documented in SUMMARY files confirmed to exist in git history:
|
||||
|
||||
| Hash | Description |
|
||||
|------|-------------|
|
||||
| `f5c4b49` | test(05-01): add failing tests for CalendarDao |
|
||||
| `c666f9a` | feat(05-01): implement CalendarDao with date-parameterized task queries |
|
||||
| `68ba7c6` | feat(05-01): add CalendarDayState model, Riverpod providers, and l10n strings |
|
||||
| `f718ee8` | feat(05-02): build CalendarStrip, CalendarTaskRow, CalendarDayList widgets |
|
||||
| `88ef248` | feat(05-02): replace HomeScreen with calendar composition and floating Today button |
|
||||
|
||||
---
|
||||
|
||||
## Human Verification Required
|
||||
|
||||
All automated checks pass. The following items require a device or emulator to confirm:
|
||||
|
||||
### 1. Calendar Strip Visual Rendering
|
||||
|
||||
**Test:** Launch the app, navigate to the home tab.
|
||||
**Expected:** Horizontal row of day cards each showing a German day abbreviation (Mo, Di, Mi, Do, Fr, Sa, So) and a date number. All cards have a light sage/green tint background. Today's card has bold text and a 2px green underline accent bar below the date number.
|
||||
**Why human:** Color fidelity, card proportions, and font weight treatment are visual properties.
|
||||
|
||||
### 2. Day Selection Updates Task List
|
||||
|
||||
**Test:** Tap several different day cards in the strip.
|
||||
**Expected:** The tapped card becomes highlighted (stronger green background + border, centered in the strip), and the task list below immediately updates to show that day's scheduled tasks.
|
||||
**Why human:** Interactive responsiveness and smooth centering animation require a running device.
|
||||
|
||||
### 3. Floating Today Button Behavior
|
||||
|
||||
**Test:** Scroll the strip well past today (e.g., 30+ days forward). Then tap the floating "Heute" button.
|
||||
**Expected:** The "Heute" FAB appears when today's card is no longer in the viewport. Tapping it re-centers today's card with a smooth scroll animation and resets the task list to today's tasks. The FAB then disappears.
|
||||
**Why human:** FAB visibility toggling based on scroll position and imperative scroll-back require real interaction.
|
||||
|
||||
### 4. Month Boundary Labels
|
||||
|
||||
**Test:** Scroll through a month boundary in the strip.
|
||||
**Expected:** At the boundary, a small month name label (e.g., "Apr") appears above the first card of the new month, and the gap between the last card of the old month and the first card of the new month is visibly wider than the normal gap.
|
||||
**Why human:** Gap width and label placement are visual properties.
|
||||
|
||||
### 5. Overdue Section Today-Only
|
||||
|
||||
**Test:** With at least one task whose nextDueDate is before today in the database, view the home screen on today's date, then tap a past or future date.
|
||||
**Expected:** On today's view, a coral-colored "Uberfaellig" section header appears above the overdue task(s) with coral-colored task names. Switching to any other day hides the overdue section entirely — only that day's scheduled tasks appear.
|
||||
**Why human:** Requires real data in the database and navigation between dates.
|
||||
|
||||
### 6. Task Completion Slide-Out Animation
|
||||
|
||||
**Test:** Tap a checkbox on any task in the day list.
|
||||
**Expected:** The task row slides out to the right while simultaneously collapsing its height to zero, over approximately 300ms, then disappears from the list.
|
||||
**Why human:** Animation smoothness, duration, and visual quality require observation on a running device.
|
||||
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
Phase 5 goal is **fully achieved at the code level**. The horizontal calendar strip replaces the stacked daily plan, the data layer correctly handles date-parameterized queries and overdue isolation, all UI widgets are substantive and properly wired, all key links are connected, all 5 CAL requirements are satisfied, and the full 101-test suite passes with zero analysis issues.
|
||||
|
||||
The `human_needed` status reflects that 6 visual and interactive behaviors (strip appearance, tap selection, Today button scroll-back, month boundary labels, overdue section isolation, and task completion animation) require a running device to confirm their real-world quality. No code gaps were found.
|
||||
|
||||
---
|
||||
|
||||
_Verified: 2026-03-16T21:00:00Z_
|
||||
_Verifier: Claude (gsd-verifier)_
|
||||
312
.planning/phases/06-task-history/06-01-PLAN.md
Normal file
312
.planning/phases/06-task-history/06-01-PLAN.md
Normal file
@@ -0,0 +1,312 @@
|
||||
---
|
||||
phase: 06-task-history
|
||||
plan: 01
|
||||
type: execute
|
||||
wave: 1
|
||||
depends_on: []
|
||||
files_modified:
|
||||
- lib/features/tasks/data/tasks_dao.dart
|
||||
- lib/features/tasks/data/tasks_dao.g.dart
|
||||
- lib/features/tasks/presentation/task_history_sheet.dart
|
||||
- lib/features/tasks/presentation/task_form_screen.dart
|
||||
- lib/features/home/presentation/calendar_task_row.dart
|
||||
- lib/l10n/app_de.arb
|
||||
- lib/l10n/app_localizations.dart
|
||||
- lib/l10n/app_localizations_de.dart
|
||||
- test/features/tasks/data/task_history_dao_test.dart
|
||||
autonomous: true
|
||||
requirements: [HIST-01, HIST-02]
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "Every task completion is recorded with a timestamp and persists across app restarts"
|
||||
- "User can open a history view from the task edit form showing all past completion dates in reverse-chronological order"
|
||||
- "History view shows a meaningful empty state if the task has never been completed"
|
||||
artifacts:
|
||||
- path: "lib/features/tasks/data/tasks_dao.dart"
|
||||
provides: "watchCompletionsForTask(int taskId) stream method"
|
||||
contains: "watchCompletionsForTask"
|
||||
- path: "lib/features/tasks/presentation/task_history_sheet.dart"
|
||||
provides: "Bottom sheet displaying task completion history"
|
||||
exports: ["showTaskHistorySheet"]
|
||||
- path: "lib/features/tasks/presentation/task_form_screen.dart"
|
||||
provides: "Verlauf button in edit mode opening history sheet"
|
||||
contains: "showTaskHistorySheet"
|
||||
- path: "lib/features/home/presentation/calendar_task_row.dart"
|
||||
provides: "onTap navigation to task edit form"
|
||||
contains: "context.go"
|
||||
- path: "test/features/tasks/data/task_history_dao_test.dart"
|
||||
provides: "Tests for completion history DAO query"
|
||||
min_lines: 30
|
||||
key_links:
|
||||
- from: "lib/features/tasks/presentation/task_form_screen.dart"
|
||||
to: "lib/features/tasks/presentation/task_history_sheet.dart"
|
||||
via: "showTaskHistorySheet call in Verlauf button onTap"
|
||||
pattern: "showTaskHistorySheet"
|
||||
- from: "lib/features/tasks/presentation/task_history_sheet.dart"
|
||||
to: "lib/features/tasks/data/tasks_dao.dart"
|
||||
via: "watchCompletionsForTask stream consumption"
|
||||
pattern: "watchCompletionsForTask"
|
||||
- from: "lib/features/home/presentation/calendar_task_row.dart"
|
||||
to: "TaskFormScreen"
|
||||
via: "GoRouter navigation on row tap"
|
||||
pattern: "context\\.go.*tasks"
|
||||
---
|
||||
|
||||
<objective>
|
||||
Add task completion history: a DAO query to fetch completions, a bottom sheet to display them, integration into the task edit form, and CalendarTaskRow onTap navigation.
|
||||
|
||||
Purpose: Users can see exactly when each task was completed in the past, building trust that the scheduling loop is working correctly.
|
||||
Output: Working history view accessible from task edit form, completion data surfaced from existing TaskCompletions table.
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@/home/jlmak/.claude/get-shit-done/workflows/execute-plan.md
|
||||
@/home/jlmak/.claude/get-shit-done/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<context>
|
||||
@.planning/PROJECT.md
|
||||
@.planning/ROADMAP.md
|
||||
@.planning/STATE.md
|
||||
@.planning/phases/06-task-history/06-CONTEXT.md
|
||||
|
||||
<interfaces>
|
||||
<!-- Key types and contracts the executor needs. Extracted from codebase. -->
|
||||
<!-- Executor should use these directly -- no codebase exploration needed. -->
|
||||
|
||||
From lib/core/database/database.dart:
|
||||
```dart
|
||||
/// TaskCompletions table: records when a task was completed.
|
||||
class TaskCompletions extends Table {
|
||||
IntColumn get id => integer().autoIncrement()();
|
||||
IntColumn get taskId => integer().references(Tasks, #id)();
|
||||
DateTimeColumn get completedAt => dateTime()();
|
||||
}
|
||||
|
||||
@DriftDatabase(
|
||||
tables: [Rooms, Tasks, TaskCompletions],
|
||||
daos: [RoomsDao, TasksDao, DailyPlanDao, CalendarDao],
|
||||
)
|
||||
class AppDatabase extends _$AppDatabase { ... }
|
||||
```
|
||||
|
||||
From lib/features/tasks/data/tasks_dao.dart:
|
||||
```dart
|
||||
@DriftAccessor(tables: [Tasks, TaskCompletions])
|
||||
class TasksDao extends DatabaseAccessor<AppDatabase> with _$TasksDaoMixin {
|
||||
TasksDao(super.attachedDatabase);
|
||||
|
||||
Stream<List<Task>> watchTasksInRoom(int roomId) { ... }
|
||||
Future<int> insertTask(TasksCompanion task) => into(tasks).insert(task);
|
||||
Future<bool> updateTask(Task task) => update(tasks).replace(task);
|
||||
Future<void> deleteTask(int taskId) { ... }
|
||||
Future<void> completeTask(int taskId, {DateTime? now}) { ... }
|
||||
Future<int> getOverdueTaskCount(int roomId, {DateTime? today}) { ... }
|
||||
}
|
||||
```
|
||||
|
||||
From lib/features/tasks/presentation/task_form_screen.dart:
|
||||
```dart
|
||||
class TaskFormScreen extends ConsumerStatefulWidget {
|
||||
final int? roomId;
|
||||
final int? taskId;
|
||||
const TaskFormScreen({super.key, this.roomId, this.taskId});
|
||||
bool get isEditing => taskId != null;
|
||||
}
|
||||
// build() returns Scaffold with AppBar + Form > ListView with fields
|
||||
// In edit mode: _existingTask is loaded via _loadExistingTask()
|
||||
```
|
||||
|
||||
From lib/features/home/presentation/calendar_task_row.dart:
|
||||
```dart
|
||||
class CalendarTaskRow extends StatelessWidget {
|
||||
const CalendarTaskRow({
|
||||
super.key,
|
||||
required this.taskWithRoom,
|
||||
required this.onCompleted,
|
||||
this.isOverdue = false,
|
||||
});
|
||||
final TaskWithRoom taskWithRoom;
|
||||
final VoidCallback onCompleted;
|
||||
final bool isOverdue;
|
||||
}
|
||||
// TaskWithRoom has: task (Task), roomName (String), roomId (int)
|
||||
```
|
||||
|
||||
From lib/features/home/domain/daily_plan_models.dart:
|
||||
```dart
|
||||
class TaskWithRoom {
|
||||
final Task task;
|
||||
final String roomName;
|
||||
final int roomId;
|
||||
const TaskWithRoom({required this.task, required this.roomName, required this.roomId});
|
||||
}
|
||||
```
|
||||
|
||||
Bottom sheet pattern from lib/features/rooms/presentation/icon_picker_sheet.dart:
|
||||
```dart
|
||||
Future<String?> showIconPickerSheet({
|
||||
required BuildContext context,
|
||||
String? selectedIconName,
|
||||
}) {
|
||||
return showModalBottomSheet<String>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
builder: (context) => IconPickerSheet(...),
|
||||
);
|
||||
}
|
||||
// Sheet uses SafeArea > Padding > Column(mainAxisSize: MainAxisSize.min) with drag handle
|
||||
```
|
||||
|
||||
Router pattern from lib/core/router/router.dart:
|
||||
```dart
|
||||
// Task edit route: /rooms/:roomId/tasks/:taskId
|
||||
GoRoute(
|
||||
path: 'tasks/:taskId',
|
||||
builder: (context, state) {
|
||||
final taskId = int.parse(state.pathParameters['taskId']!);
|
||||
return TaskFormScreen(taskId: taskId);
|
||||
},
|
||||
),
|
||||
```
|
||||
</interfaces>
|
||||
</context>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="auto" tdd="true">
|
||||
<name>Task 1: Add DAO query, provider, localization, and tests for completion history</name>
|
||||
<files>
|
||||
lib/features/tasks/data/tasks_dao.dart,
|
||||
lib/features/tasks/data/tasks_dao.g.dart,
|
||||
lib/l10n/app_de.arb,
|
||||
lib/l10n/app_localizations.dart,
|
||||
lib/l10n/app_localizations_de.dart,
|
||||
test/features/tasks/data/task_history_dao_test.dart
|
||||
</files>
|
||||
<behavior>
|
||||
- watchCompletionsForTask(taskId) returns Stream of TaskCompletion list ordered by completedAt DESC (newest first)
|
||||
- Empty list returned when no completions exist for a given taskId
|
||||
- After completeTask(taskId) is called, watchCompletionsForTask(taskId) emits a list containing the new completion with correct timestamp
|
||||
- Completions for different tasks are isolated (taskId=1 completions do not appear in taskId=2 stream)
|
||||
- Multiple completions for the same task are all returned in reverse-chronological order
|
||||
</behavior>
|
||||
<action>
|
||||
RED phase:
|
||||
Create test/features/tasks/data/task_history_dao_test.dart with tests for the behaviors above.
|
||||
Use the existing in-memory database test pattern: AppDatabase(NativeDatabase.memory()), get TasksDao, insert a room and tasks, then test.
|
||||
Run tests -- they MUST fail (watchCompletionsForTask does not exist yet).
|
||||
|
||||
GREEN phase:
|
||||
1. In lib/features/tasks/data/tasks_dao.dart, add:
|
||||
```dart
|
||||
/// Watch all completions for a task, newest first.
|
||||
Stream<List<TaskCompletion>> watchCompletionsForTask(int taskId) {
|
||||
return (select(taskCompletions)
|
||||
..where((c) => c.taskId.equals(taskId))
|
||||
..orderBy([(c) => OrderingTerm.desc(c.completedAt)]))
|
||||
.watch();
|
||||
}
|
||||
```
|
||||
2. Run `dart run build_runner build --delete-conflicting-outputs` to regenerate tasks_dao.g.dart.
|
||||
3. Run tests -- they MUST pass.
|
||||
|
||||
Then add localization strings to lib/l10n/app_de.arb:
|
||||
- "taskHistoryTitle": "Verlauf"
|
||||
- "taskHistoryEmpty": "Noch nie erledigt"
|
||||
- "taskHistoryCount": "{count} Mal erledigt" with @taskHistoryCount placeholder for count (int)
|
||||
|
||||
Run `flutter gen-l10n` to regenerate app_localizations.dart and app_localizations_de.dart.
|
||||
|
||||
NOTE: No separate Riverpod provider is needed -- the bottom sheet will access the DAO directly via appDatabaseProvider (same pattern as _loadExistingTask in TaskFormScreen). This keeps it simple since the sheet is a one-shot modal, not a long-lived screen.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>cd /home/jlmak/Projects/jlmak/HouseHoldKeaper && flutter test test/features/tasks/data/task_history_dao_test.dart -r expanded && flutter analyze --no-fatal-infos</automated>
|
||||
</verify>
|
||||
<done>
|
||||
watchCompletionsForTask method exists on TasksDao, returns Stream of completions sorted newest-first.
|
||||
All new DAO tests pass. All 101+ existing tests still pass.
|
||||
Three German localization strings (taskHistoryTitle, taskHistoryEmpty, taskHistoryCount) are available via AppLocalizations.
|
||||
</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 2: Build history bottom sheet, wire into TaskFormScreen, add CalendarTaskRow navigation</name>
|
||||
<files>
|
||||
lib/features/tasks/presentation/task_history_sheet.dart,
|
||||
lib/features/tasks/presentation/task_form_screen.dart,
|
||||
lib/features/home/presentation/calendar_task_row.dart
|
||||
</files>
|
||||
<action>
|
||||
1. Create lib/features/tasks/presentation/task_history_sheet.dart:
|
||||
- Export a top-level function: `Future<void> showTaskHistorySheet({required BuildContext context, required int taskId})`
|
||||
- Uses `showModalBottomSheet` with `isScrollControlled: true` following icon_picker_sheet.dart pattern
|
||||
- The sheet widget is a ConsumerWidget (needs ref to access DAO)
|
||||
- Uses `ref.read(appDatabaseProvider).tasksDao.watchCompletionsForTask(taskId)` wrapped in a StreamBuilder
|
||||
- Layout: SafeArea > Padding(16) > Column(mainAxisSize: min):
|
||||
a. Drag handle (same as icon_picker_sheet: Container 32x4, onSurfaceVariant 0.4 alpha, rounded)
|
||||
b. Title: AppLocalizations.of(context).taskHistoryTitle (i.e. "Verlauf"), titleMedium style
|
||||
c. Optional: completion count summary below title using taskHistoryCount string -- show only when count > 0
|
||||
d. SizedBox(height: 16)
|
||||
e. StreamBuilder on watchCompletionsForTask:
|
||||
- Loading: Center(CircularProgressIndicator())
|
||||
- Empty data: centered Column with Icon(Icons.history, size: 48, color: onSurfaceVariant) + SizedBox(8) + Text(taskHistoryEmpty), style: bodyLarge, color: onSurfaceVariant
|
||||
- Has data: ConstrainedBox(maxHeight: MediaQuery.of(context).size.height * 0.4) > ListView.builder:
|
||||
Each item: ListTile with leading Icon(Icons.check_circle_outline, color: primary), title: DateFormat('dd.MM.yyyy', 'de').format(completion.completedAt), subtitle: DateFormat('HH:mm', 'de').format(completion.completedAt)
|
||||
f. SizedBox(height: 8) at bottom
|
||||
|
||||
2. Modify lib/features/tasks/presentation/task_form_screen.dart:
|
||||
- Import task_history_sheet.dart
|
||||
- In the build() method's ListView children, AFTER the due date picker section and ONLY when `widget.isEditing` is true, add:
|
||||
```
|
||||
const SizedBox(height: 24),
|
||||
const Divider(),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.history),
|
||||
title: Text(l10n.taskHistoryTitle),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () => showTaskHistorySheet(context: context, taskId: widget.taskId!),
|
||||
),
|
||||
```
|
||||
- This adds a "Verlauf" row that opens the history bottom sheet
|
||||
|
||||
3. Modify lib/features/home/presentation/calendar_task_row.dart:
|
||||
- Add an onTap callback to the ListTile that navigates to the task edit form
|
||||
- The CalendarTaskRow already has access to taskWithRoom.task.id and taskWithRoom.roomId
|
||||
- Add to ListTile: `onTap: () => context.go('/rooms/${taskWithRoom.roomId}/tasks/${taskWithRoom.task.id}')`
|
||||
- This enables: CalendarTaskRow tap -> TaskFormScreen (edit mode) -> "Verlauf" button -> history sheet
|
||||
- Keep the existing onCompleted checkbox behavior unchanged
|
||||
</action>
|
||||
<verify>
|
||||
<automated>cd /home/jlmak/Projects/jlmak/HouseHoldKeaper && flutter test && flutter analyze --no-fatal-infos</automated>
|
||||
</verify>
|
||||
<done>
|
||||
History bottom sheet opens from TaskFormScreen in edit mode via "Verlauf" row.
|
||||
Sheet shows completion dates in dd.MM.yyyy + HH:mm format, reverse-chronological.
|
||||
Empty state shows Icons.history + "Noch nie erledigt" message.
|
||||
CalendarTaskRow tapping navigates to TaskFormScreen for that task.
|
||||
All existing tests still pass. dart analyze clean.
|
||||
</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<verification>
|
||||
Phase 6 verification checks:
|
||||
1. `flutter test` -- all tests pass (101 existing + new DAO tests)
|
||||
2. `flutter analyze --no-fatal-infos` -- zero issues
|
||||
3. Manual flow: Open app > tap a task in calendar > task edit form opens > "Verlauf" row visible > tap it > bottom sheet shows history or empty state
|
||||
4. Manual flow: Complete a task via checkbox > navigate to that task's edit form > tap "Verlauf" > new completion entry appears with timestamp
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- HIST-01: Task completion recording verified via DAO tests (completions already written by completeTask; new query surfaces them)
|
||||
- HIST-02: History bottom sheet accessible from task edit form, shows all past completions reverse-chronologically with German date/time formatting, shows meaningful empty state
|
||||
- CalendarTaskRow tapping navigates to task edit form (history one tap away)
|
||||
- Zero regressions: all existing tests pass, dart analyze clean
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
After completion, create `.planning/phases/06-task-history/06-01-SUMMARY.md`
|
||||
</output>
|
||||
131
.planning/phases/06-task-history/06-01-SUMMARY.md
Normal file
131
.planning/phases/06-task-history/06-01-SUMMARY.md
Normal file
@@ -0,0 +1,131 @@
|
||||
---
|
||||
phase: 06-task-history
|
||||
plan: 01
|
||||
subsystem: database, ui
|
||||
tags: [drift, flutter, riverpod, go_router, intl, bottom-sheet, stream]
|
||||
|
||||
# Dependency graph
|
||||
requires:
|
||||
- phase: 05-calendar-strip
|
||||
provides: CalendarTaskRow widget and CalendarDayList that render tasks in the home screen
|
||||
provides:
|
||||
- watchCompletionsForTask(taskId) DAO stream on TasksDao — sorted newest-first
|
||||
- task_history_sheet.dart with showTaskHistorySheet() function
|
||||
- Verlauf ListTile in TaskFormScreen (edit mode) opening history bottom sheet
|
||||
- CalendarTaskRow onTap navigation to TaskFormScreen for the tapped task
|
||||
affects: [07-task-sorting, future-phases-using-TaskFormScreen]
|
||||
|
||||
# Tech tracking
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "Bottom sheet follows icon_picker_sheet pattern: showModalBottomSheet with isScrollControlled, ConsumerWidget inside, SafeArea > Padding > Column(mainAxisSize.min)"
|
||||
- "StreamBuilder on DAO stream directly accessed via ref.read(appDatabaseProvider).tasksDao.methodName (no separate Riverpod provider for one-shot modals)"
|
||||
- "TDD: RED test commit followed by GREEN implementation commit"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- lib/features/tasks/presentation/task_history_sheet.dart
|
||||
- test/features/tasks/data/task_history_dao_test.dart
|
||||
modified:
|
||||
- lib/features/tasks/data/tasks_dao.dart
|
||||
- lib/features/tasks/data/tasks_dao.g.dart
|
||||
- lib/features/tasks/presentation/task_form_screen.dart
|
||||
- lib/features/home/presentation/calendar_task_row.dart
|
||||
- lib/l10n/app_de.arb
|
||||
- lib/l10n/app_localizations.dart
|
||||
- lib/l10n/app_localizations_de.dart
|
||||
|
||||
key-decisions:
|
||||
- "No separate Riverpod provider for history sheet — ref.read(appDatabaseProvider) directly in ConsumerWidget keeps it simple for a one-shot modal"
|
||||
- "CalendarTaskRow onTap routes to /rooms/:roomId/tasks/:taskId so history is always one tap away from the home screen"
|
||||
- "Count summary line shown above list when completions > 0; not shown for empty state"
|
||||
|
||||
patterns-established:
|
||||
- "History sheet: showModalBottomSheet returning Future<void>, ConsumerWidget sheet with StreamBuilder on DAO stream"
|
||||
- "Edit-mode-only ListTile pattern: if (widget.isEditing) [...] in TaskFormScreen ListView children"
|
||||
|
||||
requirements-completed: [HIST-01, HIST-02]
|
||||
|
||||
# Metrics
|
||||
duration: 5min
|
||||
completed: 2026-03-16
|
||||
---
|
||||
|
||||
# Phase 6 Plan 1: Task History Summary
|
||||
|
||||
**Drift DAO stream for task completion history, bottom sheet with reverse-chronological German-formatted dates, wired from CalendarTaskRow tap through TaskFormScreen Verlauf button**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** 5 min
|
||||
- **Started:** 2026-03-16T20:52:49Z
|
||||
- **Completed:** 2026-03-16T20:57:19Z
|
||||
- **Tasks:** 2 (Task 1 TDD: RED + GREEN + localization; Task 2: sheet + wiring + navigation)
|
||||
- **Files modified:** 9
|
||||
|
||||
## Accomplishments
|
||||
- `watchCompletionsForTask(int taskId)` added to TasksDao: returns `Stream<List<TaskCompletion>>` sorted by completedAt DESC
|
||||
- Task history bottom sheet (`task_history_sheet.dart`) with StreamBuilder, empty state, German date/time formatting via intl
|
||||
- Verlauf ListTile added to TaskFormScreen edit mode, opens history sheet on tap
|
||||
- CalendarTaskRow gains `onTap` that navigates via GoRouter to the task edit form, making history one tap away from the calendar
|
||||
|
||||
## Task Commits
|
||||
|
||||
Each task was committed atomically:
|
||||
|
||||
1. **RED - Failing DAO tests** - `2687f5e` (test)
|
||||
2. **Task 1: DAO method, localization** - `ceae7d7` (feat)
|
||||
3. **Task 2: History sheet, form wiring, navigation** - `9f902ff` (feat)
|
||||
|
||||
**Plan metadata:** (docs commit — see below)
|
||||
|
||||
_Note: TDD tasks have separate RED (test) and GREEN (feat) commits_
|
||||
|
||||
## Files Created/Modified
|
||||
- `lib/features/tasks/data/tasks_dao.dart` - Added watchCompletionsForTask stream method
|
||||
- `lib/features/tasks/data/tasks_dao.g.dart` - Regenerated by build_runner
|
||||
- `lib/features/tasks/presentation/task_history_sheet.dart` - New: bottom sheet with StreamBuilder, empty state, completion list
|
||||
- `lib/features/tasks/presentation/task_form_screen.dart` - Added Verlauf ListTile in edit mode
|
||||
- `lib/features/home/presentation/calendar_task_row.dart` - Added onTap navigation to task edit form
|
||||
- `lib/l10n/app_de.arb` - Added taskHistoryTitle, taskHistoryEmpty, taskHistoryCount strings
|
||||
- `lib/l10n/app_localizations.dart` - Regenerated (abstract class updated)
|
||||
- `lib/l10n/app_localizations_de.dart` - Regenerated (German implementation updated)
|
||||
- `test/features/tasks/data/task_history_dao_test.dart` - New: 5 tests covering empty state, single/multiple completions, task isolation, stream reactivity
|
||||
|
||||
## Decisions Made
|
||||
- No separate Riverpod provider for history sheet: `ref.read(appDatabaseProvider).tasksDao.watchCompletionsForTask(taskId)` directly in the ConsumerWidget. One-shot modals do not need a dedicated provider.
|
||||
- CalendarTaskRow navigation uses `context.go('/rooms/.../tasks/...')` consistent with existing GoRouter route patterns.
|
||||
- Removed unused `import 'package:drift/drift.dart'` from test file (Rule 1 auto-fix during GREEN verification).
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 1 - Bug] Removed unused import from test file**
|
||||
- **Found during:** Task 1 (GREEN phase, flutter analyze)
|
||||
- **Issue:** `import 'package:drift/drift.dart'` was copied from the existing tasks_dao_test.dart pattern but not needed in the new history test file (no `Value()` usage)
|
||||
- **Fix:** Removed the unused import line
|
||||
- **Files modified:** test/features/tasks/data/task_history_dao_test.dart
|
||||
- **Verification:** flutter analyze reports zero issues
|
||||
- **Committed in:** ceae7d7 (Task 1 feat commit)
|
||||
|
||||
---
|
||||
|
||||
**Total deviations:** 1 auto-fixed (1 bug — unused import)
|
||||
**Impact on plan:** Trivial cleanup. No scope creep.
|
||||
|
||||
## Issues Encountered
|
||||
None — plan executed smoothly. All 106 tests pass (101 pre-existing + 5 new DAO tests), zero analyze issues.
|
||||
|
||||
## User Setup Required
|
||||
None - no external service configuration required.
|
||||
|
||||
## Next Phase Readiness
|
||||
- Phase 6 Plan 1 complete. Task history is fully functional.
|
||||
- Phase 7 (task sorting) can proceed independently.
|
||||
- No blockers.
|
||||
|
||||
---
|
||||
*Phase: 06-task-history*
|
||||
*Completed: 2026-03-16*
|
||||
81
.planning/phases/06-task-history/06-CONTEXT.md
Normal file
81
.planning/phases/06-task-history/06-CONTEXT.md
Normal file
@@ -0,0 +1,81 @@
|
||||
# Phase 6: Task History - Context
|
||||
|
||||
**Gathered:** 2026-03-16
|
||||
**Status:** Ready for planning
|
||||
|
||||
<domain>
|
||||
## Phase Boundary
|
||||
|
||||
Let users view past completion dates for any individual task. The data layer already records completions (TaskCompletions table + completeTask writes timestamps). This phase adds a DAO query and a UI to surface that data. Requirements: HIST-01 (verify recording works), HIST-02 (view history).
|
||||
|
||||
</domain>
|
||||
|
||||
<decisions>
|
||||
## Implementation Decisions
|
||||
|
||||
### Entry point
|
||||
- From the task edit form (TaskFormScreen) in edit mode: add a "Verlauf" (History) button/row that opens the history view
|
||||
- From CalendarTaskRow: add onTap to navigate to the task edit form (currently only has checkbox) — history is then one tap away
|
||||
- No long-press or context menu — keep interaction model simple and consistent
|
||||
|
||||
### History view format
|
||||
- Bottom sheet (showModalBottomSheet) — consistent with existing template_picker_sheet and icon_picker_sheet patterns
|
||||
- Each entry shows: date formatted as "dd.MM.yyyy" and time as "HH:mm" — German locale
|
||||
- Entries listed reverse-chronological (newest first)
|
||||
- No grouping or pagination — household tasks won't have thousands of completions; simple ListView is sufficient
|
||||
|
||||
### Empty state
|
||||
- When task has never been completed: centered icon (e.g., Icons.history) + "Noch nie erledigt" message — meaningful, not just blank
|
||||
- No special state for many completions — just scroll
|
||||
|
||||
### Claude's Discretion
|
||||
- Exact bottom sheet height and styling
|
||||
- Whether to show a completion count summary at the top of the sheet
|
||||
- Animation and transition details
|
||||
- DAO query structure (single method returning List<TaskCompletion>)
|
||||
- Whether CalendarTaskRow onTap goes to edit form or directly to history
|
||||
|
||||
</decisions>
|
||||
|
||||
<specifics>
|
||||
## Specific Ideas
|
||||
|
||||
No specific requirements — user chose "You decide." Open to standard approaches that match existing app patterns.
|
||||
|
||||
</specifics>
|
||||
|
||||
<code_context>
|
||||
## Existing Code Insights
|
||||
|
||||
### Reusable Assets
|
||||
- `TaskCompletions` table: Already exists in database.dart (id, taskId, completedAt) — no schema change needed
|
||||
- `TasksDao.completeTask()`: Already inserts into taskCompletions on every completion — HIST-01 data recording is done
|
||||
- `showModalBottomSheet`: Used by template_picker_sheet.dart and icon_picker_sheet.dart — established pattern for overlays
|
||||
- `AppLocalizations` + `.arb` files: German-only localization pipeline in place
|
||||
|
||||
### Established Patterns
|
||||
- DAOs extend `DatabaseAccessor<AppDatabase>` with `@DriftAccessor` annotation
|
||||
- Riverpod `StreamProvider.autoDispose` or `FutureProvider` for reactive data
|
||||
- Feature folder structure: `features/tasks/data/`, `domain/`, `presentation/`
|
||||
- Bottom sheets use `showModalBottomSheet` with `DraggableScrollableSheet` or simple `Column`
|
||||
|
||||
### Integration Points
|
||||
- `TaskFormScreen` (edit mode): Entry point for history — add a row/button when `isEditing`
|
||||
- `TasksDao`: Add `watchCompletionsForTask(int taskId)` or `getCompletionsForTask(int taskId)` method
|
||||
- `CalendarTaskRow`: Currently no onTap — needs navigation to task edit form for history access
|
||||
- `router.dart`: Route `/rooms/:roomId/tasks/:taskId` already exists for TaskFormScreen — no new route needed if using bottom sheet
|
||||
- `app_de.arb`: Add localization strings for history UI labels
|
||||
|
||||
</code_context>
|
||||
|
||||
<deferred>
|
||||
## Deferred Ideas
|
||||
|
||||
None — discussion stayed within phase scope
|
||||
|
||||
</deferred>
|
||||
|
||||
---
|
||||
|
||||
*Phase: 06-task-history*
|
||||
*Context gathered: 2026-03-16*
|
||||
114
.planning/phases/06-task-history/6-VERIFICATION.md
Normal file
114
.planning/phases/06-task-history/6-VERIFICATION.md
Normal file
@@ -0,0 +1,114 @@
|
||||
---
|
||||
phase: 06-task-history
|
||||
verified: 2026-03-16T22:15:00Z
|
||||
status: passed
|
||||
score: 3/3 must-haves verified
|
||||
re_verification: false
|
||||
---
|
||||
|
||||
# Phase 6: Task History Verification Report
|
||||
|
||||
**Phase Goal:** Users can see exactly when each task was completed in the past, building trust that the scheduling loop is working correctly
|
||||
**Verified:** 2026-03-16T22:15:00Z
|
||||
**Status:** PASSED
|
||||
**Re-verification:** No — initial verification
|
||||
|
||||
---
|
||||
|
||||
## Goal Achievement
|
||||
|
||||
### Observable Truths
|
||||
|
||||
| # | Truth | Status | Evidence |
|
||||
|---|-------|--------|----------|
|
||||
| 1 | Every task completion is recorded with a timestamp and persists across app restarts | VERIFIED | `watchCompletionsForTask` reads from `TaskCompletions` table (persistent SQLite); `completeTask` already wrote timestamps; 5 DAO tests confirm stream returns correct data including stream reactivity test |
|
||||
| 2 | User can open a history view from the task edit form showing all past completion dates in reverse-chronological order | VERIFIED | `task_form_screen.dart` lines 192-204: `if (widget.isEditing)` guard shows `ListTile` with `onTap: () => showTaskHistorySheet(...)`. Sheet uses `StreamBuilder` on `watchCompletionsForTask` with `..orderBy([(c) => OrderingTerm.desc(c.completedAt)])`, renders dates as `dd.MM.yyyy` + `HH:mm` via intl |
|
||||
| 3 | History view shows a meaningful empty state if the task has never been completed | VERIFIED | `task_history_sheet.dart` lines 70-87: `if (completions.isEmpty)` branch renders `Icon(Icons.history, size: 48)` + `Text(l10n.taskHistoryEmpty)` ("Noch nie erledigt") |
|
||||
|
||||
**Score:** 3/3 truths verified
|
||||
|
||||
---
|
||||
|
||||
### Required Artifacts
|
||||
|
||||
| Artifact | Provides | Status | Details |
|
||||
|----------|---------|--------|---------|
|
||||
| `lib/features/tasks/data/tasks_dao.dart` | `watchCompletionsForTask(int taskId)` stream method | VERIFIED | Method exists at line 85, returns `Stream<List<TaskCompletion>>`, ordered by `completedAt DESC`, 110 lines total |
|
||||
| `lib/features/tasks/presentation/task_history_sheet.dart` | Bottom sheet displaying task completion history | VERIFIED | 137 lines, exports top-level `showTaskHistorySheet()`, `_TaskHistorySheet` is a `ConsumerWidget` with full StreamBuilder, empty state, date list |
|
||||
| `lib/features/tasks/presentation/task_form_screen.dart` | Verlauf button in edit mode opening history sheet | VERIFIED | Imports `task_history_sheet.dart` (line 13), `showTaskHistorySheet` called at line 199, guarded by `if (widget.isEditing)` |
|
||||
| `lib/features/home/presentation/calendar_task_row.dart` | onTap navigation to task edit form | VERIFIED | `ListTile.onTap` at line 39 calls `context.go('/rooms/${taskWithRoom.roomId}/tasks/${taskWithRoom.task.id}')` |
|
||||
| `test/features/tasks/data/task_history_dao_test.dart` | Tests for completion history DAO query | VERIFIED | 158 lines, 5 tests: empty state, single completion, multiple reverse-chronological, task isolation, stream reactivity — all pass |
|
||||
| `lib/features/tasks/data/tasks_dao.g.dart` | Drift-generated mixin (build_runner output) | VERIFIED | Exists, 25 lines, regenerated with `taskCompletions` table accessor present |
|
||||
|
||||
---
|
||||
|
||||
### Key Link Verification
|
||||
|
||||
| From | To | Via | Status | Details |
|
||||
|------|----|-----|--------|---------|
|
||||
| `task_form_screen.dart` | `task_history_sheet.dart` | `showTaskHistorySheet` call in Verlauf `onTap` | WIRED | Import at line 13; called at line 199 inside `if (widget.isEditing)` block |
|
||||
| `task_history_sheet.dart` | `tasks_dao.dart` | `watchCompletionsForTask` stream consumption | WIRED | `ref.read(appDatabaseProvider).tasksDao.watchCompletionsForTask(taskId)` at lines 59-62; stream result consumed by `StreamBuilder` builder |
|
||||
| `calendar_task_row.dart` | `TaskFormScreen` | GoRouter navigation on row tap | WIRED | `context.go('/rooms/${taskWithRoom.roomId}/tasks/${taskWithRoom.task.id}')` at line 39-41; route `/rooms/:roomId/tasks/:taskId` resolves to `TaskFormScreen` per router.dart |
|
||||
|
||||
---
|
||||
|
||||
### Requirements Coverage
|
||||
|
||||
| Requirement | Source Plan | Description | Status | Evidence |
|
||||
|-------------|------------|-------------|--------|----------|
|
||||
| HIST-01 | 06-01-PLAN.md | Each task completion is recorded with a timestamp | SATISFIED | `TasksDao.completeTask()` inserts into `TaskCompletions` (pre-existing); `watchCompletionsForTask` surfaces data; 5 DAO tests confirm timestamps are stored and retrieved correctly |
|
||||
| HIST-02 | 06-01-PLAN.md | User can view past completion dates for any individual task | SATISFIED | Full UI chain: `CalendarTaskRow.onTap` -> `TaskFormScreen` (edit mode) -> "Verlauf" `ListTile` -> `showTaskHistorySheet` -> `_TaskHistorySheet` StreamBuilder showing reverse-chronological German-formatted dates |
|
||||
|
||||
No orphaned requirements — REQUIREMENTS.md Traceability table shows only HIST-01 and HIST-02 mapped to Phase 6, both accounted for and marked Complete.
|
||||
|
||||
---
|
||||
|
||||
### Anti-Patterns Found
|
||||
|
||||
None. No TODOs, FIXMEs, placeholder returns, empty handlers, or stub implementations found in any of the 5 modified source files.
|
||||
|
||||
---
|
||||
|
||||
### Human Verification Required
|
||||
|
||||
#### 1. Tap-to-edit navigation in running app
|
||||
|
||||
**Test:** Launch app, ensure at least one task exists on the calendar, tap the task row (not the checkbox).
|
||||
**Expected:** App navigates to `TaskFormScreen` in edit mode showing the task's fields and a "Verlauf" row at the bottom.
|
||||
**Why human:** GoRouter navigation with `context.go` cannot be verified by static analysis; requires runtime rendering.
|
||||
|
||||
#### 2. History sheet opens with correct content
|
||||
|
||||
**Test:** In `TaskFormScreen` edit mode, tap the "Verlauf" ListTile.
|
||||
**Expected:** Bottom sheet slides up showing either: (a) the empty state with a history icon and "Noch nie erledigt", or (b) a list of past completions with `dd.MM.yyyy` dates as titles and `HH:mm` times as subtitles, newest first.
|
||||
**Why human:** `showModalBottomSheet` rendering and visual layout cannot be verified by static analysis.
|
||||
|
||||
#### 3. Live update after completing a task
|
||||
|
||||
**Test:** Complete a task via checkbox in the calendar, then navigate to that task's edit form and tap "Verlauf".
|
||||
**Expected:** The newly recorded completion appears at the top of the history sheet with today's date and approximate current time.
|
||||
**Why human:** Real-time stream reactivity through the full UI stack (checkbox -> DAO write -> stream emit -> sheet UI update) requires runtime observation.
|
||||
|
||||
---
|
||||
|
||||
### Verification Summary
|
||||
|
||||
All automated checks passed with no gaps found.
|
||||
|
||||
**Test suite:** 106/106 tests pass (101 pre-existing + 5 new DAO tests covering all specified behaviors).
|
||||
**Static analysis:** `flutter analyze --no-fatal-infos` — zero issues.
|
||||
**Commits verified:** All three phase commits exist (`2687f5e`, `ceae7d7`, `9f902ff`) with expected file changes.
|
||||
|
||||
The full feature chain is intact:
|
||||
- `TaskCompletions` table stores timestamps (HIST-01, pre-existing from data layer)
|
||||
- `watchCompletionsForTask` surfaces completions as a live Drift stream
|
||||
- `task_history_sheet.dart` renders them in German locale with reverse-chronological ordering and a meaningful empty state
|
||||
- `TaskFormScreen` (edit mode only) provides the "Verlauf" entry point
|
||||
- `CalendarTaskRow` onTap makes history reachable from the home calendar in two taps
|
||||
|
||||
Three human-only items remain for final sign-off: tap navigation, sheet rendering, and live update after completion.
|
||||
|
||||
---
|
||||
|
||||
_Verified: 2026-03-16T22:15:00Z_
|
||||
_Verifier: Claude (gsd-verifier)_
|
||||
276
.planning/phases/07-task-sorting/07-01-PLAN.md
Normal file
276
.planning/phases/07-task-sorting/07-01-PLAN.md
Normal file
@@ -0,0 +1,276 @@
|
||||
---
|
||||
phase: 07-task-sorting
|
||||
plan: 01
|
||||
type: execute
|
||||
wave: 1
|
||||
depends_on: []
|
||||
files_modified:
|
||||
- lib/features/tasks/domain/task_sort_option.dart
|
||||
- lib/features/tasks/presentation/sort_preference_notifier.dart
|
||||
- lib/features/tasks/presentation/sort_preference_notifier.g.dart
|
||||
- lib/l10n/app_de.arb
|
||||
- lib/l10n/app_localizations.dart
|
||||
- lib/l10n/app_localizations_de.dart
|
||||
- lib/features/home/presentation/calendar_providers.dart
|
||||
- lib/features/tasks/presentation/task_providers.dart
|
||||
- test/features/tasks/presentation/sort_preference_notifier_test.dart
|
||||
autonomous: true
|
||||
requirements: [SORT-01, SORT-02, SORT-03]
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "Sort preference persists across app restarts"
|
||||
- "CalendarDayList tasks are sorted according to the active sort preference"
|
||||
- "TaskListScreen tasks are sorted according to the active sort preference"
|
||||
- "Default sort is alphabetical (matches current CalendarDayList behavior)"
|
||||
artifacts:
|
||||
- path: "lib/features/tasks/domain/task_sort_option.dart"
|
||||
provides: "TaskSortOption enum with alphabetical, interval, effort values"
|
||||
exports: ["TaskSortOption"]
|
||||
- path: "lib/features/tasks/presentation/sort_preference_notifier.dart"
|
||||
provides: "SortPreferenceNotifier with SharedPreferences persistence"
|
||||
exports: ["SortPreferenceNotifier", "sortPreferenceProvider"]
|
||||
- path: "lib/features/home/presentation/calendar_providers.dart"
|
||||
provides: "calendarDayProvider sorts dayTasks by active sort preference"
|
||||
contains: "sortPreferenceProvider"
|
||||
- path: "lib/features/tasks/presentation/task_providers.dart"
|
||||
provides: "tasksInRoomProvider sorts tasks by active sort preference"
|
||||
contains: "sortPreferenceProvider"
|
||||
- path: "test/features/tasks/presentation/sort_preference_notifier_test.dart"
|
||||
provides: "Unit tests for sort preference persistence and default"
|
||||
key_links:
|
||||
- from: "lib/features/home/presentation/calendar_providers.dart"
|
||||
to: "sortPreferenceProvider"
|
||||
via: "ref.watch in calendarDayProvider"
|
||||
pattern: "ref\\.watch\\(sortPreferenceProvider\\)"
|
||||
- from: "lib/features/tasks/presentation/task_providers.dart"
|
||||
to: "sortPreferenceProvider"
|
||||
via: "ref.watch in tasksInRoomProvider"
|
||||
pattern: "ref\\.watch\\(sortPreferenceProvider\\)"
|
||||
---
|
||||
|
||||
<objective>
|
||||
Create the task sort domain model, SharedPreferences-backed persistence provider, and integrate sort logic into both task list providers (calendarDayProvider and tasksInRoomProvider).
|
||||
|
||||
Purpose: Establishes the data layer and sort logic so that task lists react to sort preference changes. The UI plan (07-02) will add the dropdown widget that writes to this provider.
|
||||
|
||||
Output: TaskSortOption enum, SortPreferenceNotifier, updated calendarDayProvider and tasksInRoomProvider with in-memory sorting, German localization strings for sort labels.
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@/home/jlmak/.claude/get-shit-done/workflows/execute-plan.md
|
||||
@/home/jlmak/.claude/get-shit-done/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<context>
|
||||
@.planning/PROJECT.md
|
||||
@.planning/ROADMAP.md
|
||||
@.planning/STATE.md
|
||||
@.planning/phases/07-task-sorting/07-CONTEXT.md
|
||||
|
||||
<interfaces>
|
||||
<!-- Key types and contracts the executor needs. Extracted from codebase. -->
|
||||
|
||||
From lib/features/tasks/domain/effort_level.dart:
|
||||
```dart
|
||||
enum EffortLevel {
|
||||
low, // 0
|
||||
medium, // 1
|
||||
high, // 2
|
||||
}
|
||||
```
|
||||
|
||||
From lib/features/tasks/domain/frequency.dart:
|
||||
```dart
|
||||
enum IntervalType {
|
||||
daily, // 0
|
||||
everyNDays, // 1
|
||||
weekly, // 2
|
||||
biweekly, // 3
|
||||
monthly, // 4
|
||||
everyNMonths, // 5
|
||||
quarterly, // 6
|
||||
yearly, // 7
|
||||
}
|
||||
```
|
||||
|
||||
From lib/features/home/domain/daily_plan_models.dart:
|
||||
```dart
|
||||
class TaskWithRoom {
|
||||
final Task task;
|
||||
final String roomName;
|
||||
final int roomId;
|
||||
}
|
||||
```
|
||||
|
||||
From lib/features/home/domain/calendar_models.dart:
|
||||
```dart
|
||||
class CalendarDayState {
|
||||
final DateTime selectedDate;
|
||||
final List<TaskWithRoom> dayTasks;
|
||||
final List<TaskWithRoom> overdueTasks;
|
||||
final int totalTaskCount;
|
||||
}
|
||||
```
|
||||
|
||||
From lib/core/theme/theme_provider.dart (pattern to follow for SharedPreferences notifier):
|
||||
```dart
|
||||
@riverpod
|
||||
class ThemeNotifier extends _$ThemeNotifier {
|
||||
@override
|
||||
ThemeMode build() {
|
||||
_loadPersistedThemeMode();
|
||||
return ThemeMode.system; // sync default, async load overrides
|
||||
}
|
||||
Future<void> _loadPersistedThemeMode() async { ... }
|
||||
Future<void> setThemeMode(ThemeMode mode) async {
|
||||
state = mode;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString(_themeModeKey, _themeModeToString(mode));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
From lib/features/home/presentation/calendar_providers.dart:
|
||||
```dart
|
||||
final calendarDayProvider = StreamProvider.autoDispose<CalendarDayState>((ref) {
|
||||
final db = ref.watch(appDatabaseProvider);
|
||||
final selectedDate = ref.watch(selectedDateProvider);
|
||||
// ... fetches dayTasks, overdueTasks, totalTaskCount
|
||||
// dayTasks come from watchTasksForDate which sorts alphabetically in SQL
|
||||
});
|
||||
```
|
||||
|
||||
From lib/features/tasks/presentation/task_providers.dart:
|
||||
```dart
|
||||
final tasksInRoomProvider = StreamProvider.family.autoDispose<List<Task>, int>((ref, roomId) {
|
||||
final db = ref.watch(appDatabaseProvider);
|
||||
return db.tasksDao.watchTasksInRoom(roomId);
|
||||
// watchTasksInRoom sorts by nextDueDate in SQL
|
||||
});
|
||||
```
|
||||
|
||||
From lib/core/database/database.dart (Task table columns relevant to sorting):
|
||||
```dart
|
||||
class Tasks extends Table {
|
||||
TextColumn get name => text().withLength(min: 1, max: 200)();
|
||||
IntColumn get intervalType => intEnum<IntervalType>()();
|
||||
IntColumn get intervalDays => integer().withDefault(const Constant(1))();
|
||||
IntColumn get effortLevel => intEnum<EffortLevel>()();
|
||||
}
|
||||
```
|
||||
</interfaces>
|
||||
</context>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="auto" tdd="true">
|
||||
<name>Task 1: Create TaskSortOption enum, SortPreferenceNotifier, and localization strings</name>
|
||||
<files>
|
||||
lib/features/tasks/domain/task_sort_option.dart,
|
||||
lib/features/tasks/presentation/sort_preference_notifier.dart,
|
||||
lib/features/tasks/presentation/sort_preference_notifier.g.dart,
|
||||
lib/l10n/app_de.arb,
|
||||
lib/l10n/app_localizations.dart,
|
||||
lib/l10n/app_localizations_de.dart,
|
||||
test/features/tasks/presentation/sort_preference_notifier_test.dart
|
||||
</files>
|
||||
<behavior>
|
||||
- Default sort preference is TaskSortOption.alphabetical
|
||||
- setSortOption(TaskSortOption.interval) updates state to interval
|
||||
- Sort preference persists: after setSortOption(effort), a fresh notifier reads back effort from SharedPreferences
|
||||
- TaskSortOption enum has exactly 3 values: alphabetical, interval, effort
|
||||
</behavior>
|
||||
<action>
|
||||
1. Create `lib/features/tasks/domain/task_sort_option.dart`:
|
||||
- `enum TaskSortOption { alphabetical, interval, effort }` — three values only, no index stability concern since this is NOT stored as intEnum in drift (stored as string in SharedPreferences)
|
||||
|
||||
2. Create `lib/features/tasks/presentation/sort_preference_notifier.dart`:
|
||||
- Follow the exact ThemeNotifier pattern from `lib/core/theme/theme_provider.dart`
|
||||
- `@riverpod class SortPreferenceNotifier extends _$SortPreferenceNotifier`
|
||||
- `build()` returns `TaskSortOption.alphabetical` synchronously (default = alphabetical per user decision for continuity with current A-Z sort in CalendarDayList), then calls `_loadPersisted()` async
|
||||
- `_loadPersisted()` reads `SharedPreferences.getString('task_sort_option')` and maps to enum
|
||||
- `setSortOption(TaskSortOption option)` sets state immediately then persists string to SharedPreferences
|
||||
- Static helpers `_fromString` / `_toString` for serialization (use enum .name property)
|
||||
- The generated provider will be named `sortPreferenceProvider` (Riverpod 3 naming convention, consistent with themeProvider)
|
||||
|
||||
3. Run `dart run build_runner build --delete-conflicting-outputs` to generate `.g.dart`
|
||||
|
||||
4. Add localization strings to `lib/l10n/app_de.arb`:
|
||||
- `"sortAlphabetical": "A\u2013Z"` (A-Z with en-dash, concise label per user decision)
|
||||
- `"sortInterval": "Intervall"` (German for interval/frequency)
|
||||
- `"sortEffort": "Aufwand"` (German for effort, matches existing taskFormEffortLabel context)
|
||||
- `"sortLabel": "Sortierung"` (label for accessibility/semantics on the dropdown)
|
||||
|
||||
5. Run `flutter gen-l10n` to regenerate localization files
|
||||
|
||||
6. Write tests in `test/features/tasks/presentation/sort_preference_notifier_test.dart`:
|
||||
- Follow the pattern from notification_settings test: `makeContainer()` helper that creates ProviderContainer, awaits `Future.delayed(Duration.zero)` for async load
|
||||
- `SharedPreferences.setMockInitialValues({})` in setUp
|
||||
- Test: default is alphabetical
|
||||
- Test: setSortOption updates state
|
||||
- Test: persisted value is loaded on restart (set mock initial values with key, verify state after load)
|
||||
</action>
|
||||
<verify>
|
||||
<automated>cd /home/jlmak/Projects/jlmak/HouseHoldKeaper && flutter test test/features/tasks/presentation/sort_preference_notifier_test.dart && flutter analyze --no-fatal-infos</automated>
|
||||
</verify>
|
||||
<done>TaskSortOption enum exists with 3 values. SortPreferenceNotifier persists to SharedPreferences. 3+ unit tests pass. ARB file has 4 new sort strings. dart analyze clean.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 2: Integrate sort logic into calendarDayProvider and tasksInRoomProvider</name>
|
||||
<files>
|
||||
lib/features/home/presentation/calendar_providers.dart,
|
||||
lib/features/tasks/presentation/task_providers.dart
|
||||
</files>
|
||||
<action>
|
||||
1. Edit `lib/features/home/presentation/calendar_providers.dart`:
|
||||
- Add import for `sort_preference_notifier.dart` and `task_sort_option.dart`
|
||||
- Inside `calendarDayProvider`, add `final sortOption = ref.watch(sortPreferenceProvider);`
|
||||
- After constructing `CalendarDayState`, apply in-memory sort to `dayTasks` list before returning. Do NOT sort overdueTasks (overdue section stays pinned at top in its existing order per user discretion decision).
|
||||
- Sort implementation — create a top-level helper function `List<TaskWithRoom> _sortTasks(List<TaskWithRoom> tasks, TaskSortOption sortOption)` that returns a new sorted list:
|
||||
- `alphabetical`: sort by `task.name.toLowerCase()` (case-insensitive A-Z)
|
||||
- `interval`: sort by `task.intervalType.index` ascending (daily=0 is most frequent, yearly=7 is least), then by `task.intervalDays` ascending as tiebreaker
|
||||
- `effort`: sort by `task.effortLevel.index` ascending (low=0, medium=1, high=2)
|
||||
- Apply: `dayTasks: _sortTasks(dayTasks, sortOption)` in the CalendarDayState constructor call
|
||||
- Note: The SQL `orderBy([OrderingTerm.asc(tasks.name)])` in CalendarDao.watchTasksForDate still runs, but the in-memory sort overrides it. This is intentional — the SQL sort provides a stable baseline, the in-memory sort applies the user's preference.
|
||||
|
||||
2. Edit `lib/features/tasks/presentation/task_providers.dart`:
|
||||
- Add import for `sort_preference_notifier.dart` and `task_sort_option.dart`
|
||||
- In `tasksInRoomProvider`, add `final sortOption = ref.watch(sortPreferenceProvider);`
|
||||
- Map the stream to apply in-memory sorting: `return db.tasksDao.watchTasksInRoom(roomId).map((tasks) => _sortTasksRaw(tasks, sortOption));`
|
||||
- Create a top-level helper `List<Task> _sortTasksRaw(List<Task> tasks, TaskSortOption sortOption)` that sorts raw Task objects (not TaskWithRoom):
|
||||
- `alphabetical`: sort by `task.name.toLowerCase()`
|
||||
- `interval`: sort by `task.intervalType.index`, then `task.intervalDays`
|
||||
- `effort`: sort by `task.effortLevel.index`
|
||||
- Returns a new sorted list (do not mutate the original)
|
||||
|
||||
3. Verify both providers react to sort preference changes by running existing tests (they should still pass since default sort is alphabetical and current data is already alphabetically sorted or test data is single-item).
|
||||
</action>
|
||||
<verify>
|
||||
<automated>cd /home/jlmak/Projects/jlmak/HouseHoldKeaper && flutter test && flutter analyze --no-fatal-infos</automated>
|
||||
</verify>
|
||||
<done>calendarDayProvider watches sortPreferenceProvider and sorts dayTasks accordingly. tasksInRoomProvider watches sortPreferenceProvider and sorts tasks accordingly. All 106+ existing tests pass. dart analyze clean.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<verification>
|
||||
- `flutter test` — all 106+ tests pass (existing + new sort preference tests)
|
||||
- `flutter analyze --no-fatal-infos` — zero issues
|
||||
- `sortPreferenceProvider` is watchable and defaults to alphabetical
|
||||
- Both calendarDayProvider and tasksInRoomProvider react to sort preference changes
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- TaskSortOption enum exists with alphabetical, interval, effort values
|
||||
- SortPreferenceNotifier persists sort preference to SharedPreferences
|
||||
- Default sort is alphabetical (continuity with existing A-Z sort)
|
||||
- calendarDayProvider sorts dayTasks by active sort (overdue section unsorted)
|
||||
- tasksInRoomProvider sorts tasks by active sort
|
||||
- All tests pass, analyze clean
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
After completion, create `.planning/phases/07-task-sorting/07-01-SUMMARY.md`
|
||||
</output>
|
||||
138
.planning/phases/07-task-sorting/07-01-SUMMARY.md
Normal file
138
.planning/phases/07-task-sorting/07-01-SUMMARY.md
Normal file
@@ -0,0 +1,138 @@
|
||||
---
|
||||
phase: 07-task-sorting
|
||||
plan: 01
|
||||
subsystem: ui
|
||||
tags: [flutter, riverpod, shared_preferences, sorting, localization]
|
||||
|
||||
# Dependency graph
|
||||
requires:
|
||||
- phase: 05-calendar-strip
|
||||
provides: calendarDayProvider and CalendarDayState used by sort integration
|
||||
- phase: 06-task-history
|
||||
provides: task domain model and CalendarTaskRow context
|
||||
|
||||
provides:
|
||||
- TaskSortOption enum (alphabetical, interval, effort)
|
||||
- SortPreferenceNotifier with SharedPreferences persistence
|
||||
- sortPreferenceProvider (keepAlive Riverpod provider)
|
||||
- calendarDayProvider with in-memory sort of dayTasks
|
||||
- tasksInRoomProvider with in-memory sort via stream.map
|
||||
- German localization strings: sortAlphabetical, sortInterval, sortEffort, sortLabel
|
||||
|
||||
affects: [07-02-sort-ui, any phase using calendarDayProvider or tasksInRoomProvider]
|
||||
|
||||
# Tech tracking
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "SortPreferenceNotifier: sync default return, async _loadPersisted() — same pattern as ThemeNotifier"
|
||||
- "In-memory sort helper functions (_sortTasks, _sortTasksRaw) applied after DB stream emit"
|
||||
- "overdueTasks intentionally unsorted — only dayTasks sorted"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- lib/features/tasks/domain/task_sort_option.dart
|
||||
- lib/features/tasks/presentation/sort_preference_notifier.dart
|
||||
- lib/features/tasks/presentation/sort_preference_notifier.g.dart
|
||||
- test/features/tasks/presentation/sort_preference_notifier_test.dart
|
||||
modified:
|
||||
- lib/features/home/presentation/calendar_providers.dart
|
||||
- lib/features/tasks/presentation/task_providers.dart
|
||||
- lib/l10n/app_de.arb
|
||||
- lib/l10n/app_localizations.dart
|
||||
- lib/l10n/app_localizations_de.dart
|
||||
|
||||
key-decisions:
|
||||
- "Default sort is alphabetical — continuity with existing A-Z SQL sort in CalendarDayList"
|
||||
- "overdueTasks are NOT sorted — they stay pinned at the top in existing order"
|
||||
- "Sort stored as string (enum.name) in SharedPreferences — not intEnum, so reordering enum is safe"
|
||||
- "SortPreferenceNotifier uses keepAlive: true — global preference should never be disposed"
|
||||
|
||||
patterns-established:
|
||||
- "SortPreferenceNotifier pattern: sync default + async _loadPersisted() — matches ThemeNotifier"
|
||||
- "In-memory sort via stream.map in StreamProvider — DB SQL sort provides stable baseline, in-memory overrides"
|
||||
|
||||
requirements-completed: [SORT-01, SORT-02, SORT-03]
|
||||
|
||||
# Metrics
|
||||
duration: 4min
|
||||
completed: 2026-03-16
|
||||
---
|
||||
|
||||
# Phase 07 Plan 01: Task Sort Domain and Provider Summary
|
||||
|
||||
**TaskSortOption enum + SharedPreferences-backed SortPreferenceNotifier wired into calendarDayProvider and tasksInRoomProvider with in-memory alphabetical/interval/effort sorting**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** 4 min
|
||||
- **Started:** 2026-03-16T21:29:32Z
|
||||
- **Completed:** 2026-03-16T21:33:37Z
|
||||
- **Tasks:** 2
|
||||
- **Files modified:** 9
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- TaskSortOption enum (alphabetical, interval, effort) with SharedPreferences persistence via SortPreferenceNotifier
|
||||
- calendarDayProvider now watches sortPreferenceProvider and sorts dayTasks in-memory; overdueTasks intentionally unsorted
|
||||
- tasksInRoomProvider now watches sortPreferenceProvider and applies sort via stream.map
|
||||
- 7 new unit tests for SortPreferenceNotifier covering default, state update, persistence, and restart recovery
|
||||
- 4 German localization strings added (sortAlphabetical, sortInterval, sortEffort, sortLabel)
|
||||
|
||||
## Task Commits
|
||||
|
||||
Each task was committed atomically:
|
||||
|
||||
1. **TDD RED: Failing sort preference tests** - `a9f2983` (test)
|
||||
2. **Task 1: TaskSortOption enum, SortPreferenceNotifier, localization** - `13c7d62` (feat)
|
||||
3. **Task 2: Sort integration into calendarDayProvider and tasksInRoomProvider** - `3697e4e` (feat)
|
||||
|
||||
## Files Created/Modified
|
||||
|
||||
- `lib/features/tasks/domain/task_sort_option.dart` - TaskSortOption enum with alphabetical/interval/effort values
|
||||
- `lib/features/tasks/presentation/sort_preference_notifier.dart` - SortPreferenceNotifier with SharedPreferences persistence
|
||||
- `lib/features/tasks/presentation/sort_preference_notifier.g.dart` - Generated Riverpod provider code
|
||||
- `lib/features/home/presentation/calendar_providers.dart` - Added sortPreferenceProvider watch + _sortTasks helper
|
||||
- `lib/features/tasks/presentation/task_providers.dart` - Added sortPreferenceProvider watch + _sortTasksRaw helper + stream.map
|
||||
- `lib/l10n/app_de.arb` - Added sortAlphabetical, sortInterval, sortEffort, sortLabel strings
|
||||
- `lib/l10n/app_localizations.dart` - Regenerated with sort string getters
|
||||
- `lib/l10n/app_localizations_de.dart` - Regenerated with German sort string implementations
|
||||
- `test/features/tasks/presentation/sort_preference_notifier_test.dart` - 7 unit tests for sort preference
|
||||
|
||||
## Decisions Made
|
||||
|
||||
- Default sort is alphabetical for continuity with existing SQL A-Z sort in CalendarDayList
|
||||
- overdueTasks section is explicitly NOT sorted — stays pinned at top in existing order
|
||||
- Sort preference stored as enum.name string in SharedPreferences (not intEnum) so enum reordering is always safe
|
||||
- SortPreferenceNotifier uses `keepAlive: true` — global app preference must not be disposed
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
None - plan executed exactly as written.
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
None.
|
||||
|
||||
## User Setup Required
|
||||
|
||||
None - no external service configuration required.
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
- sortPreferenceProvider is live and defaults to alphabetical
|
||||
- Both task list providers react to sort preference changes immediately
|
||||
- Ready for 07-02: sort UI (dropdown in AppBar) to write to sortPreferenceProvider
|
||||
|
||||
---
|
||||
*Phase: 07-task-sorting*
|
||||
*Completed: 2026-03-16*
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
- FOUND: lib/features/tasks/domain/task_sort_option.dart
|
||||
- FOUND: lib/features/tasks/presentation/sort_preference_notifier.dart
|
||||
- FOUND: lib/features/tasks/presentation/sort_preference_notifier.g.dart
|
||||
- FOUND: test/features/tasks/presentation/sort_preference_notifier_test.dart
|
||||
- FOUND: .planning/phases/07-task-sorting/07-01-SUMMARY.md
|
||||
- Commits a9f2983, 13c7d62, 3697e4e all verified in git log
|
||||
214
.planning/phases/07-task-sorting/07-02-PLAN.md
Normal file
214
.planning/phases/07-task-sorting/07-02-PLAN.md
Normal file
@@ -0,0 +1,214 @@
|
||||
---
|
||||
phase: 07-task-sorting
|
||||
plan: 02
|
||||
type: execute
|
||||
wave: 2
|
||||
depends_on: ["07-01"]
|
||||
files_modified:
|
||||
- lib/features/tasks/presentation/sort_dropdown.dart
|
||||
- lib/features/home/presentation/home_screen.dart
|
||||
- lib/features/tasks/presentation/task_list_screen.dart
|
||||
- test/features/home/presentation/home_screen_test.dart
|
||||
autonomous: true
|
||||
requirements: [SORT-01, SORT-02, SORT-03]
|
||||
|
||||
must_haves:
|
||||
truths:
|
||||
- "A sort dropdown is visible in the HomeScreen AppBar showing the current sort label"
|
||||
- "A sort dropdown is visible in the TaskListScreen AppBar showing the current sort label"
|
||||
- "Tapping the dropdown shows three options: A-Z, Intervall, Aufwand"
|
||||
- "Selecting a sort option updates the task list order immediately"
|
||||
- "The sort preference persists across screen navigations and app restarts"
|
||||
artifacts:
|
||||
- path: "lib/features/tasks/presentation/sort_dropdown.dart"
|
||||
provides: "Reusable SortDropdown ConsumerWidget"
|
||||
exports: ["SortDropdown"]
|
||||
- path: "lib/features/home/presentation/home_screen.dart"
|
||||
provides: "HomeScreen with AppBar containing SortDropdown"
|
||||
contains: "SortDropdown"
|
||||
- path: "lib/features/tasks/presentation/task_list_screen.dart"
|
||||
provides: "TaskListScreen AppBar with SortDropdown alongside edit/delete"
|
||||
contains: "SortDropdown"
|
||||
key_links:
|
||||
- from: "lib/features/tasks/presentation/sort_dropdown.dart"
|
||||
to: "sortPreferenceProvider"
|
||||
via: "ref.watch for display, ref.read for mutation"
|
||||
pattern: "ref\\.watch\\(sortPreferenceProvider\\)"
|
||||
- from: "lib/features/home/presentation/home_screen.dart"
|
||||
to: "lib/features/tasks/presentation/sort_dropdown.dart"
|
||||
via: "SortDropdown widget in AppBar actions"
|
||||
pattern: "SortDropdown"
|
||||
- from: "lib/features/tasks/presentation/task_list_screen.dart"
|
||||
to: "lib/features/tasks/presentation/sort_dropdown.dart"
|
||||
via: "SortDropdown widget in AppBar actions"
|
||||
pattern: "SortDropdown"
|
||||
---
|
||||
|
||||
<objective>
|
||||
Build the sort dropdown widget and wire it into both task list screens (HomeScreen and TaskListScreen), adding an AppBar to HomeScreen.
|
||||
|
||||
Purpose: Gives users visible access to the sort controls. The data layer from Plan 01 already sorts reactively; this plan adds the UI trigger.
|
||||
|
||||
Output: SortDropdown reusable widget, updated HomeScreen with AppBar, updated TaskListScreen with dropdown in existing AppBar, updated tests.
|
||||
</objective>
|
||||
|
||||
<execution_context>
|
||||
@/home/jlmak/.claude/get-shit-done/workflows/execute-plan.md
|
||||
@/home/jlmak/.claude/get-shit-done/templates/summary.md
|
||||
</execution_context>
|
||||
|
||||
<context>
|
||||
@.planning/PROJECT.md
|
||||
@.planning/ROADMAP.md
|
||||
@.planning/STATE.md
|
||||
@.planning/phases/07-task-sorting/07-CONTEXT.md
|
||||
@.planning/phases/07-task-sorting/07-01-SUMMARY.md
|
||||
|
||||
<interfaces>
|
||||
<!-- Interfaces from Plan 01 that this plan depends on -->
|
||||
|
||||
From lib/features/tasks/domain/task_sort_option.dart (created in 07-01):
|
||||
```dart
|
||||
enum TaskSortOption { alphabetical, interval, effort }
|
||||
```
|
||||
|
||||
From lib/features/tasks/presentation/sort_preference_notifier.dart (created in 07-01):
|
||||
```dart
|
||||
@riverpod
|
||||
class SortPreferenceNotifier extends _$SortPreferenceNotifier {
|
||||
TaskSortOption build(); // returns alphabetical by default
|
||||
Future<void> setSortOption(TaskSortOption option);
|
||||
}
|
||||
// Generated as: sortPreferenceProvider
|
||||
```
|
||||
|
||||
From lib/l10n/app_de.arb (strings added in 07-01):
|
||||
```
|
||||
sortAlphabetical: "A-Z"
|
||||
sortInterval: "Intervall"
|
||||
sortEffort: "Aufwand"
|
||||
sortLabel: "Sortierung"
|
||||
```
|
||||
|
||||
<!-- Existing interfaces being modified -->
|
||||
|
||||
From lib/features/home/presentation/home_screen.dart:
|
||||
```dart
|
||||
class HomeScreen extends ConsumerStatefulWidget {
|
||||
// Currently: Stack with CalendarStrip + CalendarDayList + floating Today FAB
|
||||
// No AppBar — body sits directly inside AppShell's Scaffold
|
||||
}
|
||||
```
|
||||
|
||||
From lib/features/tasks/presentation/task_list_screen.dart:
|
||||
```dart
|
||||
class TaskListScreen extends ConsumerWidget {
|
||||
// Has its own Scaffold with AppBar containing edit + delete IconButtons
|
||||
// AppBar actions: [edit, delete]
|
||||
}
|
||||
```
|
||||
|
||||
From lib/features/home/presentation/calendar_strip.dart:
|
||||
```dart
|
||||
class CalendarStrip extends StatefulWidget {
|
||||
const CalendarStrip({super.key, required this.controller, this.onTodayVisibilityChanged});
|
||||
final CalendarStripController controller;
|
||||
final ValueChanged<bool>? onTodayVisibilityChanged;
|
||||
}
|
||||
```
|
||||
</interfaces>
|
||||
</context>
|
||||
|
||||
<tasks>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 1: Build SortDropdown widget and integrate into HomeScreen and TaskListScreen</name>
|
||||
<files>
|
||||
lib/features/tasks/presentation/sort_dropdown.dart,
|
||||
lib/features/home/presentation/home_screen.dart,
|
||||
lib/features/tasks/presentation/task_list_screen.dart
|
||||
</files>
|
||||
<action>
|
||||
1. Create `lib/features/tasks/presentation/sort_dropdown.dart`:
|
||||
- A `ConsumerWidget` named `SortDropdown`
|
||||
- Uses `PopupMenuButton<TaskSortOption>` (Material 3, better than DropdownButton for AppBar trailing actions — it opens a menu overlay rather than inline expansion)
|
||||
- `ref.watch(sortPreferenceProvider)` to get current sort option
|
||||
- The button child shows the current sort label as a Text widget using l10n strings:
|
||||
- `alphabetical` -> `l10n.sortAlphabetical` (A-Z)
|
||||
- `interval` -> `l10n.sortInterval` (Intervall)
|
||||
- `effort` -> `l10n.sortEffort` (Aufwand)
|
||||
- Style the button child as a Row with `Icon(Icons.sort)` + `SizedBox(width: 4)` + label Text. Use `theme.textTheme.labelLarge` for the text.
|
||||
- `itemBuilder` returns 3 `PopupMenuItem<TaskSortOption>` entries with check marks: for each option, show a Row with `Icon(Icons.check, size: 18)` (visible only when selected, invisible when not via `Opacity(opacity: isSelected ? 1 : 0)`) + `SizedBox(width: 8)` + label Text
|
||||
- `onSelected`: `ref.read(sortPreferenceProvider.notifier).setSortOption(value)`
|
||||
- Helper method `String _label(TaskSortOption option, AppLocalizations l10n)` that maps enum to l10n string
|
||||
|
||||
2. Edit `lib/features/home/presentation/home_screen.dart`:
|
||||
- HomeScreen currently returns a `Stack` with `Column(CalendarStrip, Expanded(CalendarDayList))` + optional floating Today button
|
||||
- Wrap the entire current Stack in a `Scaffold` with an `AppBar`:
|
||||
- `AppBar(title: Text(l10n.tabHome), actions: [const SortDropdown()])`
|
||||
- The `tabHome` l10n string already exists ("Ubersicht") — reuse it as the AppBar title for the home screen
|
||||
- body: the existing Stack content
|
||||
- Keep CalendarStrip, CalendarDayList, and floating Today FAB exactly as they are
|
||||
- Import `sort_dropdown.dart`
|
||||
- Note: HomeScreen is inside AppShell's Scaffold body. Adding a nested Scaffold is fine and standard for per-tab AppBars in StatefulShellRoute.indexedStack. The AppShell Scaffold provides the bottom nav; the inner Scaffold provides the AppBar.
|
||||
|
||||
3. Edit `lib/features/tasks/presentation/task_list_screen.dart`:
|
||||
- In the existing `AppBar.actions` list, add `const SortDropdown()` BEFORE the edit and delete IconButtons. Order: [SortDropdown, edit, delete].
|
||||
- Import `sort_dropdown.dart`
|
||||
- No other changes to TaskListScreen
|
||||
</action>
|
||||
<verify>
|
||||
<automated>cd /home/jlmak/Projects/jlmak/HouseHoldKeaper && flutter analyze --no-fatal-infos</automated>
|
||||
</verify>
|
||||
<done>SortDropdown widget exists showing current sort label with sort icon. HomeScreen has AppBar with title "Ubersicht" and SortDropdown. TaskListScreen AppBar has SortDropdown before edit/delete buttons. dart analyze clean.</done>
|
||||
</task>
|
||||
|
||||
<task type="auto">
|
||||
<name>Task 2: Update tests for HomeScreen AppBar and sort dropdown</name>
|
||||
<files>
|
||||
test/features/home/presentation/home_screen_test.dart
|
||||
</files>
|
||||
<action>
|
||||
1. Edit `test/features/home/presentation/home_screen_test.dart`:
|
||||
- Add import for `sort_preference_notifier.dart` and `task_sort_option.dart`
|
||||
- In the `_buildApp` helper, add a provider override for `sortPreferenceProvider`:
|
||||
```dart
|
||||
sortPreferenceProvider.overrideWith(SortPreferenceNotifier.new),
|
||||
```
|
||||
This will use the real notifier with mock SharedPreferences (already set up in setUp).
|
||||
- Add a new test group `'HomeScreen sort dropdown'`:
|
||||
- Test: "shows sort dropdown in AppBar" — pump the app with tasks, verify `find.byType(PopupMenuButton<TaskSortOption>)` findsOneWidget
|
||||
- Test: "shows AppBar with title" — verify `find.text('Ubersicht')` findsOneWidget (the tabHome l10n string)
|
||||
- Verify all existing tests still pass. The addition of an AppBar wrapping the existing content should not break existing assertions since they look for specific widgets/text within the tree.
|
||||
|
||||
2. Run full test suite to confirm no regressions.
|
||||
</action>
|
||||
<verify>
|
||||
<automated>cd /home/jlmak/Projects/jlmak/HouseHoldKeaper && flutter test && flutter analyze --no-fatal-infos</automated>
|
||||
</verify>
|
||||
<done>Home screen tests verify AppBar with sort dropdown is present. All 108+ tests pass (106 existing + 2+ new). dart analyze clean.</done>
|
||||
</task>
|
||||
|
||||
</tasks>
|
||||
|
||||
<verification>
|
||||
- `flutter test` — all tests pass including new sort dropdown tests
|
||||
- `flutter analyze --no-fatal-infos` — zero issues
|
||||
- HomeScreen has AppBar with SortDropdown visible
|
||||
- TaskListScreen has SortDropdown in AppBar actions
|
||||
- Tapping dropdown shows 3 options with check mark on current selection
|
||||
- Selecting a different sort option reorders the task list reactively
|
||||
</verification>
|
||||
|
||||
<success_criteria>
|
||||
- SortDropdown widget is reusable and shows current sort with icon
|
||||
- HomeScreen has AppBar titled "Ubersicht" with SortDropdown in trailing actions
|
||||
- TaskListScreen has SortDropdown before edit/delete buttons in AppBar
|
||||
- Sort selection updates task list order immediately (reactive via provider)
|
||||
- Sort preference persists (set in one screen, visible in another after navigation)
|
||||
- All tests pass, analyze clean
|
||||
</success_criteria>
|
||||
|
||||
<output>
|
||||
After completion, create `.planning/phases/07-task-sorting/07-02-SUMMARY.md`
|
||||
</output>
|
||||
125
.planning/phases/07-task-sorting/07-02-SUMMARY.md
Normal file
125
.planning/phases/07-task-sorting/07-02-SUMMARY.md
Normal file
@@ -0,0 +1,125 @@
|
||||
---
|
||||
phase: 07-task-sorting
|
||||
plan: 02
|
||||
subsystem: ui
|
||||
tags: [flutter, riverpod, material3, popup-menu, sort-ui, localization]
|
||||
|
||||
# Dependency graph
|
||||
requires:
|
||||
- phase: 07-task-sorting
|
||||
plan: 01
|
||||
provides: sortPreferenceProvider, TaskSortOption enum, German sort l10n strings
|
||||
|
||||
provides:
|
||||
- SortDropdown ConsumerWidget (PopupMenuButton<TaskSortOption> with check marks)
|
||||
- HomeScreen with AppBar (title: Übersicht, actions: SortDropdown)
|
||||
- TaskListScreen AppBar with SortDropdown before edit/delete buttons
|
||||
|
||||
affects: [home_screen_test.dart, app_shell_test.dart, any screen showing HomeScreen]
|
||||
|
||||
# Tech tracking
|
||||
tech-stack:
|
||||
added: []
|
||||
patterns:
|
||||
- "PopupMenuButton<TaskSortOption> with Opacity check mark — avoids layout shift vs conditional Icon"
|
||||
- "Nested Scaffold inside AppShell tab body — standard pattern for per-tab AppBars in StatefulShellRoute"
|
||||
|
||||
key-files:
|
||||
created:
|
||||
- lib/features/tasks/presentation/sort_dropdown.dart
|
||||
modified:
|
||||
- lib/features/home/presentation/home_screen.dart
|
||||
- lib/features/tasks/presentation/task_list_screen.dart
|
||||
- test/features/home/presentation/home_screen_test.dart
|
||||
- test/shell/app_shell_test.dart
|
||||
|
||||
key-decisions:
|
||||
- "Used PopupMenuButton instead of DropdownButton for AppBar — menu overlay vs inline expansion, consistent with Material 3 AppBar action patterns"
|
||||
- "Opacity(opacity: isSelected ? 1 : 0) for check mark — preserves item width alignment vs conditional show/hide"
|
||||
- "HomeScreen Scaffold is nested inside AppShell Scaffold — standard StatefulShellRoute pattern for per-tab AppBars"
|
||||
|
||||
# Metrics
|
||||
duration: 4min
|
||||
completed: 2026-03-16
|
||||
---
|
||||
|
||||
# Phase 07 Plan 02: Sort Dropdown UI Summary
|
||||
|
||||
**SortDropdown ConsumerWidget using PopupMenuButton wired into HomeScreen AppBar (title: Übersicht) and TaskListScreen AppBar before edit/delete actions**
|
||||
|
||||
## Performance
|
||||
|
||||
- **Duration:** 4 min
|
||||
- **Started:** 2026-03-16T21:35:56Z
|
||||
- **Completed:** 2026-03-16T21:39:24Z
|
||||
- **Tasks:** 2
|
||||
- **Files modified:** 5 (1 created, 4 modified)
|
||||
|
||||
## Accomplishments
|
||||
|
||||
- SortDropdown ConsumerWidget: PopupMenuButton<TaskSortOption> with sort icon, current label, and check mark on active option
|
||||
- HomeScreen wrapped in Scaffold with AppBar titled "Übersicht" and SortDropdown in trailing actions
|
||||
- TaskListScreen AppBar has SortDropdown before the existing edit/delete IconButtons
|
||||
- 2 new tests in HomeScreen test suite: verifies PopupMenuButton and AppBar title presence
|
||||
- Auto-fixed app_shell_test regression caused by "Übersicht" now appearing twice (AppBar + bottom nav)
|
||||
|
||||
## Task Commits
|
||||
|
||||
Each task was committed atomically:
|
||||
|
||||
1. **Task 1: SortDropdown widget and HomeScreen/TaskListScreen integration** - `e5eccb7` (feat)
|
||||
2. **Task 2: Sort dropdown tests and AppShell test fix** - `a3e4d02` (feat)
|
||||
|
||||
## Files Created/Modified
|
||||
|
||||
- `lib/features/tasks/presentation/sort_dropdown.dart` - Reusable SortDropdown ConsumerWidget with PopupMenuButton<TaskSortOption>
|
||||
- `lib/features/home/presentation/home_screen.dart` - Added Scaffold with AppBar (Übersicht title + SortDropdown)
|
||||
- `lib/features/tasks/presentation/task_list_screen.dart` - Added SortDropdown before edit/delete in AppBar actions
|
||||
- `test/features/home/presentation/home_screen_test.dart` - Added sortPreferenceProvider override + 2 new sort dropdown tests
|
||||
- `test/shell/app_shell_test.dart` - Fixed findsOneWidget -> findsWidgets for 'Übersicht' (now in AppBar + bottom nav)
|
||||
|
||||
## Decisions Made
|
||||
|
||||
- Used PopupMenuButton instead of DropdownButton for AppBar actions — menu overlay is cleaner in AppBar context (Material 3)
|
||||
- Opacity trick for check mark: `Opacity(opacity: isSelected ? 1 : 0)` preserves item width so labels align regardless of selection
|
||||
- HomeScreen uses nested Scaffold for AppBar — standard pattern in StatefulShellRoute.indexedStack; AppShell provides bottom nav, HomeScreen provides AppBar
|
||||
|
||||
## Deviations from Plan
|
||||
|
||||
### Auto-fixed Issues
|
||||
|
||||
**1. [Rule 1 - Bug] Fixed AppShell test regression from 'Übersicht' duplicate**
|
||||
- **Found during:** Task 2 test run
|
||||
- **Issue:** `app_shell_test.dart` expected `findsOneWidget` for 'Übersicht'. Adding the HomeScreen AppBar title caused the string to appear twice (AppBar + bottom nav label).
|
||||
- **Fix:** Changed `findsOneWidget` to `findsWidgets` in `app_shell_test.dart` line 67. Applied same fix to new `home_screen_test.dart` AppBar title test.
|
||||
- **Files modified:** `test/shell/app_shell_test.dart`, `test/features/home/presentation/home_screen_test.dart`
|
||||
- **Commit:** `a3e4d02`
|
||||
|
||||
## Issues Encountered
|
||||
|
||||
None beyond the auto-fixed regression.
|
||||
|
||||
## User Setup Required
|
||||
|
||||
None - no external service configuration required.
|
||||
|
||||
## Next Phase Readiness
|
||||
|
||||
- Phase 07 (task sorting) is now complete: data layer (07-01) + UI layer (07-02)
|
||||
- Sort dropdown is live in both HomeScreen and TaskListScreen AppBars
|
||||
- Selecting a sort option reactively reorders task lists via sortPreferenceProvider
|
||||
- Preference persists across app restarts via SharedPreferences
|
||||
|
||||
---
|
||||
*Phase: 07-task-sorting*
|
||||
*Completed: 2026-03-16*
|
||||
|
||||
## Self-Check: PASSED
|
||||
|
||||
- FOUND: lib/features/tasks/presentation/sort_dropdown.dart
|
||||
- FOUND: lib/features/home/presentation/home_screen.dart (modified)
|
||||
- FOUND: lib/features/tasks/presentation/task_list_screen.dart (modified)
|
||||
- FOUND: test/features/home/presentation/home_screen_test.dart (modified)
|
||||
- FOUND: test/shell/app_shell_test.dart (modified)
|
||||
- Commits e5eccb7, a3e4d02 verified in git log
|
||||
- All 115 tests pass, dart analyze clean
|
||||
91
.planning/phases/07-task-sorting/07-CONTEXT.md
Normal file
91
.planning/phases/07-task-sorting/07-CONTEXT.md
Normal file
@@ -0,0 +1,91 @@
|
||||
# Phase 7: Task Sorting - Context
|
||||
|
||||
**Gathered:** 2026-03-16
|
||||
**Status:** Ready for planning
|
||||
|
||||
<domain>
|
||||
## Phase Boundary
|
||||
|
||||
Add sort controls to task list screens so users can reorder tasks by name (alphabetical), frequency interval, or effort level. The sort preference persists across app restarts. Requirements: SORT-01, SORT-02, SORT-03.
|
||||
|
||||
</domain>
|
||||
|
||||
<decisions>
|
||||
## Implementation Decisions
|
||||
|
||||
### Sort control widget
|
||||
- Dropdown button in the AppBar, right side (trailing actions position)
|
||||
- When collapsed, shows the current sort name as text (e.g., "A-Z", "Intervall", "Aufwand")
|
||||
- Expands to show the 3 sort options as a standard dropdown menu
|
||||
|
||||
### Sort option labels
|
||||
- Claude's discretion — pick German labels that fit the app's existing localization style (concise but clear)
|
||||
|
||||
### Sort scope
|
||||
- One global sort preference applies to all task list screens
|
||||
- Same dropdown appears in both the home screen (CalendarDayList) and per-room (TaskListScreen) AppBars
|
||||
|
||||
### Persistence
|
||||
- Store the sort preference in SharedPreferences (simple key-value for a single enum)
|
||||
- No database schema change needed
|
||||
- Persists across app restarts per success criteria
|
||||
|
||||
### Default sort
|
||||
- Claude's discretion — pick the least disruptive default (likely alphabetical to match current CalendarDayList behavior)
|
||||
|
||||
### Claude's Discretion
|
||||
- Sort option label text (German, concise)
|
||||
- Default sort order (recommend alphabetical for continuity)
|
||||
- Whether TaskListScreen also gets the dropdown (recommend yes for consistency with global setting, since the success criteria says "task list screens" plural)
|
||||
- Sort direction (always ascending — A-Z, daily→yearly, low→high — no toggle needed for MVP)
|
||||
- Dropdown styling (Material 3 DropdownButton or PopupMenuButton variant)
|
||||
- Sort icon or visual indicator in the dropdown
|
||||
- How overdue section interacts with sorting (recommend: overdue section stays pinned at top regardless of sort, only day tasks are sorted)
|
||||
|
||||
</decisions>
|
||||
|
||||
<specifics>
|
||||
## Specific Ideas
|
||||
|
||||
No specific requirements — open to standard approaches that match existing app patterns.
|
||||
|
||||
</specifics>
|
||||
|
||||
<code_context>
|
||||
## Existing Code Insights
|
||||
|
||||
### Reusable Assets
|
||||
- `EffortLevel` enum (low/medium/high) with `.index` for ordering — directly usable for effort sort
|
||||
- `IntervalType` enum with `.index` ordered roughly by frequency (daily=0 through yearly=7) — usable for interval sort
|
||||
- `FrequencyInterval.presets` list ordered most-frequent to least — reference for sort order
|
||||
- `Task.name` field — direct alphabetical sort target
|
||||
- `CalendarDayList` and `TaskListScreen` — the two list widgets that need sort integration
|
||||
- `AppLocalizations` + `.arb` files — existing German localization pipeline
|
||||
|
||||
### Established Patterns
|
||||
- Manual `StreamProvider.autoDispose` for drift types (riverpod_generator issue) — sort provider follows same pattern
|
||||
- `calendarDayProvider` watches `selectedDateProvider` — can also watch a sort preference provider
|
||||
- `tasksInRoomProvider` family provider — can be extended with sort parameter or read global sort
|
||||
- Feature folder structure: `features/home/`, `features/tasks/` — sort logic may live in a shared location or in each feature
|
||||
|
||||
### Integration Points
|
||||
- `HomeScreen` AppBar — add dropdown to trailing actions
|
||||
- `TaskListScreen` AppBar — already has edit/delete actions; add dropdown alongside
|
||||
- `CalendarDao.watchTasksForDate()` — currently sorts alphabetically; needs sort-aware query or in-memory sort
|
||||
- `TasksDao.watchTasksInRoom()` — currently sorts by nextDueDate; needs sort-aware query or in-memory sort
|
||||
- `SharedPreferences` — not yet used in the app; needs package addition and provider setup
|
||||
- `app_de.arb` — add localization strings for sort labels
|
||||
|
||||
</code_context>
|
||||
|
||||
<deferred>
|
||||
## Deferred Ideas
|
||||
|
||||
None — discussion stayed within phase scope
|
||||
|
||||
</deferred>
|
||||
|
||||
---
|
||||
|
||||
*Phase: 07-task-sorting*
|
||||
*Context gathered: 2026-03-16*
|
||||
135
.planning/phases/07-task-sorting/7-VERIFICATION.md
Normal file
135
.planning/phases/07-task-sorting/7-VERIFICATION.md
Normal file
@@ -0,0 +1,135 @@
|
||||
---
|
||||
phase: 07-task-sorting
|
||||
verified: 2026-03-16T22:00:00Z
|
||||
status: passed
|
||||
score: 9/9 must-haves verified
|
||||
re_verification: false
|
||||
---
|
||||
|
||||
# Phase 7: Task Sorting Verification Report
|
||||
|
||||
**Phase Goal:** Users can reorder task lists by the dimension most useful to them — name, how often the task recurs, or how much effort it requires
|
||||
**Verified:** 2026-03-16T22:00:00Z
|
||||
**Status:** passed
|
||||
**Re-verification:** No — initial verification
|
||||
|
||||
---
|
||||
|
||||
## Goal Achievement
|
||||
|
||||
### Observable Truths
|
||||
|
||||
| # | Truth | Status | Evidence |
|
||||
|----|--------------------------------------------------------------------------------|------------|------------------------------------------------------------------------------------------------------|
|
||||
| 1 | Sort preference persists across app restarts | VERIFIED | `SortPreferenceNotifier._loadPersisted()` reads `SharedPreferences.getString('task_sort_option')` on build; 2 restart-recovery tests pass |
|
||||
| 2 | CalendarDayList tasks are sorted according to the active sort preference | VERIFIED | `calendarDayProvider` calls `ref.watch(sortPreferenceProvider)` and applies `_sortTasks(dayTasks, sortOption)` before returning `CalendarDayState` |
|
||||
| 3 | TaskListScreen tasks are sorted according to the active sort preference | VERIFIED | `tasksInRoomProvider` calls `ref.watch(sortPreferenceProvider)` and applies `stream.map((tasks) => _sortTasksRaw(tasks, sortOption))` |
|
||||
| 4 | Default sort is alphabetical (matches current CalendarDayList behavior) | VERIFIED | `SortPreferenceNotifier.build()` returns `TaskSortOption.alphabetical` synchronously; test "build() returns default state of alphabetical" confirms |
|
||||
| 5 | A sort dropdown is visible in the HomeScreen AppBar showing the current label | VERIFIED | `HomeScreen.build()` returns `Scaffold(appBar: AppBar(actions: const [SortDropdown()]))` — wired and rendered |
|
||||
| 6 | A sort dropdown is visible in the TaskListScreen AppBar | VERIFIED | `TaskListScreen.build()` AppBar actions list: `[const SortDropdown(), edit IconButton, delete IconButton]` |
|
||||
| 7 | Tapping the dropdown shows three options: A-Z, Intervall, Aufwand | VERIFIED | `SortDropdown` builds `PopupMenuButton` from `TaskSortOption.values` (3 items), labels map to `l10n.sortAlphabetical/sortInterval/sortEffort` |
|
||||
| 8 | Selecting a sort option updates the task list order immediately | VERIFIED | `onSelected` calls `ref.read(sortPreferenceProvider.notifier).setSortOption(value)`; providers watch `sortPreferenceProvider` and rebuild reactively |
|
||||
| 9 | The sort preference persists across screen navigations and app restarts | VERIFIED | `@Riverpod(keepAlive: true)` prevents disposal during navigation; SharedPreferences stores and reloads value |
|
||||
|
||||
**Score:** 9/9 truths verified
|
||||
|
||||
---
|
||||
|
||||
## Required Artifacts
|
||||
|
||||
### Plan 07-01 Artifacts
|
||||
|
||||
| Artifact | Expected | Status | Details |
|
||||
|----------|----------|--------|---------|
|
||||
| `lib/features/tasks/domain/task_sort_option.dart` | `TaskSortOption` enum with alphabetical, interval, effort | VERIFIED | Exactly 3 values, comments match intent. No stubs. |
|
||||
| `lib/features/tasks/presentation/sort_preference_notifier.dart` | `SortPreferenceNotifier` with SharedPreferences persistence | VERIFIED | `build()` returns `alphabetical` synchronously, `_loadPersisted()` async, `setSortOption()` sets state + persists. Pattern matches `ThemeNotifier`. |
|
||||
| `lib/features/tasks/presentation/sort_preference_notifier.g.dart` | Generated Riverpod provider file | VERIFIED | Generated correctly; `sortPreferenceProvider` declared as `SortPreferenceNotifierProvider._()` with `isAutoDispose: false` (keepAlive). |
|
||||
| `lib/features/home/presentation/calendar_providers.dart` | `calendarDayProvider` sorts `dayTasks` by active sort preference | VERIFIED | `ref.watch(sortPreferenceProvider)` present. `_sortTasks()` helper implements all 3 sort modes. `overdueTasks` intentionally unsorted. |
|
||||
| `lib/features/tasks/presentation/task_providers.dart` | `tasksInRoomProvider` sorts tasks by active sort preference | VERIFIED | `ref.watch(sortPreferenceProvider)` present. `_sortTasksRaw()` helper + `stream.map()` applied correctly. |
|
||||
| `test/features/tasks/presentation/sort_preference_notifier_test.dart` | Unit tests for sort preference persistence and default | VERIFIED | 7 tests: default alphabetical, setSortOption interval, setSortOption effort, persist to SharedPreferences, restart recovery (effort), restart recovery (interval), unknown value fallback. |
|
||||
|
||||
### Plan 07-02 Artifacts
|
||||
|
||||
| Artifact | Expected | Status | Details |
|
||||
|----------|----------|--------|---------|
|
||||
| `lib/features/tasks/presentation/sort_dropdown.dart` | Reusable `SortDropdown` `ConsumerWidget` | VERIFIED | `ConsumerWidget`, `PopupMenuButton<TaskSortOption>`, Opacity check mark pattern, `ref.watch` for display, `ref.read` for mutation, `_label()` helper. |
|
||||
| `lib/features/home/presentation/home_screen.dart` | HomeScreen with AppBar containing `SortDropdown` | VERIFIED | `Scaffold(appBar: AppBar(title: Text(l10n.tabHome), actions: const [SortDropdown()]))`. Existing Stack body preserved. |
|
||||
| `lib/features/tasks/presentation/task_list_screen.dart` | TaskListScreen AppBar with `SortDropdown` before edit/delete | VERIFIED | `actions: [const SortDropdown(), IconButton(edit), IconButton(delete)]`. Correct order. |
|
||||
|
||||
---
|
||||
|
||||
## Key Link Verification
|
||||
|
||||
### Plan 07-01 Key Links
|
||||
|
||||
| From | To | Via | Status | Details |
|
||||
|------|----|-----|--------|---------|
|
||||
| `calendar_providers.dart` | `sortPreferenceProvider` | `ref.watch(sortPreferenceProvider)` in `calendarDayProvider` | WIRED | Line 77: `final sortOption = ref.watch(sortPreferenceProvider);`. Applied at line 101: `dayTasks: _sortTasks(dayTasks, sortOption)`. |
|
||||
| `task_providers.dart` | `sortPreferenceProvider` | `ref.watch(sortPreferenceProvider)` in `tasksInRoomProvider` | WIRED | Line 43: `final sortOption = ref.watch(sortPreferenceProvider);`. Applied at lines 44-46 via `stream.map`. |
|
||||
|
||||
### Plan 07-02 Key Links
|
||||
|
||||
| From | To | Via | Status | Details |
|
||||
|------|----|-----|--------|---------|
|
||||
| `sort_dropdown.dart` | `sortPreferenceProvider` | `ref.watch` for display, `ref.read` for mutation | WIRED | Line 21: `ref.watch(sortPreferenceProvider)`. Line 27: `ref.read(sortPreferenceProvider.notifier).setSortOption(value)`. |
|
||||
| `home_screen.dart` | `sort_dropdown.dart` | `SortDropdown` widget in AppBar actions | WIRED | Import on line 7. Used in `AppBar(actions: const [SortDropdown()])` on line 37. |
|
||||
| `task_list_screen.dart` | `sort_dropdown.dart` | `SortDropdown` widget in AppBar actions | WIRED | Import on line 7. Used in `actions: [const SortDropdown(), ...]` on line 31. |
|
||||
|
||||
---
|
||||
|
||||
## Requirements Coverage
|
||||
|
||||
| Requirement | Source Plan | Description | Status | Evidence |
|
||||
|-------------|-------------|-------------|--------|----------|
|
||||
| SORT-01 | 07-01, 07-02 | User can sort tasks alphabetically | SATISFIED | `TaskSortOption.alphabetical` is the default. `_sortTasks()` and `_sortTasksRaw()` implement case-insensitive A-Z sort. `SortDropdown` displays "A–Z" label (l10n). |
|
||||
| SORT-02 | 07-01, 07-02 | User can sort tasks by frequency interval | SATISFIED | `TaskSortOption.interval` sort implemented: `intervalType.index` ascending with `intervalDays` tiebreaker. Displayed as "Intervall" in `SortDropdown`. |
|
||||
| SORT-03 | 07-01, 07-02 | User can sort tasks by effort level | SATISFIED | `TaskSortOption.effort` sort implemented: `effortLevel.index` ascending (low=0, medium=1, high=2). Displayed as "Aufwand" in `SortDropdown`. |
|
||||
|
||||
No orphaned requirements. All three SORT requirements are claimed by both plans and fully implemented.
|
||||
|
||||
---
|
||||
|
||||
## Anti-Patterns Found
|
||||
|
||||
None. All seven implementation files scanned — no TODO, FIXME, XXX, HACK, PLACEHOLDER, return null, return {}, return [], or empty arrow functions found.
|
||||
|
||||
---
|
||||
|
||||
## Human Verification Required
|
||||
|
||||
### 1. Visual check: Sort dropdown appearance in AppBar
|
||||
|
||||
**Test:** Launch the app, navigate to HomeScreen. Verify the AppBar shows a sort icon (Icons.sort) followed by the current sort label text "A–Z".
|
||||
**Expected:** Sort icon and "A–Z" text visible in the top-right AppBar area.
|
||||
**Why human:** Widget rendering and visual layout cannot be verified programmatically.
|
||||
|
||||
### 2. Popup menu interaction: Check marks on active option
|
||||
|
||||
**Test:** Tap the sort dropdown, verify three items appear with a check mark next to the currently selected option and no check mark on the other two.
|
||||
**Expected:** Check mark visible on "A–Z" (default), invisible (but space-preserving) on "Intervall" and "Aufwand".
|
||||
**Why human:** Opacity(0) vs Opacity(1) rendering and visual alignment cannot be verified with grep.
|
||||
|
||||
### 3. Reactive reorder on selection
|
||||
|
||||
**Test:** With tasks loaded in HomeScreen, tap the sort dropdown and select "Aufwand". Verify the task list reorders immediately without a page reload.
|
||||
**Expected:** Task list updates instantly, sorted low-effort first.
|
||||
**Why human:** Real-time Riverpod reactive rebuild requires a running app to observe.
|
||||
|
||||
### 4. Cross-screen persistence of sort preference
|
||||
|
||||
**Test:** Select "Intervall" in HomeScreen, then navigate to a room's TaskListScreen. Verify the sort dropdown there also shows "Intervall".
|
||||
**Expected:** Sort preference is shared across screens (same `sortPreferenceProvider`, `keepAlive: true`).
|
||||
**Why human:** Cross-screen navigation state cannot be verified statically.
|
||||
|
||||
---
|
||||
|
||||
## Gaps Summary
|
||||
|
||||
None. All 9 observable truths verified. All artifacts exist, are substantive, and are correctly wired. All 3 requirements (SORT-01, SORT-02, SORT-03) are fully satisfied. All 5 commits (a9f2983, 13c7d62, 3697e4e, e5eccb7, a3e4d02) confirmed present in git log. No anti-patterns detected in implementation files.
|
||||
|
||||
The phase delivers its stated goal: users can reorder task lists by name (A–Z), frequency interval, or effort level via a persistent, reactive sort preference accessible from both HomeScreen and TaskListScreen AppBars.
|
||||
|
||||
---
|
||||
|
||||
_Verified: 2026-03-16T22:00:00Z_
|
||||
_Verifier: Claude (gsd-verifier)_
|
||||
@@ -45,6 +45,16 @@ class CalendarDao extends DatabaseAccessor<AppDatabase>
|
||||
});
|
||||
}
|
||||
|
||||
/// Returns the total count of tasks across all rooms and dates.
|
||||
///
|
||||
/// Used by the UI to distinguish first-run empty state from celebration state.
|
||||
Future<int> getTaskCount() async {
|
||||
final countExp = tasks.id.count();
|
||||
final query = selectOnly(tasks)..addColumns([countExp]);
|
||||
final result = await query.getSingle();
|
||||
return result.read(countExp) ?? 0;
|
||||
}
|
||||
|
||||
/// Watch tasks whose [nextDueDate] is strictly before [referenceDate].
|
||||
///
|
||||
/// Returns tasks sorted by [nextDueDate] ascending (oldest first).
|
||||
|
||||
@@ -6,10 +6,16 @@ class CalendarDayState {
|
||||
final List<TaskWithRoom> dayTasks;
|
||||
final List<TaskWithRoom> overdueTasks;
|
||||
|
||||
/// Total number of tasks in the database (across all days/rooms).
|
||||
/// Used by the UI to distinguish first-run empty state (no tasks exist at all)
|
||||
/// from celebration state (tasks exist but today's are all done).
|
||||
final int totalTaskCount;
|
||||
|
||||
const CalendarDayState({
|
||||
required this.selectedDate,
|
||||
required this.dayTasks,
|
||||
required this.overdueTasks,
|
||||
required this.totalTaskCount,
|
||||
});
|
||||
|
||||
/// True when both day tasks and overdue tasks are empty.
|
||||
|
||||
310
lib/features/home/presentation/calendar_day_list.dart
Normal file
310
lib/features/home/presentation/calendar_day_list.dart
Normal file
@@ -0,0 +1,310 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'package:household_keeper/features/home/domain/daily_plan_models.dart';
|
||||
import 'package:household_keeper/features/home/domain/calendar_models.dart';
|
||||
import 'package:household_keeper/features/home/presentation/calendar_providers.dart';
|
||||
import 'package:household_keeper/features/home/presentation/calendar_task_row.dart';
|
||||
import 'package:household_keeper/features/tasks/presentation/task_providers.dart';
|
||||
import 'package:household_keeper/l10n/app_localizations.dart';
|
||||
|
||||
/// Warm coral/terracotta color for overdue section header.
|
||||
const _overdueColor = Color(0xFFE07A5F);
|
||||
|
||||
/// Shows the task list for the selected calendar day.
|
||||
///
|
||||
/// Watches [calendarDayProvider] and renders one of several states:
|
||||
/// - Loading spinner while data loads
|
||||
/// - Error text on failure
|
||||
/// - First-run empty state (no rooms/tasks at all) — prompts to create a room
|
||||
/// - Empty day state (tasks exist elsewhere but not this day)
|
||||
/// - Celebration state (today is selected and all tasks are done)
|
||||
/// - Has-tasks state with optional overdue section (today only) and checkboxes
|
||||
class CalendarDayList extends ConsumerStatefulWidget {
|
||||
const CalendarDayList({super.key});
|
||||
|
||||
@override
|
||||
ConsumerState<CalendarDayList> createState() => _CalendarDayListState();
|
||||
}
|
||||
|
||||
class _CalendarDayListState extends ConsumerState<CalendarDayList> {
|
||||
/// Task IDs currently animating out after completion.
|
||||
final Set<int> _completingTaskIds = {};
|
||||
|
||||
void _onTaskCompleted(int taskId) {
|
||||
setState(() {
|
||||
_completingTaskIds.add(taskId);
|
||||
});
|
||||
ref.read(taskActionsProvider.notifier).completeTask(taskId);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final theme = Theme.of(context);
|
||||
final dayState = ref.watch(calendarDayProvider);
|
||||
|
||||
return dayState.when(
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error: (error, _) => Center(child: Text(error.toString())),
|
||||
data: (state) {
|
||||
// Clean up animation IDs for tasks that are no longer in the data.
|
||||
_completingTaskIds.removeWhere((id) =>
|
||||
!state.overdueTasks.any((t) => t.task.id == id) &&
|
||||
!state.dayTasks.any((t) => t.task.id == id));
|
||||
|
||||
return _buildContent(context, state, l10n, theme);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContent(
|
||||
BuildContext context,
|
||||
CalendarDayState state,
|
||||
AppLocalizations l10n,
|
||||
ThemeData theme,
|
||||
) {
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
final isToday = state.selectedDate == today;
|
||||
|
||||
// State (a): First-run empty — no tasks exist at all in the database.
|
||||
if (state.isEmpty && state.totalTaskCount == 0) {
|
||||
return _buildFirstRunEmpty(context, l10n, theme);
|
||||
}
|
||||
|
||||
// State (e): Celebration — today is selected and all tasks are done
|
||||
// (totalTaskCount > 0 so at least some task exists somewhere, but today
|
||||
// has none remaining after completion).
|
||||
if (isToday && state.dayTasks.isEmpty && state.overdueTasks.isEmpty && state.totalTaskCount > 0) {
|
||||
return _buildCelebration(l10n, theme);
|
||||
}
|
||||
|
||||
// State (d): Empty day — tasks exist elsewhere but not this day.
|
||||
if (state.isEmpty) {
|
||||
return _buildEmptyDay(theme);
|
||||
}
|
||||
|
||||
// State (f): Has tasks — render overdue section (today only) + day tasks.
|
||||
return _buildTaskList(state, l10n, theme);
|
||||
}
|
||||
|
||||
/// First-run: no rooms/tasks created yet.
|
||||
Widget _buildFirstRunEmpty(
|
||||
BuildContext context,
|
||||
AppLocalizations l10n,
|
||||
ThemeData theme,
|
||||
) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.checklist_rounded,
|
||||
size: 80,
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.4),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
l10n.dailyPlanNoTasks,
|
||||
style: theme.textTheme.headlineSmall,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
l10n.homeEmptyMessage,
|
||||
style: theme.textTheme.bodyLarge?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
FilledButton.tonal(
|
||||
onPressed: () => context.go('/rooms'),
|
||||
child: Text(l10n.homeEmptyAction),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Celebration state: today is selected and all tasks are done.
|
||||
Widget _buildCelebration(AppLocalizations l10n, ThemeData theme) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.celebration_outlined,
|
||||
size: 80,
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.4),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
l10n.dailyPlanAllClearTitle,
|
||||
style: theme.textTheme.headlineSmall,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
l10n.dailyPlanAllClearMessage,
|
||||
style: theme.textTheme.bodyLarge?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Empty day: tasks exist elsewhere but nothing scheduled for this day.
|
||||
Widget _buildEmptyDay(ThemeData theme) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.event_available,
|
||||
size: 48,
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.3),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
'Keine Aufgaben',
|
||||
style: theme.textTheme.bodyLarge?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.5),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Task list with optional overdue section.
|
||||
Widget _buildTaskList(
|
||||
CalendarDayState state,
|
||||
AppLocalizations l10n,
|
||||
ThemeData theme,
|
||||
) {
|
||||
final items = <Widget>[];
|
||||
|
||||
// Overdue section (today only, when overdue tasks exist).
|
||||
if (state.overdueTasks.isNotEmpty) {
|
||||
items.add(_buildSectionHeader(l10n.dailyPlanSectionOverdue, theme,
|
||||
color: _overdueColor));
|
||||
for (final tw in state.overdueTasks) {
|
||||
items.add(_buildAnimatedTaskRow(tw, isOverdue: true));
|
||||
}
|
||||
}
|
||||
|
||||
// Day tasks section.
|
||||
for (final tw in state.dayTasks) {
|
||||
items.add(_buildAnimatedTaskRow(tw, isOverdue: false));
|
||||
}
|
||||
|
||||
return ListView(children: items);
|
||||
}
|
||||
|
||||
Widget _buildSectionHeader(
|
||||
String title,
|
||||
ThemeData theme, {
|
||||
required Color color,
|
||||
}) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: Text(
|
||||
title,
|
||||
style: theme.textTheme.titleMedium?.copyWith(color: color),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAnimatedTaskRow(TaskWithRoom tw, {required bool isOverdue}) {
|
||||
final isCompleting = _completingTaskIds.contains(tw.task.id);
|
||||
|
||||
if (isCompleting) {
|
||||
return _CompletingTaskRow(
|
||||
key: ValueKey('completing-${tw.task.id}'),
|
||||
taskWithRoom: tw,
|
||||
isOverdue: isOverdue,
|
||||
);
|
||||
}
|
||||
|
||||
return CalendarTaskRow(
|
||||
key: ValueKey('task-${tw.task.id}'),
|
||||
taskWithRoom: tw,
|
||||
isOverdue: isOverdue,
|
||||
onCompleted: () => _onTaskCompleted(tw.task.id),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A task row that animates (slide + size) to zero height on completion.
|
||||
class _CompletingTaskRow extends StatefulWidget {
|
||||
const _CompletingTaskRow({
|
||||
super.key,
|
||||
required this.taskWithRoom,
|
||||
required this.isOverdue,
|
||||
});
|
||||
|
||||
final TaskWithRoom taskWithRoom;
|
||||
final bool isOverdue;
|
||||
|
||||
@override
|
||||
State<_CompletingTaskRow> createState() => _CompletingTaskRowState();
|
||||
}
|
||||
|
||||
class _CompletingTaskRowState extends State<_CompletingTaskRow>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final AnimationController _controller;
|
||||
late final Animation<double> _sizeAnimation;
|
||||
late final Animation<Offset> _slideAnimation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
vsync: this,
|
||||
);
|
||||
_sizeAnimation = Tween<double>(begin: 1.0, end: 0.0).animate(
|
||||
CurvedAnimation(parent: _controller, curve: Curves.easeInOut),
|
||||
);
|
||||
_slideAnimation = Tween<Offset>(
|
||||
begin: Offset.zero,
|
||||
end: const Offset(1.0, 0.0),
|
||||
).animate(
|
||||
CurvedAnimation(parent: _controller, curve: Curves.easeInOut),
|
||||
);
|
||||
_controller.forward();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizeTransition(
|
||||
sizeFactor: _sizeAnimation,
|
||||
child: SlideTransition(
|
||||
position: _slideAnimation,
|
||||
child: CalendarTaskRow(
|
||||
taskWithRoom: widget.taskWithRoom,
|
||||
isOverdue: widget.isOverdue,
|
||||
onCompleted: () {}, // Already completing — ignore repeat taps.
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:household_keeper/core/providers/database_provider.dart';
|
||||
import 'package:household_keeper/features/home/domain/calendar_models.dart';
|
||||
import 'package:household_keeper/features/home/domain/daily_plan_models.dart';
|
||||
import 'package:household_keeper/features/tasks/domain/task_sort_option.dart';
|
||||
import 'package:household_keeper/features/tasks/presentation/sort_preference_notifier.dart';
|
||||
|
||||
/// Notifier that manages the currently selected date in the calendar strip.
|
||||
///
|
||||
@@ -27,17 +29,52 @@ final selectedDateProvider =
|
||||
SelectedDateNotifier.new,
|
||||
);
|
||||
|
||||
/// Sort a list of [TaskWithRoom] by the given [sortOption].
|
||||
///
|
||||
/// Returns a new sorted list; never mutates the original.
|
||||
/// Only [dayTasks] are sorted — the overdue section stays in its existing
|
||||
/// order per user decision.
|
||||
List<TaskWithRoom> _sortTasks(
|
||||
List<TaskWithRoom> tasks,
|
||||
TaskSortOption sortOption,
|
||||
) {
|
||||
final sorted = List<TaskWithRoom>.from(tasks);
|
||||
switch (sortOption) {
|
||||
case TaskSortOption.alphabetical:
|
||||
sorted.sort((a, b) => a.task.name.toLowerCase().compareTo(
|
||||
b.task.name.toLowerCase(),
|
||||
));
|
||||
case TaskSortOption.interval:
|
||||
sorted.sort((a, b) {
|
||||
final cmp = a.task.intervalType.index.compareTo(
|
||||
b.task.intervalType.index,
|
||||
);
|
||||
if (cmp != 0) return cmp;
|
||||
return a.task.intervalDays.compareTo(b.task.intervalDays);
|
||||
});
|
||||
case TaskSortOption.effort:
|
||||
sorted.sort((a, b) => a.task.effortLevel.index.compareTo(
|
||||
b.task.effortLevel.index,
|
||||
));
|
||||
}
|
||||
return sorted;
|
||||
}
|
||||
|
||||
/// Reactive calendar day state: tasks for the selected date + overdue tasks.
|
||||
///
|
||||
/// Overdue tasks are only included when the selected date is today.
|
||||
/// Past and future dates show only tasks originally due on that day.
|
||||
///
|
||||
/// dayTasks are sorted in-memory according to the active [sortPreferenceProvider].
|
||||
/// overdueTasks retain their existing order (pinned at top, unsorted per design).
|
||||
///
|
||||
/// Defined manually (not @riverpod) because riverpod_generator has trouble
|
||||
/// with drift's generated [Task] type. Same pattern as [dailyPlanProvider].
|
||||
final calendarDayProvider =
|
||||
StreamProvider.autoDispose<CalendarDayState>((ref) {
|
||||
final db = ref.watch(appDatabaseProvider);
|
||||
final selectedDate = ref.watch(selectedDateProvider);
|
||||
final sortOption = ref.watch(sortPreferenceProvider);
|
||||
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
@@ -57,10 +94,13 @@ final calendarDayProvider =
|
||||
overdueTasks = const [];
|
||||
}
|
||||
|
||||
final totalTaskCount = await db.calendarDao.getTaskCount();
|
||||
|
||||
return CalendarDayState(
|
||||
selectedDate: selectedDate,
|
||||
dayTasks: dayTasks,
|
||||
dayTasks: _sortTasks(dayTasks, sortOption),
|
||||
overdueTasks: overdueTasks,
|
||||
totalTaskCount: totalTaskCount,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
348
lib/features/home/presentation/calendar_strip.dart
Normal file
348
lib/features/home/presentation/calendar_strip.dart
Normal file
@@ -0,0 +1,348 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:household_keeper/features/home/presentation/calendar_providers.dart';
|
||||
|
||||
/// Number of days in the past and future to show in the strip.
|
||||
const _kPastDays = 90;
|
||||
const _kFutureDays = 90;
|
||||
|
||||
/// Total number of day cards in the strip.
|
||||
const _kTotalDays = _kPastDays + 1 + _kFutureDays;
|
||||
|
||||
/// Fixed card width and height for each day card.
|
||||
const _kCardWidth = 56.0;
|
||||
const _kCardHeight = 72.0;
|
||||
|
||||
/// Default horizontal margin between cards.
|
||||
const _kCardMargin = 4.0;
|
||||
|
||||
/// Wider gap inserted at month boundaries (left side margin of the first-of-month card).
|
||||
const _kMonthBoundaryGap = 16.0;
|
||||
|
||||
/// Controller that allows external code (e.g. the Today button) to trigger
|
||||
/// a scroll-to-today animation on the strip.
|
||||
class CalendarStripController {
|
||||
VoidCallback? _scrollToToday;
|
||||
|
||||
/// Animate the strip to center today's card.
|
||||
void scrollToToday() => _scrollToToday?.call();
|
||||
}
|
||||
|
||||
/// A horizontal scrollable strip of day cards spanning [_kPastDays] days in the
|
||||
/// past and [_kFutureDays] days in the future.
|
||||
///
|
||||
/// Each card shows:
|
||||
/// - German day abbreviation (Mo, Di, Mi, Do, Fr, Sa, So)
|
||||
/// - Date number (day of month)
|
||||
///
|
||||
/// The selected card is highlighted and always centered.
|
||||
/// Today's card uses bold text + an accent underline bar.
|
||||
/// Month boundaries get a wider gap and a small month label.
|
||||
class CalendarStrip extends ConsumerStatefulWidget {
|
||||
const CalendarStrip({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.onTodayVisibilityChanged,
|
||||
});
|
||||
|
||||
/// Controller for programmatic scroll-to-today.
|
||||
final CalendarStripController controller;
|
||||
|
||||
/// Called when today's card enters or leaves the viewport.
|
||||
final ValueChanged<bool> onTodayVisibilityChanged;
|
||||
|
||||
@override
|
||||
ConsumerState<CalendarStrip> createState() => _CalendarStripState();
|
||||
}
|
||||
|
||||
class _CalendarStripState extends ConsumerState<CalendarStrip> {
|
||||
late final ScrollController _scrollController;
|
||||
late final DateTime _today;
|
||||
late final List<DateTime> _dates;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
final now = DateTime.now();
|
||||
_today = DateTime(now.year, now.month, now.day);
|
||||
|
||||
// Build the date list: _kPastDays before today, today, _kFutureDays after.
|
||||
_dates = List.generate(
|
||||
_kTotalDays,
|
||||
(i) => _today.subtract(Duration(days: _kPastDays - i)),
|
||||
);
|
||||
|
||||
// Calculate initial scroll offset so today's card is centered.
|
||||
_scrollController = ScrollController(
|
||||
initialScrollOffset: _offsetForIndex(_kPastDays),
|
||||
);
|
||||
|
||||
_scrollController.addListener(_onScroll);
|
||||
|
||||
// Register the scroll-to-today callback on the controller.
|
||||
widget.controller._scrollToToday = _animateToToday;
|
||||
|
||||
// After first frame, animate to center today with a short delay so the
|
||||
// strip has laid out its children.
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
_animateToToday();
|
||||
// Initial visibility check
|
||||
_onScroll();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_scrollController.removeListener(_onScroll);
|
||||
_scrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// Returns the scroll offset that centers the card at [index].
|
||||
double _offsetForIndex(int index) {
|
||||
// Sum the widths of all items before [index], then subtract half the viewport
|
||||
// width so the card is centered. We approximate viewport as screen width
|
||||
// because we cannot access it here; we compensate in the post-frame callback.
|
||||
double offset = 0;
|
||||
for (int i = 0; i < index; i++) {
|
||||
offset += _itemWidth(i);
|
||||
}
|
||||
// Center by subtracting half the card container width (will be corrected post-frame).
|
||||
return offset;
|
||||
}
|
||||
|
||||
/// Returns the total width occupied by the item at [index], including margins
|
||||
/// and any month-boundary gap on its left side.
|
||||
double _itemWidth(int index) {
|
||||
final date = _dates[index];
|
||||
final leftMargin = _isFirstOfMonth(date) && index > 0
|
||||
? _kMonthBoundaryGap
|
||||
: _kCardMargin;
|
||||
// Each item = leftMargin + card width + rightMargin
|
||||
return leftMargin + _kCardWidth + _kCardMargin;
|
||||
}
|
||||
|
||||
bool _isFirstOfMonth(DateTime date) => date.day == 1;
|
||||
|
||||
void _animateToToday() {
|
||||
if (!mounted || !_scrollController.hasClients) return;
|
||||
final viewportWidth = _scrollController.position.viewportDimension;
|
||||
double targetOffset = 0;
|
||||
for (int i = 0; i < _kPastDays; i++) {
|
||||
targetOffset += _itemWidth(i);
|
||||
}
|
||||
// Center today's card in the viewport.
|
||||
targetOffset -= (viewportWidth - _kCardWidth) / 2;
|
||||
targetOffset = targetOffset.clamp(
|
||||
_scrollController.position.minScrollExtent,
|
||||
_scrollController.position.maxScrollExtent,
|
||||
);
|
||||
_scrollController.animateTo(
|
||||
targetOffset,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeOut,
|
||||
);
|
||||
}
|
||||
|
||||
void _animateToIndex(int index) {
|
||||
if (!mounted || !_scrollController.hasClients) return;
|
||||
final viewportWidth = _scrollController.position.viewportDimension;
|
||||
double targetOffset = 0;
|
||||
for (int i = 0; i < index; i++) {
|
||||
targetOffset += _itemWidth(i);
|
||||
}
|
||||
targetOffset -= (viewportWidth - _kCardWidth) / 2;
|
||||
targetOffset = targetOffset.clamp(
|
||||
_scrollController.position.minScrollExtent,
|
||||
_scrollController.position.maxScrollExtent,
|
||||
);
|
||||
_scrollController.animateTo(
|
||||
targetOffset,
|
||||
duration: const Duration(milliseconds: 250),
|
||||
curve: Curves.easeOut,
|
||||
);
|
||||
}
|
||||
|
||||
void _onScroll() {
|
||||
if (!mounted || !_scrollController.hasClients) return;
|
||||
final viewportWidth = _scrollController.position.viewportDimension;
|
||||
final scrollOffset = _scrollController.offset;
|
||||
|
||||
// Calculate the left edge of today's card.
|
||||
double todayLeftEdge = 0;
|
||||
for (int i = 0; i < _kPastDays; i++) {
|
||||
todayLeftEdge += _itemWidth(i);
|
||||
}
|
||||
final todayRightEdge = todayLeftEdge + _kCardWidth;
|
||||
|
||||
// Today is visible if any part of the card is in the viewport.
|
||||
final isVisible =
|
||||
todayRightEdge > scrollOffset &&
|
||||
todayLeftEdge < scrollOffset + viewportWidth;
|
||||
|
||||
widget.onTodayVisibilityChanged(isVisible);
|
||||
}
|
||||
|
||||
void _onCardTapped(int index) {
|
||||
final tappedDate = _dates[index];
|
||||
ref.read(selectedDateProvider.notifier).selectDate(tappedDate);
|
||||
_animateToIndex(index);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final selectedDate = ref.watch(selectedDateProvider);
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return SizedBox(
|
||||
height: _kCardHeight + 24, // extra height for month label
|
||||
child: ListView.builder(
|
||||
controller: _scrollController,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: _kTotalDays,
|
||||
itemBuilder: (context, index) {
|
||||
final date = _dates[index];
|
||||
final isToday = date == _today;
|
||||
final isSelected = date == selectedDate;
|
||||
final isFirstOfMonth = _isFirstOfMonth(date) && index > 0;
|
||||
|
||||
return _DayCardItem(
|
||||
date: date,
|
||||
isToday: isToday,
|
||||
isSelected: isSelected,
|
||||
isFirstOfMonth: isFirstOfMonth,
|
||||
onTap: () => _onCardTapped(index),
|
||||
theme: theme,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A single day card in the calendar strip, with optional month boundary label.
|
||||
class _DayCardItem extends StatelessWidget {
|
||||
const _DayCardItem({
|
||||
required this.date,
|
||||
required this.isToday,
|
||||
required this.isSelected,
|
||||
required this.isFirstOfMonth,
|
||||
required this.onTap,
|
||||
required this.theme,
|
||||
});
|
||||
|
||||
final DateTime date;
|
||||
final bool isToday;
|
||||
final bool isSelected;
|
||||
final bool isFirstOfMonth;
|
||||
final VoidCallback onTap;
|
||||
final ThemeData theme;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final leftMargin = isFirstOfMonth ? _kMonthBoundaryGap : _kCardMargin;
|
||||
|
||||
// Card background color: selected gets full primaryContainer, others get
|
||||
// a subtle tint of primaryContainer.
|
||||
final bgColor = isSelected
|
||||
? theme.colorScheme.primaryContainer
|
||||
: theme.colorScheme.primaryContainer.withValues(alpha: 0.3);
|
||||
|
||||
// Border: selected card gets a primary color border.
|
||||
final border = isSelected
|
||||
? Border.all(color: theme.colorScheme.primary, width: 1.5)
|
||||
: null;
|
||||
|
||||
// Text weight: today uses bold.
|
||||
final fontWeight = isToday ? FontWeight.bold : FontWeight.normal;
|
||||
|
||||
// Day abbreviation (German locale): Mo, Di, Mi, Do, Fr, Sa, So
|
||||
final dayAbbr = DateFormat('E', 'de').format(date);
|
||||
// Date number
|
||||
final dayNum = date.day.toString();
|
||||
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// Month label at boundary
|
||||
if (isFirstOfMonth)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(left: leftMargin),
|
||||
child: SizedBox(
|
||||
width: _kCardWidth + _kCardMargin,
|
||||
child: Text(
|
||||
DateFormat('MMM', 'de').format(date),
|
||||
style: theme.textTheme.labelSmall?.copyWith(
|
||||
color: theme.colorScheme.primary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
const SizedBox(height: 16), // Reserve space for month label row
|
||||
|
||||
// Day card
|
||||
GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
width: _kCardWidth,
|
||||
height: _kCardHeight,
|
||||
margin: EdgeInsets.only(left: leftMargin, right: _kCardMargin),
|
||||
decoration: BoxDecoration(
|
||||
color: bgColor,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: border,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
// German day abbreviation
|
||||
Text(
|
||||
dayAbbr,
|
||||
style: theme.textTheme.labelSmall?.copyWith(
|
||||
fontWeight: fontWeight,
|
||||
color: isSelected
|
||||
? theme.colorScheme.onPrimaryContainer
|
||||
: theme.colorScheme.onSurface.withValues(alpha: 0.7),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
// Date number
|
||||
Text(
|
||||
dayNum,
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
fontWeight: fontWeight,
|
||||
color: isSelected
|
||||
? theme.colorScheme.onPrimaryContainer
|
||||
: theme.colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
// Today accent underline bar
|
||||
const SizedBox(height: 4),
|
||||
if (isToday)
|
||||
Container(
|
||||
width: 20,
|
||||
height: 2,
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.primary,
|
||||
borderRadius: BorderRadius.circular(1),
|
||||
),
|
||||
)
|
||||
else
|
||||
const SizedBox(height: 2),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
72
lib/features/home/presentation/calendar_task_row.dart
Normal file
72
lib/features/home/presentation/calendar_task_row.dart
Normal file
@@ -0,0 +1,72 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'package:household_keeper/features/home/domain/daily_plan_models.dart';
|
||||
|
||||
/// Warm coral/terracotta color for overdue task name text.
|
||||
const _overdueColor = Color(0xFFE07A5F);
|
||||
|
||||
/// A task row adapted for the calendar day list.
|
||||
///
|
||||
/// Shows task name, a tappable room tag (navigates to room task list),
|
||||
/// and an interactive checkbox. Does NOT show a relative date — the
|
||||
/// calendar strip already communicates which day is selected.
|
||||
///
|
||||
/// When [isOverdue] is true the task name uses coral text to visually
|
||||
/// distinguish overdue carry-over from today's regular tasks.
|
||||
class CalendarTaskRow extends StatelessWidget {
|
||||
const CalendarTaskRow({
|
||||
super.key,
|
||||
required this.taskWithRoom,
|
||||
required this.onCompleted,
|
||||
this.isOverdue = false,
|
||||
});
|
||||
|
||||
final TaskWithRoom taskWithRoom;
|
||||
|
||||
/// Called when the user checks the checkbox.
|
||||
final VoidCallback onCompleted;
|
||||
|
||||
/// When true, task name is rendered in coral color.
|
||||
final bool isOverdue;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final task = taskWithRoom.task;
|
||||
|
||||
return ListTile(
|
||||
onTap: () => context.go(
|
||||
'/rooms/${taskWithRoom.roomId}/tasks/${taskWithRoom.task.id}',
|
||||
),
|
||||
leading: Checkbox(
|
||||
value: false,
|
||||
onChanged: (_) => onCompleted(),
|
||||
),
|
||||
title: Text(
|
||||
task.name,
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
color: isOverdue ? _overdueColor : null,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
subtitle: GestureDetector(
|
||||
onTap: () => context.go('/rooms/${taskWithRoom.roomId}'),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: theme.colorScheme.secondaryContainer,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
taskWithRoom.roomName,
|
||||
style: theme.textTheme.labelSmall?.copyWith(
|
||||
color: theme.colorScheme.onSecondaryContainer,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'package:household_keeper/features/home/domain/daily_plan_models.dart';
|
||||
import 'package:household_keeper/features/home/presentation/daily_plan_providers.dart';
|
||||
import 'package:household_keeper/features/home/presentation/daily_plan_task_row.dart';
|
||||
import 'package:household_keeper/features/home/presentation/progress_card.dart';
|
||||
import 'package:household_keeper/features/tasks/presentation/task_providers.dart';
|
||||
import 'package:household_keeper/features/home/presentation/calendar_day_list.dart';
|
||||
import 'package:household_keeper/features/home/presentation/calendar_providers.dart';
|
||||
import 'package:household_keeper/features/home/presentation/calendar_strip.dart';
|
||||
import 'package:household_keeper/features/tasks/presentation/sort_dropdown.dart';
|
||||
import 'package:household_keeper/l10n/app_localizations.dart';
|
||||
|
||||
/// Warm coral/terracotta color for overdue section header.
|
||||
const _overdueColor = Color(0xFFE07A5F);
|
||||
|
||||
/// The app's primary screen: daily plan showing what's due today,
|
||||
/// overdue tasks, and a preview of tomorrow.
|
||||
/// The app's primary screen: a horizontal calendar strip at the top with a
|
||||
/// day task list below.
|
||||
///
|
||||
/// Replaces the former placeholder with a full daily workflow:
|
||||
/// see what's due, check it off, feel progress.
|
||||
/// Replaces the former stacked overdue/today/tomorrow daily plan layout.
|
||||
/// Users navigate by tapping day cards to see that day's tasks.
|
||||
class HomeScreen extends ConsumerStatefulWidget {
|
||||
const HomeScreen({super.key});
|
||||
|
||||
@@ -25,364 +20,56 @@ class HomeScreen extends ConsumerStatefulWidget {
|
||||
}
|
||||
|
||||
class _HomeScreenState extends ConsumerState<HomeScreen> {
|
||||
/// Task IDs currently animating out after completion.
|
||||
final Set<int> _completingTaskIds = {};
|
||||
late final CalendarStripController _stripController =
|
||||
CalendarStripController();
|
||||
|
||||
void _onTaskCompleted(int taskId) {
|
||||
setState(() {
|
||||
_completingTaskIds.add(taskId);
|
||||
});
|
||||
ref.read(taskActionsProvider.notifier).completeTask(taskId);
|
||||
}
|
||||
/// Whether to show the floating "Heute" button.
|
||||
/// True when the user has scrolled away from today's card.
|
||||
bool _showTodayButton = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final theme = Theme.of(context);
|
||||
final dailyPlan = ref.watch(dailyPlanProvider);
|
||||
|
||||
return dailyPlan.when(
|
||||
loading: () => const Center(child: CircularProgressIndicator()),
|
||||
error: (error, _) => Center(child: Text(error.toString())),
|
||||
data: (state) {
|
||||
// Clean up completing IDs that are no longer in the data
|
||||
_completingTaskIds.removeWhere((id) =>
|
||||
!state.overdueTasks.any((t) => t.task.id == id) &&
|
||||
!state.todayTasks.any((t) => t.task.id == id));
|
||||
|
||||
return _buildDailyPlan(context, state, l10n, theme);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDailyPlan(
|
||||
BuildContext context,
|
||||
DailyPlanState state,
|
||||
AppLocalizations l10n,
|
||||
ThemeData theme,
|
||||
) {
|
||||
// Case a: No tasks at all (user hasn't created any rooms/tasks)
|
||||
if (state.totalTodayCount == 0 &&
|
||||
state.tomorrowTasks.isEmpty &&
|
||||
state.completedTodayCount == 0) {
|
||||
return _buildNoTasksState(l10n, theme);
|
||||
}
|
||||
|
||||
// Case b: All clear -- there WERE tasks today but all are done
|
||||
if (state.overdueTasks.isEmpty &&
|
||||
state.todayTasks.isEmpty &&
|
||||
state.completedTodayCount > 0 &&
|
||||
state.tomorrowTasks.isEmpty) {
|
||||
return _buildAllClearState(state, l10n, theme);
|
||||
}
|
||||
|
||||
// Case c: Nothing today, but stuff tomorrow -- show celebration + tomorrow
|
||||
if (state.overdueTasks.isEmpty &&
|
||||
state.todayTasks.isEmpty &&
|
||||
state.completedTodayCount == 0 &&
|
||||
state.tomorrowTasks.isNotEmpty) {
|
||||
return _buildAllClearWithTomorrow(state, l10n, theme);
|
||||
}
|
||||
|
||||
// Case b extended: all clear with tomorrow tasks
|
||||
if (state.overdueTasks.isEmpty &&
|
||||
state.todayTasks.isEmpty &&
|
||||
state.completedTodayCount > 0 &&
|
||||
state.tomorrowTasks.isNotEmpty) {
|
||||
return _buildAllClearWithTomorrow(state, l10n, theme);
|
||||
}
|
||||
|
||||
// Case d: Normal state -- tasks exist
|
||||
return _buildNormalState(state, l10n, theme);
|
||||
}
|
||||
|
||||
/// No tasks at all -- first-run empty state.
|
||||
Widget _buildNoTasksState(AppLocalizations l10n, ThemeData theme) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.checklist_rounded,
|
||||
size: 80,
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.4),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
l10n.dailyPlanNoTasks,
|
||||
style: theme.textTheme.headlineSmall,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
l10n.homeEmptyMessage,
|
||||
style: theme.textTheme.bodyLarge?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
FilledButton.tonal(
|
||||
onPressed: () => context.go('/rooms'),
|
||||
child: Text(l10n.homeEmptyAction),
|
||||
),
|
||||
],
|
||||
),
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(l10n.tabHome),
|
||||
actions: const [SortDropdown()],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// All tasks done, no tomorrow tasks -- celebration state.
|
||||
Widget _buildAllClearState(
|
||||
DailyPlanState state,
|
||||
AppLocalizations l10n,
|
||||
ThemeData theme,
|
||||
) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 32),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ProgressCard(
|
||||
completed: state.completedTodayCount,
|
||||
total: state.totalTodayCount,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Icon(
|
||||
Icons.celebration_outlined,
|
||||
size: 80,
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.4),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
l10n.dailyPlanAllClearTitle,
|
||||
style: theme.textTheme.headlineSmall,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
l10n.dailyPlanAllClearMessage,
|
||||
style: theme.textTheme.bodyLarge?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// All clear for today but tomorrow tasks exist.
|
||||
Widget _buildAllClearWithTomorrow(
|
||||
DailyPlanState state,
|
||||
AppLocalizations l10n,
|
||||
ThemeData theme,
|
||||
) {
|
||||
return ListView(
|
||||
children: [
|
||||
ProgressCard(
|
||||
completed: state.completedTodayCount,
|
||||
total: state.totalTodayCount,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Center(
|
||||
child: Column(
|
||||
body: Stack(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.celebration_outlined,
|
||||
size: 80,
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.4),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
l10n.dailyPlanAllClearTitle,
|
||||
style: theme.textTheme.headlineSmall,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
l10n.dailyPlanAllClearMessage,
|
||||
style: theme.textTheme.bodyLarge?.copyWith(
|
||||
color: theme.colorScheme.onSurface.withValues(alpha: 0.6),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
CalendarStrip(
|
||||
controller: _stripController,
|
||||
onTodayVisibilityChanged: (visible) {
|
||||
setState(() => _showTodayButton = !visible);
|
||||
},
|
||||
),
|
||||
const Expanded(child: CalendarDayList()),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
_buildTomorrowSection(state, l10n, theme),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// Normal state with overdue/today/tomorrow sections.
|
||||
Widget _buildNormalState(
|
||||
DailyPlanState state,
|
||||
AppLocalizations l10n,
|
||||
ThemeData theme,
|
||||
) {
|
||||
return ListView(
|
||||
children: [
|
||||
ProgressCard(
|
||||
completed: state.completedTodayCount,
|
||||
total: state.totalTodayCount,
|
||||
),
|
||||
// Overdue section (conditional)
|
||||
if (state.overdueTasks.isNotEmpty) ...[
|
||||
_buildSectionHeader(
|
||||
l10n.dailyPlanSectionOverdue,
|
||||
theme,
|
||||
color: _overdueColor,
|
||||
),
|
||||
...state.overdueTasks.map(
|
||||
(tw) => _buildAnimatedTaskRow(tw, showCheckbox: true),
|
||||
),
|
||||
],
|
||||
// Today section
|
||||
_buildSectionHeader(
|
||||
l10n.dailyPlanSectionToday,
|
||||
theme,
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
if (state.todayTasks.isEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: Text(
|
||||
l10n.dailyPlanAllClearMessage,
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
if (_showTodayButton)
|
||||
Positioned(
|
||||
bottom: 16,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Center(
|
||||
child: FloatingActionButton.extended(
|
||||
onPressed: () {
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
ref
|
||||
.read(selectedDateProvider.notifier)
|
||||
.selectDate(today);
|
||||
_stripController.scrollToToday();
|
||||
},
|
||||
icon: const Icon(Icons.today),
|
||||
label: Text(l10n.calendarTodayButton),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
...state.todayTasks.map(
|
||||
(tw) => _buildAnimatedTaskRow(tw, showCheckbox: true),
|
||||
),
|
||||
// Tomorrow section (conditional, collapsed)
|
||||
if (state.tomorrowTasks.isNotEmpty)
|
||||
_buildTomorrowSection(state, l10n, theme),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSectionHeader(
|
||||
String title,
|
||||
ThemeData theme, {
|
||||
required Color color,
|
||||
}) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: Text(
|
||||
title,
|
||||
style: theme.textTheme.titleMedium?.copyWith(color: color),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAnimatedTaskRow(
|
||||
TaskWithRoom tw, {
|
||||
required bool showCheckbox,
|
||||
}) {
|
||||
final isCompleting = _completingTaskIds.contains(tw.task.id);
|
||||
|
||||
if (isCompleting) {
|
||||
return _CompletingTaskRow(
|
||||
key: ValueKey('completing-${tw.task.id}'),
|
||||
taskWithRoom: tw,
|
||||
);
|
||||
}
|
||||
|
||||
return DailyPlanTaskRow(
|
||||
key: ValueKey('task-${tw.task.id}'),
|
||||
taskWithRoom: tw,
|
||||
showCheckbox: showCheckbox,
|
||||
onCompleted: () => _onTaskCompleted(tw.task.id),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTomorrowSection(
|
||||
DailyPlanState state,
|
||||
AppLocalizations l10n,
|
||||
ThemeData theme,
|
||||
) {
|
||||
return ExpansionTile(
|
||||
initiallyExpanded: false,
|
||||
title: Text(
|
||||
l10n.dailyPlanUpcomingCount(state.tomorrowTasks.length),
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
children: state.tomorrowTasks
|
||||
.map(
|
||||
(tw) => DailyPlanTaskRow(
|
||||
key: ValueKey('tomorrow-${tw.task.id}'),
|
||||
taskWithRoom: tw,
|
||||
showCheckbox: false,
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A task row that animates to zero height on completion.
|
||||
class _CompletingTaskRow extends StatefulWidget {
|
||||
const _CompletingTaskRow({
|
||||
super.key,
|
||||
required this.taskWithRoom,
|
||||
});
|
||||
|
||||
final TaskWithRoom taskWithRoom;
|
||||
|
||||
@override
|
||||
State<_CompletingTaskRow> createState() => _CompletingTaskRowState();
|
||||
}
|
||||
|
||||
class _CompletingTaskRowState extends State<_CompletingTaskRow>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late final AnimationController _controller;
|
||||
late final Animation<double> _sizeAnimation;
|
||||
late final Animation<Offset> _slideAnimation;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = AnimationController(
|
||||
duration: const Duration(milliseconds: 300),
|
||||
vsync: this,
|
||||
);
|
||||
_sizeAnimation = Tween<double>(begin: 1.0, end: 0.0).animate(
|
||||
CurvedAnimation(parent: _controller, curve: Curves.easeInOut),
|
||||
);
|
||||
_slideAnimation = Tween<Offset>(
|
||||
begin: Offset.zero,
|
||||
end: const Offset(1.0, 0.0),
|
||||
).animate(
|
||||
CurvedAnimation(parent: _controller, curve: Curves.easeInOut),
|
||||
);
|
||||
_controller.forward();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizeTransition(
|
||||
sizeFactor: _sizeAnimation,
|
||||
child: SlideTransition(
|
||||
position: _slideAnimation,
|
||||
child: DailyPlanTaskRow(
|
||||
taskWithRoom: widget.taskWithRoom,
|
||||
showCheckbox: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -81,6 +81,14 @@ class TasksDao extends DatabaseAccessor<AppDatabase> with _$TasksDaoMixin {
|
||||
});
|
||||
}
|
||||
|
||||
/// Watch all completions for a task, newest first.
|
||||
Stream<List<TaskCompletion>> watchCompletionsForTask(int taskId) {
|
||||
return (select(taskCompletions)
|
||||
..where((c) => c.taskId.equals(taskId))
|
||||
..orderBy([(c) => OrderingTerm.desc(c.completedAt)]))
|
||||
.watch();
|
||||
}
|
||||
|
||||
/// Count overdue tasks in a room (nextDueDate before today).
|
||||
Future<int> getOverdueTaskCount(int roomId, {DateTime? today}) async {
|
||||
final now = today ?? DateTime.now();
|
||||
|
||||
9
lib/features/tasks/domain/task_sort_option.dart
Normal file
9
lib/features/tasks/domain/task_sort_option.dart
Normal file
@@ -0,0 +1,9 @@
|
||||
/// Sort options for task lists.
|
||||
///
|
||||
/// Stored as a string in SharedPreferences (not as intEnum in the database),
|
||||
/// so reordering these values is safe.
|
||||
enum TaskSortOption {
|
||||
alphabetical, // A–Z by task name
|
||||
interval, // by frequency interval (most frequent first)
|
||||
effort, // by effort level (low → medium → high)
|
||||
}
|
||||
71
lib/features/tasks/presentation/sort_dropdown.dart
Normal file
71
lib/features/tasks/presentation/sort_dropdown.dart
Normal file
@@ -0,0 +1,71 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import 'package:household_keeper/features/tasks/domain/task_sort_option.dart';
|
||||
import 'package:household_keeper/features/tasks/presentation/sort_preference_notifier.dart';
|
||||
import 'package:household_keeper/l10n/app_localizations.dart';
|
||||
|
||||
/// A reusable sort dropdown widget for use in AppBar actions.
|
||||
///
|
||||
/// Displays the current sort option as a labelled button with a sort icon.
|
||||
/// Tapping opens a popup menu with three options: A–Z, Intervall, Aufwand.
|
||||
/// The active option is indicated with a visible check mark.
|
||||
///
|
||||
/// Reads sort state from [sortPreferenceProvider] and writes via
|
||||
/// [SortPreferenceNotifier.setSortOption].
|
||||
class SortDropdown extends ConsumerWidget {
|
||||
const SortDropdown({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final current = ref.watch(sortPreferenceProvider);
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return PopupMenuButton<TaskSortOption>(
|
||||
onSelected: (value) =>
|
||||
ref.read(sortPreferenceProvider.notifier).setSortOption(value),
|
||||
itemBuilder: (context) => TaskSortOption.values.map((option) {
|
||||
final isSelected = option == current;
|
||||
return PopupMenuItem<TaskSortOption>(
|
||||
value: option,
|
||||
child: Row(
|
||||
children: [
|
||||
Opacity(
|
||||
opacity: isSelected ? 1.0 : 0.0,
|
||||
child: const Icon(Icons.check, size: 18),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(_label(option, l10n)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(Icons.sort),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
_label(current, l10n),
|
||||
style: theme.textTheme.labelLarge,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _label(TaskSortOption option, AppLocalizations l10n) {
|
||||
switch (option) {
|
||||
case TaskSortOption.alphabetical:
|
||||
return l10n.sortAlphabetical;
|
||||
case TaskSortOption.interval:
|
||||
return l10n.sortInterval;
|
||||
case TaskSortOption.effort:
|
||||
return l10n.sortEffort;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'package:household_keeper/features/tasks/domain/task_sort_option.dart';
|
||||
|
||||
part 'sort_preference_notifier.g.dart';
|
||||
|
||||
const _sortOptionKey = 'task_sort_option';
|
||||
|
||||
/// Notifier that manages the active task sort preference.
|
||||
///
|
||||
/// Defaults to [TaskSortOption.alphabetical] synchronously (matching the
|
||||
/// existing A-Z sort in CalendarDayList), then loads the persisted value
|
||||
/// asynchronously on first build.
|
||||
///
|
||||
/// Follows the same pattern as [ThemeNotifier] in
|
||||
/// `lib/core/theme/theme_provider.dart`.
|
||||
@Riverpod(keepAlive: true)
|
||||
class SortPreferenceNotifier extends _$SortPreferenceNotifier {
|
||||
@override
|
||||
TaskSortOption build() {
|
||||
_loadPersisted();
|
||||
return TaskSortOption.alphabetical;
|
||||
}
|
||||
|
||||
Future<void> _loadPersisted() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final persisted = prefs.getString(_sortOptionKey);
|
||||
if (persisted != null) {
|
||||
state = _fromString(persisted);
|
||||
}
|
||||
}
|
||||
|
||||
/// Update the active sort preference and persist it.
|
||||
Future<void> setSortOption(TaskSortOption option) async {
|
||||
state = option;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setString(_sortOptionKey, _toString(option));
|
||||
}
|
||||
|
||||
static TaskSortOption _fromString(String value) {
|
||||
switch (value) {
|
||||
case 'alphabetical':
|
||||
return TaskSortOption.alphabetical;
|
||||
case 'interval':
|
||||
return TaskSortOption.interval;
|
||||
case 'effort':
|
||||
return TaskSortOption.effort;
|
||||
default:
|
||||
return TaskSortOption.alphabetical;
|
||||
}
|
||||
}
|
||||
|
||||
static String _toString(TaskSortOption option) {
|
||||
return option.name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'sort_preference_notifier.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint, type=warning
|
||||
/// Notifier that manages the active task sort preference.
|
||||
///
|
||||
/// Defaults to [TaskSortOption.alphabetical] synchronously (matching the
|
||||
/// existing A-Z sort in CalendarDayList), then loads the persisted value
|
||||
/// asynchronously on first build.
|
||||
///
|
||||
/// Follows the same pattern as [ThemeNotifier] in
|
||||
/// `lib/core/theme/theme_provider.dart`.
|
||||
|
||||
@ProviderFor(SortPreferenceNotifier)
|
||||
final sortPreferenceProvider = SortPreferenceNotifierProvider._();
|
||||
|
||||
/// Notifier that manages the active task sort preference.
|
||||
///
|
||||
/// Defaults to [TaskSortOption.alphabetical] synchronously (matching the
|
||||
/// existing A-Z sort in CalendarDayList), then loads the persisted value
|
||||
/// asynchronously on first build.
|
||||
///
|
||||
/// Follows the same pattern as [ThemeNotifier] in
|
||||
/// `lib/core/theme/theme_provider.dart`.
|
||||
final class SortPreferenceNotifierProvider
|
||||
extends $NotifierProvider<SortPreferenceNotifier, TaskSortOption> {
|
||||
/// Notifier that manages the active task sort preference.
|
||||
///
|
||||
/// Defaults to [TaskSortOption.alphabetical] synchronously (matching the
|
||||
/// existing A-Z sort in CalendarDayList), then loads the persisted value
|
||||
/// asynchronously on first build.
|
||||
///
|
||||
/// Follows the same pattern as [ThemeNotifier] in
|
||||
/// `lib/core/theme/theme_provider.dart`.
|
||||
SortPreferenceNotifierProvider._()
|
||||
: super(
|
||||
from: null,
|
||||
argument: null,
|
||||
retry: null,
|
||||
name: r'sortPreferenceProvider',
|
||||
isAutoDispose: false,
|
||||
dependencies: null,
|
||||
$allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
@override
|
||||
String debugGetCreateSourceHash() => _$sortPreferenceNotifierHash();
|
||||
|
||||
@$internal
|
||||
@override
|
||||
SortPreferenceNotifier create() => SortPreferenceNotifier();
|
||||
|
||||
/// {@macro riverpod.override_with_value}
|
||||
Override overrideWithValue(TaskSortOption value) {
|
||||
return $ProviderOverride(
|
||||
origin: this,
|
||||
providerOverride: $SyncValueProvider<TaskSortOption>(value),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String _$sortPreferenceNotifierHash() =>
|
||||
r'5d7f2c5d06b82b4114262ee05cf890ebe717fe2a';
|
||||
|
||||
/// Notifier that manages the active task sort preference.
|
||||
///
|
||||
/// Defaults to [TaskSortOption.alphabetical] synchronously (matching the
|
||||
/// existing A-Z sort in CalendarDayList), then loads the persisted value
|
||||
/// asynchronously on first build.
|
||||
///
|
||||
/// Follows the same pattern as [ThemeNotifier] in
|
||||
/// `lib/core/theme/theme_provider.dart`.
|
||||
|
||||
abstract class _$SortPreferenceNotifier extends $Notifier<TaskSortOption> {
|
||||
TaskSortOption build();
|
||||
@$mustCallSuper
|
||||
@override
|
||||
void runBuild() {
|
||||
final ref = this.ref as $Ref<TaskSortOption, TaskSortOption>;
|
||||
final element =
|
||||
ref.element
|
||||
as $ClassProviderElement<
|
||||
AnyNotifier<TaskSortOption, TaskSortOption>,
|
||||
TaskSortOption,
|
||||
Object?,
|
||||
Object?
|
||||
>;
|
||||
element.handleCreate(ref, build);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import '../../../core/providers/database_provider.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
import '../domain/effort_level.dart';
|
||||
import '../domain/frequency.dart';
|
||||
import 'task_history_sheet.dart';
|
||||
import 'task_providers.dart';
|
||||
|
||||
/// Full-screen form for task creation and editing.
|
||||
@@ -186,6 +187,21 @@ class _TaskFormScreenState extends ConsumerState<TaskFormScreen> {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
_buildDueDatePicker(theme),
|
||||
|
||||
// History section (edit mode only)
|
||||
if (widget.isEditing) ...[
|
||||
const SizedBox(height: 24),
|
||||
const Divider(),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.history),
|
||||
title: Text(l10n.taskHistoryTitle),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () => showTaskHistorySheet(
|
||||
context: context,
|
||||
taskId: widget.taskId!,
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
136
lib/features/tasks/presentation/task_history_sheet.dart
Normal file
136
lib/features/tasks/presentation/task_history_sheet.dart
Normal file
@@ -0,0 +1,136 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../../../core/database/database.dart';
|
||||
import '../../../core/providers/database_provider.dart';
|
||||
import '../../../l10n/app_localizations.dart';
|
||||
|
||||
/// Shows a modal bottom sheet displaying the completion history for a task.
|
||||
///
|
||||
/// The sheet displays all past completions in reverse-chronological order
|
||||
/// (newest first). If the task has never been completed, an empty state is shown.
|
||||
Future<void> showTaskHistorySheet({
|
||||
required BuildContext context,
|
||||
required int taskId,
|
||||
}) {
|
||||
return showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
builder: (context) => _TaskHistorySheet(taskId: taskId),
|
||||
);
|
||||
}
|
||||
|
||||
class _TaskHistorySheet extends ConsumerWidget {
|
||||
const _TaskHistorySheet({required this.taskId});
|
||||
|
||||
final int taskId;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
final theme = Theme.of(context);
|
||||
final colorScheme = theme.colorScheme;
|
||||
final l10n = AppLocalizations.of(context);
|
||||
|
||||
return SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
// Drag handle
|
||||
Container(
|
||||
width: 32,
|
||||
height: 4,
|
||||
margin: const EdgeInsets.only(bottom: 16),
|
||||
decoration: BoxDecoration(
|
||||
color: colorScheme.onSurfaceVariant.withValues(alpha: 0.4),
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
),
|
||||
// Title
|
||||
Text(
|
||||
l10n.taskHistoryTitle,
|
||||
style: theme.textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
// Completion list via StreamBuilder
|
||||
StreamBuilder<List<TaskCompletion>>(
|
||||
stream: ref
|
||||
.read(appDatabaseProvider)
|
||||
.tasksDao
|
||||
.watchCompletionsForTask(taskId),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
|
||||
final completions = snapshot.data!;
|
||||
|
||||
if (completions.isEmpty) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.history,
|
||||
size: 48,
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
l10n.taskHistoryEmpty,
|
||||
style: theme.textTheme.bodyLarge?.copyWith(
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// Show count summary
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
l10n.taskHistoryCount(completions.length),
|
||||
style: theme.textTheme.bodyMedium?.copyWith(
|
||||
color: colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight:
|
||||
MediaQuery.of(context).size.height * 0.4,
|
||||
),
|
||||
child: ListView.builder(
|
||||
shrinkWrap: true,
|
||||
itemCount: completions.length,
|
||||
itemBuilder: (context, index) {
|
||||
final completion = completions[index];
|
||||
final dateStr = DateFormat('dd.MM.yyyy', 'de')
|
||||
.format(completion.completedAt);
|
||||
final timeStr = DateFormat('HH:mm', 'de')
|
||||
.format(completion.completedAt);
|
||||
return ListTile(
|
||||
leading: Icon(
|
||||
Icons.check_circle_outline,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
title: Text(dateStr),
|
||||
subtitle: Text(timeStr),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'package:household_keeper/core/database/database.dart';
|
||||
import 'package:household_keeper/core/providers/database_provider.dart';
|
||||
import 'package:household_keeper/features/tasks/presentation/sort_dropdown.dart';
|
||||
import 'package:household_keeper/features/tasks/presentation/task_providers.dart';
|
||||
import 'package:household_keeper/features/tasks/presentation/task_row.dart';
|
||||
import 'package:household_keeper/l10n/app_localizations.dart';
|
||||
@@ -27,6 +28,7 @@ class TaskListScreen extends ConsumerWidget {
|
||||
appBar: AppBar(
|
||||
title: _RoomTitle(roomId: roomId),
|
||||
actions: [
|
||||
const SortDropdown(),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.edit),
|
||||
onPressed: () => context.go('/rooms/$roomId/edit'),
|
||||
|
||||
@@ -6,17 +6,44 @@ import 'package:household_keeper/core/database/database.dart';
|
||||
import 'package:household_keeper/core/providers/database_provider.dart';
|
||||
import 'package:household_keeper/features/tasks/domain/effort_level.dart';
|
||||
import 'package:household_keeper/features/tasks/domain/frequency.dart';
|
||||
import 'package:household_keeper/features/tasks/domain/task_sort_option.dart';
|
||||
import 'package:household_keeper/features/tasks/presentation/sort_preference_notifier.dart';
|
||||
|
||||
part 'task_providers.g.dart';
|
||||
|
||||
/// Stream provider family for tasks in a specific room, sorted by due date.
|
||||
/// Sort a list of [Task] by the given [sortOption].
|
||||
///
|
||||
/// Returns a new sorted list; never mutates the original.
|
||||
List<Task> _sortTasksRaw(List<Task> tasks, TaskSortOption sortOption) {
|
||||
final sorted = List<Task>.from(tasks);
|
||||
switch (sortOption) {
|
||||
case TaskSortOption.alphabetical:
|
||||
sorted.sort((a, b) => a.name.toLowerCase().compareTo(
|
||||
b.name.toLowerCase(),
|
||||
));
|
||||
case TaskSortOption.interval:
|
||||
sorted.sort((a, b) {
|
||||
final cmp = a.intervalType.index.compareTo(b.intervalType.index);
|
||||
if (cmp != 0) return cmp;
|
||||
return a.intervalDays.compareTo(b.intervalDays);
|
||||
});
|
||||
case TaskSortOption.effort:
|
||||
sorted.sort((a, b) => a.effortLevel.index.compareTo(b.effortLevel.index));
|
||||
}
|
||||
return sorted;
|
||||
}
|
||||
|
||||
/// Stream provider family for tasks in a specific room, sorted by active sort preference.
|
||||
///
|
||||
/// Defined manually because riverpod_generator has trouble with drift's
|
||||
/// generated [Task] type in family provider return types.
|
||||
final tasksInRoomProvider =
|
||||
StreamProvider.family.autoDispose<List<Task>, int>((ref, roomId) {
|
||||
final db = ref.watch(appDatabaseProvider);
|
||||
return db.tasksDao.watchTasksInRoom(roomId);
|
||||
final sortOption = ref.watch(sortPreferenceProvider);
|
||||
return db.tasksDao
|
||||
.watchTasksInRoom(roomId)
|
||||
.map((tasks) => _sortTasksRaw(tasks, sortOption));
|
||||
});
|
||||
|
||||
/// Notifier for task mutations: create, update, delete, complete.
|
||||
|
||||
@@ -107,5 +107,17 @@
|
||||
"overdue": { "type": "int" }
|
||||
}
|
||||
},
|
||||
"calendarTodayButton": "Heute"
|
||||
"calendarTodayButton": "Heute",
|
||||
"taskHistoryTitle": "Verlauf",
|
||||
"taskHistoryEmpty": "Noch nie erledigt",
|
||||
"taskHistoryCount": "{count} Mal erledigt",
|
||||
"@taskHistoryCount": {
|
||||
"placeholders": {
|
||||
"count": { "type": "int" }
|
||||
}
|
||||
},
|
||||
"sortAlphabetical": "A\u2013Z",
|
||||
"sortInterval": "Intervall",
|
||||
"sortEffort": "Aufwand",
|
||||
"sortLabel": "Sortierung"
|
||||
}
|
||||
|
||||
@@ -519,6 +519,48 @@ abstract class AppLocalizations {
|
||||
/// In de, this message translates to:
|
||||
/// **'Heute'**
|
||||
String get calendarTodayButton;
|
||||
|
||||
/// No description provided for @taskHistoryTitle.
|
||||
///
|
||||
/// In de, this message translates to:
|
||||
/// **'Verlauf'**
|
||||
String get taskHistoryTitle;
|
||||
|
||||
/// No description provided for @taskHistoryEmpty.
|
||||
///
|
||||
/// In de, this message translates to:
|
||||
/// **'Noch nie erledigt'**
|
||||
String get taskHistoryEmpty;
|
||||
|
||||
/// No description provided for @taskHistoryCount.
|
||||
///
|
||||
/// In de, this message translates to:
|
||||
/// **'{count} Mal erledigt'**
|
||||
String taskHistoryCount(int count);
|
||||
|
||||
/// No description provided for @sortAlphabetical.
|
||||
///
|
||||
/// In de, this message translates to:
|
||||
/// **'A–Z'**
|
||||
String get sortAlphabetical;
|
||||
|
||||
/// No description provided for @sortInterval.
|
||||
///
|
||||
/// In de, this message translates to:
|
||||
/// **'Intervall'**
|
||||
String get sortInterval;
|
||||
|
||||
/// No description provided for @sortEffort.
|
||||
///
|
||||
/// In de, this message translates to:
|
||||
/// **'Aufwand'**
|
||||
String get sortEffort;
|
||||
|
||||
/// No description provided for @sortLabel.
|
||||
///
|
||||
/// In de, this message translates to:
|
||||
/// **'Sortierung'**
|
||||
String get sortLabel;
|
||||
}
|
||||
|
||||
class _AppLocalizationsDelegate
|
||||
|
||||
@@ -239,4 +239,27 @@ class AppLocalizationsDe extends AppLocalizations {
|
||||
|
||||
@override
|
||||
String get calendarTodayButton => 'Heute';
|
||||
|
||||
@override
|
||||
String get taskHistoryTitle => 'Verlauf';
|
||||
|
||||
@override
|
||||
String get taskHistoryEmpty => 'Noch nie erledigt';
|
||||
|
||||
@override
|
||||
String taskHistoryCount(int count) {
|
||||
return '$count Mal erledigt';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sortAlphabetical => 'A–Z';
|
||||
|
||||
@override
|
||||
String get sortInterval => 'Intervall';
|
||||
|
||||
@override
|
||||
String get sortEffort => 'Aufwand';
|
||||
|
||||
@override
|
||||
String get sortLabel => 'Sortierung';
|
||||
}
|
||||
|
||||
@@ -5,12 +5,15 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'package:household_keeper/core/database/database.dart';
|
||||
import 'package:household_keeper/core/router/router.dart';
|
||||
import 'package:household_keeper/features/home/domain/daily_plan_models.dart';
|
||||
import 'package:household_keeper/features/home/presentation/daily_plan_providers.dart';
|
||||
import 'package:household_keeper/features/home/domain/calendar_models.dart';
|
||||
import 'package:household_keeper/features/home/presentation/calendar_providers.dart';
|
||||
import 'package:household_keeper/features/rooms/presentation/room_providers.dart';
|
||||
import 'package:household_keeper/features/tasks/domain/effort_level.dart';
|
||||
import 'package:household_keeper/features/tasks/domain/frequency.dart';
|
||||
import 'package:household_keeper/features/tasks/domain/task_sort_option.dart';
|
||||
import 'package:household_keeper/features/tasks/presentation/sort_preference_notifier.dart';
|
||||
import 'package:household_keeper/l10n/app_localizations.dart';
|
||||
import 'package:household_keeper/features/home/domain/daily_plan_models.dart';
|
||||
|
||||
/// Helper to create a test [Task] with sensible defaults.
|
||||
Task _makeTask({
|
||||
@@ -51,18 +54,20 @@ TaskWithRoom _makeTaskWithRoom({
|
||||
);
|
||||
}
|
||||
|
||||
/// Build the app with dailyPlanProvider overridden to the given state.
|
||||
/// Build the app with calendarDayProvider overridden to the given state.
|
||||
///
|
||||
/// Uses [UncontrolledProviderScope] with a [ProviderContainer] to avoid
|
||||
/// the riverpod_lint scoped_providers_should_specify_dependencies warning.
|
||||
Widget _buildApp(DailyPlanState planState) {
|
||||
Widget _buildApp(CalendarDayState dayState) {
|
||||
final container = ProviderContainer(overrides: [
|
||||
dailyPlanProvider.overrideWith(
|
||||
(ref) => Stream.value(planState),
|
||||
calendarDayProvider.overrideWith(
|
||||
(ref) => Stream.value(dayState),
|
||||
),
|
||||
selectedDateProvider.overrideWith(SelectedDateNotifier.new),
|
||||
roomWithStatsListProvider.overrideWith(
|
||||
(ref) => Stream.value([]),
|
||||
),
|
||||
sortPreferenceProvider.overrideWith(SortPreferenceNotifier.new),
|
||||
]);
|
||||
|
||||
return UncontrolledProviderScope(
|
||||
@@ -81,17 +86,21 @@ void main() {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
});
|
||||
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
final yesterday = today.subtract(const Duration(days: 1));
|
||||
|
||||
group('HomeScreen empty states', () {
|
||||
testWidgets('shows no-tasks empty state when no tasks exist at all',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(_buildApp(const DailyPlanState(
|
||||
overdueTasks: [],
|
||||
todayTasks: [],
|
||||
tomorrowTasks: [],
|
||||
completedTodayCount: 0,
|
||||
totalTodayCount: 0,
|
||||
await tester.pumpWidget(_buildApp(CalendarDayState(
|
||||
selectedDate: today,
|
||||
dayTasks: const [],
|
||||
overdueTasks: const [],
|
||||
totalTaskCount: 0,
|
||||
)));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
// Should show "Noch keine Aufgaben angelegt" (dailyPlanNoTasks)
|
||||
expect(find.text('Noch keine Aufgaben angelegt'), findsOneWidget);
|
||||
@@ -99,58 +108,53 @@ void main() {
|
||||
expect(find.text('Raum erstellen'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('shows all-clear state when all tasks are done',
|
||||
testWidgets('shows celebration state when tasks exist but today is clear',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(_buildApp(const DailyPlanState(
|
||||
overdueTasks: [],
|
||||
todayTasks: [],
|
||||
tomorrowTasks: [],
|
||||
completedTodayCount: 3,
|
||||
totalTodayCount: 3,
|
||||
await tester.pumpWidget(_buildApp(CalendarDayState(
|
||||
selectedDate: today,
|
||||
dayTasks: const [],
|
||||
overdueTasks: const [],
|
||||
totalTaskCount: 5, // tasks exist elsewhere
|
||||
)));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
// Should show celebration empty state
|
||||
expect(find.text('Alles erledigt! \u{1F31F}'), findsOneWidget);
|
||||
// Should show celebration state
|
||||
expect(find.byIcon(Icons.celebration_outlined), findsOneWidget);
|
||||
// Progress card should show 3/3
|
||||
expect(find.text('3 von 3 erledigt'), findsOneWidget);
|
||||
expect(find.text('Alles erledigt! \u{1F31F}'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('shows empty-day state for non-today date with no tasks',
|
||||
(tester) async {
|
||||
final tomorrow = today.add(const Duration(days: 1));
|
||||
await tester.pumpWidget(_buildApp(CalendarDayState(
|
||||
selectedDate: tomorrow,
|
||||
dayTasks: const [],
|
||||
overdueTasks: const [],
|
||||
totalTaskCount: 5, // tasks exist on other days
|
||||
)));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
// Should show "Keine Aufgaben" (not celebration — not today)
|
||||
expect(find.text('Keine Aufgaben'), findsOneWidget);
|
||||
expect(find.byIcon(Icons.event_available), findsOneWidget);
|
||||
});
|
||||
});
|
||||
|
||||
group('HomeScreen normal state', () {
|
||||
testWidgets('shows progress card with correct counts', (tester) async {
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
|
||||
await tester.pumpWidget(_buildApp(DailyPlanState(
|
||||
overdueTasks: [],
|
||||
todayTasks: [
|
||||
testWidgets('shows overdue section when overdue tasks exist (today)',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(_buildApp(CalendarDayState(
|
||||
selectedDate: today,
|
||||
dayTasks: [
|
||||
_makeTaskWithRoom(
|
||||
id: 1,
|
||||
id: 2,
|
||||
taskName: 'Staubsaugen',
|
||||
roomName: 'Wohnzimmer',
|
||||
nextDueDate: today,
|
||||
),
|
||||
],
|
||||
tomorrowTasks: [],
|
||||
completedTodayCount: 2,
|
||||
totalTodayCount: 3,
|
||||
)));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Progress card should show 2/3
|
||||
expect(find.text('2 von 3 erledigt'), findsOneWidget);
|
||||
expect(find.byType(LinearProgressIndicator), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('shows overdue section when overdue tasks exist',
|
||||
(tester) async {
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
final yesterday = today.subtract(const Duration(days: 1));
|
||||
|
||||
await tester.pumpWidget(_buildApp(DailyPlanState(
|
||||
overdueTasks: [
|
||||
_makeTaskWithRoom(
|
||||
id: 1,
|
||||
@@ -159,24 +163,13 @@ void main() {
|
||||
nextDueDate: yesterday,
|
||||
),
|
||||
],
|
||||
todayTasks: [
|
||||
_makeTaskWithRoom(
|
||||
id: 2,
|
||||
taskName: 'Staubsaugen',
|
||||
roomName: 'Wohnzimmer',
|
||||
nextDueDate: today,
|
||||
),
|
||||
],
|
||||
tomorrowTasks: [],
|
||||
completedTodayCount: 0,
|
||||
totalTodayCount: 2,
|
||||
totalTaskCount: 2,
|
||||
)));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
// Should show overdue section header
|
||||
expect(find.text('\u00dcberf\u00e4llig'), findsOneWidget);
|
||||
// Should show today section header (may also appear as relative date)
|
||||
expect(find.text('Heute'), findsAtLeast(1));
|
||||
// Should show both tasks
|
||||
expect(find.text('Boden wischen'), findsOneWidget);
|
||||
expect(find.text('Staubsaugen'), findsOneWidget);
|
||||
@@ -185,54 +178,37 @@ void main() {
|
||||
expect(find.text('Wohnzimmer'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('shows collapsed tomorrow section with count',
|
||||
testWidgets('does not show overdue section for non-today date',
|
||||
(tester) async {
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
// On a future date, overdueTasks will be empty (calendarDayProvider
|
||||
// only populates overdueTasks when isToday).
|
||||
final tomorrow = today.add(const Duration(days: 1));
|
||||
|
||||
await tester.pumpWidget(_buildApp(DailyPlanState(
|
||||
overdueTasks: [],
|
||||
todayTasks: [
|
||||
await tester.pumpWidget(_buildApp(CalendarDayState(
|
||||
selectedDate: tomorrow,
|
||||
dayTasks: [
|
||||
_makeTaskWithRoom(
|
||||
id: 1,
|
||||
taskName: 'Staubsaugen',
|
||||
roomName: 'Wohnzimmer',
|
||||
nextDueDate: today,
|
||||
),
|
||||
],
|
||||
tomorrowTasks: [
|
||||
_makeTaskWithRoom(
|
||||
id: 2,
|
||||
taskName: 'Fenster putzen',
|
||||
roomName: 'Schlafzimmer',
|
||||
nextDueDate: tomorrow,
|
||||
),
|
||||
_makeTaskWithRoom(
|
||||
id: 3,
|
||||
taskName: 'Bett beziehen',
|
||||
roomName: 'Schlafzimmer',
|
||||
nextDueDate: tomorrow,
|
||||
),
|
||||
],
|
||||
completedTodayCount: 0,
|
||||
totalTodayCount: 1,
|
||||
overdueTasks: const [], // No overdue for non-today
|
||||
totalTaskCount: 1,
|
||||
)));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
// Should show collapsed tomorrow section with count
|
||||
expect(find.text('Demn\u00e4chst (2)'), findsOneWidget);
|
||||
// Tomorrow tasks should NOT be visible (collapsed by default)
|
||||
expect(find.text('Fenster putzen'), findsNothing);
|
||||
// Should NOT show overdue section header
|
||||
expect(find.text('\u00dcberf\u00e4llig'), findsNothing);
|
||||
// Should show day task
|
||||
expect(find.text('Staubsaugen'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('today tasks have checkboxes', (tester) async {
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
|
||||
await tester.pumpWidget(_buildApp(DailyPlanState(
|
||||
overdueTasks: [],
|
||||
todayTasks: [
|
||||
testWidgets('tasks have checkboxes', (tester) async {
|
||||
await tester.pumpWidget(_buildApp(CalendarDayState(
|
||||
selectedDate: today,
|
||||
dayTasks: [
|
||||
_makeTaskWithRoom(
|
||||
id: 1,
|
||||
taskName: 'Staubsaugen',
|
||||
@@ -240,14 +216,63 @@ void main() {
|
||||
nextDueDate: today,
|
||||
),
|
||||
],
|
||||
tomorrowTasks: [],
|
||||
completedTodayCount: 0,
|
||||
totalTodayCount: 1,
|
||||
overdueTasks: const [],
|
||||
totalTaskCount: 1,
|
||||
)));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
// Today task should have a checkbox
|
||||
// Task should have a checkbox
|
||||
expect(find.byType(Checkbox), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('calendar strip is shown', (tester) async {
|
||||
await tester.pumpWidget(_buildApp(CalendarDayState(
|
||||
selectedDate: today,
|
||||
dayTasks: const [],
|
||||
overdueTasks: const [],
|
||||
totalTaskCount: 0,
|
||||
)));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
// The strip is a horizontal ListView — verify it exists by finding
|
||||
// ListView widgets (strip + potentially the task list).
|
||||
expect(find.byType(ListView), findsWidgets);
|
||||
});
|
||||
});
|
||||
|
||||
group('HomeScreen sort dropdown', () {
|
||||
testWidgets('shows sort dropdown in AppBar', (tester) async {
|
||||
await tester.pumpWidget(_buildApp(CalendarDayState(
|
||||
selectedDate: today,
|
||||
dayTasks: const [],
|
||||
overdueTasks: const [],
|
||||
totalTaskCount: 0,
|
||||
)));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
// SortDropdown wraps a PopupMenuButton<TaskSortOption>
|
||||
expect(
|
||||
find.byType(PopupMenuButton<TaskSortOption>),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('shows AppBar with title', (tester) async {
|
||||
await tester.pumpWidget(_buildApp(CalendarDayState(
|
||||
selectedDate: today,
|
||||
dayTasks: const [],
|
||||
overdueTasks: const [],
|
||||
totalTaskCount: 0,
|
||||
)));
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
// tabHome l10n string is 'Übersicht'. It appears in the AppBar title
|
||||
// and also in the bottom navigation bar label — use findsWidgets.
|
||||
expect(find.text('\u00dcbersicht'), findsWidgets);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
157
test/features/tasks/data/task_history_dao_test.dart
Normal file
157
test/features/tasks/data/task_history_dao_test.dart
Normal file
@@ -0,0 +1,157 @@
|
||||
import 'package:drift/native.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:household_keeper/core/database/database.dart';
|
||||
import 'package:household_keeper/features/tasks/domain/effort_level.dart';
|
||||
import 'package:household_keeper/features/tasks/domain/frequency.dart';
|
||||
|
||||
void main() {
|
||||
late AppDatabase db;
|
||||
late int roomId;
|
||||
|
||||
setUp(() async {
|
||||
db = AppDatabase(NativeDatabase.memory());
|
||||
roomId = await db.roomsDao.insertRoom(
|
||||
RoomsCompanion.insert(name: 'Kueche', iconName: 'kitchen'),
|
||||
);
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
await db.close();
|
||||
});
|
||||
|
||||
group('TasksDao.watchCompletionsForTask', () {
|
||||
test('returns empty list when task has no completions', () async {
|
||||
final taskId = await db.tasksDao.insertTask(
|
||||
TasksCompanion.insert(
|
||||
roomId: roomId,
|
||||
name: 'Staubsaugen',
|
||||
intervalType: IntervalType.weekly,
|
||||
effortLevel: EffortLevel.medium,
|
||||
nextDueDate: DateTime(2026, 3, 15),
|
||||
),
|
||||
);
|
||||
|
||||
final completions =
|
||||
await db.tasksDao.watchCompletionsForTask(taskId).first;
|
||||
|
||||
expect(completions, isEmpty);
|
||||
});
|
||||
|
||||
test('returns completion after completeTask is called', () async {
|
||||
final taskId = await db.tasksDao.insertTask(
|
||||
TasksCompanion.insert(
|
||||
roomId: roomId,
|
||||
name: 'Abspuelen',
|
||||
intervalType: IntervalType.daily,
|
||||
effortLevel: EffortLevel.low,
|
||||
nextDueDate: DateTime(2026, 3, 15),
|
||||
),
|
||||
);
|
||||
|
||||
final completionTime = DateTime(2026, 3, 15, 10, 30);
|
||||
await db.tasksDao.completeTask(taskId, now: completionTime);
|
||||
|
||||
final completions =
|
||||
await db.tasksDao.watchCompletionsForTask(taskId).first;
|
||||
|
||||
expect(completions.length, 1);
|
||||
expect(completions.first.taskId, taskId);
|
||||
expect(completions.first.completedAt, completionTime);
|
||||
});
|
||||
|
||||
test('returns multiple completions in reverse-chronological order', () async {
|
||||
final taskId = await db.tasksDao.insertTask(
|
||||
TasksCompanion.insert(
|
||||
roomId: roomId,
|
||||
name: 'Fenster putzen',
|
||||
intervalType: IntervalType.monthly,
|
||||
effortLevel: EffortLevel.high,
|
||||
nextDueDate: DateTime(2026, 1, 1),
|
||||
),
|
||||
);
|
||||
|
||||
// Complete multiple times with specific timestamps
|
||||
final time1 = DateTime(2026, 1, 10, 9, 0);
|
||||
final time2 = DateTime(2026, 2, 12, 14, 30);
|
||||
final time3 = DateTime(2026, 3, 15, 8, 0);
|
||||
|
||||
// Insert out of order to verify ordering is enforced by query
|
||||
await db.tasksDao.completeTask(taskId, now: time1);
|
||||
await db.tasksDao.completeTask(taskId, now: time2);
|
||||
await db.tasksDao.completeTask(taskId, now: time3);
|
||||
|
||||
final completions =
|
||||
await db.tasksDao.watchCompletionsForTask(taskId).first;
|
||||
|
||||
expect(completions.length, 3);
|
||||
// Newest first (reverse-chronological)
|
||||
expect(completions[0].completedAt, time3);
|
||||
expect(completions[1].completedAt, time2);
|
||||
expect(completions[2].completedAt, time1);
|
||||
});
|
||||
|
||||
test('completions for different tasks are isolated', () async {
|
||||
final taskId1 = await db.tasksDao.insertTask(
|
||||
TasksCompanion.insert(
|
||||
roomId: roomId,
|
||||
name: 'Task A',
|
||||
intervalType: IntervalType.daily,
|
||||
effortLevel: EffortLevel.low,
|
||||
nextDueDate: DateTime(2026, 3, 15),
|
||||
),
|
||||
);
|
||||
|
||||
final taskId2 = await db.tasksDao.insertTask(
|
||||
TasksCompanion.insert(
|
||||
roomId: roomId,
|
||||
name: 'Task B',
|
||||
intervalType: IntervalType.daily,
|
||||
effortLevel: EffortLevel.low,
|
||||
nextDueDate: DateTime(2026, 3, 15),
|
||||
),
|
||||
);
|
||||
|
||||
await db.tasksDao.completeTask(taskId1, now: DateTime(2026, 3, 15));
|
||||
|
||||
final completionsForTask1 =
|
||||
await db.tasksDao.watchCompletionsForTask(taskId1).first;
|
||||
final completionsForTask2 =
|
||||
await db.tasksDao.watchCompletionsForTask(taskId2).first;
|
||||
|
||||
expect(completionsForTask1.length, 1);
|
||||
expect(completionsForTask1.first.taskId, taskId1);
|
||||
expect(completionsForTask2, isEmpty);
|
||||
});
|
||||
|
||||
test('stream emits updated list after new completion is added', () async {
|
||||
final taskId = await db.tasksDao.insertTask(
|
||||
TasksCompanion.insert(
|
||||
roomId: roomId,
|
||||
name: 'Bodenwischen',
|
||||
intervalType: IntervalType.weekly,
|
||||
effortLevel: EffortLevel.medium,
|
||||
nextDueDate: DateTime(2026, 3, 15),
|
||||
),
|
||||
);
|
||||
|
||||
// Collect stream emissions
|
||||
final emissions = <List<TaskCompletion>>[];
|
||||
final subscription = db.tasksDao
|
||||
.watchCompletionsForTask(taskId)
|
||||
.listen(emissions.add);
|
||||
|
||||
// Wait for initial empty emission
|
||||
await Future<void>.delayed(const Duration(milliseconds: 50));
|
||||
expect(emissions.isNotEmpty, isTrue);
|
||||
expect(emissions.last, isEmpty);
|
||||
|
||||
// Complete the task
|
||||
await db.tasksDao.completeTask(taskId, now: DateTime(2026, 3, 15, 9, 0));
|
||||
await Future<void>.delayed(const Duration(milliseconds: 50));
|
||||
|
||||
expect(emissions.last.length, 1);
|
||||
|
||||
await subscription.cancel();
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'package:household_keeper/features/tasks/domain/task_sort_option.dart';
|
||||
import 'package:household_keeper/features/tasks/presentation/sort_preference_notifier.dart';
|
||||
|
||||
/// Helper: create a container and wait for the initial async _loadPersisted()
|
||||
/// to finish.
|
||||
Future<ProviderContainer> makeContainer() async {
|
||||
final container = ProviderContainer();
|
||||
// Trigger build
|
||||
container.read(sortPreferenceProvider);
|
||||
// Allow the async _loadPersisted() to complete
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
return container;
|
||||
}
|
||||
|
||||
void main() {
|
||||
setUp(() {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
});
|
||||
|
||||
group('SortPreferenceNotifier', () {
|
||||
test('build() returns default state of alphabetical', () async {
|
||||
final container = ProviderContainer();
|
||||
addTearDown(container.dispose);
|
||||
|
||||
final state = container.read(sortPreferenceProvider);
|
||||
|
||||
expect(state, TaskSortOption.alphabetical);
|
||||
});
|
||||
|
||||
test('setSortOption(interval) updates state to interval', () async {
|
||||
final container = await makeContainer();
|
||||
addTearDown(container.dispose);
|
||||
|
||||
await container
|
||||
.read(sortPreferenceProvider.notifier)
|
||||
.setSortOption(TaskSortOption.interval);
|
||||
|
||||
expect(container.read(sortPreferenceProvider), TaskSortOption.interval);
|
||||
});
|
||||
|
||||
test('setSortOption(effort) updates state to effort', () async {
|
||||
final container = await makeContainer();
|
||||
addTearDown(container.dispose);
|
||||
|
||||
await container
|
||||
.read(sortPreferenceProvider.notifier)
|
||||
.setSortOption(TaskSortOption.effort);
|
||||
|
||||
expect(container.read(sortPreferenceProvider), TaskSortOption.effort);
|
||||
});
|
||||
|
||||
test('setSortOption persists to SharedPreferences', () async {
|
||||
final container = await makeContainer();
|
||||
addTearDown(container.dispose);
|
||||
|
||||
await container
|
||||
.read(sortPreferenceProvider.notifier)
|
||||
.setSortOption(TaskSortOption.effort);
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
expect(prefs.getString('task_sort_option'), 'effort');
|
||||
});
|
||||
|
||||
test('persisted value is loaded on restart (effort)', () async {
|
||||
SharedPreferences.setMockInitialValues({
|
||||
'task_sort_option': 'effort',
|
||||
});
|
||||
|
||||
final container = await makeContainer();
|
||||
addTearDown(container.dispose);
|
||||
|
||||
expect(container.read(sortPreferenceProvider), TaskSortOption.effort);
|
||||
});
|
||||
|
||||
test('persisted value is loaded on restart (interval)', () async {
|
||||
SharedPreferences.setMockInitialValues({
|
||||
'task_sort_option': 'interval',
|
||||
});
|
||||
|
||||
final container = await makeContainer();
|
||||
addTearDown(container.dispose);
|
||||
|
||||
expect(container.read(sortPreferenceProvider), TaskSortOption.interval);
|
||||
});
|
||||
|
||||
test('unknown persisted value falls back to alphabetical', () async {
|
||||
SharedPreferences.setMockInitialValues({
|
||||
'task_sort_option': 'unknown_value',
|
||||
});
|
||||
|
||||
final container = await makeContainer();
|
||||
addTearDown(container.dispose);
|
||||
|
||||
expect(container.read(sortPreferenceProvider), TaskSortOption.alphabetical);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -4,8 +4,8 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'package:household_keeper/core/router/router.dart';
|
||||
import 'package:household_keeper/features/home/domain/daily_plan_models.dart';
|
||||
import 'package:household_keeper/features/home/presentation/daily_plan_providers.dart';
|
||||
import 'package:household_keeper/features/home/domain/calendar_models.dart';
|
||||
import 'package:household_keeper/features/home/presentation/calendar_providers.dart';
|
||||
import 'package:household_keeper/features/rooms/presentation/room_providers.dart';
|
||||
import 'package:household_keeper/l10n/app_localizations.dart';
|
||||
|
||||
@@ -15,6 +15,9 @@ void main() {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
});
|
||||
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
|
||||
/// Helper to build the app with providers overridden for testing.
|
||||
///
|
||||
/// Uses [UncontrolledProviderScope] with a [ProviderContainer] to avoid
|
||||
@@ -26,15 +29,16 @@ void main() {
|
||||
roomWithStatsListProvider.overrideWith(
|
||||
(ref) => Stream.value([]),
|
||||
),
|
||||
// Override daily plan to return empty state so HomeScreen
|
||||
// renders without a database.
|
||||
dailyPlanProvider.overrideWith(
|
||||
(ref) => Stream.value(const DailyPlanState(
|
||||
overdueTasks: [],
|
||||
todayTasks: [],
|
||||
tomorrowTasks: [],
|
||||
completedTodayCount: 0,
|
||||
totalTodayCount: 0,
|
||||
// Override selected date to avoid any DB access.
|
||||
selectedDateProvider.overrideWith(SelectedDateNotifier.new),
|
||||
// Override calendar day provider to return empty first-run state so
|
||||
// HomeScreen renders without a database.
|
||||
calendarDayProvider.overrideWith(
|
||||
(ref) => Stream.value(CalendarDayState(
|
||||
selectedDate: today,
|
||||
dayTasks: const [],
|
||||
overdueTasks: const [],
|
||||
totalTaskCount: 0,
|
||||
)),
|
||||
),
|
||||
]);
|
||||
@@ -53,13 +57,15 @@ void main() {
|
||||
testWidgets('renders 3 navigation destinations with correct German labels',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(buildApp());
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
// Verify 3 NavigationDestination widgets are rendered
|
||||
expect(find.byType(NavigationDestination), findsNWidgets(3));
|
||||
|
||||
// Verify correct German labels from ARB (with umlauts)
|
||||
expect(find.text('\u00dcbersicht'), findsOneWidget);
|
||||
// Verify correct German labels from ARB (with umlauts).
|
||||
// 'Übersicht' appears in both the bottom nav and the HomeScreen AppBar.
|
||||
expect(find.text('\u00dcbersicht'), findsWidgets);
|
||||
expect(find.text('R\u00e4ume'), findsOneWidget);
|
||||
expect(find.text('Einstellungen'), findsOneWidget);
|
||||
});
|
||||
@@ -67,22 +73,24 @@ void main() {
|
||||
testWidgets('tapping a destination changes the selected tab',
|
||||
(tester) async {
|
||||
await tester.pumpWidget(buildApp());
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
// Initially on Home tab (index 0) -- verify home empty state is shown
|
||||
// (dailyPlanNoTasks text from the daily plan empty state)
|
||||
// Initially on Home tab (index 0) -- verify home first-run empty state
|
||||
expect(find.text('Noch keine Aufgaben angelegt'), findsOneWidget);
|
||||
|
||||
// Tap the Rooms tab (second destination)
|
||||
await tester.tap(find.text('R\u00e4ume'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
// Verify we see Rooms content now (empty state)
|
||||
expect(find.text('Hier ist noch alles leer!'), findsOneWidget);
|
||||
|
||||
// Tap the Settings tab (third destination)
|
||||
await tester.tap(find.text('Einstellungen'));
|
||||
await tester.pumpAndSettle();
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 500));
|
||||
|
||||
// Verify we see Settings content now
|
||||
expect(find.text('Darstellung'), findsOneWidget);
|
||||
|
||||
Reference in New Issue
Block a user