Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import mifos_mobile.feature.savings_account.generated.resources.feature_account_
import mifos_mobile.feature.savings_account.generated.resources.feature_savings_account
import mifos_mobile.feature.savings_account.generated.resources.feature_savings_account_dashboard
import mifos_mobile.feature.savings_account.generated.resources.feature_savings_account_items
import mifos_mobile.feature.savings_account.generated.resources.feature_savings_filter_pending_account
import mifos_mobile.feature.savings_account.generated.resources.feature_savings_no_accounts_found
import org.jetbrains.compose.resources.StringResource
import org.jetbrains.compose.resources.stringResource
Expand All @@ -52,7 +53,7 @@ import org.mifos.mobile.core.designsystem.theme.AppColors
import org.mifos.mobile.core.designsystem.theme.DesignToken
import org.mifos.mobile.core.designsystem.theme.MifosMobileTheme
import org.mifos.mobile.core.designsystem.theme.MifosTypography
import org.mifos.mobile.core.model.LoanStatus
import org.mifos.mobile.core.model.SavingStatus
import org.mifos.mobile.core.ui.component.EmptyDataView
import org.mifos.mobile.core.ui.component.MifosAccountCard
import org.mifos.mobile.core.ui.component.MifosDashboardCard
Expand Down Expand Up @@ -254,6 +255,19 @@ internal fun SavingsAccountContent(
)
}
} else {
val statusOrder = remember {
listOf(
SavingStatus.ACTIVE.status,
SavingStatus.SUBMIT_AND_PENDING_APPROVAL.status,
SavingStatus.CLOSED.status,
SavingStatus.INACTIVE.status,
)
}
val sortedAccounts = remember(state.savingsAccount) {
state.savingsAccount.orEmpty().sortedWith(
compareBy { statusOrder.indexOf(it.status?.value) },
)
}
LazyColumn(
modifier = Modifier
.fillMaxSize()
Expand All @@ -262,30 +276,34 @@ internal fun SavingsAccountContent(
item {
Spacer(modifier = Modifier.height(DesignToken.spacing.small))
}
items(state.savingsAccount.orEmpty()) { account ->
items(sortedAccounts) { account ->
val color = when (account.status?.value) {
LoanStatus.ACTIVE.status -> AppColors.customEnable
LoanStatus.SUBMIT_AND_PENDING_APPROVAL.status -> AppColors.customYellow
LoanStatus.WITHDRAWN.status, LoanStatus.MATURED.status ->
MaterialTheme.colorScheme.error
SavingStatus.ACTIVE.status -> AppColors.customEnable
SavingStatus.SUBMIT_AND_PENDING_APPROVAL.status -> AppColors.customYellow

SavingStatus.INACTIVE.status -> MaterialTheme.colorScheme.error

else -> MaterialTheme.colorScheme.onSurface
}
val accountStatus = if (account.status?.active == true) {
CurrencyFormatter.format(
account.accountBalance,
account.currency?.code,
account.currency?.decimalPlaces,
)
} else {
if (account.status?.value == SavingStatus.SUBMIT_AND_PENDING_APPROVAL.status) {
stringResource(Res.string.feature_savings_filter_pending_account)
} else {
account.status?.value ?: ""
}
}

MifosAccountCard(
accountId = account.id,
accountNumber = account.accountNo,
accountType = account.productName,
accountStatus = (
if (account.status?.active == true) {
CurrencyFormatter.format(
account.accountBalance,
account.currency?.code,
account.currency?.decimalPlaces,
)
} else {
account.status?.value ?: ""
}
),
accountStatus = accountStatus,
accountStatusColor = color,
onAccountClick = {
onAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import org.koin.core.module.dsl.viewModelOf
import org.koin.dsl.module
import org.mifos.mobile.feature.third.party.transfer.thirdPartyTransfer.TptViewModel

/**
* Koin module for the Third Party Transfer feature.
*
* This module provides the ViewModel for the TPT screen.
*/
val ThirdPartyTransferModule = module {
viewModelOf(::TptViewModel)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,56 @@ import org.mifos.mobile.core.model.entity.payload.ReviewTransferPayload
import org.mifos.mobile.feature.third.party.transfer.thirdPartyTransfer.TptScreenRoute
import org.mifos.mobile.feature.third.party.transfer.thirdPartyTransfer.tptScreenDestination

/**
* Sealed class representing the possible navigation destinations from the TPT screen.
*/
sealed class TptNavigationDestination {
// Add more as needed
object Notification : TptNavigationDestination()
/**
* Navigation destination for the Notification screen.
*/
data object Notification : TptNavigationDestination()

/**
* Navigation destination for the Transfer Process screen.
*
* @param payload The payload containing the details of the transfer to be reviewed.
*/
class TransferProcess(val payload: ReviewTransferPayload) : TptNavigationDestination()
object AddBeneficiaryScreen : TptNavigationDestination()

/**
* Navigation destination for the Add Beneficiary screen.
*/
data object AddBeneficiaryScreen : TptNavigationDestination()
}

/**
* A type alias for the navigator function that handles navigation to a [TptNavigationDestination].
*/
typealias TptNavigator = (TptNavigationDestination) -> Unit

/**
* The route for the Third Party Transfer navigation graph.
*/
@Serializable
data object ThirdPartyTransferNavGraphRoute

/**
* Navigates to the TPT navigation graph.
*
* @param navOptions The navigation options to apply to this navigation.
*/
fun NavController.navigateToTptGraph(navOptions: NavOptions? = null) {
this.navigate(
ThirdPartyTransferNavGraphRoute,
navOptions = navOptions,
)
}

/**
* Defines the TPT navigation graph.
*
* @param onNavigate The navigator function to handle navigation to other screens.
*/
fun NavGraphBuilder.tptGraphDestination(
onNavigate: TptNavigator,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ import org.mifos.mobile.core.ui.utils.ScreenUiState
import org.mifos.mobile.feature.third.party.transfer.navigation.TptNavigationDestination
import org.mifos.mobile.feature.third.party.transfer.navigation.TptNavigator

/**
* Composable function for the Third Party Transfer screen.
*
* @param onNavigate The navigator function to handle navigation to other screens.
* @param viewModel The ViewModel for the TPT screen.
*/
@Composable
internal fun TptScreen(
onNavigate: TptNavigator,
Expand Down Expand Up @@ -99,6 +105,12 @@ internal fun TptScreen(
)
}

/**
* Composable function for displaying dialogs on the TPT screen.
*
* @param dialogState The current state of the dialog.
* @param onAction The action to be performed when the dialog is dismissed.
*/
@Composable
internal fun TptDialog(
dialogState: TptState.DialogState?,
Expand All @@ -118,6 +130,13 @@ internal fun TptDialog(
}
}

/**
* Composable function for the content of the TPT screen.
*
* @param state The current state of the TPT screen.
* @param onAction The action to be performed when a user interacts with the screen.
* @param modifier The modifier to be applied to the layout.
*/
@Composable
internal fun TprContent(
state: TptState,
Expand Down Expand Up @@ -177,6 +196,13 @@ internal fun TprContent(
}
}

/**
* Composable function for the TPT form.
*
* @param state The current state of the TPT screen.
* @param onAction The action to be performed when a user interacts with the form.
* @param modifier The modifier to be applied to the layout.
*/
@Composable
internal fun TptForm(
state: TptState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,26 @@ import kotlinx.serialization.Serializable
import org.mifos.mobile.core.ui.composableWithSlideTransitions
import org.mifos.mobile.feature.third.party.transfer.navigation.TptNavigator

/**
* The route for the TPT screen.
*/
@Serializable
data object TptScreenRoute

/**
* Navigates to the TPT screen.
*
* @param navOptions The navigation options to apply to this navigation.
*/
fun NavController.navigateToTptScreen(navOptions: NavOptions? = null) {
this.navigate(TptScreenRoute, navOptions)
}

/**
* Defines the TPT screen destination.
*
* @param onNavigate The navigator function to handle navigation to other screens.
*/
fun NavGraphBuilder.tptScreenDestination(
onNavigate: TptNavigator,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ internal class TptViewModel(
/**
* Represents the state of the Make Transfer screen.
*
* @property accountId The ID of the account.
* @property clientId The ID of the current user.
* @property outstandingBalance The outstanding balance of the primary account, if applicable.
* @property amount The amount entered by the user for the transfer.
Expand Down
Loading