Skip to content

Commit 2bcafd7

Browse files
authored
Documentation Added for feature/accounts (#2981)
1 parent 6eb1d22 commit 2bcafd7

File tree

9 files changed

+199
-36
lines changed

9 files changed

+199
-36
lines changed

feature/accounts/src/commonMain/kotlin/org/mifos/mobile/feature/accounts/accountTransactions/AccountsTransactionNavigation.kt

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

20+
/**
21+
* Navigation route for the Account Transactions Screen.
22+
*
23+
* @param accountType The type of account to be displayed.
24+
* @param accountId The ID of the account to be displayed.
25+
*/
26+
2027
@Serializable
2128
data class AccountTransactionsNavRoute(
2229
val accountType: String,
2330
val accountId: Long,
2431
)
2532

33+
/**
34+
* Navigates to the Account Transactions Screen with the specified account type and ID.
35+
*
36+
* @param accountType The type of account to be displayed.
37+
* @param accountId The ID of the account to be displayed.
38+
* @param navOptions Optional navigation options for the transaction screen.
39+
*/
2640
fun NavController.navigateToAccountTransactionsScreen(
2741
accountType: String,
2842
accountId: Long,
@@ -31,6 +45,11 @@ fun NavController.navigateToAccountTransactionsScreen(
3145
this.navigate(AccountTransactionsNavRoute(accountType, accountId), navOptions)
3246
}
3347

48+
/**
49+
* Adds the Account Transactions Screen to the navigation graph.
50+
*
51+
* @param navigateBack The function to be called when the back button is pressed.
52+
*/
3453
fun NavGraphBuilder.accountTransactionsDestination(
3554
navigateBack: () -> Unit,
3655
) {

feature/accounts/src/commonMain/kotlin/org/mifos/mobile/feature/accounts/accountTransactions/TransactionScreen.kt

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ import org.mifos.mobile.core.ui.utils.EventsEffect
6666
import org.mifos.mobile.core.ui.utils.ScreenUiState
6767
import org.mifos.mobile.feature.accounts.component.FilterSection
6868
import org.mifos.mobile.feature.accounts.model.TransactionFilterType
69-
69+
/**
70+
* Composable function for the Account Transactions Screen.
71+
*
72+
* @param navigateBack The function to be called when the back button is pressed.
73+
* @param viewModel The ViewModel for the Account Transactions Screen.
74+
*/
7075
@Composable
7176
internal fun TransactionScreen(
7277
navigateBack: () -> Unit,
@@ -97,6 +102,13 @@ internal fun TransactionScreen(
97102
)
98103
}
99104

105+
/**
106+
* Composable function for the Account Transactions Screen Content.
107+
*
108+
* @param state The current state of the Account Transactions Screen.
109+
* @param onAction The function to be called when an action is performed.
110+
* @param modifier Optional modifier for the content.
111+
*/
100112
@Composable
101113
internal fun TransactionScreenContent(
102114
state: AccountTransactionState,
@@ -206,6 +218,12 @@ internal fun TransactionScreenContent(
206218
}
207219
}
208220

221+
/**
222+
* Composable function for the Account Transactions Dialog.
223+
*
224+
* @param state The current state of the Account Transactions Screen.
225+
* @param onAction The function to be called when an action is performed.
226+
*/
209227
@Composable
210228
internal fun AccountTransactionsDialog(
211229
state: AccountTransactionState,
@@ -232,6 +250,12 @@ internal fun AccountTransactionsDialog(
232250
}
233251
}
234252

253+
/**
254+
* Composable function for the Account Transactions Action Bar.
255+
*
256+
* @param onAction The function to be called when an action is performed.
257+
* @param modifier Optional modifier for the action bar.
258+
*/
235259
@Composable
236260
internal fun ActionBar(
237261
onAction: (AccountTransactionAction) -> Unit,
@@ -289,6 +313,13 @@ internal fun ActionBar(
289313
}
290314
}
291315

316+
/**
317+
* Composable function for the Account Transactions Filters.
318+
*
319+
* @param state The current state of the Account Transactions Screen.
320+
* @param onAction The function to be called when an action is performed.
321+
* @param modifier Optional modifier for the filters.
322+
*/
292323
@Composable
293324
internal fun TransactionFilters(
294325
state: AccountTransactionState,

feature/accounts/src/commonMain/kotlin/org/mifos/mobile/feature/accounts/accountTransactions/TransactionViewModel.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ internal class AccountsTransactionViewModel(
159159
}
160160
}
161161

162+
/**
163+
* Handles the refresh action by checking the network status and loading transactions.
164+
*/
162165
private fun handleRefresh() {
163166
viewModelScope.launch {
164167
if (!state.networkStatus) {
@@ -170,6 +173,11 @@ internal class AccountsTransactionViewModel(
170173
}
171174
}
172175

176+
/**
177+
* Handles the network result by updating the network status and UI state.
178+
*
179+
* @param isOnline Boolean indicating whether the network is online.
180+
*/
173181
private fun handleNetworkResult(isOnline: Boolean) {
174182
updateState {
175183
it.copy(networkStatus = isOnline)
@@ -376,6 +384,10 @@ internal class AccountsTransactionViewModel(
376384
}
377385
}
378386

387+
/**
388+
* Handles the result of the savings transactions API call by updating the UI state
389+
* based on [DataState] — success, loading, or error.
390+
*/
379391
private fun handleSavingsTransactionsResult(dataState: DataState<SavingsWithAssociations>) {
380392
when (dataState) {
381393
is DataState.Error -> {
@@ -428,6 +440,10 @@ internal class AccountsTransactionViewModel(
428440
}
429441
}
430442

443+
/**
444+
* Handles the result of the loan transactions API call by updating the UI state
445+
* based on [DataState] — success, loading, or error.
446+
*/
431447
private fun handleLoanTransactionsResult(dataState: DataState<LoanWithAssociations?>) {
432448
when (dataState) {
433449
is DataState.Error -> {
@@ -688,6 +704,14 @@ internal data class AccountTransactionState(
688704

689705
/**
690706
* Sealed interface representing actions that can be performed on the account transactions screen.
707+
* @property Refresh Action to refresh the transaction data.
708+
* @property DismissDialog Action to dismiss any currently shown dialog.
709+
* @property OnNavigateBackClick Action to navigate back to the previous screen.
710+
* @property ToggleFilter Action to toggle the visibility of the filter dialog.
711+
* @property ResetFilters Action to reset all filters to their default state.
712+
* @property GetFilterResults Action to get the results of the filter dialog.
713+
* @property ReceiveNetworkResult Action to receive the result of the network status check.
714+
* @property ToggleCheckbox Action to toggle a specific checkbox filter.
691715
*/
692716
internal sealed interface AccountTransactionAction {
693717
data object Refresh : AccountTransactionAction
@@ -746,6 +770,7 @@ internal sealed interface AccountTransactionAction {
746770

747771
/**
748772
* Sealed interface representing one-time events to be sent to the UI.
773+
* @property OnNavigateBack Event to navigate back to the previous screen.
749774
*/
750775
sealed interface AccountTransactionEvent {
751776
data object OnNavigateBack : AccountTransactionEvent

feature/accounts/src/commonMain/kotlin/org/mifos/mobile/feature/accounts/accounts/AccountNavigation.kt

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

20+
/**
21+
* Navigation route for the Accounts Screen.
22+
*
23+
* @param accountType The type of account to be displayed.
24+
*/
2025
@Serializable
2126
data class AccountNavRoute(
2227
val accountType: String,
2328
)
2429

30+
/**
31+
* Navigates to the Accounts Screen.
32+
*
33+
* @param accountType The type of account to be displayed.
34+
* @param navOptions The navigation options to be applied.
35+
*/
2536
fun NavController.navigateToAccountsScreen(
2637
accountType: String,
2738
navOptions: NavOptions? = null,
2839
) {
2940
this.navigate(AccountNavRoute(accountType), navOptions)
3041
}
3142

43+
/**
44+
* Adds the Accounts Screen to the navigation graph.
45+
*
46+
* @param navigateBack The function to be called when the back button is pressed.
47+
* @param onAccountClicked The function to be called when an account is clicked.
48+
*/
3249
fun NavGraphBuilder.accountsDestination(
3350
navigateBack: () -> Unit,
3451
onAccountClicked: (accountType: String, accountId: Long) -> Unit,

feature/accounts/src/commonMain/kotlin/org/mifos/mobile/feature/accounts/accounts/AccountsScreen.kt

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ import org.mifos.mobile.feature.accounts.model.FilterType
5454
import org.mifos.mobile.feature.loanaccount.loanAccount.LoanAccountScreen
5555
import org.mifos.mobile.feature.savingsaccount.savingsAccount.SavingsAccountScreen
5656
import org.mifos.mobile.feature.shareaccount.shareAccount.ShareAccountScreen
57-
57+
/**
58+
* Composable function that displays the Accounts Screen.
59+
*
60+
* @param navigateBack The function to be called when the back button is pressed.
61+
* @param onAccountClicked The function to be called when an account is clicked.
62+
* @param viewModel The ViewModel to be used for the screen.
63+
*/
5864
@Composable
5965
internal fun AccountsScreen(
6066
navigateBack: () -> Unit,
@@ -87,6 +93,13 @@ internal fun AccountsScreen(
8793
)
8894
}
8995

96+
/**
97+
* Composable function that displays the Accounts Dialog.
98+
*
99+
* @param state The state of the screen.
100+
* @param onAction The function to be called when an action is performed.
101+
* @param modifier Modifier to be applied to the layout.
102+
*/
90103
@Composable
91104
internal fun AccountsDialog(
92105
state: AccountsState,
@@ -111,6 +124,13 @@ internal fun AccountsDialog(
111124
}
112125
}
113126

127+
/**
128+
* Composable function that displays the Savings Account Filters Dialog.
129+
*
130+
* @param state The state of the screen.
131+
* @param onAction The function to be called when an action is performed.
132+
* @param modifier Modifier to be applied to the layout.
133+
*/
114134
@Composable
115135
internal fun SavingsAccountFilters(
116136
state: AccountsState,
@@ -182,6 +202,13 @@ internal fun SavingsAccountFilters(
182202
}
183203
}
184204

205+
/**
206+
* Composable function that displays the Account Screen Content.
207+
*
208+
* @param state The state of the screen.
209+
* @param onAction The function to be called when an action is performed.
210+
* @param modifier Modifier to be applied to the layout.
211+
*/
185212
@Composable
186213
internal fun AccountScreenContent(
187214
state: AccountsState,

feature/accounts/src/commonMain/kotlin/org/mifos/mobile/feature/accounts/accounts/AccountsViewModel.kt

Lines changed: 25 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -205,91 +205,82 @@ internal class AccountsViewModel(
205205
/**
206206
* UI state for the Accounts screen, containing filter options, dialog visibility,
207207
* current account type, and refresh signals.
208+
*
209+
* @property isRefreshing Indicates if the screen is currently refreshing data.
210+
* @property checkboxOptions List of checkboxes for filter options.
211+
* @property selectedFilters List of currently selected filters.
212+
* @property accountType Current account type filter.
213+
* @property toggleFilterDialog Whether the filter dialog is open.
214+
* @property accountTypeFiltersCount Count of selected account type filters.
215+
* @property accountStatusFiltersCount Count of selected account status filters.
216+
* @property refreshSignal Signal to trigger data refresh.
217+
* @property dialogState Current dialog state (Error or Filters).
218+
* @property uiState Overall UI state of the screen (Loading, Success, Error).
219+
*
208220
*/
209221
internal data class AccountsState
210222
@OptIn(ExperimentalTime::class)
211223
constructor(
212224
val isRefreshing: Boolean = false,
213-
214-
/** Current filter checkboxes shown in the dialog */
215225
val checkboxOptions: List<CheckboxStatus> = emptyList(),
216-
217-
/** Confirmed filters applied to the data */
218226
val selectedFilters: List<CheckboxStatus> = emptyList(),
219-
220-
/** Selected account type (Savings, Loan, Share) */
221227
val accountType: AccountType = AccountType.SAVINGS,
222-
223-
/** Whether filter dialog is visible */
224228
val toggleFilterDialog: Boolean = false,
225-
226-
/** Count of selected account-type filters */
227229
val accountTypeFiltersCount: Int? = 0,
228-
229-
/** Count of selected status filters */
230230
val accountStatusFiltersCount: Int? = 0,
231-
232-
/** Used to trigger data refresh downstream */
233231
val refreshSignal: Long = Clock.System.now().epochSeconds,
234-
235-
/** Current dialog being shown (loading, filters, error) */
236232
val dialogState: DialogState? = null,
237-
238-
/** Hold the state of the screen */
239233
val uiState: ScreenUiState = ScreenUiState.Loading,
240234
) {
241235

242-
/**
243-
* Defines various dialog states in the Accounts screen.
244-
*/
245236
sealed interface DialogState {
246237
data class Error(val message: String) : DialogState
247238
data object Filters : DialogState
248239
}
249240

250-
/** True if any checkbox is selected */
251241
val isAnyFilterSelected = checkboxOptions.any { it.isChecked }
252242
}
253243

254244
/**
255245
* Defines all user or internal actions that can be triggered in the Accounts screen.
246+
*
247+
* @property ToggleFilter Opens or closes the filter dialog
248+
* @property ResetFilters Clears all filters and selections
249+
* @property DismissDialog Dismisses any open dialog
250+
* @property GetFilterResults Applies filter and triggers refresh
251+
* @property OnNavigateBack Handles back navigation
252+
* @property Refresh Initiates refresh of data
253+
* @property RefreshCompleted Signals that refresh is done
254+
* @property OnAccountClicked When an account card is clicked
255+
* @property SetCheckboxFilterList Sets the checkbox list based on account type
256+
* @property ToggleCheckbox Toggles a specific checkbox in the dialog
256257
*/
257258
internal sealed interface AccountsAction {
258259

259-
/** Opens or closes the filter dialog */
260260
data object ToggleFilter : AccountsAction
261261

262-
/** Clears all filters and selections */
263262
data object ResetFilters : AccountsAction
264263

265-
/** Dismisses any open dialog */
266264
data object DismissDialog : AccountsAction
267265

268-
/** Applies filter and triggers refresh */
269266
data object GetFilterResults : AccountsAction
270267

271-
/** Handles back navigation */
272268
data object OnNavigateBack : AccountsAction
273269

274-
/** Initiates refresh of data */
275270
data object Refresh : AccountsAction
276271

277-
/** Signals that refresh is done */
278272
data object RefreshCompleted : AccountsAction
279273

280-
/** When an account card is clicked */
281274
data class OnAccountClicked(
282275
val accountId: Long,
283276
val accountType: String,
284277
) : AccountsAction
285278

286-
/** Sets the checkbox list based on account type */
287279
data class SetCheckboxFilterList(
288280
val checkBoxList: List<CheckboxStatus>,
289281
val accountType: String,
290282
) : AccountsAction
291283

292-
/** Toggles a specific checkbox */
293284
data class ToggleCheckbox(
294285
val label: StringResource,
295286
val type: FilterType,
@@ -298,13 +289,13 @@ internal sealed interface AccountsAction {
298289

299290
/**
300291
* Defines one-time events sent from AccountsViewModel to UI.
292+
* @property NavigateBack Navigate back to previous screen
293+
* @property AccountClicked Navigate to account detail screen
301294
*/
302295
sealed interface AccountsEvent {
303296

304-
/** Navigate back to previous screen */
305297
data object NavigateBack : AccountsEvent
306298

307-
/** Navigate to account detail screen */
308299
data class AccountClicked(
309300
val accountId: Long,
310301
val accountType: String,

0 commit comments

Comments
 (0)