fix episode overview focus on mobile
This commit is contained in:
+21
-14
@@ -52,6 +52,7 @@ import ru.shadowsparky.ui.components.ExpressiveLazyColumn
|
||||
import ru.shadowsparky.ui.components.IconButton
|
||||
import ru.shadowsparky.ui.components.Loading
|
||||
import ru.shadowsparky.ui.components.TopAppBar
|
||||
import ru.shadowsparky.ui.components.isTv
|
||||
import ru.shadowsparky.vbox.shared.domain.OfflineState
|
||||
import ru.shadowsparky.vbox.shared.domain.OfflineVideo
|
||||
import ru.shadowsparky.vbox.shared.domain.model.Episode
|
||||
@@ -170,6 +171,7 @@ fun EpisodesOverviewList(
|
||||
isSaveMode: Boolean,
|
||||
onOfflineClicked: (EpisodeWithOfflineInfo) -> Unit
|
||||
) {
|
||||
val isTv = isTv()
|
||||
if (errorCode != null) {
|
||||
ErrorContent(
|
||||
errorCode,
|
||||
@@ -190,15 +192,19 @@ fun EpisodesOverviewList(
|
||||
key = { item -> item.episode.episode }
|
||||
) { index, episode ->
|
||||
EpisodeInfo(
|
||||
Modifier.onFocusChanged { state ->
|
||||
if (state.isFocused) focusedIndex = index
|
||||
}.then(
|
||||
if (index == focusedIndex) {
|
||||
Modifier.focusRequester(requester)
|
||||
} else {
|
||||
Modifier
|
||||
}
|
||||
),
|
||||
if (isTv) {
|
||||
Modifier.onFocusChanged { state ->
|
||||
if (state.isFocused) focusedIndex = index
|
||||
}.then(
|
||||
if (index == focusedIndex) {
|
||||
Modifier.focusRequester(requester)
|
||||
} else {
|
||||
Modifier
|
||||
}
|
||||
)
|
||||
} else {
|
||||
Modifier
|
||||
},
|
||||
onLaunch,
|
||||
episode,
|
||||
onClipboardAction,
|
||||
@@ -210,11 +216,12 @@ fun EpisodesOverviewList(
|
||||
}
|
||||
}
|
||||
LaunchedEffect(episodes) {
|
||||
if (episodes.isEmpty()) return@LaunchedEffect
|
||||
val index = focusedIndex.coerceIn(episodes.indices)
|
||||
lazyListState.scrollToItem(index)
|
||||
withFrameNanos {}
|
||||
requester.requestFocus()
|
||||
if (isTv && episodes.isNotEmpty()) {
|
||||
val index = focusedIndex.coerceIn(episodes.indices)
|
||||
lazyListState.scrollToItem(index)
|
||||
withFrameNanos {}
|
||||
requester.requestFocus()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Loading()
|
||||
|
||||
Reference in New Issue
Block a user