Commit 773285b
feat: Implement Comeback System Improvements (Feature 4)
This completes Feature 4 of the planned enhancements with three major components:
1. Dynamic FTP Estimation
- Added detectedFtp, ftpDetectedAt, ftpDetectionMethod fields to ComebackMode
- Implemented hasFtpSuggestion getter to detect when athlete improves beyond effective FTP
- Added three detection methods in comeback_service: 20-minute power test, sweet-spot analysis, normalized power trend
- Added acceptFtpSuggestion() and dismissFtpSuggestion() methods
- FTP suggestions persist for 7 days and require performance > effective FTP
2. Wellness Trend Visualization
- Created wellness_trend_chart.dart with 7-day rolling line chart
- Color-coded wellness scores: green (≥75%), blue (≥50%), orange (≥25%), red (<25%)
- Added _TrendIndicator to show wellness progression (Steigend/Stabil/Fallend)
- Shows axis labels with weekday abbreviations and percentage scale
- Responsive touch tooltips showing score and date
3. Smart Phase Progression
- Created phase_readiness_card.dart with conditional phase advancement
- Added isReadyForNextPhase getter with three criteria:
* Minimum 5 days in current phase
* Average wellness score ≥60% for last 3 days
* Resting HR not elevated (≤110% of baseline)
- Added phaseProgressionRecommendation getter providing user guidance
- Manual override button available after 7 days with warning dialog
- Integrated into comeback_setup_page with conditional rendering
4. Comprehensive Testing
- Created comeback_mode_test.dart with 44 tests (100% passing)
- Tests cover: FTP suggestion logic, phase readiness criteria, phase progression recommendations
- Tests validate JSON serialization/deserialization with new fields
- Tests verify copyWith functionality and entity equality
Files modified:
- lib/domain/entities/comeback_mode.dart (4 new fields, 4 new getters, updated serialization)
- lib/core/services/comeback_service.dart (4 new methods for FTP detection and phase management)
- lib/features/comeback/presentation/pages/comeback_setup_page.dart (integrated new widgets)
Files created:
- lib/features/comeback/presentation/widgets/wellness_trend_chart.dart (150 lines)
- lib/features/comeback/presentation/widgets/phase_readiness_card.dart (190 lines)
- test/domain/entities/comeback_mode_test.dart (950 lines, 44 tests)
All code compiles successfully with only pre-existing info-level analyzer warnings.
Feature 4 implementation (5 phases, 3-4 hours) is now complete and ready for manual testing.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>1 parent 587d926 commit 773285b
File tree
6 files changed
+1877
-2
lines changed- lib
- core/services
- domain/entities
- features/comeback/presentation
- pages
- widgets
- test/domain/entities
6 files changed
+1877
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
49 | | - | |
| 51 | + | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| 57 | + | |
55 | 58 | | |
56 | | - | |
| 59 | + | |
| 60 | + | |
57 | 61 | | |
58 | 62 | | |
59 | 63 | | |
| |||
110 | 114 | | |
111 | 115 | | |
112 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
113 | 296 | | |
114 | 297 | | |
115 | 298 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
222 | 225 | | |
223 | 226 | | |
224 | 227 | | |
| |||
228 | 231 | | |
229 | 232 | | |
230 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
231 | 237 | | |
232 | 238 | | |
233 | 239 | | |
| |||
336 | 342 | | |
337 | 343 | | |
338 | 344 | | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
339 | 417 | | |
340 | 418 | | |
341 | 419 | | |
| |||
344 | 422 | | |
345 | 423 | | |
346 | 424 | | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
347 | 428 | | |
348 | 429 | | |
349 | 430 | | |
| |||
353 | 434 | | |
354 | 435 | | |
355 | 436 | | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
356 | 440 | | |
357 | 441 | | |
358 | 442 | | |
| |||
372 | 456 | | |
373 | 457 | | |
374 | 458 | | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
375 | 464 | | |
376 | 465 | | |
377 | 466 | | |
| |||
383 | 472 | | |
384 | 473 | | |
385 | 474 | | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
386 | 478 | | |
387 | 479 | | |
388 | 480 | | |
| |||
394 | 486 | | |
395 | 487 | | |
396 | 488 | | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
397 | 492 | | |
398 | 493 | | |
0 commit comments