Skip to content

Commit

Permalink
🐛 修复焦点问题
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoxieyoulei committed Apr 21, 2024
1 parent 2e42886 commit 9f0870e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,19 @@ fun PanelIptvGroupList(
iptvGroupList: IptvGroupList = IptvGroupList(),
epgList: EpgList = EpgList(),
onIptvSelected: (Iptv) -> Unit = {},
listState: TvLazyListState = rememberTvLazyListState(
max(
0,
iptvGroupList.iptvGroupIdx(currentIptv)
)
state: TvLazyListState = rememberTvLazyListState(
max(0, iptvGroupList.iptvGroupIdx(currentIptv))
),
onListStateChanged: () -> Unit = {},
) {
val childPadding = rememberChildPadding()

LaunchedEffect(listState) {
snapshotFlow { listState.isScrollInProgress }.collect { onListStateChanged() }
LaunchedEffect(state) {
snapshotFlow { state.isScrollInProgress }.collect { onListStateChanged() }
}

TvLazyColumn(
state = listState,
state = state,
modifier = modifier,
verticalArrangement = Arrangement.spacedBy(14.dp),
contentPadding = PaddingValues(bottom = childPadding.bottom),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -42,10 +43,12 @@ fun PanelIptvItem(
) {
var isFocused by remember { mutableStateOf(false) }
val focusRequester = remember { FocusRequester() }
var hasFocused by rememberSaveable { mutableStateOf(false) }

LaunchedEffect(Unit) {
if (initialFocused) {
if (initialFocused && !hasFocused) {
focusRequester.requestFocus()
hasFocused = true
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ fun PanelIptvList(
iptvList: IptvList = IptvList(),
epgList: EpgList = EpgList(),
onIptvSelected: (Iptv) -> Unit = {},
listState: TvLazyListState = rememberTvLazyListState(max(0, iptvList.indexOf(currentIptv))),
state: TvLazyListState = rememberTvLazyListState(max(0, iptvList.indexOf(currentIptv))),
onListStateChanged: () -> Unit = {},
) {
val childPadding = rememberChildPadding()

LaunchedEffect(listState) {
snapshotFlow { listState.isScrollInProgress }.collect { onListStateChanged() }
LaunchedEffect(state) {
snapshotFlow { state.isScrollInProgress }.collect { onListStateChanged() }
}

TvLazyRow(
state = listState,
state = state,
modifier = modifier,
horizontalArrangement = Arrangement.spacedBy(10.dp),
contentPadding = PaddingValues(start = childPadding.start, end = childPadding.end),
Expand Down

0 comments on commit 9f0870e

Please sign in to comment.