Skip to content

Commit 1af413c

Browse files
committed
documentation update for the feature/application
1 parent 768a6a6 commit 1af413c

File tree

6 files changed

+162
-0
lines changed

6 files changed

+162
-0
lines changed

feature/savings-application/src/commonMain/kotlin/org/mifos/mobile/feature/savings/application/di/SavingsApplicationModule.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,21 @@ import org.koin.dsl.module
1414
import org.mifos.mobile.feature.savings.application.fillApplication.SavingsFillApplicationViewModel
1515
import org.mifos.mobile.feature.savings.application.savingsApplication.SavingsApplyViewModel
1616

17+
/**
18+
* Koin module for providing dependencies related to the Savings Application feature.
19+
*
20+
* This module declares the ViewModels used in the savings account application process,
21+
* allowing Koin's dependency injection framework to construct and provide them where needed.
22+
*/
1723
val savingsApplicationModule = module {
24+
/**
25+
* Provides an instance of [SavingsApplyViewModel].
26+
* This ViewModel manages the logic for the initial savings application screen.
27+
*/
1828
viewModelOf(::SavingsApplyViewModel)
29+
/**
30+
* Provides an instance of [SavingsFillApplicationViewModel].
31+
* This ViewModel handles the logic for filling out the details of a new savings application.
32+
*/
1933
viewModelOf(::SavingsFillApplicationViewModel)
2034
}

feature/savings-application/src/commonMain/kotlin/org/mifos/mobile/feature/savings/application/fillApplication/FillApplicationRoute.kt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,35 @@ import androidx.navigation.NavOptions
1717
import kotlinx.serialization.Serializable
1818
import org.mifos.mobile.core.ui.composableWithSlideTransitions
1919

20+
/**
21+
* A type-safe, serializable route for the "Fill Savings Application" screen.
22+
*
23+
* This class encapsulates the necessary parameters required to fill out a new
24+
* savings account application, ensuring robust and error-free navigation.
25+
*
26+
* @property savingsProductId The unique identifier of the selected savings product.
27+
* @property fieldOfficerId The unique identifier of the assigned field officer.
28+
* @property fieldOfficerName The name of the assigned field officer.
29+
*/
2030
@Serializable
2131
data class SavingsFillApplicationRoute(
2232
val savingsProductId: Long,
2333
val fieldOfficerId: Long,
2434
val fieldOfficerName: String,
2535
)
2636

37+
/**
38+
* Navigates to the "Fill Savings Application" screen.
39+
*
40+
* This is an extension function on [NavController] that simplifies the process
41+
* of navigating to the application form by constructing and passing the
42+
* [SavingsFillApplicationRoute] with the required product and officer details.
43+
*
44+
* @param savingsProductId The ID of the savings product.
45+
* @param fieldOfficerId The ID of the field officer.
46+
* @param fieldOfficerName The name of the field officer.
47+
* @param navOptions Optional [NavOptions] to apply to this navigation operation.
48+
*/
2749
fun NavController.navigateToSavingsFillApplicationScreen(
2850
savingsProductId: Long,
2951
fieldOfficerId: Long,
@@ -33,6 +55,20 @@ fun NavController.navigateToSavingsFillApplicationScreen(
3355
this.navigate(SavingsFillApplicationRoute(savingsProductId, fieldOfficerId, fieldOfficerName), navOptions)
3456
}
3557

58+
59+
/**
60+
* Defines the composable destination for the "Fill Savings Application" screen
61+
* within the navigation graph.
62+
*
63+
* This function sets up the route and the screen content (`SavingsFillApplicationScreen`),
64+
* and wires up the necessary navigation callbacks for actions initiated from the screen.
65+
*
66+
* @param navigateToAuthenticateScreen A lambda to navigate to an authentication screen,
67+
* typically required before submitting the application.
68+
* @param navigateToStatusScreen A lambda to navigate to a generic status/result screen
69+
* after the application submission is complete.
70+
* @param navigateBack A lambda function to handle the back navigation event.
71+
*/
3672
fun NavGraphBuilder.savingsFillApplicationDestination(
3773
navigateToAuthenticateScreen: () -> Unit,
3874
navigateToStatusScreen: (String, String, String, String, String) -> Unit,

feature/savings-application/src/commonMain/kotlin/org/mifos/mobile/feature/savings/application/fillApplication/FillApplicationScreen.kt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ import org.mifos.mobile.core.ui.component.MifosProgressIndicatorOverlay
6363
import org.mifos.mobile.core.ui.utils.EventsEffect
6464
import org.mifos.mobile.core.ui.utils.ScreenUiState
6565

66+
/**
67+
* A stateful composable serving as the entry point for the "Fill Savings Application" screen.
68+
*
69+
* This function connects to the [SavingsFillApplicationViewModel] to observe state, handle UI
70+
* events, and orchestrate navigation based on user actions and ViewModel commands.
71+
*
72+
* @param navigateBack A lambda to handle the back navigation event.
73+
* @param navigateToStatusScreen A lambda to navigate to a generic status screen after an operation.
74+
* @param navigateToAuthenticateScreen A lambda to navigate to an authentication screen for sensitive actions.
75+
* @param viewModel The ViewModel responsible for the screen's logic and state.
76+
*/
6677
@Composable
6778
internal fun SavingsFillApplicationScreen(
6879
navigateBack: () -> Unit,
@@ -106,6 +117,16 @@ internal fun SavingsFillApplicationScreen(
106117
)
107118
}
108119

120+
/**
121+
* A composable responsible for displaying dialogs based on the [SavingsApplicationDialogState].
122+
*
123+
* This function handles the presentation of error dialogs and confirmation dialogs
124+
* for unsaved changes.
125+
*
126+
* @param state The current [SavingsApplicationState] used for context like network status.
127+
* @param dialogState The current state of the dialog to be displayed.
128+
* @param onAction A callback to send actions (like dismiss or confirm) to the ViewModel.
129+
*/
109130
@Composable
110131
internal fun SavingsFillApplicationDialog(
111132
state: SavingsApplicationState,
@@ -135,6 +156,16 @@ internal fun SavingsFillApplicationDialog(
135156
}
136157
}
137158

159+
/**
160+
* A stateless composable that renders the main UI for the "Fill Savings Application" screen.
161+
*
162+
* It conditionally displays UI based on the [ScreenUiState] (e.g., loading, error, success).
163+
* The success state includes a form with various input fields for the application details.
164+
*
165+
* @param state The current [SavingsApplicationState] to render.
166+
* @param onAction A callback to send user actions to the ViewModel.
167+
* @param modifier The [Modifier] to be applied to the layout.
168+
*/
138169
@Composable
139170
internal fun SavingsFillApplicationContent(
140171
state: SavingsApplicationState,

feature/savings-application/src/commonMain/kotlin/org/mifos/mobile/feature/savings/application/navigation/SavingsApplicationNavGraph.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,38 @@ import org.mifos.mobile.feature.savings.application.fillApplication.savingsFillA
1919
import org.mifos.mobile.feature.savings.application.savingsApplication.SavingsApplyRoute
2020
import org.mifos.mobile.feature.savings.application.savingsApplication.savingsApplyDestination
2121

22+
/**
23+
* A type-safe, serializable object representing the route for the nested
24+
* Savings Application navigation graph.
25+
*/
2226
@Serializable
2327
data object SavingsApplicationNavGraph
2428

29+
/**
30+
* Navigates to the Savings Application navigation graph.
31+
*
32+
* This is a convenience extension function on [NavController] that encapsulates
33+
* the logic for navigating to the start of the savings application feature.
34+
*
35+
* @param navOptions Optional [NavOptions] to apply to this navigation operation.
36+
*/
2537
fun NavController.navigateToSavingsApplicationGraph(navOptions: NavOptions? = null) {
2638
this.navigate(SavingsApplicationNavGraph, navOptions)
2739
}
2840

41+
/**
42+
* Builds the nested navigation graph for the savings account application feature.
43+
*
44+
* This function defines all the destinations within the savings application module
45+
* (product selection and form filling) and wires them together. It promotes a
46+
* decoupled architecture by accepting lambdas for navigation to external screens.
47+
*
48+
* @param navController The [NavController] used for handling navigation events within the graph.
49+
* @param navigateToAuthenticateScreen Lambda to navigate to an authentication screen,
50+
* required before submitting the application.
51+
* @param navigateToStatusScreen Lambda to navigate to a generic status/result screen
52+
* after the application submission is complete.
53+
*/
2954
fun NavGraphBuilder.savingsApplicationNavGraph(
3055
navController: NavController,
3156
navigateToAuthenticateScreen: () -> Unit,

feature/savings-application/src/commonMain/kotlin/org/mifos/mobile/feature/savings/application/savingsApplication/SavingsApplyRoute.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,38 @@ import androidx.navigation.NavOptions
1515
import kotlinx.serialization.Serializable
1616
import org.mifos.mobile.core.ui.composableWithSlideTransitions
1717

18+
/**
19+
* A type-safe, serializable object representing the route for the initial
20+
* "Apply for Savings Account" screen. This serves as the entry point for
21+
* the savings application flow.
22+
*/
1823
@Serializable
1924
data object SavingsApplyRoute
2025

26+
/**
27+
* Navigates to the "Apply for Savings Account" screen.
28+
*
29+
* This is an extension function on [NavController] that simplifies navigating
30+
* to the savings product selection screen.
31+
*
32+
* @param navOptions Optional [NavOptions] to apply to this navigation operation.
33+
*/
2134
fun NavController.navigateToSavingsApplyScreen(
2235
navOptions: NavOptions? = null,
2336
) =
2437
navigate(SavingsApplyRoute, navOptions)
2538

39+
/**
40+
* Defines the composable destination for the "Apply for Savings Account" screen
41+
* within the navigation graph.
42+
*
43+
* This function sets up the route, the screen content (`SavingsApplyScreen`),
44+
* and wires up the navigation callbacks for actions initiated from this screen.
45+
*
46+
* @param navigateToFillDetailsScreen A lambda to navigate to the application form screen,
47+
* passing the selected product ID, officer ID, and officer name.
48+
* @param navigateBack A lambda function to handle the back navigation event.
49+
*/
2650
fun NavGraphBuilder.savingsApplyDestination(
2751
navigateToFillDetailsScreen: (Long, Long, String) -> Unit,
2852
navigateBack: () -> Unit,

feature/savings-application/src/commonMain/kotlin/org/mifos/mobile/feature/savings/application/savingsApplication/SavingsApplyScreen.kt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ import org.mifos.mobile.core.ui.component.MifosProgressIndicatorOverlay
5151
import org.mifos.mobile.core.ui.utils.EventsEffect
5252
import org.mifos.mobile.core.ui.utils.ScreenUiState
5353

54+
/**
55+
* A stateful composable that serves as the entry point for the "Apply for Savings" screen.
56+
*
57+
* This function connects to the [SavingsApplyViewModel] to observe UI state and handle
58+
* one-time events. It is responsible for orchestrating navigation to the next step
59+
* in the application process.
60+
*
61+
* @param navigateBack A lambda function to handle back navigation events.
62+
* @param navigateToFillDetailsScreen A lambda to navigate to the detailed application form,
63+
* passing product and officer information.
64+
* @param viewModel The ViewModel responsible for the screen's logic and state.
65+
*/
5466
@Composable
5567
internal fun SavingsApplyScreen(
5668
navigateBack: () -> Unit,
@@ -87,6 +99,15 @@ internal fun SavingsApplyScreen(
8799
)
88100
}
89101

102+
/**
103+
* A composable responsible for displaying dialogs based on the [SavingsApplicationDialogState].
104+
*
105+
* This function handles the presentation of error dialogs and confirmation dialogs
106+
* for unsaved changes.
107+
*
108+
* @param dialogState The current state of the dialog to be displayed.
109+
* @param onAction A callback to send actions (like dismiss or confirm) to the ViewModel.
110+
*/
90111
@Composable
91112
internal fun SavingsAccountDialog(
92113
dialogState: SavingsApplicationDialogState?,
@@ -114,6 +135,17 @@ internal fun SavingsAccountDialog(
114135
}
115136
}
116137

138+
139+
/**
140+
* A stateless composable that renders the main UI for the "Apply for Savings" screen.
141+
*
142+
* It conditionally displays UI based on the [ScreenUiState] (e.g., loading, error, success).
143+
* The success state includes dropdowns for selecting a savings product and a field officer.
144+
*
145+
* @param state The current [SavingsApplicationState] to render.
146+
* @param onAction A callback to send user actions to the ViewModel.
147+
* @param modifier The [Modifier] to be applied to the layout.
148+
*/
117149
@Composable
118150
internal fun SavingsAccountContent(
119151
state: SavingsApplicationState,

0 commit comments

Comments
 (0)