diff --git a/app/src/main/java/eu/kanade/presentation/browse/anime/GlobalAnimeSearchScreen.kt b/app/src/main/java/eu/kanade/presentation/browse/anime/GlobalAnimeSearchScreen.kt index 54c87954a4..a62e41cc81 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/anime/GlobalAnimeSearchScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/anime/GlobalAnimeSearchScreen.kt @@ -4,6 +4,10 @@ import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.runtime.Composable import androidx.compose.runtime.State +import androidx.compose.ui.Modifier +import androidx.compose.ui.focus.FocusRequester +import androidx.compose.ui.focus.focusProperties +import androidx.compose.ui.focus.focusRequester import eu.kanade.presentation.browse.GlobalSearchErrorResultItem import eu.kanade.presentation.browse.GlobalSearchLoadingResultItem import eu.kanade.presentation.browse.GlobalSearchResultItem @@ -30,6 +34,7 @@ fun GlobalAnimeSearchScreen( onClickItem: (Anime) -> Unit, onLongClickItem: (Anime) -> Unit, ) { + val (toolbarFocus, contentFocus) = FocusRequester.createRefs() Scaffold( topBar = { scrollBehavior -> GlobalAnimeSearchToolbar( @@ -44,6 +49,11 @@ fun GlobalAnimeSearchScreen( onlyShowHasResults = state.onlyShowHasResults, onToggleResults = onToggleResults, scrollBehavior = scrollBehavior, + modifier = Modifier + .focusRequester(toolbarFocus) + .focusProperties { + down = contentFocus + } ) }, ) { paddingValues -> @@ -54,6 +64,7 @@ fun GlobalAnimeSearchScreen( onClickSource = onClickSource, onClickItem = onClickItem, onLongClickItem = onLongClickItem, + modifier = Modifier.focusRequester(contentFocus) ) } } @@ -66,10 +77,12 @@ internal fun GlobalSearchContent( onClickSource: (AnimeCatalogueSource) -> Unit, onClickItem: (Anime) -> Unit, onLongClickItem: (Anime) -> Unit, + modifier: Modifier = Modifier, fromSourceId: Long? = null, ) { LazyColumn( contentPadding = contentPadding, + modifier = modifier ) { items.forEach { (source, result) -> item(key = source.id) { diff --git a/app/src/main/java/eu/kanade/presentation/browse/anime/components/GlobalAnimeSearchToolbar.kt b/app/src/main/java/eu/kanade/presentation/browse/anime/components/GlobalAnimeSearchToolbar.kt index e7219ef1e9..6d529ce4c1 100644 --- a/app/src/main/java/eu/kanade/presentation/browse/anime/components/GlobalAnimeSearchToolbar.kt +++ b/app/src/main/java/eu/kanade/presentation/browse/anime/components/GlobalAnimeSearchToolbar.kt @@ -26,6 +26,7 @@ import androidx.compose.material3.VerticalDivider import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.focus.focusRequester import eu.kanade.presentation.components.SearchToolbar import eu.kanade.tachiyomi.ui.browse.anime.source.globalsearch.AnimeSourceFilter import tachiyomi.i18n.MR @@ -45,6 +46,7 @@ fun GlobalAnimeSearchToolbar( onlyShowHasResults: Boolean, onToggleResults: () -> Unit, scrollBehavior: TopAppBarScrollBehavior, + modifier: Modifier = Modifier, ) { Column(modifier = Modifier.background(MaterialTheme.colorScheme.surface)) { Box { @@ -69,7 +71,8 @@ fun GlobalAnimeSearchToolbar( Row( modifier = Modifier .horizontalScroll(rememberScrollState()) - .padding(horizontal = MaterialTheme.padding.small), + .padding(horizontal = MaterialTheme.padding.small) + .then(modifier), horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small), ) { // TODO: make this UX better; it only applies when triggering a new search