Skip to content

Commit 43af85e

Browse files
authored
Documentation Done for feature/share-account. (#2993)
1 parent 6268b3b commit 43af85e

File tree

3 files changed

+109
-35
lines changed

3 files changed

+109
-35
lines changed

feature/share-account/src/commonMain/kotlin/org/mifos/mobile/feature/shareaccount/shareAccount/ShareAccountRoute.kt

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

20+
/**
21+
* A serializable object representing the route to the Share Account screen.
22+
*/
2023
@Serializable
2124
data object ShareAccountRoute
2225

26+
/**
27+
* Navigates to the Share Account screen.
28+
*
29+
* @param navOptions Optional navigation options.
30+
*/
2331
fun NavController.navigateToShareAccountScreen(navOptions: NavOptions? = null) =
2432
navigate(ShareAccountRoute, navOptions)
2533

34+
/**
35+
* Defines the destination for the Share Account screen in the navigation graph.
36+
*
37+
* @param navigateBack A function to navigate back to the previous screen.
38+
*/
2639
fun NavGraphBuilder.shareAccountDestination(
2740
navigateBack: () -> Unit,
2841
) {

feature/share-account/src/commonMain/kotlin/org/mifos/mobile/feature/shareaccount/shareAccount/ShareAccountScreen.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ import org.mifos.mobile.core.ui.utils.EventsEffect
5959
import org.mifos.mobile.core.ui.utils.ScreenUiState
6060
import kotlin.collections.orEmpty
6161

62+
/**
63+
* A Composable function that represents the Share Account screen.
64+
*
65+
* @param navigateBack A function to navigate back to the previous screen.
66+
* @param onAccountClicked A function to handle account click events.
67+
* @param refreshSignal A signal to trigger a refresh of the account data.
68+
* @param onLoadingCompleted A function to be called when loading is completed.
69+
* @param accountTypeFilters A list of account type filters.
70+
* @param accountStatusFilters A list of account status filters.
71+
* @param filtersClicked A function to handle filter click events.
72+
* @param viewModel An instance of [ShareAccountsViewmodel].
73+
*/
6274
@Composable
6375
fun ShareAccountScreen(
6476
navigateBack: () -> Unit,
@@ -115,6 +127,12 @@ fun ShareAccountScreen(
115127
)
116128
}
117129

130+
/**
131+
* A Composable function that displays a dialog based on the [ShareAccountsState.DialogState].
132+
*
133+
* @param dialogState The state of the dialog to be displayed.
134+
* @param onAction A function to handle actions from the dialog.
135+
*/
118136
@Composable
119137
internal fun ShareAccountDialog(
120138
dialogState: ShareAccountsState.DialogState?,
@@ -133,6 +151,13 @@ internal fun ShareAccountDialog(
133151
}
134152
}
135153

154+
/**
155+
* A Composable function that displays the content of the Share Account screen.
156+
*
157+
* @param state The current state of the screen.
158+
* @param onAction A function to handle actions from the screen.
159+
* @param filtersClicked A function to handle filter click events.
160+
*/
136161
@Composable
137162
internal fun ShareAccountContent(
138163
state: ShareAccountsState,

feature/share-account/src/commonMain/kotlin/org/mifos/mobile/feature/shareaccount/shareAccount/ShareAccountViewModel.kt

Lines changed: 71 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ import org.mifos.mobile.core.model.entity.accounts.share.ShareAccount
2727
import org.mifos.mobile.core.model.entity.client.ClientAccounts
2828
import org.mifos.mobile.core.ui.utils.BaseViewModel
2929
import org.mifos.mobile.core.ui.utils.ScreenUiState
30-
import org.mifos.mobile.core.ui.utils.ScreenUiState.Network
3130
import org.mifos.mobile.feature.shareaccount.utils.FilterUtil
32-
import kotlin.collections.firstOrNull
3331

3432
// TODO: Refactor according to figma design
3533
/**
@@ -158,8 +156,7 @@ class ShareAccountsViewmodel(
158156

159157
/**
160158
* Retries the data fetching process. If the network is unavailable, it shows
161-
* a network error dialog. Otherwise, it triggers the `loadAccounts` `fetchClient`,
162-
* `fetchLonPurpose` function.
159+
* a network error dialog. Otherwise, it triggers the `loadAccounts` function.
163160
*/
164161
private fun retry() {
165162
viewModelScope.launch {
@@ -309,48 +306,49 @@ class ShareAccountsViewmodel(
309306
/**
310307
* State holder for the Share Accounts screen.
311308
* Contains all values needed to render the UI and manage logic.
309+
*
310+
* @property shareAccounts The list of share accounts.
311+
* @property originalAccounts The original list of share accounts.
312+
* @property isFilteredEmpty A flag indicating if the filtered list is empty.
313+
* @property firstLaunch A flag indicating if this is the first launch of the screen.
314+
* @property items The number of filtered accounts.
315+
* @property totalLoanAmount The total share amount computed from accounts.
316+
* @property currency The currency symbol (e.g., ₹, $, etc.).
317+
* @property decimals The number of decimals to display for the amount.
318+
* @property networkConnection The network connectivity status.
319+
* @property clientId The current client ID from user preferences.
320+
* @property dialogState The currently active dialog (Error).
321+
* @property selectedFilters The filters currently applied.
322+
* @property isAmountVisible A flag to control whether account balances are visible.
323+
* @property uiState The current UI state of the screen.
324+
* @property networkStatus The network connectivity status.
312325
*/
313326
data class ShareAccountsState(
314327
val shareAccounts: List<ShareAccount>?,
315328
val originalAccounts: List<ShareAccount>? = null,
316329
val isFilteredEmpty: Boolean = false,
317330
val firstLaunch: Boolean = true,
318-
319-
/** Number of filtered accounts */
320331
val items: Int? = 0,
321-
322-
/** Total share amount computed from accounts */
323332
val totalLoanAmount: String? = "",
324-
325-
/** Currency symbol (e.g., ₹, $, etc.) */
326333
val currency: String? = "",
327-
328-
/** Decimals to display amount*/
329334
val decimals: Int? = 2,
330-
331-
/** Network connectivity status */
332335
val networkConnection: Boolean? = true,
333-
334-
/** Current client ID from user preferences */
335336
val clientId: Long?,
336-
337-
/** Currently active dialog (Error) */
338337
val dialogState: DialogState? = null,
339-
340-
/** Filters currently applied */
341338
val selectedFilters: List<StringResource?> = emptyList(),
342-
343-
/** Controls whether account balances are visible */
344339
val isAmountVisible: Boolean = false,
345-
346340
val uiState: ScreenUiState? = ScreenUiState.Loading,
347-
348341
val networkStatus: Boolean = false,
349342
) {
350343
/**
351344
* Represents UI dialog states.
352345
*/
353346
sealed interface DialogState {
347+
/**
348+
* An error dialog state.
349+
*
350+
* @property message The error message to display.
351+
*/
354352
data class Error(val message: String) : DialogState
355353
}
356354
}
@@ -359,35 +357,64 @@ data class ShareAccountsState(
359357
* Represents user or system actions for the Share Accounts screen.
360358
*/
361359
sealed interface ShareAccountsAction {
360+
/**
361+
* Action triggered on the first launch of the screen.
362+
*/
362363
data object OnFirstLaunched : ShareAccountsAction
363364

364-
/** Dismiss any open dialog */
365+
/**
366+
* Action to dismiss any open dialog.
367+
*/
365368
data object OnDismissDialog : ShareAccountsAction
366369

367-
/** Navigate back from the screen */
370+
/**
371+
* Action to navigate back from the screen.
372+
*/
368373
data object OnNavigateBack : ShareAccountsAction
369374

370-
/** Toggle visibility of share amount */
375+
/**
376+
* Action to toggle the visibility of the share amount.
377+
*/
371378
data object ToggleAmountVisible : ShareAccountsAction
372379

373-
/** Load share accounts with applied filters */
380+
/**
381+
* Action to load share accounts with applied filters.
382+
*
383+
* @property filters The list of filters to apply.
384+
*/
374385
data class LoadAccounts(val filters: List<StringResource?>) : ShareAccountsAction
375386

376-
/** Retry loading with same filters */
387+
/**
388+
* Action to retry loading with the same filters.
389+
*/
377390
data object OnRetry : ShareAccountsAction
378391

379-
/** Navigate to a selected account's detail page */
392+
/**
393+
* Action triggered when an account is clicked.
394+
*
395+
* @property accountId The ID of the clicked account.
396+
* @property accountType The type of the clicked account.
397+
*/
380398
data class OnAccountClicked(val accountId: Long, val accountType: String) : ShareAccountsAction
381399

382-
/** Action to observe network status */
400+
/**
401+
* Action to observe the network status.
402+
*
403+
* @property isOnline A boolean indicating if the device is online.
404+
*/
383405
data class ReceiveNetworkStatus(val isOnline: Boolean) : ShareAccountsAction
384406

385407
/**
386408
* Internal-only actions triggered by repository/data flow.
387409
*/
388410
sealed interface Internal : ShareAccountsAction {
389411

390-
/** Called when share account data is received from repository */
412+
/**
413+
* Called when share account data is received from the repository.
414+
*
415+
* @property filters The list of filters applied.
416+
* @property dataState The result of fetching the share accounts.
417+
*/
391418
data class ReceiveShareAccounts(
392419
val filters: List<StringResource?>,
393420
val dataState: DataState<ClientAccounts>,
@@ -400,12 +427,21 @@ sealed interface ShareAccountsAction {
400427
*/
401428
sealed interface ShareAccountsEvent {
402429

403-
/** Trigger navigation to selected share account's detail screen */
430+
/**
431+
* Trigger navigation to the selected share account's detail screen.
432+
*
433+
* @property accountId The ID of the clicked account.
434+
* @property accountType The type of the clicked account.
435+
*/
404436
data class AccountClicked(val accountId: Long, val accountType: String) : ShareAccountsEvent
405437

406-
/** Signals the UI that loading is complete */
438+
/**
439+
* Signals the UI that loading is complete.
440+
*/
407441
data object LoadingCompleted : ShareAccountsEvent
408442

409-
/** Navigates back to the previous screen */
443+
/**
444+
* Navigates back to the previous screen.
445+
*/
410446
data object NavigateBack : ShareAccountsEvent
411447
}

0 commit comments

Comments
 (0)