BalanceCard clickable
This commit is contained in:
parent
a7f51909cd
commit
c97e422928
@ -69,7 +69,10 @@ fun HeaderCard(modifier: Modifier = Modifier, balance: String, onCategoryButton:
|
|||||||
elevation = 8.dp,
|
elevation = 8.dp,
|
||||||
shape = RoundedCornerShape(12.dp),
|
shape = RoundedCornerShape(12.dp),
|
||||||
clip = false
|
clip = false
|
||||||
)
|
),
|
||||||
|
onClick = {
|
||||||
|
onCategoryButton()
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package at.xaxa.ledger.ui.category.overview
|
package at.xaxa.ledger.ui.category.overview
|
||||||
|
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableFloatStateOf
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.lifecycle.SavedStateHandle
|
import androidx.lifecycle.SavedStateHandle
|
||||||
@ -9,7 +10,6 @@ import androidx.lifecycle.viewModelScope
|
|||||||
import at.xaxa.ledger.data.EntryRepository
|
import at.xaxa.ledger.data.EntryRepository
|
||||||
import at.xaxa.ledger.data.db.Category.CategoryEntity
|
import at.xaxa.ledger.data.db.Category.CategoryEntity
|
||||||
import at.xaxa.ledger.ui.category.add.CategoryListUIState
|
import at.xaxa.ledger.ui.category.add.CategoryListUIState
|
||||||
import at.xaxa.ledger.ui.category.add.CategoryUIState
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.flowOf
|
import kotlinx.coroutines.flow.flowOf
|
||||||
@ -24,6 +24,8 @@ class OverviewCategoryViewModel(
|
|||||||
private val savedStateHandle: SavedStateHandle,
|
private val savedStateHandle: SavedStateHandle,
|
||||||
private val repository: EntryRepository
|
private val repository: EntryRepository
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
|
var balance by mutableFloatStateOf(0.0f)
|
||||||
|
private set // Restrict external modification
|
||||||
var categoryUiState by mutableStateOf(CategoryListUIState())
|
var categoryUiState by mutableStateOf(CategoryListUIState())
|
||||||
private set
|
private set
|
||||||
|
|
||||||
@ -40,4 +42,9 @@ class OverviewCategoryViewModel(
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fun calculateBalance() {
|
||||||
|
viewModelScope.launch {
|
||||||
|
balance = repository.calculateBalance()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user