Merged
Conversation
This commit introduces the foundation for habit tracking by adding the necessary data structures, database schema, and repository implementation.
- **Domain Models:**
- Added `Habit` and `HabitFrequency` (Daily/Weekly) models.
- Introduced `HabitWithStatus` to track completion and streaks.
- Defined `HabitRepository` interface for managing habits and their completion entries.
- **Database:**
- Bounded database version to 11.
- Created `habits` table to store habit configuration (name, icon, color, frequency).
- Created `habit_entries` table with a foreign key to `habits` to track daily completions.
- Implemented `MIGRATION_10_11` to handle the new schema.
- Added `HabitDao` with support for toggling entries within a transaction and querying habits with their related entries.
- **Data Layer:**
- Implemented `HabitRepositoryImpl` to handle data operations and mapping between domain and entity models.
- Updated `DatabaseModule` and `RepositoryModule` to provide and bind habit-related dependencies.
- **Project Configuration:**
- Included the new `:feature:habits` module in `settings.gradle.kts`.
This commit introduces the core data and domain logic for habit tracking, including streak calculation and status management. It also organizes existing task-related use cases into a dedicated sub-package.
- **Habit Tracking:**
- **Database:** Bumps schema to version 11, adding `habits` and `habit_entries` tables. `HabitEntity` is correctly registered in `FlowStateDatabase`.
- **Domain:** Introduces `HabitEntryFlat` and `HabitWithStatus` models.
- **Repository:** Adds `getAllEntries` to `HabitRepository` to fetch all habit completions across the application.
- **Use Cases:** Implements new use cases for habits:
- `GetHabitsWithStatusUseCase`: Calculates daily completion status and current streaks.
- `ToggleHabitEntryUseCase`, `InsertHabitUseCase`, and `DeleteHabitUseCase`.
- **Refactoring:**
- **Use Cases:** Moves `ToggleTaskUseCase` and `DeleteTaskUseCase` from `com.markel.flowstate.core.domain.usecase` to `com.markel.flowstate.core.domain.usecase.tasks`.
- **ViewModels/Tests:** Updates imports in `TaskViewModel`, `TaskEditorViewModel`, and associated unit tests to reflect the new use case package structure.
- **Clean up:** Removes unused imports in `FlowViewModel`.
- **Data Layer:**
- Adds `HabitEntryFlatEntity` and updates `HabitDao` with a query to retrieve all entries as a flow.
- Adds an index on `habitId` in `HabitEntryEntity` for better query performance.
This commit introduces the UI components, ViewModel, and screen implementation for habit tracking, replacing the previous placeholder.
- **Habit Screen:**
- Created `HabitScreen` as the main entry point, featuring a `LazyColumn` for habit cards and a Floating Action Button to add new habits.
- Implemented `HabitViewModel` to manage UI state, utilizing `GetHabitsWithStatusUseCase`, `InsertHabitUseCase`, and `ToggleHabitEntryUseCase`.
- Integrated `HabitEmptyState` to guide users when no habits exist.
- **Components:**
- **`HabitCard`:** Displays habit progress using a horizontal week calendar (via `Kizitonwose` calendar library). It includes a completion toggle and a deletion dialog.
- **`AddHabitDialog`:** Provides a form to enter a habit name and select a color from a predefined palette.
- **`HabitToggleButton`:** A custom animated checkbox with scale and color transitions.
- **Resources & Localization:**
- Added string resources for English (`en`) and Spanish (`es`) covering dialogs, labels, and empty states.
- Added `check_24px` and `add_24px` vector drawables to the design system.
- **Project Configuration:**
- Configured the `:feature:habits` module with necessary dependencies (Hilt, Compose, Calendar library).
- Registered `HabitScreen` in `MainActivity` navigation and added the module dependency to the `:app` build script.
- Removed stale `.idea` configuration files.
A lot of changes.
A header with motivational message and 2 rings ( day time and habit completion).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add habits with detailed information for each one