From 19e91a47d2f6f5c0915c5aeeaf34eec3e9e3c05e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastia=CC=81n=20Cardona=20Henao?= Date: Thu, 20 Nov 2025 16:28:31 +0100 Subject: [PATCH 1/2] feature/MM/437-development_onboarding_doc --- .../dep_graph_feature_onboarding_language.svg | 176 ++++++++++++++++++ feature/onboarding-language/README.md | 49 +++++ .../SetOnboardingLanguageViewModel.kt | 71 +++++++ 3 files changed, 296 insertions(+) create mode 100644 docs/images/graphs/dep_graph_feature_onboarding_language.svg create mode 100644 feature/onboarding-language/README.md diff --git a/docs/images/graphs/dep_graph_feature_onboarding_language.svg b/docs/images/graphs/dep_graph_feature_onboarding_language.svg new file mode 100644 index 0000000000..ebbf760428 --- /dev/null +++ b/docs/images/graphs/dep_graph_feature_onboarding_language.svg @@ -0,0 +1,176 @@ + + + + +G + + + +:feature:onboarding-language + +:feature:onboarding-language + + + +:core:designsystem + +:core:designsystem + + + +:feature:onboarding-language->:core:designsystem + + + + + +:core:ui + +:core:ui + + + +:feature:onboarding-language->:core:ui + + + + + +:core:data + +:core:data + + + +:feature:onboarding-language->:core:data + + + + + +:core:model + +:core:model + + + +:feature:onboarding-language->:core:model + + + + + +:core:common + +:core:common + + + +:feature:onboarding-language->:core:common + + + + + +:core:ui->:core:designsystem + + + + + +:core:ui->:core:model + + + + + +:core:ui->:core:common + + + + + +:core:data->:core:model + + + + + +:core:data->:core:common + + + + + +:core:network + +:core:network + + + +:core:data->:core:network + + + + + +:core:database + +:core:database + + + +:core:data->:core:database + + + + + +:core:datastore + +:core:datastore + + + +:core:data->:core:datastore + + + + + +:core:model->:core:common + + + + + +:core:network->:core:model + + + + + +:core:network->:core:common + + + + + +:core:network->:core:datastore + + + + + +:core:datastore->:core:model + + + + + +:core:datastore->:core:common + + + + + diff --git a/feature/onboarding-language/README.md b/feature/onboarding-language/README.md new file mode 100644 index 0000000000..b1380fb64b --- /dev/null +++ b/feature/onboarding-language/README.md @@ -0,0 +1,49 @@ +# Onboarding Language Module + +## Dependencies + +![Dependency Graph](../docs/images/graphs/dep_graph_feature_onboarding_language.svg) + +## Sequence Diagram + +```mermaid +sequenceDiagram + participant User + participant Screen as SetOnboardingLanguageScreen + participant ViewModel as SetOnboardingLanguageViewModel + participant Repository as UserPreferencesRepository + + User->>Screen: Selects language + Screen->>ViewModel: handleAction(SetLanguage(language)) + ViewModel->>Repository: setLanguage(language) + Repository-->>ViewModel: Language updated + ViewModel->>Screen: Update UI with new language + + Note over Screen,Repository: Language preference is now persisted + + User->>Screen: Clicks continue + Screen->>ViewModel: handleAction(ContinueToNextScreen) + ViewModel-->>Screen: Navigate to next screen +``` + +## Architecture + +```mermaid +graph TD + subgraph UI Layer + A[SetOnboardingLanguageScreen] -->|Observes| B[SetOnboardingLanguageViewModel] + end + + subgraph Domain Layer + B -->|Uses| C[UserPreferencesRepository] + end + + subgraph Data Layer + C -->|Manages| D[Language Preferences] + end + + style A fill:#e3f2fd,stroke:#1565c0 + style B fill:#e8f5e9,stroke:#2e7d32 + style C fill:#fff3e0,stroke:#f57c00 + style D fill:#f3e5f5,stroke:#7b1fa2 +``` \ No newline at end of file diff --git a/feature/onboarding-language/src/commonMain/kotlin/org/mifos/mobile/feature/onboarding/language/SetOnboardingLanguageViewModel.kt b/feature/onboarding-language/src/commonMain/kotlin/org/mifos/mobile/feature/onboarding/language/SetOnboardingLanguageViewModel.kt index 55ab4afddb..5c34fd6ee7 100644 --- a/feature/onboarding-language/src/commonMain/kotlin/org/mifos/mobile/feature/onboarding/language/SetOnboardingLanguageViewModel.kt +++ b/feature/onboarding-language/src/commonMain/kotlin/org/mifos/mobile/feature/onboarding/language/SetOnboardingLanguageViewModel.kt @@ -19,6 +19,16 @@ import org.mifos.mobile.core.datastore.UserPreferencesRepository import org.mifos.mobile.core.model.LanguageConfig import org.mifos.mobile.core.ui.utils.BaseViewModel +/** + * ViewModel responsible for managing the onboarding language selection screen state and business logic. + * + * This ViewModel handles: + * - Loading the current language preference + * - Updating the selected language + * - Managing the onboarding flow state + * + * @property repository [UserPreferencesRepository] for accessing and modifying user preferences + */ internal class SetOnboardingLanguageViewModel( private val repository: UserPreferencesRepository, ) : BaseViewModel( @@ -31,6 +41,10 @@ internal class SetOnboardingLanguageViewModel( .launchIn(viewModelScope) } + /** + * Processes incoming actions and delegates to appropriate handlers. + * @param action The action to process + */ override fun handleAction(action: OnboardingLanguageAction) { when (action) { is OnboardingLanguageAction.Internal.LoadLanguage -> handleLoadLanguage(action) @@ -38,6 +52,24 @@ internal class SetOnboardingLanguageViewModel( } } + /** + * Updates the selected language and updates onboarding state. + * + * This method will: + * 1. Persist the new language preference + * 2. Update the UI state + * 3. Mark onboarding as complete + * + * @param action Contains the new language configuration + * + * Example: + * ```kotlin + * // When user selects a language + * viewModel.trySendAction( + * OnboardingLanguageAction.SetLanguage(selectedLanguage) + * ) + * ``` + */ private fun handleSetLanguage(action: OnboardingLanguageAction.SetLanguage) { viewModelScope.launch { repository.setLanguage(action.languageConfig) @@ -49,6 +81,23 @@ internal class SetOnboardingLanguageViewModel( } } + /** + * Updates the current language in the state. + * + * This is called internally when the language preference changes. + * + * @param action Contains the language to load + * + * Example: + * ```kotlin + * // Internal usage - triggered by language preference changes + * private fun onLanguagePreferenceChanged(newLanguage: LanguageConfig) { + * trySendAction( + * OnboardingLanguageAction.Internal.LoadLanguage(newLanguage) + * ) + * } + * ``` + */ private fun handleLoadLanguage(action: OnboardingLanguageAction.Internal.LoadLanguage) { mutableStateFlow.update { it.copy(currentLanguage = action.language) @@ -56,16 +105,38 @@ internal class SetOnboardingLanguageViewModel( } } +/** + * Represents the UI state for the language selection screen. + * @property currentLanguage The currently selected language + */ internal data class OnboardingLanguageState( val currentLanguage: LanguageConfig, ) +/** + * Events that can be triggered from the UI. + * Currently not used but available for future extensions. + */ internal sealed interface OnboardingLanguageEvent +/** + * Actions that can be processed by the ViewModel. + */ internal sealed interface OnboardingLanguageAction { + /** + * Action to set a new language. + * @property languageConfig The language configuration to set + */ data class SetLanguage(val languageConfig: LanguageConfig) : OnboardingLanguageAction + /** + * Internal actions used by the ViewModel for state management. + */ sealed interface Internal : OnboardingLanguageAction { + /** + * Action to load a language configuration. + * @property language The language configuration to load + */ data class LoadLanguage(val language: LanguageConfig) : Internal } } From 758ecd3883f245a74fb91b730f610a11e8dbd567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Cardona=20Henao?= <73314356+SCHsebastian@users.noreply.github.com> Date: Thu, 20 Nov 2025 22:56:51 +0100 Subject: [PATCH 2/2] Update README to remove continue action details Removed user action flow for continuing to the next screen. --- feature/onboarding-language/README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/feature/onboarding-language/README.md b/feature/onboarding-language/README.md index b1380fb64b..5c0cbda42d 100644 --- a/feature/onboarding-language/README.md +++ b/feature/onboarding-language/README.md @@ -20,10 +20,6 @@ sequenceDiagram ViewModel->>Screen: Update UI with new language Note over Screen,Repository: Language preference is now persisted - - User->>Screen: Clicks continue - Screen->>ViewModel: handleAction(ContinueToNextScreen) - ViewModel-->>Screen: Navigate to next screen ``` ## Architecture @@ -46,4 +42,4 @@ graph TD style B fill:#e8f5e9,stroke:#2e7d32 style C fill:#fff3e0,stroke:#f57c00 style D fill:#f3e5f5,stroke:#7b1fa2 -``` \ No newline at end of file +```