Keep screen on when showing synchronized lyrics (#521)

This commit is contained in:
vfsfitvnm 2022-10-26 11:56:09 +02:00
parent 5de8221f4a
commit 2d632c19de

View file

@ -27,6 +27,7 @@ import androidx.compose.foundation.text.BasicText
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.material.ripple.rememberRipple import androidx.compose.material.ripple.rememberRipple
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
@ -40,6 +41,7 @@ import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalView
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
@ -98,6 +100,7 @@ fun Lyrics(
val (colorPalette, typography) = LocalAppearance.current val (colorPalette, typography) = LocalAppearance.current
val context = LocalContext.current val context = LocalContext.current
val menuState = LocalMenuState.current val menuState = LocalMenuState.current
val currentView = LocalView.current
var isShowingSynchronizedLyrics by rememberPreference(isShowingSynchronizedLyricsKey, false) var isShowingSynchronizedLyrics by rememberPreference(isShowingSynchronizedLyricsKey, false)
@ -174,6 +177,15 @@ fun Lyrics(
) )
} }
if (isShowingSynchronizedLyrics) {
DisposableEffect(Unit) {
currentView.keepScreenOn = true
onDispose {
currentView.keepScreenOn = false
}
}
}
Box( Box(
contentAlignment = Alignment.Center, contentAlignment = Alignment.Center,
modifier = modifier modifier = modifier