Skip to content

Commit

Permalink
Wrapped account items in cards, removed hardcoded colors, and applied…
Browse files Browse the repository at this point in the history
… default checkbox colors
  • Loading branch information
HekmatullahAmin committed Feb 14, 2025
1 parent 5ee98d4 commit 9b7dbf8
Show file tree
Hide file tree
Showing 9 changed files with 240 additions and 260 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@
*/
package org.mifos.mobile.feature.account.account.screens

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import mifos_mobile.feature.account.generated.resources.Res
Expand All @@ -39,7 +34,7 @@ import org.mifos.mobile.core.common.Constants
import org.mifos.mobile.core.common.CurrencyFormatter
import org.mifos.mobile.core.common.DateHelper
import org.mifos.mobile.core.model.entity.accounts.loan.LoanAccount
import org.mifos.mobile.feature.account.account.utils.AccountTypeItemIndicator
import org.mifos.mobile.feature.account.account.utils.AccountCard

@Composable
internal fun LoanAccountContent(
Expand Down Expand Up @@ -74,7 +69,8 @@ internal fun LoanAccountContent(
}

LazyColumn(
modifier = modifier.fillMaxSize(),
modifier = modifier.fillMaxSize().padding(top = 8.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
state = lazyColumnState,
) {
items(items = accounts) { loanAccount ->
Expand Down Expand Up @@ -163,52 +159,20 @@ private fun AccountScreenLoanListItem(
}
}

Row(
modifier = modifier.clickable {
AccountCard(
accountNo = loanAccount.accountNo,
productName = loanAccount.productName,
statusString = stringResource,
balance = CurrencyFormatter.format(
balance = loanAccount.loanBalance,
currencyCode = loanAccount.currency?.code,
maximumFractionDigits = 2,
),
indicatorColor = color,
textColor = numColor,
onClick = {
onItemClick.invoke(Constants.LOAN_ACCOUNTS, loanAccount.id)
},
verticalAlignment = Alignment.CenterVertically,
) {
AccountTypeItemIndicator(color)

Column(modifier = Modifier.padding(all = 12.dp)) {
loanAccount.accountNo?.let {
Text(
text = it,
style = MaterialTheme.typography.bodyLarge,
)
}

loanAccount.productName?.let {
Text(
text = it,
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}

Text(
text = stringResource,
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}

Spacer(Modifier.weight(1f))

numColor?.let {
val amountBalance = if (loanAccount.loanBalance != 0.0) loanAccount.loanBalance else 0.0
Text(
text = CurrencyFormatter.format(
balance = amountBalance,
currencyCode = loanAccount.currency?.code,
maximumFractionDigits = 2,
),
modifier = Modifier
.align(Alignment.CenterVertically)
.padding(end = 16.dp),
color = it,
)
}
}
modifier = modifier,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@
*/
package org.mifos.mobile.feature.account.account.screens

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import mifos_mobile.feature.account.generated.resources.Res
Expand All @@ -38,7 +33,7 @@ import org.mifos.mobile.core.common.Constants
import org.mifos.mobile.core.common.CurrencyFormatter
import org.mifos.mobile.core.common.DateHelper
import org.mifos.mobile.core.model.entity.accounts.savings.SavingAccount
import org.mifos.mobile.feature.account.account.utils.AccountTypeItemIndicator
import org.mifos.mobile.feature.account.account.utils.AccountCard

@Composable
internal fun SavingsAccountContent(
Expand Down Expand Up @@ -73,7 +68,8 @@ internal fun SavingsAccountContent(
}

LazyColumn(
modifier = modifier.fillMaxSize(),
modifier = modifier.fillMaxSize().padding(top = 8.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
state = lazyColumnState,
) {
items(items = accounts) { savingAccount ->
Expand Down Expand Up @@ -136,63 +132,31 @@ private fun AccountScreenSavingsListItem(
}
}

Row(
modifier = modifier.clickable {
val currencySymbolOrCode =
savingAccount.currency?.displaySymbol ?: savingAccount.currency?.code ?: ""

val formattedBalance = CurrencyFormatter.format(
balance = savingAccount.accountBalance,
currencyCode = savingAccount.currency?.code,
maximumFractionDigits = 2,
)

val amountAndCurrency = stringResource(
Res.string.feature_account_string_and_string,
formattedBalance,
currencySymbolOrCode,
)

AccountCard(
accountNo = savingAccount.accountNo,
productName = savingAccount.productName,
statusString = stringResource,
balance = amountAndCurrency,
indicatorColor = color,
textColor = numColor,
onClick = {
onItemClick.invoke(Constants.SAVINGS_ACCOUNTS, savingAccount.id)
},
verticalAlignment = Alignment.CenterVertically,
) {
AccountTypeItemIndicator(color)

Column(modifier = Modifier.padding(all = 12.dp)) {
savingAccount.accountNo?.let {
Text(
text = it,
style = MaterialTheme.typography.bodyLarge,
)
}

savingAccount.productName?.let {
Text(
text = it,
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}

if (stringResource != null) {
Text(
text = stringResource,
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
}

Spacer(Modifier.weight(1f))

numColor?.let { color ->
val currencySymbolOrCode =
savingAccount.currency?.displaySymbol ?: savingAccount.currency?.code ?: ""
val formattedBalance = CurrencyFormatter.format(
balance = savingAccount.accountBalance,
currencyCode = savingAccount.currency?.code,
maximumFractionDigits = 2,
)

val amountAndCurrency = stringResource(
Res.string.feature_account_string_and_string,
formattedBalance,
currencySymbolOrCode,
)

Text(
text = amountAndCurrency,
modifier = Modifier
.align(Alignment.CenterVertically)
.padding(end = 16.dp),
color = color,
)
}
}
modifier = modifier,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,21 @@
package org.mifos.mobile.feature.account.account.screens

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import mifos_mobile.feature.account.generated.resources.Res
import mifos_mobile.feature.account.generated.resources.feature_account_approved
import mifos_mobile.feature.account.generated.resources.feature_account_pending
import org.jetbrains.compose.resources.stringResource
import org.mifos.mobile.core.model.entity.accounts.share.ShareAccount
import org.mifos.mobile.feature.account.account.utils.AccountTypeItemIndicator
import org.mifos.mobile.feature.account.account.utils.ShareAccountCard

@Composable
internal fun AccountScreenShareContent(
Expand Down Expand Up @@ -68,7 +58,8 @@ internal fun AccountScreenShareContent(
}

LazyColumn(
modifier = modifier.fillMaxSize(),
modifier = modifier.fillMaxSize().padding(top = 8.dp),
verticalArrangement = Arrangement.spacedBy(8.dp),
state = lazyColumnState,
) {
items(items = accounts) { shareAccount ->
Expand Down Expand Up @@ -102,64 +93,10 @@ private fun AccountScreenShareListItem(
}
}

Row(
ShareAccountCard(
shareAccount = shareAccount,
indicatorColor = color,
setSharingAccountDetail = setSharingAccountDetail,
modifier = modifier,
verticalAlignment = Alignment.CenterVertically,
) {
AccountTypeItemIndicator(color)

Column(modifier = Modifier.padding(all = 12.dp)) {
shareAccount.accountNo?.let {
Text(
text = it,
style = MaterialTheme.typography.bodyLarge,
)
}

shareAccount.productName?.let {
Text(
text = it,
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}

Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
) {
Row {
Text(
text = stringResource(resource = Res.string.feature_account_pending),
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)

Text(
text = " ${shareAccount.totalPendingForApprovalShares}",
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurface,
)
}

if (setSharingAccountDetail) {
Row {
Text(
text = stringResource(resource = Res.string.feature_account_approved),
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)

Text(
modifier = Modifier.padding(end = 12.dp),
text = " ${shareAccount.totalApprovedShares}",
style = MaterialTheme.typography.bodyLarge,
color = MaterialTheme.colorScheme.onSurface,
)
}
}
}
}
Spacer(Modifier.weight(1f))
}
)
}
Loading

0 comments on commit 9b7dbf8

Please sign in to comment.