Added keys for holdings and transaction groups
This commit is contained in:
parent
c6f4b6d250
commit
4531380bac
|
@ -13,8 +13,8 @@ import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import net.codinux.banking.client.model.Amount
|
import net.codinux.banking.client.model.Amount
|
||||||
import net.codinux.banking.client.model.securitiesaccount.Holding
|
|
||||||
import net.codinux.banking.persistence.entities.BankAccessEntity
|
import net.codinux.banking.persistence.entities.BankAccessEntity
|
||||||
|
import net.codinux.banking.persistence.entities.HoldingEntity
|
||||||
import net.codinux.banking.ui.config.Colors
|
import net.codinux.banking.ui.config.Colors
|
||||||
import net.codinux.banking.ui.config.DI
|
import net.codinux.banking.ui.config.DI
|
||||||
import net.codinux.banking.ui.config.Style
|
import net.codinux.banking.ui.config.Style
|
||||||
|
@ -31,7 +31,7 @@ private val formatUtil = DI.formatUtil
|
||||||
fun GroupedTransactionsListItems(
|
fun GroupedTransactionsListItems(
|
||||||
modifier: Modifier,
|
modifier: Modifier,
|
||||||
transactionsToDisplay: List<AccountTransactionViewModel>,
|
transactionsToDisplay: List<AccountTransactionViewModel>,
|
||||||
holdingsToDisplay: List<Holding>,
|
holdingsToDisplay: List<HoldingEntity>,
|
||||||
banksById: Map<Long, BankAccessEntity>,
|
banksById: Map<Long, BankAccessEntity>,
|
||||||
transactionsGrouping: TransactionsGrouping
|
transactionsGrouping: TransactionsGrouping
|
||||||
) {
|
) {
|
||||||
|
@ -65,9 +65,9 @@ fun GroupedTransactionsListItems(
|
||||||
RoundedCornersCard {
|
RoundedCornersCard {
|
||||||
Column(Modifier.background(Color.White)) {
|
Column(Modifier.background(Color.White)) {
|
||||||
holdingsToDisplay.forEachIndexed { index, holding ->
|
holdingsToDisplay.forEachIndexed { index, holding ->
|
||||||
// key(statementOfHoldings.id) {
|
key(holding.id) {
|
||||||
HoldingListItem(holding, index % 2 == 1, index < holdingsToDisplay.size - 1)
|
HoldingListItem(holding, index % 2 == 1, index < holdingsToDisplay.size - 1)
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,49 +76,51 @@ fun GroupedTransactionsListItems(
|
||||||
}
|
}
|
||||||
|
|
||||||
items(groupedByDate.keys.sortedDescending()) { groupingDate ->
|
items(groupedByDate.keys.sortedDescending()) { groupingDate ->
|
||||||
Column(Modifier.fillMaxWidth()) {
|
key(groupingDate.toEpochDays()) {
|
||||||
Text(
|
Column(Modifier.fillMaxWidth()) {
|
||||||
text = DI.formatUtil.formatGroupingDate(groupingDate, transactionsGrouping),
|
Text(
|
||||||
color = Style.ListItemHeaderTextColor,
|
text = DI.formatUtil.formatGroupingDate(groupingDate, transactionsGrouping),
|
||||||
fontSize = 16.sp,
|
color = Style.ListItemHeaderTextColor,
|
||||||
fontWeight = FontWeight.SemiBold,
|
fontSize = 16.sp,
|
||||||
modifier = Modifier.padding(top = 8.dp, bottom = 2.dp),
|
fontWeight = FontWeight.SemiBold,
|
||||||
)
|
modifier = Modifier.padding(top = 8.dp, bottom = 2.dp),
|
||||||
|
)
|
||||||
|
|
||||||
Spacer(Modifier.height(4.dp))
|
Spacer(Modifier.height(4.dp))
|
||||||
|
|
||||||
val monthTransactions = groupedByDate[groupingDate].orEmpty().sortedByDescending { it.valueDate }
|
val monthTransactions = groupedByDate[groupingDate].orEmpty().sortedByDescending { it.valueDate }
|
||||||
|
|
||||||
RoundedCornersCard {
|
RoundedCornersCard {
|
||||||
Column(Modifier.background(Color.White)) { // LazyColumn inside LazyColumn is not allowed
|
Column(Modifier.background(Color.White)) { // LazyColumn inside LazyColumn is not allowed
|
||||||
monthTransactions.forEachIndexed { index, transaction ->
|
monthTransactions.forEachIndexed { index, transaction ->
|
||||||
key(transaction.id) {
|
key(transaction.id) {
|
||||||
TransactionListItem(banksById[transaction.bankId], transaction, index, monthTransactions.size)
|
TransactionListItem(banksById[transaction.bankId], transaction, index, monthTransactions.size)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
Modifier.fillMaxWidth().padding(top = 10.dp),
|
Modifier.fillMaxWidth().padding(top = 10.dp),
|
||||||
horizontalAlignment = Alignment.End
|
horizontalAlignment = Alignment.End
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = formatUtil.formatAmount(calculator.sumIncome(monthTransactions),
|
text = formatUtil.formatAmount(calculator.sumIncome(monthTransactions),
|
||||||
calculator.getTransactionsCurrency(monthTransactions)),
|
calculator.getTransactionsCurrency(monthTransactions)),
|
||||||
color = formatUtil.getColorForAmount(Amount.Zero, showColoredAmounts)
|
color = formatUtil.getColorForAmount(Amount.Zero, showColoredAmounts)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
Modifier.fillMaxWidth().padding(top = 2.dp, bottom = 16.dp),
|
Modifier.fillMaxWidth().padding(top = 2.dp, bottom = 16.dp),
|
||||||
horizontalAlignment = Alignment.End
|
horizontalAlignment = Alignment.End
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = formatUtil.formatAmount(calculator.sumExpenses(monthTransactions),
|
text = formatUtil.formatAmount(calculator.sumExpenses(monthTransactions),
|
||||||
calculator.getTransactionsCurrency(monthTransactions)),
|
calculator.getTransactionsCurrency(monthTransactions)),
|
||||||
color = formatUtil.getColorForAmount(Amount("-1"), showColoredAmounts)
|
color = formatUtil.getColorForAmount(Amount("-1"), showColoredAmounts)
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,9 +69,9 @@ fun TransactionsList(uiState: UiState, uiSettings: UiSettings, isMobile: Boolean
|
||||||
} else {
|
} else {
|
||||||
LazyColumn(transactionsListModifier, contentPadding = PaddingValues(top = 8.dp, bottom = 16.dp)) {
|
LazyColumn(transactionsListModifier, contentPadding = PaddingValues(top = 8.dp, bottom = 16.dp)) {
|
||||||
itemsIndexed(holdingsToDisplay) { index, holding ->
|
itemsIndexed(holdingsToDisplay) { index, holding ->
|
||||||
// key(holding.isin) {
|
key(holding.id) {
|
||||||
HoldingListItem(holding, index % 2 == 1, index < holdingsToDisplay.size - 1)
|
HoldingListItem(holding, index % 2 == 1, index < holdingsToDisplay.size - 1)
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
itemsIndexed(transactionsToDisplay) { index, transaction ->
|
itemsIndexed(transactionsToDisplay) { index, transaction ->
|
||||||
|
|
Loading…
Reference in New Issue