Skip to content
Open
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
1 change: 1 addition & 0 deletions core/ui/src/commonMain/composeResources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<string name="core_ui_no_data">No Data</string>
<string name="core_ui_something_went_wrong">Something went wrong</string>
<string name="core_ui_core_common_working">Core Common Working</string>
<string name="core_ui_click_to_add_new">Click to add new</string>

<!-- Mifos Client Fee -->
<string name="core_ui_name">Name</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ package com.mifos.core.ui.components

import androidclient.core.ui.generated.resources.Res
import androidclient.core.ui.generated.resources.core_ui_click_here_to_view_filled_state
import androidclient.core.ui.generated.resources.core_ui_click_to_add_new
import androidclient.core.ui.generated.resources.core_ui_no_item_found
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
Expand All @@ -19,6 +20,7 @@ import androidx.compose.foundation.layout.height
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.mifos.core.designsystem.component.MifosButton
import com.mifos.core.designsystem.theme.DesignToken
import com.mifos.core.designsystem.theme.MifosTheme
import com.mifos.core.designsystem.theme.MifosTypography
Expand All @@ -30,6 +32,8 @@ fun MifosEmptyCard(
msg: String? = stringResource(Res.string.core_ui_click_here_to_view_filled_state),
title: String = stringResource(Res.string.core_ui_no_item_found),
modifier: Modifier = Modifier,
onClick: () -> Unit = {},
isButtonPresent: Boolean = false,
) {
MifosListingComponentOutline {
Column(modifier.fillMaxWidth()) {
Expand All @@ -44,6 +48,15 @@ fun MifosEmptyCard(
style = MifosTypography.bodySmall,
)
}
if (isButtonPresent) {
Spacer(Modifier.height((DesignToken.padding.medium)))
MifosButton(
onClick = onClick,
modifier = Modifier.fillMaxWidth(),
) {
Text(stringResource(Res.string.core_ui_click_to_add_new))
}
}
}
}
}
Expand All @@ -52,6 +65,14 @@ fun MifosEmptyCard(
@Composable
private fun MifosEmptyCardPreview() {
MifosTheme {
MifosEmptyCard("Add any to show")
MifosEmptyCard("Add any to show", isButtonPresent = false)
}
}

@Preview
@Composable
private fun MifosEmptyCardWithButtonPreview() {
MifosTheme {
MifosEmptyCard("Add any to show", isButtonPresent = true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,13 @@
<string name="feature_fixed_deposit_interest_empty_date">Date Not Found</string>
<string name="feature_fixed_account_created_successfully">Share account created successfully</string>

<!-- Empty list handling -->
<string name="feature_share_account_empty_list_message">No Share Account Found</string>
<string name="feature_fixed_account_empty_list_message">No Fixed Deposit Account Found</string>
<string name="feature_recurring_account_empty_list_message">No Recurring Deposit Account Found</string>
<string name="feature_savings_account_empty_list_message">No Savings Account Found</string>
<string name="feature_loan_account_empty_list_message">No Loan Account Found</string>

<!-- Filters -->
<string name="feature_client_filters">Filters</string>
<string name="feature_client_account_status">Account Status</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ fun NavGraphBuilder.clientLoanAccountsDestination(
navController: NavController,
navigateToViewAccount: (Int) -> Unit,
navigateToMakeRepayment: (Int) -> Unit,
createAccount: (Int) -> Unit,
) {
composable<ClientLoanAccountsRoute> {
ClientLoanAccountsScreenRoute(
navigateBack = navigateBack,
viewAccount = navigateToViewAccount,
makeRepayment = navigateToMakeRepayment,
navController = navController,
createAccount = { clientId -> createAccount(clientId) },
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package com.mifos.feature.client.clientLoanAccounts

import androidclient.feature.client.generated.resources.Res
import androidclient.feature.client.generated.resources.add_icon
import androidclient.feature.client.generated.resources.cash_bundel
import androidclient.feature.client.generated.resources.client_savings_item
import androidclient.feature.client.generated.resources.feature_client_account_status
Expand All @@ -20,6 +21,7 @@ import androidclient.feature.client.generated.resources.feature_client_status_ac
import androidclient.feature.client.generated.resources.feature_client_status_closed
import androidclient.feature.client.generated.resources.feature_client_status_overpaid
import androidclient.feature.client.generated.resources.feature_client_status_pending
import androidclient.feature.client.generated.resources.feature_loan_account_empty_list_message
import androidclient.feature.client.generated.resources.filter
import androidclient.feature.client.generated.resources.search
import androidclient.feature.client.generated.resources.wallet
Expand Down Expand Up @@ -82,6 +84,7 @@ internal fun ClientLoanAccountsScreenRoute(
makeRepayment: (Int) -> Unit,
viewAccount: (Int) -> Unit,
navController: NavController,
createAccount: (Int) -> Unit,
viewModel: ClientLoanAccountsViewModel = koinViewModel(),
) {
val state by viewModel.stateFlow.collectAsStateWithLifecycle()
Expand All @@ -92,6 +95,7 @@ internal fun ClientLoanAccountsScreenRoute(
is ClientLoanAccountsEvent.MakeRepayment -> makeRepayment(event.id)
ClientLoanAccountsEvent.NavigateBack -> navigateBack()
is ClientLoanAccountsEvent.ViewAccount -> viewAccount(event.id)
is ClientLoanAccountsEvent.AddAccount -> createAccount(event.clientId)
}
}

Expand Down Expand Up @@ -141,6 +145,7 @@ private fun ClientLoanAccountsScreen(
ClientsAccountHeader(
totalItem = state.loanAccounts.size.toString(),
onAction = onAction,
isLoanScreenEmpty = state.loanAccounts.isEmpty(),
isFilterActive = state.selectedStatus.isNotEmpty(),
)

Expand All @@ -162,7 +167,11 @@ private fun ClientLoanAccountsScreen(
Spacer(modifier = Modifier.height(DesignToken.padding.large))

if (state.loanAccounts.isEmpty()) {
MifosEmptyCard()
MifosEmptyCard(
msg = stringResource(Res.string.feature_loan_account_empty_list_message),
isButtonPresent = true,
onClick = { onAction.invoke(ClientLoanAccountsAction.AddAccount) },
)
} else {
LazyColumn {
items(state.loanAccounts) { loan ->
Expand Down Expand Up @@ -234,9 +243,11 @@ private fun ClientsAccountHeader(
totalItem: String,
isFilterActive: Boolean,
onAction: (ClientLoanAccountsAction) -> Unit,
isLoanScreenEmpty: Boolean,
) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
) {
Column {
Text(
Expand All @@ -252,39 +263,48 @@ private fun ClientsAccountHeader(

Spacer(modifier = Modifier.weight(1f))

IconButton(
onClick = { onAction.invoke(ClientLoanAccountsAction.ToggleSearch) },
) {
// add a cross icon when its active, talk with design team
Icon(
painter = painterResource(Res.drawable.search),
contentDescription = null,
)
}

Box(
modifier = Modifier.wrapContentSize(),
contentAlignment = Alignment.Center,
) {
if (!isLoanScreenEmpty) {
IconButton(
onClick = { onAction.invoke(ClientLoanAccountsAction.ToggleFilter) },
onClick = { onAction.invoke(ClientLoanAccountsAction.ToggleSearch) },
) {
// add a cross icon when its active, talk with design team
Icon(
painter = painterResource(Res.drawable.filter),
painter = painterResource(Res.drawable.search),
contentDescription = null,
)
}

if (isFilterActive) {
Box(
modifier = Modifier
.align(Alignment.TopEnd)
.padding(top = 12.dp, end = 16.dp)
.size(8.dp)
.clip(CircleShape)
.background(MaterialTheme.colorScheme.error),
IconButton(
onClick = { onAction.invoke(ClientLoanAccountsAction.AddAccount) },
) {
Icon(
painter = painterResource(Res.drawable.add_icon),
contentDescription = null,
)
}
Box(
modifier = Modifier.wrapContentSize(),
contentAlignment = Alignment.Center,
) {
IconButton(
onClick = { onAction.invoke(ClientLoanAccountsAction.ToggleFilter) },
) {
Icon(
painter = painterResource(Res.drawable.filter),
contentDescription = null,
)
}

if (isFilterActive) {
Box(
modifier = Modifier
.align(Alignment.TopEnd)
.padding(top = 12.dp, end = 16.dp)
.size(8.dp)
.clip(CircleShape)
.background(MaterialTheme.colorScheme.error),
)
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ class ClientLoanAccountsViewModel(
ClientLoanAccountsAction.NavigateBack -> {
sendEvent(ClientLoanAccountsEvent.NavigateBack)
}

ClientLoanAccountsAction.AddAccount -> {
sendEvent(ClientLoanAccountsEvent.AddAccount(route.clientId))
}
}
}

Expand Down Expand Up @@ -207,12 +211,14 @@ data class ClientLoanAccountsState(

sealed interface ClientLoanAccountsEvent {
data object NavigateBack : ClientLoanAccountsEvent
data class AddAccount(val clientId: Int) : ClientLoanAccountsEvent
data class MakeRepayment(val id: Int) : ClientLoanAccountsEvent
data class ViewAccount(val id: Int) : ClientLoanAccountsEvent
}

sealed interface ClientLoanAccountsAction {
data object ToggleSearch : ClientLoanAccountsAction
data object AddAccount : ClientLoanAccountsAction

data object NavigateBack : ClientLoanAccountsAction
data object ToggleFilter : ClientLoanAccountsAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package com.mifos.feature.client.fixedDepositAccount
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import com.mifos.feature.client.newFixedDepositAccount.navigateToCreateFixedDepositRoute
import kotlinx.serialization.Serializable

@Serializable
Expand All @@ -31,6 +32,7 @@ fun NavGraphBuilder.clientFixedDepositAccountDestination(
navigateBack = navigateBack,
onApproveAccount = onApproveAccount,
onViewAccount = onViewAccount,
createAccount = { clientId -> navController.navigateToCreateFixedDepositRoute(clientId) },
)
}
}
Expand Down
Loading