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 @@ -647,6 +647,12 @@
<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>


</resources>
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,10 +10,12 @@
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_dialog_action_ok
import androidclient.feature.client.generated.resources.feature_client_loan_account
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.update_default_account_title
Expand All @@ -36,6 +38,7 @@ import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
Expand All @@ -61,6 +64,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 @@ -70,6 +74,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 @@ -114,6 +119,7 @@ private fun ClientLoanAccountsScreen(
ClientsAccountHeader(
totalItem = state.loanAccounts.size.toString(),
onAction = onAction,
isLoanScreenEmpty = state.loanAccounts.isEmpty(),
)

if (state.isSearchBarActive) {
Expand All @@ -134,7 +140,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 @@ -206,9 +216,11 @@ private fun ClientLoanAccountsScreen(
private fun ClientsAccountHeader(
totalItem: String,
onAction: (ClientLoanAccountsAction) -> Unit,
isLoanScreenEmpty: Boolean,
) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
) {
Column {
Text(
Expand All @@ -224,23 +236,32 @@ 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,
)
}

IconButton(
onClick = { onAction.invoke(ClientLoanAccountsAction.ToggleFilter) },
) {
Icon(
painter = painterResource(Res.drawable.filter),
contentDescription = null,
)
if (!isLoanScreenEmpty) {
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,
)
}
IconButton(
onClick = { onAction.invoke(ClientLoanAccountsAction.AddAccount) },
) {
Icon(
painter = painterResource(Res.drawable.add_icon),
contentDescription = null,
)
}
IconButton(
onClick = { onAction.invoke(ClientLoanAccountsAction.ToggleFilter) },
) {
Icon(
painter = painterResource(Res.drawable.filter),
contentDescription = null,
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ class ClientLoanAccountsViewModel(
ClientLoanAccountsAction.NavigateBack -> {
sendEvent(ClientLoanAccountsEvent.NavigateBack)
}

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

Expand Down Expand Up @@ -147,12 +151,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
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
package com.mifos.feature.client.fixedDepositAccount

import androidclient.feature.client.generated.resources.Res
import androidclient.feature.client.generated.resources.client_empty_card_message
import androidclient.feature.client.generated.resources.add_icon
import androidclient.feature.client.generated.resources.client_product_fixed_deposit_account
import androidclient.feature.client.generated.resources.client_profile_fixed_deposit_account_title
import androidclient.feature.client.generated.resources.client_savings_item
import androidclient.feature.client.generated.resources.client_savings_not_avilable
import androidclient.feature.client.generated.resources.client_savings_pending_approval
import androidclient.feature.client.generated.resources.feature_client_dialog_action_ok
import androidclient.feature.client.generated.resources.feature_fixed_account_empty_list_message
import androidclient.feature.client.generated.resources.filter
import androidclient.feature.client.generated.resources.search
import androidx.compose.foundation.clickable
Expand All @@ -42,6 +43,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.navigation.NavController
Expand All @@ -68,6 +70,7 @@ fun FixedDepositAccountScreen(
onApproveAccount: (String) -> Unit,
onViewAccount: (String) -> Unit,
modifier: Modifier = Modifier,
createAccount: (Int) -> Unit,
viewModel: FixedDepositAccountViewModel = koinViewModel(),
) {
val state by viewModel.stateFlow.collectAsStateWithLifecycle()
Expand All @@ -82,6 +85,8 @@ fun FixedDepositAccountScreen(
is FixedDepositAccountEvent.OnViewAccount -> {
onViewAccount(event.accountNumber)
}

is FixedDepositAccountEvent.AddAccount -> createAccount(event.clientId)
}
}

Expand Down Expand Up @@ -168,6 +173,10 @@ fun FixedDepositAccountScaffold(
onToggleFilter = {
onAction(FixedDepositAccountAction.ToggleFilter)
},
addAccount = {
onAction(FixedDepositAccountAction.AddAccount)
},
isFixedDepositScreenEmpty = state.fixedDepositAccount.isEmpty(),
)

// todo implement search bar functionality
Expand All @@ -189,7 +198,11 @@ fun FixedDepositAccountScaffold(
Spacer(modifier = Modifier.height(DesignToken.padding.largeIncreasedExtra))

if (state.fixedDepositAccount.isEmpty()) {
MifosEmptyCard(msg = stringResource(Res.string.client_empty_card_message))
MifosEmptyCard(
msg = stringResource(Res.string.feature_fixed_account_empty_list_message),
isButtonPresent = true,
onClick = { onAction.invoke(FixedDepositAccountAction.AddAccount) },
)
} else {
LazyColumn {
itemsIndexed(state.fixedDepositAccount) { index, fixedDepositAccount ->
Expand Down Expand Up @@ -262,11 +275,14 @@ fun FixedDepositAccountHeader(
totalItem: String,
onToggleFilter: () -> Unit,
modifier: Modifier = Modifier,
addAccount: () -> Unit,
onToggleSearch: () -> Unit,
isFixedDepositScreenEmpty: Boolean,
) {
Row(
modifier = modifier.fillMaxWidth()
.wrapContentHeight(),
verticalAlignment = Alignment.CenterVertically,
) {
Column {
Text(
Expand All @@ -282,22 +298,33 @@ fun FixedDepositAccountHeader(

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

Icon(
painter = painterResource(Res.drawable.search),
contentDescription = null,
modifier = Modifier.clickable {
onToggleSearch.invoke()
},
)
if (!isFixedDepositScreenEmpty) {
Icon(
painter = painterResource(Res.drawable.search),
contentDescription = null,
modifier = Modifier.clickable {
onToggleSearch.invoke()
},
)

Spacer(modifier = Modifier.width(DesignToken.spacing.largeIncreased))
Spacer(modifier = Modifier.width(DesignToken.spacing.largeIncreased))

Icon(
painter = painterResource(Res.drawable.filter),
contentDescription = null,
modifier = Modifier.clickable {
onToggleFilter.invoke()
},
)
Icon(
painter = painterResource(Res.drawable.add_icon),
contentDescription = null,
modifier = Modifier.clickable {
addAccount.invoke()
},
)
Spacer(modifier = Modifier.width(DesignToken.spacing.largeIncreased))

Icon(
painter = painterResource(Res.drawable.filter),
contentDescription = null,
modifier = Modifier.clickable {
onToggleFilter.invoke()
},
)
}
}
}
Loading