diff --git a/app/src/main/java/be/chvp/nanoledger/ui/main/MainActivity.kt b/app/src/main/java/be/chvp/nanoledger/ui/main/MainActivity.kt index 32a0fac..9d75bb9 100644 --- a/app/src/main/java/be/chvp/nanoledger/ui/main/MainActivity.kt +++ b/app/src/main/java/be/chvp/nanoledger/ui/main/MainActivity.kt @@ -204,10 +204,11 @@ fun MainContent( LazyColumn(modifier = Modifier.fillMaxSize()) { items(transactions?.size ?: 0) { val index = transactions!!.size - it - 1 + val (originalIndex, transaction) = transactions!![index] TransactionCard( - transactions!![index], - index == selected, - { mainViewModel.toggleSelect(index) }, + transaction, + originalIndex == selected, + { mainViewModel.toggleSelect(originalIndex) }, Modifier.fillMaxWidth().padding( 8.dp, if (it == 0) 8.dp else 4.dp, diff --git a/app/src/main/java/be/chvp/nanoledger/ui/main/MainViewModel.kt b/app/src/main/java/be/chvp/nanoledger/ui/main/MainViewModel.kt index f7816f4..511f36d 100644 --- a/app/src/main/java/be/chvp/nanoledger/ui/main/MainViewModel.kt +++ b/app/src/main/java/be/chvp/nanoledger/ui/main/MainViewModel.kt @@ -38,10 +38,11 @@ class MainViewModel val filteredTransactions = transactions.switchMap { ts -> _query.map { query -> + val indexedTs = ts.mapIndexed { index, t -> index to t } if (query.equals("")) { - ts + indexedTs } else { - ts.filter { t -> t.contains(query) } + indexedTs.filter { (i, t) -> t.contains(query) } } } }