Skip to content

Feature: habits#4

Merged
Markel15 merged 6 commits intomasterfrom
feature/habits
Mar 15, 2026
Merged

Feature: habits#4
Markel15 merged 6 commits intomasterfrom
feature/habits

Conversation

@Markel15
Copy link
Owner

Add habits with detailed information for each one

Markel15 and others added 5 commits March 11, 2026 18:31
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 header with motivational message and 2 rings ( day time and habit completion).
@Markel15 Markel15 merged commit 350306a into master Mar 15, 2026
1 check passed
@Markel15 Markel15 deleted the feature/habits branch March 15, 2026 16:22
@Markel15 Markel15 restored the feature/habits branch March 15, 2026 16:22
@Markel15 Markel15 deleted the feature/habits branch March 15, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant