Skip to content

Conversation

@Aryan-Baglane
Copy link
Contributor

@Aryan-Baglane Aryan-Baglane commented Nov 2, 2025

Fixes

No Jira issue created — this PR adds inline documentation comments for better code clarity and maintainability.

Summary

This PR adds or improves KDoc-style documentation comments across several classes in the feature/settings module.

Changes Made

  • Added KDoc comments for ViewModels and screens under feature/settings/src/commonMain/kotlin/org/mifos/mobile.feature.settings
  • Improved readability and consistency of function and parameter descriptions.

Screenshots

Before After
N/A N/A

Checklist

  • No UI changes — screenshots not required.
  • Verified code compiles successfully.
  • Static analysis passed (./gradlew check).
  • Single commit (squashed if needed).

Summary by CodeRabbit

Release Notes

  • New Features

    • Complete Settings navigation structure with About, App Info, Help, FAQ, and Language/Theme selection screens
    • Help screen with phone support, email support, and FAQ integration
    • Password change functionality with strength validation and feedback
    • Passcode update with validation and visibility controls
    • Language and theme selection interfaces
    • Enhanced logout confirmation dialog with state management
  • Improvements

    • Settings items now display icons and subtitles for better organization
    • Settings profile card with user information
    • Input validation with real-time error feedback

@coderabbitai
Copy link

coderabbitai bot commented Nov 2, 2025

Walkthrough

This PR implements a comprehensive settings feature module for a mobile application, adding multiple screens (About, AppInfo, FAQ, Help, Language, Password change, Passcode update, Theme) with MVVM architecture, navigation setup, and state management integrated with Compose UI components.

Changes

Cohort / File(s) Summary
Navigation Setup
feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/about/AboutNavigation.kt, appInfo/AppInfoNavigation.kt, faq/FaqNavigation.kt, help/HelpNavigation.kt, language/LanguageRoute.kt, passcode/UpdatePasscodeNavigation.kt, password/ChangePasswordNavigation.kt, theme/ChangeThemeRoute.kt, settings/SettingsRoute.kt, navigation/SettingsNavGraphRoute.kt
Adds navigation extension functions and destination builders for all settings screens. Each file introduces navigateTo* methods on NavController and *Destination builders on NavGraphBuilder, wiring callbacks (onBackClick, navigation targets) and registering composable destinations with appropriate transitions.
Settings Root Navigation & Graph
navigation/SettingsNavGraphRoute.kt
Introduces SettingsNavGraphRoute as entry point to nested settings navigation graph; adds settingsGraph builder to register all settings destinations and helper to navigate between screens within the graph.
Core Screens
about/AboutScreen.kt, appInfo/AppInfoScreen.kt, language/LanguageScreen.kt, theme/ChangeThemeScreen.kt
Adds stateful screen entry points wiring ViewModel/DI dependencies, delegates to stateless content composables. Includes KDoc documentation, DI defaults, and preview annotations.
Complex Validation Screens
password/ChangePasswordScreen.kt, passcode/UpdatePasscodeScreen.kt
Introduces dual-overload screens: stateful entry point with ViewModel wiring and stateless composable consuming state/actions. Includes dialog state management, input validation UI, and error display logic.
List-Based Screens
faq/FaqScreen.kt, help/HelpScreen.kt
Adds FAQ list selection with expandable content and Help screen with multiple support card types (phone, email, FAQ contact). Includes refactored card components with parameterized callbacks and resources.
Settings Root Screen & Dialog
settings/SettingsScreen.kt, componenets/MifosLogoutDilaog.kt
Introduces SettingsScreen with profile display and action list, wires logout confirmation dialog with LogoutDialogState sealed interface (Hidden/Shown variants).
State & ViewModel Logic
faq/FaqViewmodel.kt, password/ChangePasswordViewModel.kt, passcode/UpdatePasscodeViewModel.kt
Implements full MVVM workflows with state/event/action hierarchies. Includes input validation (debounced), strength checking, dialog state machines, and error handling. Complex logic for password strength feedback and passcode mismatch detection.
Component Model & DI
componenets/SettingsItems.kt, di/SettingsModule.kt
Updates SettingsItems sealed class with subTitle and icon fields; all data objects (Password, AuthPasscode, Language, Theme, AboutUs, FAQ, Help, AppInfo, Logout) now supply these properties and route identifiers. Adds SettingsModule DI registrations for new ViewModels.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SettingsScreen
    participant ViewModel
    participant Repository
    participant Dialog

    User->>SettingsScreen: Click Settings Item
    SettingsScreen->>ViewModel: trySendAction(action)
    ViewModel->>ViewModel: handleAction()
    
    alt Validation Flow (Password/Passcode)
        ViewModel->>ViewModel: validate input<br/>(debounced)
        ViewModel->>ViewModel: emit state with<br/>errors or feedback
        SettingsScreen->>SettingsScreen: Update UI<br/>with errors
    end
    
    User->>SettingsScreen: Click Submit
    SettingsScreen->>ViewModel: trySendAction(SubmitClick)
    ViewModel->>Repository: Update (password/<br/>passcode/settings)
    Repository-->>ViewModel: Result<T>
    
    alt Success
        ViewModel->>ViewModel: emit Internal.Result<br/>success action
        ViewModel->>Dialog: Show Success Dialog
        Dialog-->>User: Success message
    else Error/Validation Fail
        ViewModel->>Dialog: Show Error Dialog
        Dialog-->>User: Error message
    end
    
    User->>SettingsScreen: Click Back/Navigate
    SettingsScreen->>ViewModel: trySendEvent(OnNavigateBack)
    ViewModel->>ViewModel: clearSensitiveData()
    ViewModel-->>SettingsScreen: Emit event
    SettingsScreen->>User: Navigate back
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45–75 minutes

Areas requiring extra attention:

  • Validation Logic: ChangePasswordViewModel and UpdatePasscodeViewModel contain extensive input validation, debounce handling, and strength checking; verify correctness of regex/length constraints and cross-field validation (e.g., newPassword ≠ oldPassword, confirmPassword == newPassword).
  • Dialog State Machines: Review state transitions in LoadingDialog → SuccessDialog/ErrorDialog flows across password, passcode, and logout dialogs; ensure no stuck states or missing dismissal paths.
  • Navigation Graph Integration: SettingsNavGraphRoute wires all destinations; verify route parameters, transition types (push vs. slide), and callback wiring match expected navigation flows.
  • SettingsItems Refactoring: Changes to SettingsItems sealed class add subTitle and icon fields across all nine data objects; verify all usages in downstream screens/lists reflect the new structure.
  • ViewModel State Initialization: Each ViewModel subscribes to repository streams or loads data on init (e.g., FaqViewModel.loadFaqList, UpdatePasscodeViewModel.subscribeToPasscode); confirm subscriptions are canceled in onCleared to prevent memory leaks.
  • DI & koinViewModel Defaults: Multiple screens now default to koinViewModel() for DI; verify module registrations in SettingsModule cover all ViewModels (watch for duplicate UpdatePasscodeViewModel registration noted in diff).

Poem

🐰 A warren of screens now organized so neat,
With passwords and passcodes to keep users sweet,
From themes to FAQ, each item aligned,
Settings flow smoothly through structured design!
Validation and dialogs, no state left behind! 🎯

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The PR title "docs update/MM-442" is misleading relative to the actual scope and nature of the changes. While the PR objectives mention adding KDoc-style documentation, the raw_summary reveals extensive structural changes including multiple new sealed interfaces and data classes, comprehensive MVVM implementations for several screens, major screen composable refactoring (stateful/stateless separation), new navigation helpers, dependency registrations, and significant business logic additions. Documentation improvements represent only a minor aspect of this changeset, not the primary change. A developer scanning the commit history with this title would be significantly misled about what the PR actually implements.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 80.81% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (6)
feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/appInfo/AppInfoScreen.kt (1)

51-91: Correct inaccurate App Info KDoc.

AppInfoScreen is described as a “stateful wrapper,” yet it simply delegates to AppInfoContent without holding state. Likewise, AppInfoContent claims to render links to legal documents, but those buttons are still commented out. Please update the KDoc so it accurately reflects the current behavior, or reintroduce the missing UI before keeping those descriptions. A possible wording tweak:

- * The main composable for the App Info screen, which acts as a stateful wrapper
- * around the core UI content.
+ * The main composable entry point for the App Info screen that delegates to the stateless
+ * UI content.
@@
- * Renders the stateless UI content for the App Info screen. This includes details
- * about the app, version, and links to legal documents.
+ * Renders the stateless UI content for the App Info screen. This includes the app details
+ * and version information (legal links can be wired in once the corresponding screens exist).
feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/passcode/UpdatePasscodeViewModel.kt (1)

284-295: Clear confirm passcode error in clearSensitiveData.

The new KDoc says we clear every field and its error, but confirmPasscodeError is left untouched. After a successful update the confirm field is blank yet the old error resurfaces, which keeps the UI in an error state during the next interaction. Please null out the confirm error when wiping sensitive state.

Apply this diff to resolve it:

         mutableStateFlow.update {
             it.copy(
                 oldPasscode = "",
                 newPasscode = "",
                 confirmPasscode = "",
                 oldPasscodeError = null,
                 newPasscodeError = null,
+                confirmPasscodeError = null,
             )
         }
feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/password/ChangePasswordViewModel.kt (2)

331-353: Surface failures as errors, not successes.

If repository.updateAccountPassword throws, we currently flip the dialog to DialogState.Success while showing the failure string. That leaves the UI in a “success” state despite the operation failing. Please switch this to an error dialog (or otherwise treat it as a failure) so UX and logic stay aligned.

Suggested change:

                 mutableStateFlow.update {
                     it.copy(
-                        dialogState = PasswordState.DialogState.Success(Res.string.password_update_failed),
+                        dialogState = PasswordState.DialogState.Error(Res.string.password_update_failed),
                     )
                 }

363-404: Do not force logout on failed attempts.

The documentation says we log the user out after a successful change, yet the coroutine after the when logs out for every result. This kicks users back to login even after validation failures or backend errors. Please remove or guard that unconditional logout so it only runs when the update succeeds.

One way to fix it:

-        viewModelScope.launch {
-            delay(2500)
-            userDataRepository.logOut()
-        }
feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/password/ChangePasswordScreen.kt (1)

155-168: Restore the new password error hint.

The conditional on Line 157 is inverted, so hint is always null and the field never surfaces state.newPasswordError. Users lose the inline validation message whenever the new password is invalid. Flip the condition (or just assign the property directly) so the hint displays whenever an error exists.

-        hint = if (state.newPasswordError == null) {
-            state.newPasswordError
-        } else {
-            null
-        },
+        hint = if (state.newPasswordError != null) {
+            state.newPasswordError
+        } else {
+            null
+        },
feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/di/SettingsModule.kt (1)

26-34: Remove duplicate UpdatePasscodeViewModel registration

viewModelOf(::UpdatePasscodeViewModel) is declared twice. Koin treats this as an illegal duplicate definition and will throw DefinitionOverrideException when the module loads, breaking app start-up. Please keep only one registration.

     viewModelOf(::SettingsViewModel)
     viewModelOf(::UpdatePasscodeViewModel)
     viewModelOf(::ChangePasswordViewModel)
-    viewModelOf(::UpdatePasscodeViewModel)
     viewModelOf(::FaqViewModel)
     viewModelOf(::LanguageViewModel)
     viewModelOf(::ChangeThemeViewModel)
🧹 Nitpick comments (2)
feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/passcode/UpdatePasscodeScreen.kt (1)

46-53: Excellent documentation!

The KDoc comments clearly distinguish between stateful and stateless composables, accurately describe parameters, and follow proper conventions. This significantly improves code readability.

One optional refinement: The parameter name viewmodel at line 58 could be viewModel (capital M) for consistency with naming conventions in other files (e.g., SettingsScreen.kt line 75), but the current KDoc accurately reflects the actual parameter name.

Also applies to: 85-92, 117-123, 200-206

feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/faq/FaqViewmodel.kt (1)

84-129: Comprehensive state and action documentation!

The KDoc comments provide clear descriptions of the state structure, events, and actions. The documentation helps developers understand the data flow and available operations.

Optional refinement: Consider standardizing the documentation style for events and actions. For example, lines 99 and 102 use full sentences ("Signals that the UI should...") while lines 110 and 113 use sentence fragments ("An action to..."). Either style works, but consistency enhances readability.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 43af85e and 68eb9b0.

📒 Files selected for processing (25)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/about/AboutNavigation.kt (2 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/about/AboutScreen.kt (3 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/appInfo/AppInfoNavigation.kt (1 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/appInfo/AppInfoScreen.kt (2 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/componenets/MifosLogoutDilaog.kt (3 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/componenets/SettingsItems.kt (11 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/di/SettingsModule.kt (1 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/faq/FaqNavigation.kt (2 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/faq/FaqScreen.kt (4 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/faq/FaqViewmodel.kt (3 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/help/HelpNavigation.kt (1 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/help/HelpScreen.kt (15 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/language/LanguageRoute.kt (1 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/language/LanguageScreen.kt (4 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/navigation/SettingsNavGraphRoute.kt (2 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/passcode/UpdatePasscodeNavigation.kt (1 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/passcode/UpdatePasscodeScreen.kt (4 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/passcode/UpdatePasscodeViewModel.kt (11 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/password/ChangePasswordNavigation.kt (1 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/password/ChangePasswordScreen.kt (4 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/password/ChangePasswordViewModel.kt (18 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/settings/SettingsRoute.kt (1 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/settings/SettingsScreen.kt (5 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/theme/ChangeThemeRoute.kt (2 hunks)
  • feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/theme/ChangeThemeScreen.kt (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/passcode/UpdatePasscodeViewModel.kt (1)
feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/password/ChangePasswordViewModel.kt (1)
  • clearSensitiveData (486-499)
feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/password/ChangePasswordViewModel.kt (1)
feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/passcode/UpdatePasscodeViewModel.kt (1)
  • clearSensitiveData (286-296)
🔇 Additional comments (7)
feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/language/LanguageScreen.kt (1)

43-72: KDoc clarifies stateful wrapper responsibilities

The added documentation neatly explains how LanguageScreen wires state and actions around the stateless content. Nice clarity boost.

feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/faq/FaqNavigation.kt (1)

18-44: Navigation docs are helpful

The KDoc accurately captures the destination wiring and the new navigation helper. Thanks for tightening this up.

feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/faq/FaqScreen.kt (1)

51-199: Documentation matches the FAQ flow

The new comments describe the MVVM wiring and preview usage well. Improves readability without altering behavior.

feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/theme/ChangeThemeScreen.kt (1)

42-149: Theme screen KDoc reads well

Documentation clearly separates the responsibilities between the stateful wrapper, stateless content, and preview. No issues spotted.

feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/navigation/SettingsNavGraphRoute.kt (1)

29-32: Well-documented navigation architecture!

The KDoc comments provide clear explanations of the navigation graph structure, entry points, and helper functions. The documentation accurately describes the purpose of each function and properly distinguishes between public and internal APIs.

Also applies to: 36-41, 45-50, 92-98

feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/faq/FaqViewmodel.kt (1)

22-25: Clear ViewModel documentation!

The KDoc comments effectively explain the ViewModel's responsibilities, including state management, action handling, and data loading. The descriptions are accurate and helpful.

Also applies to: 36-40, 59-62

feature/settings/src/commonMain/kotlin/org/mifos/mobile/feature/settings/settings/SettingsScreen.kt (1)

60-70: Excellent composable documentation!

The KDoc comments provide comprehensive coverage of all major composables in the Settings screen. The documentation clearly explains the role of each component, distinguishes between stateful and stateless variants, and accurately describes all parameters. This significantly enhances maintainability.

Also applies to: 103-109, 134-143, 203-209, 255-261

@WizCoderr
Copy link
Contributor

great work

@WizCoderr
Copy link
Contributor

@therajanmaurya Sir it is ready for merge

@therajanmaurya therajanmaurya merged commit 989d07e into openMF:development Nov 4, 2025
8 checks passed
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.

6 participants