Skip to content

Commit 768a6a6

Browse files
Docs update[ feature/savingAccounts] MM-440 (#2998)
1 parent 989d07e commit 768a6a6

File tree

11 files changed

+393
-7
lines changed

11 files changed

+393
-7
lines changed

feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/components/SavingsActionItems.kt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,48 @@ import org.mifos.mobile.core.common.Constants
2626
import org.mifos.mobile.core.designsystem.icon.MifosIcons
2727

2828
// TODO add some constants or enum class for routes and use
29+
/**
30+
* A sealed class representing the distinct user-facing actions available for a savings account.
31+
* Each action is defined as a `data object` and encapsulates UI-related metadata.
32+
*
33+
* This class is used to dynamically generate UI components, such as a list of action buttons or cards.
34+
*
35+
* @property title The string resource for the action's primary title.
36+
* @property subTitle The string resource for the action's descriptive subtitle or tip.
37+
* @property icon The [ImageVector] used to visually represent the action.
38+
* @property route A unique string identifier used for navigation or logic handling related to the action.
39+
*/
2940
sealed class SavingsActionItems(
3041
val title: StringResource,
3142
val subTitle: StringResource,
3243
val icon: ImageVector,
3344
val route: String,
3445
) {
35-
46+
/** Represents the action to initiate a money transfer from the account. */
3647
data object Transfer : SavingsActionItems(
3748
title = Res.string.feature_account_action_transfer,
3849
subTitle = Res.string.feature_account_action_transfer_tip,
3950
icon = MifosIcons.MoneyHand,
4051
route = Constants.TRANSFER,
4152
)
4253

54+
/** Represents the action to view the transaction history of the account. */
4355
data object Transactions : SavingsActionItems(
4456
title = Res.string.feature_account_action_transactions,
4557
subTitle = Res.string.feature_account_action_transactions_tip,
4658
icon = MifosIcons.ChatHistory,
4759
route = Constants.TRANSACTIONS,
4860
)
4961

62+
/** Represents the action to view any charges applied to the account. */
5063
data object Charges : SavingsActionItems(
5164
title = Res.string.feature_account_action_charges,
5265
subTitle = Res.string.feature_account_action_charges_tip,
5366
icon = MifosIcons.ReceiptMoney,
5467
route = Constants.CHARGES,
5568
)
5669

70+
/** Represents the action to display a QR code associated with the account for receiving payments. */
5771
data object QrCode : SavingsActionItems(
5872
title = Res.string.feature_account_action_qr,
5973
subTitle = Res.string.feature_account_action_qr_tip,
@@ -62,6 +76,10 @@ sealed class SavingsActionItems(
6276
)
6377
}
6478

79+
/**
80+
* An immutable list containing the standard set of actions available for a savings account.
81+
* This list is used to populate UI elements that display all possible account actions in a predefined order.
82+
*/
6583
internal val savingsAccountActions: ImmutableList<SavingsActionItems> = persistentListOf(
6684
SavingsActionItems.Transfer,
6785
SavingsActionItems.Transactions,

feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/di/SavingsAccountModule.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,32 @@ import org.mifos.mobile.feature.savingsaccount.savingsAccountDetails.SavingsAcco
1616
import org.mifos.mobile.feature.savingsaccount.savingsAccountUpdate.AccountUpdateViewModel
1717
import org.mifos.mobile.feature.savingsaccount.savingsAccountWithdraw.AccountWithdrawViewModel
1818

19+
/**
20+
* Koin module for providing dependencies related to the Savings Account feature.
21+
*
22+
* This module declares all the ViewModels used across the savings account screens,
23+
* allowing Koin's dependency injection framework to construct and provide them where needed.
24+
* The `viewModelOf` factory automatically handles the resolution of constructor dependencies for each ViewModel.
25+
*/
1926
val savingsAccountModule = module {
27+
/**
28+
* Provides an instance of [SavingsAccountViewmodel].
29+
* This ViewModel is responsible for the main savings account list screen.
30+
*/
2031
viewModelOf(::SavingsAccountViewmodel)
32+
/**
33+
* Provides an instance of [SavingsAccountDetailsViewModel].
34+
* This ViewModel manages the logic for the savings account details screen.
35+
*/
2136
viewModelOf(::SavingsAccountDetailsViewModel)
37+
/**
38+
* Provides an instance of [AccountUpdateViewModel].
39+
* This ViewModel handles the logic for updating savings account details.
40+
*/
2241
viewModelOf(::AccountUpdateViewModel)
42+
/**
43+
* Provides an instance of [AccountWithdrawViewModel].
44+
* This ViewModel is responsible for the account withdrawal screen logic.
45+
*/
2346
viewModelOf(::AccountWithdrawViewModel)
2447
}

feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/navigation/SavingsNavigation.kt

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,39 @@ import org.mifos.mobile.feature.savingsaccount.savingsAccountUpdate.navigateToSa
2424
import org.mifos.mobile.feature.savingsaccount.savingsAccountUpdate.savingsAccountUpdateDestination
2525
import org.mifos.mobile.feature.savingsaccount.savingsAccountWithdraw.savingsAccountWithdrawDestination
2626

27+
/**
28+
* A serializable, type-safe route representing the entry point for the nested
29+
* savings account navigation graph.
30+
*/
2731
@Serializable
2832
data object SavingsGraphRoute
2933

34+
/**
35+
* Navigates to the savings account navigation graph.
36+
*
37+
* This is a convenience extension function on [NavController] that encapsulates the
38+
* logic for navigating to the start of the savings account feature.
39+
*
40+
* @param navOptions Optional [NavOptions] to apply to this navigation operation.
41+
*/
3042
fun NavController.navigateToSavingsGraph(navOptions: NavOptions? = null) =
3143
navigate(SavingsAccountRoute, navOptions)
3244

45+
/**
46+
* Builds the nested navigation graph for the savings account feature.
47+
*
48+
* This function defines all the destinations within the savings account module and
49+
* wires them together. It takes lambdas for navigating to screens both inside and
50+
* outside of this feature's scope, promoting a decoupled architecture.
51+
*
52+
* @param navController The [NavController] used for handling navigation events within the graph.
53+
* @param navigateToClientChargeScreen Lambda to navigate to the client charges screen.
54+
* @param navigateToTransferScreen Lambda to navigate to the fund transfer screen.
55+
* @param navigateToAuthenticateScreen Lambda to navigate to an authentication screen.
56+
* @param navigateToStatusScreen Lambda to navigate to a generic status/result screen after an operation.
57+
* @param navigateToSavingsAccountTransactionScreen Lambda to navigate to the transaction history screen.
58+
* @param navigateToQrCodeScreen Lambda to navigate to the QR code display screen.
59+
*/
3360
fun NavGraphBuilder.savingsNavGraph(
3461
navController: NavController,
3562
navigateToClientChargeScreen: (String, Long) -> Unit,
@@ -42,25 +69,28 @@ fun NavGraphBuilder.savingsNavGraph(
4269
navigation<SavingsGraphRoute>(
4370
startDestination = SavingsAccountRoute,
4471
) {
72+
// Destination for the list of savings accounts
4573
savingsAccountDestination(
4674
navigateBack = navController::popBackStack,
4775
)
48-
76+
// Destination for the details of a single savings account
4977
savingsAccountDetailsDestination(
5078
navigateBack = navController::popBackStack,
5179
navigateToClientChargeScreen = navigateToClientChargeScreen,
52-
navigateToUpdateScreen = navController::navigateToSavingsAccountUpdateScreen,
53-
navigateToSavingsAccountTransactionScreen = navigateToSavingsAccountTransactionScreen,
80+
navigateToUpdateScreen =
81+
navController::navigateToSavingsAccountUpdateScreen,
82+
navigateToSavingsAccountTransactionScreen =
83+
navigateToSavingsAccountTransactionScreen,
5484
navigateToQrCodeScreen = navigateToQrCodeScreen,
5585
navigateToTransferScreen = navigateToTransferScreen,
5686
)
57-
87+
// Destination for updating a savings account (e.g., deposit)
5888
savingsAccountUpdateDestination(
5989
navigateBack = navController::popBackStack,
6090
navigateToStatusScreen = navigateToStatusScreen,
6191
navigateToAuthenticateScreen = navigateToAuthenticateScreen,
6292
)
63-
93+
// Destination for withdrawing from a savings account
6494
savingsAccountWithdrawDestination(
6595
navigateBack = navController::popBackStack,
6696
navigateToStatusScreen = navigateToStatusScreen,

feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountNavigation.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,36 @@ 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 main Savings Account list screen.
22+
* This object serves as the unique identifier for this destination in the
23+
* navigation graph, making navigation more robust and less error-prone.
24+
*/
2025
@Serializable
2126
data object SavingsAccountRoute
2227

28+
/**
29+
* Navigates to the main Savings Account list screen.
30+
*
31+
* This is an extension function on [NavController] that simplifies the process
32+
* of navigating to the savings account list destination.
33+
*
34+
* @param navOptions Optional [NavOptions] to apply to this navigation operation,
35+
* allowing for customization of transition animations or back stack behavior.
36+
*/
2337
fun NavController.navigateToSavingsAccountScreen(navOptions: NavOptions? = null) =
2438
navigate(SavingsAccountRoute, navOptions)
2539

40+
/**
41+
* Defines the composable destination for the "Savings Account" list screen
42+
* within the navigation graph.
43+
*
44+
* This function sets up the route and the content to be displayed (`SavingsAccountScreen`),
45+
* along with specifying the screen enter/exit transitions.
46+
*
47+
* @param navigateBack A lambda function to be invoked when the user initiates a
48+
* back action from the [SavingsAccountScreen].
49+
*/
2650
fun NavGraphBuilder.savingsAccountDestination(
2751
navigateBack: () -> Unit,
2852
) {

feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccount/SavingsAccountScreen.kt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,22 @@ import org.mifos.mobile.core.ui.component.MifosProgressIndicator
6262
import org.mifos.mobile.core.ui.utils.EventsEffect
6363
import org.mifos.mobile.core.ui.utils.ScreenUiState
6464

65+
/**
66+
* A stateful composable that serves as the main entry point for the Savings Account list screen.
67+
*
68+
* This screen is responsible for observing state from the [SavingsAccountViewmodel], handling
69+
* user events, and orchestrating the display of the savings account data. It also manages
70+
* data loading triggers, including initial launch and external refresh signals.
71+
*
72+
* @param navigateBack A lambda to handle the back navigation event.
73+
* @param onAccountClicked A callback invoked when a savings account item is clicked, providing the account type and ID.
74+
* @param refreshSignal A signal to trigger a data refresh when its value changes.
75+
* @param onLoadingCompleted A callback invoked when the data loading process finishes.
76+
* @param accountTypeFilters A list of string resources representing the applied account type filters.
77+
* @param accountStatusFilters A list of string resources representing the applied account status filters.
78+
* @param filtersClicked A lambda to handle the click event on the filter icon.
79+
* @param viewModel The [SavingsAccountViewmodel] instance for this screen, typically provided by Koin.
80+
*/
6581
@Composable
6682
fun SavingsAccountScreen(
6783
navigateBack: () -> Unit,
@@ -110,6 +126,13 @@ fun SavingsAccountScreen(
110126
)
111127
}
112128

129+
/**
130+
* A composable responsible for displaying dialogs based on the [SavingsAccountState].
131+
* Currently, it handles the display of an error dialog with a retry option.
132+
*
133+
* @param dialogState The current state of the dialog from [SavingsAccountState].
134+
* @param onAction A callback to send actions, like retry, to the ViewModel.
135+
*/
113136
@Composable
114137
internal fun SavingsAccountDialog(
115138
dialogState: SavingsAccountState.DialogState?,
@@ -127,6 +150,16 @@ internal fun SavingsAccountDialog(
127150
}
128151
}
129152

153+
/**
154+
* A stateless composable that renders the main UI for the Savings Account screen.
155+
*
156+
* It conditionally displays UI elements based on the [ScreenUiState], such as a loading
157+
* indicator, error messages, an empty data view, or the success view with the list of accounts.
158+
*
159+
* @param state The current [SavingsAccountState] to render.
160+
* @param onAction A callback to send user actions to the ViewModel.
161+
* @param filtersClicked A lambda to handle the click event on the filter icon.
162+
*/
130163
@Composable
131164
internal fun SavingsAccountContent(
132165
state: SavingsAccountState,
@@ -289,6 +322,13 @@ internal fun SavingsAccountContent(
289322
}
290323
}
291324

325+
/**
326+
* A Jetpack Compose preview for the [SavingsAccountContent].
327+
*
328+
* This provides a design-time visualization of the savings account screen UI in
329+
* Android Studio, configured with a default empty state.
330+
*/
331+
292332
@Preview
293333
@Composable
294334
private fun Savings_Account_Preview() {

feature/savings-account/src/commonMain/kotlin/org/mifos/mobile/feature/savingsaccount/savingsAccountDetails/SavingsAccountDetailsNavigation.kt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,40 @@ import org.mifos.mobile.core.model.entity.AccountDetails
2121
import org.mifos.mobile.core.model.enums.TransferType
2222
import org.mifos.mobile.core.ui.composableWithSlideTransitions
2323

24+
/**
25+
* Type-safe, serializable route for the Savings Account Details screen.
26+
*
27+
* @property accountId The unique ID of the savings account to display.
28+
*/
2429
@Serializable
2530
data class SavingsAccountDetailsRoute(
2631
val accountId: Long,
2732
)
2833

29-
fun NavController.navigateToSavingsAccountDetailsScreen(accountId: Long, navOptions: NavOptions? = null) =
34+
/**
35+
* Navigates to the Savings Account Details screen.
36+
*
37+
* @param accountId The ID of the savings account.
38+
* @param navOptions Optional navigation options.
39+
*/
40+
41+
fun NavController.navigateToSavingsAccountDetailsScreen(
42+
accountId: Long,
43+
navOptions: NavOptions? = null,
44+
) =
3045
navigate(SavingsAccountDetailsRoute(accountId), navOptions)
3146

47+
/**
48+
* Defines the composable destination for the "Savings Account Details" screen.
49+
* This sets up the route, content, and navigation callbacks.
50+
*
51+
* @param navigateBack Handles back navigation.
52+
* @param navigateToTransferScreen Navigates to the fund transfer screen.
53+
* @param navigateToClientChargeScreen Navigates to the account charges screen.
54+
* @param navigateToUpdateScreen Navigates to the account update screen.
55+
* @param navigateToSavingsAccountTransactionScreen Navigates to the transaction history.
56+
* @param navigateToQrCodeScreen Navigates to the QR code display screen.
57+
*/
3258
fun NavGraphBuilder.savingsAccountDetailsDestination(
3359
navigateBack: () -> Unit,
3460
navigateToTransferScreen: (AccountDetails) -> Unit,

0 commit comments

Comments
 (0)