mirror of
https://github.com/mihonapp/mihon.git
synced 2025-08-26 08:01:31 +02:00
Compare commits
2 Commits
cb3c8fef73
...
22b2cef837
Author | SHA1 | Date | |
---|---|---|---|
|
22b2cef837 | ||
|
6bd9353912 |
@@ -13,7 +13,6 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
@@ -57,22 +56,26 @@ fun DisplayRefreshHost(
|
||||
val flashMode by hostState.flashMode.collectAsState()
|
||||
val flashInterval by hostState.flashIntervalPref.collectAsState()
|
||||
|
||||
var bothColor by remember { mutableStateOf(Color.White) }
|
||||
var currentColor by remember { mutableStateOf<Color?>(null) }
|
||||
|
||||
LaunchedEffect(currentDisplayRefresh) {
|
||||
if (currentDisplayRefresh) {
|
||||
launch {
|
||||
delay(refreshDuration.milliseconds)
|
||||
hostState.currentDisplayRefresh = false
|
||||
}
|
||||
if (flashMode == ReaderPreferences.FlashColor.WHITE_BLACK) {
|
||||
launch {
|
||||
bothColor = Color.White
|
||||
delay(refreshDuration.milliseconds / 2)
|
||||
bothColor = Color.Black
|
||||
}
|
||||
}
|
||||
if (!currentDisplayRefresh) {
|
||||
currentColor = null
|
||||
return@LaunchedEffect
|
||||
}
|
||||
|
||||
val refreshDurationHalf = refreshDuration.milliseconds / 2
|
||||
currentColor = if (flashMode == ReaderPreferences.FlashColor.BLACK) {
|
||||
Color.Black
|
||||
} else {
|
||||
Color.White
|
||||
}
|
||||
delay(refreshDurationHalf)
|
||||
if (flashMode == ReaderPreferences.FlashColor.WHITE_BLACK) {
|
||||
currentColor = Color.Black
|
||||
}
|
||||
delay(refreshDurationHalf)
|
||||
hostState.currentDisplayRefresh = false
|
||||
}
|
||||
|
||||
LaunchedEffect(flashInterval) {
|
||||
@@ -82,12 +85,6 @@ fun DisplayRefreshHost(
|
||||
Canvas(
|
||||
modifier = modifier.fillMaxSize(),
|
||||
) {
|
||||
if (currentDisplayRefresh) {
|
||||
when (flashMode) {
|
||||
ReaderPreferences.FlashColor.BLACK -> drawRect(Color.Black)
|
||||
ReaderPreferences.FlashColor.WHITE -> drawRect(Color.White)
|
||||
ReaderPreferences.FlashColor.WHITE_BLACK -> drawRect(bothColor)
|
||||
}
|
||||
}
|
||||
currentColor?.let { drawRect(it) }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user