Implement a Recent Workouts page that displays a list of the user's completed workouts, integrated into the existing app structure using Provider for state management.
Objectives
- Create a Recent Workouts page accessible from the main screen
- Implement data persistence for completed workouts using Drift
- Ensure data integrity and support for future migrations
- Integrate with existing Provider-based state management
- Update the workout screen to allow users to indicate they have completed the workout, so it will be persisted to the database
Requirements
UI/UX
- Add a calendar icon button to the Choose Workout Category screen, placed next to the dark/light theme toggle in the upper right corner
- Create a "Recent Workouts" page accessible by tapping the calendar icon
- Display workouts in a list format, sorted by most recent first
- For each workout, show:
- Date of completion
- List of exercises completed, including:
- Exercise name
- Muscle targets
- Joint targets
- Implement standard Flutter navigation to allow users to return to the Choose Workout Category screen
- Implement infinite scrolling or pagination for performance
Data Model and Exercise Management
Exercise Data Management
- Maintain the current structure of defining exercises as Dart classes for balance, cardio, mobility, strength, and stretching exercises
- Implement a mechanism to synchronize the Dart-defined exercises with the SQLite database:
- Create a process to insert/upsert exercises from Dart classes into the Exercise table
- Ensure this process runs on app initialization and after updates
Data Model
- Use Drift (SQLite) for local data persistence
- Create DAOs (Data Access Objects) for CRUD operations on workouts and exercises
- Design a relational data model that includes:
- Workout table (id, date)
- WorkoutExercise table (id, workout_id, exercise_id)
- Exercise table (id, name, category, muscle_targets, joint_targets, version)
- Add a 'version' field to track changes in exercise definitions
- Use appropriate indexing for optimal query performance
Data Synchronization and Migrations
- Implement a versioning system for the exercise library
- Create a migration system that can:
- Initialize the Exercise table with data from Dart classes on first run
- Upsert exercises when the app is updated and exercise definitions change
- Handle scenarios where exercises are added, modified, or removed
- Ensure that historical workout data remains intact and consistent when exercise definitions change
State Management
- Continue using Provider for state management
- Create a new Provider for managing Recent Workouts data
- Integrate the new Provider with existing Providers as necessary
Architecture
- Maintain the current architecture using Provider
- Implement a repository pattern for data access
- Ensure separation of concerns between UI, business logic, and data layers
Testing
- Write unit tests for data models and repositories
- Implement integration tests for database operations
- Create widget tests for the Recent Workouts page and updated Choose Workout Category screen
Additional Tasks
- Develop a utility class or function to convert Dart exercise objects to database records
- Implement a database seeding mechanism for the initial population of the Exercise table
- Create a version tracking system for the exercise library
- Develop migration scripts to handle exercise library updates
- Implement logic to run necessary migrations on app startup or update
Acceptance Criteria
- Users can access the Recent Workouts page by tapping the calendar icon on the Choose Workout Category screen
- The Recent Workouts page displays a list of completed workouts with correct information
- Workouts are persisted locally and survive app restarts
- The implementation uses Drift for data persistence
- The data model is designed to support future features and migrations
- Provider is used for state management of the Recent Workouts feature
- Users can navigate back to the Choose Workout Category screen from the Recent Workouts page
- Unit, integration, and widget tests are implemented with >80% coverage
- Exercise data from Dart classes is correctly synchronized with the SQLite database
- Updates to the exercise library in Dart code are reflected in the database after app updates
- Historical workout data remains consistent and accessible after exercise library updates
Future Considerations
While not part of this feature request, keep the following future enhancements in mind:
- Calendar view of workouts
- Statistical analysis of workout history
- Muscle group and joint engagement tracking
- Anatomical display of exercise focus areas
- Workout recommendations based on history
- Sync capabilities with cloud storage
Implementation Notes
- Ensure the new Recent Workouts feature integrates smoothly with the existing app structure and navigation flow
- Use caution when designing the data model to ensure it can handle future changes to exercise lists or categories without breaking historical data
- Implement proper database migrations to support schema changes over time
- Consider using type-safe queries and code generation features of Drift to catch potential issues at compile-time
- Document any assumptions made about the data model or potential limitations for future reference
- Develop a robust synchronization mechanism between Dart-defined exercises and the SQLite database
- Implement a versioning system for exercise definitions to track changes over time
- Create a migration strategy that can handle updates to the exercise library without compromising historical workout data
- Consider edge cases such as exercises being removed or significantly modified, and how this affects the display and analysis of historical workouts
- Document the process for updating the exercise library, including any necessary steps for database migration
Resources
Definition of Done
- Feature is implemented and meets all requirements
- Code is reviewed and approved by at least one other developer
- All tests are passing with required coverage
- Documentation is updated, including any necessary migration guides
- Feature is tested on all supported platforms (Web, iOS, Android)
- Performance is verified to meet or exceed existing app standards
- Exercise synchronization mechanism is implemented and tested
- Migration system for exercise library updates is in place and verified
- Documentation is updated to include the process for modifying the exercise library and its impact on the database
Implement a Recent Workouts page that displays a list of the user's completed workouts, integrated into the existing app structure using Provider for state management.
Objectives
Requirements
UI/UX
Data Model and Exercise Management
Exercise Data Management
Data Model
Data Synchronization and Migrations
State Management
Architecture
Testing
Additional Tasks
Acceptance Criteria
Future Considerations
While not part of this feature request, keep the following future enhancements in mind:
Implementation Notes
Resources
Definition of Done