Skip to content

Commit

Permalink
Focus "Home" tab by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix committed Oct 5, 2024
1 parent 6927139 commit 1014f65
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ package nl.ndat.tvlauncher.ui.toolbar

import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.key
import androidx.compose.runtime.remember
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.focusRestorer
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
Expand All @@ -28,9 +32,12 @@ fun ToolbarTabs() {
stringResource(R.string.tab_apps),
)

val focusRequester = remember { FocusRequester() }
LaunchedEffect(Unit) { focusRequester.requestFocus() }
TabRow(
selectedTabIndex = selectedTabIndex,
modifier = Modifier
.focusRequester(focusRequester)
.focusRestorer(),
) {
tabs.forEachIndexed { tabIndex, name ->
Expand Down

0 comments on commit 1014f65

Please sign in to comment.