@@ -27,9 +27,7 @@ import org.mifos.mobile.core.model.entity.accounts.share.ShareAccount
2727import org.mifos.mobile.core.model.entity.client.ClientAccounts
2828import org.mifos.mobile.core.ui.utils.BaseViewModel
2929import org.mifos.mobile.core.ui.utils.ScreenUiState
30- import org.mifos.mobile.core.ui.utils.ScreenUiState.Network
3130import 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 */
313326data 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 */
361359sealed 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 */
401428sealed 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