From 2d632c19dea4df176fa4075bc32fdefdea40568c Mon Sep 17 00:00:00 2001 From: vfsfitvnm Date: Wed, 26 Oct 2022 11:56:09 +0200 Subject: [PATCH] Keep screen on when showing synchronized lyrics (#521) --- .../it/vfsfitvnm/vimusic/ui/screens/player/Lyrics.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/player/Lyrics.kt b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/player/Lyrics.kt index c4bb709..eb6eb99 100644 --- a/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/player/Lyrics.kt +++ b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/player/Lyrics.kt @@ -27,6 +27,7 @@ import androidx.compose.foundation.text.BasicText import androidx.compose.foundation.verticalScroll import androidx.compose.material.ripple.rememberRipple import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue 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.platform.LocalContext import androidx.compose.ui.platform.LocalDensity +import androidx.compose.ui.platform.LocalView import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp @@ -98,6 +100,7 @@ fun Lyrics( val (colorPalette, typography) = LocalAppearance.current val context = LocalContext.current val menuState = LocalMenuState.current + val currentView = LocalView.current var isShowingSynchronizedLyrics by rememberPreference(isShowingSynchronizedLyricsKey, false) @@ -174,6 +177,15 @@ fun Lyrics( ) } + if (isShowingSynchronizedLyrics) { + DisposableEffect(Unit) { + currentView.keepScreenOn = true + onDispose { + currentView.keepScreenOn = false + } + } + } + Box( contentAlignment = Alignment.Center, modifier = modifier