mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-08 23:51:21 +02:00
Smooth lyric animations a bit
This commit is contained in:
parent
9c53abf152
commit
860369b8eb
1 changed files with 12 additions and 2 deletions
|
|
@ -26,6 +26,7 @@ import androidx.compose.ui.focus.focusProperties
|
||||||
import androidx.compose.ui.focus.focusRequester
|
import androidx.compose.ui.focus.focusRequester
|
||||||
import androidx.compose.ui.focus.onFocusChanged
|
import androidx.compose.ui.focus.onFocusChanged
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.tv.material3.ClickableSurfaceDefaults
|
import androidx.tv.material3.ClickableSurfaceDefaults
|
||||||
import androidx.tv.material3.MaterialTheme
|
import androidx.tv.material3.MaterialTheme
|
||||||
|
|
@ -33,6 +34,7 @@ import androidx.tv.material3.Surface
|
||||||
import androidx.tv.material3.Text
|
import androidx.tv.material3.Text
|
||||||
import com.github.damontecres.wholphin.ui.ifElse
|
import com.github.damontecres.wholphin.ui.ifElse
|
||||||
import com.github.damontecres.wholphin.ui.tryRequestFocus
|
import com.github.damontecres.wholphin.ui.tryRequestFocus
|
||||||
|
import com.github.damontecres.wholphin.ui.util.rememberDelayedNestedScroll
|
||||||
import org.jellyfin.sdk.model.api.LyricDto
|
import org.jellyfin.sdk.model.api.LyricDto
|
||||||
import org.jellyfin.sdk.model.api.LyricLine
|
import org.jellyfin.sdk.model.api.LyricLine
|
||||||
|
|
||||||
|
|
@ -48,6 +50,9 @@ fun LyricsContent(
|
||||||
val focusRequesters =
|
val focusRequesters =
|
||||||
remember(lyrics) { List(lyrics?.lyrics.orEmpty().size) { FocusRequester() } }
|
remember(lyrics) { List(lyrics?.lyrics.orEmpty().size) { FocusRequester() } }
|
||||||
val listState = rememberLazyListState(currentLyricPosition ?: 0)
|
val listState = rememberLazyListState(currentLyricPosition ?: 0)
|
||||||
|
|
||||||
|
val scrollConnection = rememberDelayedNestedScroll(yDelay = .66f)
|
||||||
|
|
||||||
val bringIntoViewRequester = remember { BringIntoViewRequester() }
|
val bringIntoViewRequester = remember { BringIntoViewRequester() }
|
||||||
if (!lyricsHaveFocus) {
|
if (!lyricsHaveFocus) {
|
||||||
LaunchedEffect(currentLyricPosition) {
|
LaunchedEffect(currentLyricPosition) {
|
||||||
|
|
@ -61,7 +66,10 @@ fun LyricsContent(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Column(modifier) {
|
Column(
|
||||||
|
modifier
|
||||||
|
.nestedScroll(scrollConnection),
|
||||||
|
) {
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
state = listState,
|
state = listState,
|
||||||
contentPadding = PaddingValues(),
|
contentPadding = PaddingValues(),
|
||||||
|
|
@ -115,8 +123,10 @@ fun LyricsContent(
|
||||||
Modifier
|
Modifier
|
||||||
.focusRequester(focusRequesters[index]),
|
.focusRequester(focusRequesters[index]),
|
||||||
) {
|
) {
|
||||||
|
val text =
|
||||||
|
remember(lyric.text) { lyric.text.ifBlank { " " } }
|
||||||
Text(
|
Text(
|
||||||
text = lyric.text,
|
text = text,
|
||||||
style = MaterialTheme.typography.bodyLarge,
|
style = MaterialTheme.typography.bodyLarge,
|
||||||
color = if (focused) MaterialTheme.colorScheme.onSurface else color,
|
color = if (focused) MaterialTheme.colorScheme.onSurface else color,
|
||||||
modifier =
|
modifier =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue