Rodri Represa
06/10/2021, 2:25 PMvar test = mutableStateOf<List<Int>>(emptyList())
/**
I add some values to test {0,1,2}
**/
test = emptyList()
Filip Wiesner
06/10/2021, 2:28 PMtest
is type MutableState<List<Int>>
you can't just assign type List
to it.
Should it be var test by mutableStateOf<List<Int>>(emptyList())
?Filip Wiesner
06/10/2021, 2:31 PMRodri Represa
06/10/2021, 2:36 PMRodri Represa
06/10/2021, 2:36 PMvar filledDays by mutableStateOf<List<Int>>(emptyList())
var startDay by mutableStateOf<Int?>(null)
var endDay by mutableStateOf<Int?>(null)
var nextEndDay: Boolean = false
fun fill() {
var list = filledDays.toMutableList()
for (i in startDay!!..endDay!!) {
list.add(i)
}
filledDays = list
}
fun click(day: Int) {
if (nextEndDay) {
if (day > startDay!!) {
endDay = day
nextEndDay = false
fill()
} else {
startDay(day)
}
} else {
startDay(day)
}
}
fun startDay(day: Int) {
startDay = day
endDay = null
filledDays = emptyList()
nextEndDay = true
squareSpeed = 50
}
Filip Wiesner
06/10/2021, 3:01 PMstartDay()
does not clear the filledDays
by assigning emptyList()
to it?Rodri Represa
06/10/2021, 3:03 PMFilip Wiesner
06/10/2021, 3:24 PMmutableStateListOf
instead of mutableStateOf
I think this should theoretically work.
And from where do you observe that startDay
did not overwrite the state? From UI or you can you see it in the fill()
function? My question is if the value actually did not change or if the change just did not trigger recomposition.
But I haven't touched Compose in few weeks so I might not be the best person to answer this 😅Rodri Represa
06/11/2021, 7:12 AMmutableStateListOf
, however I still having the issue. Look at the video, when you click set your starDay and endDay in the calendar, the days which are in the middle are supposed to be added at the same time to the mutableStateListOf and the they should be filled all at the same time, however, when you change your dates quickly, the previous range still filled despite of I remove them from the mutableStateListOf and added again. If you see the last attempt, i'm waiting more time, and my days are filled correctly, all at the same time. When you debug, the mutableStateListOf is successfully empty and filled again, but it seems the previous range still on cache or something if you empty and fill it quickly.