feat : Added Time Based Sorting
Summary by CodeRabbit
-
New Features
- Time-based dark mode: choose "Based on Time" in settings to enable automatic dark mode during a configurable time window (default 18:00–06:00).
- New time-picker dialog in Settings to set start/end times with Apply/Cancel controls and updated localized strings.
-
Chores
- Updated project wiring and dependencies to support the new theming features.
✏️ Tip: You can customize this high-level summary in your review settings.
Adds time-based dark theme support: new TimeBasedTheme model and BASED_ON_TIME enum; DateHelper utilities; repository and datastore observables/setters; UI for selecting time ranges (TimeBasedThemeDialog) and settings wiring; AppViewModel observes and applies time-based theme updates. Also a small AppThemeExtensions branch added for BASED_ON_TIME. 🎯 4 (Complex) | ⏱️ ~45 minutes 🐰📝 Walkthrough
Walkthrough
Changes
Cohort / File(s)
Summary
Data Models
core/model/.../TimeBasedTheme.kt, core/model/.../DarkThemeConfig.kt, core/model/.../UserData.ktNew
TimeBasedTheme data class; added BASED_ON_TIME to DarkThemeConfig; UserData gains timeBasedTheme and DEFAULT updated (also enableScreenCapture set true).
Time Utilities
core/common/.../DateHelper.kt, cmp-android/src/main/kotlin/cmp/android/app/AppThemeExtensions.ktNew
DateHelper with isDarkModeBasedOnTime(), formatTimeRange(), format(); AppThemeExtensions.isDarkMode now handles BASED_ON_TIME (mapped to false branch in extension).
Repository / Datastore
core/data/.../UserDataRepository.kt, core/data/.../UserDataRepositoryImpl.kt, core/datastore/.../UserPreferencesRepository.kt, core/datastore/.../UserPreferencesRepositoryImpl.ktAdded
observeTimeBasedThemeConfig: Flow<TimeBasedTheme> and suspend setTimeBasedThemeConfig(TimeBasedTheme) across repo and datastore interfaces and implementations; wiring to persist and emit time-based theme.
App State & Navigation
cmp-navigation/src/commonMain/kotlin/cmp/navigation/AppViewModel.ktAppState gains timeBasedTheme; new AppAction.Internal.TimeBasedThemeUpdate; AppViewModel observes time-based config, dispatches and handles updates, and computes darkTheme considering BASED_ON_TIME via DateHelper.
Settings UI & ViewModel
feature/settings/.../SettingsDialog.kt, feature/settings/.../SettingsScreen.kt, feature/settings/.../SettingsViewmodel.kt, feature/settings/build.gradle.ktsAdded
TimeBasedThemeDialog composable and helpers (TimeRow, TimePickerDialog); SettingsDialog signature gains onChangeTimeBasedTheme; SettingsViewmodel and UserEditableSettings include timeBasedTheme and updateTimeBasedThemeConfig(); added core.common dependency.
Resources & Classpath
feature/settings/src/commonMain/composeResources/values/strings.xml, cmp-android/dependencies/prodReleaseRuntimeClasspath.tree.txtAdded strings for time-based theme UI (start/end labels, apply/cancel/ok, labels); runtime classpath snapshot extended to include
project :core:common entries in dependency tree.Sequence Diagram(s)
sequenceDiagram
actor User
participant SettingsUI as Settings UI
participant TimeDialog as TimeBasedThemeDialog
participant SettingsVM as SettingsViewmodel
participant Repo as UserDataRepository
participant Prefs as UserPreferencesRepository
participant AppVM as AppViewModel
participant DateHelper as DateHelper
participant Theme as AppThemeExtensions
User->>SettingsUI: Choose "Based on Time"
SettingsUI->>TimeDialog: Open time picker
User->>TimeDialog: Set start/end -> Confirm
TimeDialog->>SettingsVM: updateTimeBasedThemeConfig(timeBasedTheme)
SettingsVM->>Repo: setTimeBasedThemeConfig(timeBasedTheme)
Repo->>Prefs: setTimeBasedThemeConfig(timeBasedTheme)
Prefs->>Prefs: Persist
Prefs-->>AppVM: observeTimeBasedThemeConfig emits
AppVM->>AppVM: Dispatch TimeBasedThemeUpdate
AppVM->>DateHelper: isDarkModeBasedOnTime(start,end)
DateHelper-->>AppVM: true/false
AppVM->>Theme: Apply dark/light theme
Theme-->>User: Render updated theme
Estimated code review effort
Poem
I nibble at dusk and nibble at dawn,
I set the hours where shadows are drawn;
A hop, a tick, a toggled light—
Time-made twilight feels just right;
Hooray for themes that follow the sun!
Pre-merge checks and finishing touches
❌ Failed checks (2 warnings)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Title check | ⚠️ Warning | The title 'Added Time Based Sorting' does not accurately describe the changeset. The PR implements time-based theming (dark mode scheduling), not sorting functionality. | Update the title to reflect the actual feature: 'feat: Add time-based dark mode theming' or 'feat: Implement scheduled dark mode based on time of day'. |
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 2.70% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (1 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
📜 Recent review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between dc74175e4bc1fbbf7e92863a3fb082e276a9efbd and eab2553ea94d0b43d97b7bc169761f8b781ad926.
📒 Files selected for processing (2)
core/datastore/src/commonMain/kotlin/org/mifos/core/datastore/UserPreferencesRepository.ktcore/datastore/src/commonMain/kotlin/org/mifos/core/datastore/UserPreferencesRepositoryImpl.kt
🚧 Files skipped from review as they are similar to previous changes (2)
- core/datastore/src/commonMain/kotlin/org/mifos/core/datastore/UserPreferencesRepositoryImpl.kt
- core/datastore/src/commonMain/kotlin/org/mifos/core/datastore/UserPreferencesRepository.kt
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.