Fix "Flash on page change" gives black screen on page change

Fixes #108

(cherry picked from commit 38d6ab80ce868707829dbc81de4170afe3c2f2a5)
This commit is contained in:
AntsyLich 2024-01-20 16:33:50 +06:00 committed by Cuong M. Tran
parent 5ce158b189
commit a87ca2a34f
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2

View file

@ -11,6 +11,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import kotlinx.coroutines.delay
import kotlin.time.Duration.Companion.seconds
@Stable
class DisplayRefreshHost {
@ -30,15 +31,15 @@ fun DisplayRefreshHost(
val currentDisplayRefresh = hostState.currentDisplayRefresh
LaunchedEffect(currentDisplayRefresh) {
if (currentDisplayRefresh) {
delay(1500)
delay(1.5.seconds)
hostState.currentDisplayRefresh = false
}
}
if (currentDisplayRefresh) {
Canvas(
modifier = modifier.fillMaxSize(),
) {
Canvas(
modifier = modifier.fillMaxSize(),
) {
if (currentDisplayRefresh) {
drawRect(Color.Black)
}
}