diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/transactions/GroupedTransactionsListItems.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/transactions/GroupedTransactionsListItems.kt index 1558e78..cd0ba01 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/transactions/GroupedTransactionsListItems.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/transactions/GroupedTransactionsListItems.kt @@ -13,8 +13,8 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp 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.HoldingEntity import net.codinux.banking.ui.config.Colors import net.codinux.banking.ui.config.DI import net.codinux.banking.ui.config.Style @@ -31,7 +31,7 @@ private val formatUtil = DI.formatUtil fun GroupedTransactionsListItems( modifier: Modifier, transactionsToDisplay: List, - holdingsToDisplay: List, + holdingsToDisplay: List, banksById: Map, transactionsGrouping: TransactionsGrouping ) { @@ -65,9 +65,9 @@ fun GroupedTransactionsListItems( RoundedCornersCard { Column(Modifier.background(Color.White)) { holdingsToDisplay.forEachIndexed { index, holding -> -// key(statementOfHoldings.id) { + key(holding.id) { HoldingListItem(holding, index % 2 == 1, index < holdingsToDisplay.size - 1) -// } + } } } } @@ -76,49 +76,51 @@ fun GroupedTransactionsListItems( } items(groupedByDate.keys.sortedDescending()) { groupingDate -> - Column(Modifier.fillMaxWidth()) { - Text( - text = DI.formatUtil.formatGroupingDate(groupingDate, transactionsGrouping), - color = Style.ListItemHeaderTextColor, - fontSize = 16.sp, - fontWeight = FontWeight.SemiBold, - modifier = Modifier.padding(top = 8.dp, bottom = 2.dp), - ) + key(groupingDate.toEpochDays()) { + Column(Modifier.fillMaxWidth()) { + Text( + text = DI.formatUtil.formatGroupingDate(groupingDate, transactionsGrouping), + color = Style.ListItemHeaderTextColor, + fontSize = 16.sp, + 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 { - Column(Modifier.background(Color.White)) { // LazyColumn inside LazyColumn is not allowed - monthTransactions.forEachIndexed { index, transaction -> - key(transaction.id) { - TransactionListItem(banksById[transaction.bankId], transaction, index, monthTransactions.size) + RoundedCornersCard { + Column(Modifier.background(Color.White)) { // LazyColumn inside LazyColumn is not allowed + monthTransactions.forEachIndexed { index, transaction -> + key(transaction.id) { + TransactionListItem(banksById[transaction.bankId], transaction, index, monthTransactions.size) + } } } } - } - Column( - Modifier.fillMaxWidth().padding(top = 10.dp), - horizontalAlignment = Alignment.End - ) { - Text( - text = formatUtil.formatAmount(calculator.sumIncome(monthTransactions), - calculator.getTransactionsCurrency(monthTransactions)), - color = formatUtil.getColorForAmount(Amount.Zero, showColoredAmounts) - ) - } + Column( + Modifier.fillMaxWidth().padding(top = 10.dp), + horizontalAlignment = Alignment.End + ) { + Text( + text = formatUtil.formatAmount(calculator.sumIncome(monthTransactions), + calculator.getTransactionsCurrency(monthTransactions)), + color = formatUtil.getColorForAmount(Amount.Zero, showColoredAmounts) + ) + } - Column( - Modifier.fillMaxWidth().padding(top = 2.dp, bottom = 16.dp), - horizontalAlignment = Alignment.End - ) { - Text( - text = formatUtil.formatAmount(calculator.sumExpenses(monthTransactions), - calculator.getTransactionsCurrency(monthTransactions)), - color = formatUtil.getColorForAmount(Amount("-1"), showColoredAmounts) - ) + Column( + Modifier.fillMaxWidth().padding(top = 2.dp, bottom = 16.dp), + horizontalAlignment = Alignment.End + ) { + Text( + text = formatUtil.formatAmount(calculator.sumExpenses(monthTransactions), + calculator.getTransactionsCurrency(monthTransactions)), + color = formatUtil.getColorForAmount(Amount("-1"), showColoredAmounts) + ) + } } } } diff --git a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/transactions/TransactionsList.kt b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/transactions/TransactionsList.kt index 916b717..c553bda 100644 --- a/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/transactions/TransactionsList.kt +++ b/composeApp/src/commonMain/kotlin/net/codinux/banking/ui/composables/transactions/TransactionsList.kt @@ -69,9 +69,9 @@ fun TransactionsList(uiState: UiState, uiSettings: UiSettings, isMobile: Boolean } else { LazyColumn(transactionsListModifier, contentPadding = PaddingValues(top = 8.dp, bottom = 16.dp)) { itemsIndexed(holdingsToDisplay) { index, holding -> -// key(holding.isin) { + key(holding.id) { HoldingListItem(holding, index % 2 == 1, index < holdingsToDisplay.size - 1) -// } + } } itemsIndexed(transactionsToDisplay) { index, transaction ->