From 0f926c043506300867b54b011d5c3f42d7b2f2ff Mon Sep 17 00:00:00 2001 From: Elijah Date: Sat, 24 Oct 2026 11:20:23 -0700 Subject: [PATCH] Keep Library tab focus within its section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Right from the Library tab had nothing beside it, so focus searched upward into the top bar and opened Home. In the A–Z view it now moves to the genre/watch/sort row (and Left returns), the end of that row stops, and the Discover view's Library tab no longer leaves the section. The tab is now labelled "Library". Co-Authored-By: Claude Opus 5.5 --- app/src/main/java/tv/kaleido/app/BrowseScreens.kt | 11 +++++++---- app/src/main/java/tv/kaleido/app/FocusedBrowse.kt | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/tv/kaleido/app/BrowseScreens.kt b/app/src/main/java/tv/kaleido/app/BrowseScreens.kt index 7d8f3ee..cb8e9b9 100644 --- a/app/src/main/java/tv/kaleido/app/BrowseScreens.kt +++ b/app/src/main/java/tv/kaleido/app/BrowseScreens.kt @@ -112,24 +112,27 @@ private fun anticipateTileMove(vm:KaleidoViewModel,items:List,index:Int,d var sortMenu by remember{mutableStateOf(false)} var genreMenu by remember{mutableStateOf(false)} var sectionMenu by remember{mutableStateOf(false)} + // Without explicit links, Right from Library searches upward and lands on (and opens) Home. + val libraryFocus=remember{FocusRequester()};val filterFocus=remember{FocusRequester()} + val filters=vm.section!=null||vm.busy Column(Modifier.fillMaxSize()) { Row(Modifier.fillMaxWidth().height(64.dp).padding(horizontal=Cinema.gutter),verticalAlignment=Alignment.CenterVertically) { Text(name,color=Accent,fontSize=29.sp,lineHeight=34.sp,fontWeight=FontWeight.SemiBold,letterSpacing=(-.8).sp) Spacer(Modifier.width(21.dp)) NavigationLabel("Discover",!vm.allTitles){vm.setAll(false)} - NavigationLabel("Library · A–Z",vm.allTitles,initialFocus=vm.focusId=="library-entry"){vm.setAll(true)} + NavigationLabel("Library",vm.allTitles,modifier=Modifier.focusRequester(libraryFocus).focusProperties{right=if(filters)filterFocus else FocusRequester.Cancel},initialFocus=vm.focusId=="library-entry"){vm.setAll(true)} Spacer(Modifier.weight(1f)) if(vm.sections.count{it.type==vm.section?.type}>1)TvButton(vm.section?.title ?: "Library"){sectionMenu=true} else if(!vm.allTitles)Text("${vm.total} titles",color=Muted,fontSize=11.sp,lineHeight=16.sp) } - if(vm.section==null&&!vm.busy)EmptyState("No $name library","This server has no matching library.") + if(!filters)EmptyState("No $name library","This server has no matching library.") else { Row(Modifier.fillMaxWidth().height(43.dp).padding(horizontal=Cinema.gutter),verticalAlignment=Alignment.CenterVertically,horizontalArrangement=Arrangement.spacedBy(8.dp)) { Text("${vm.total} titles",color=Muted,fontSize=11.sp,lineHeight=16.sp) Spacer(Modifier.weight(1f)) - TvButton((if(vm.genre.isBlank())"All genres"else vm.genres.firstOrNull{it.first==vm.genre}?.second ?: "Genre")+" ⌄"){genreMenu=true} + TvButton((if(vm.genre.isBlank())"All genres"else vm.genres.firstOrNull{it.first==vm.genre}?.second ?: "Genre")+" ⌄",Modifier.focusRequester(filterFocus).focusProperties{left=libraryFocus}){genreMenu=true} TvButton(if(vm.unwatched)"Unwatched ✓"else "Unwatched",selected=vm.unwatched){vm.filter(unwatchedValue=!vm.unwatched)} - TvButton((sortLabels.firstOrNull{it.first==vm.sort}?.second ?: "Title: A–Z")+" ⌄"){sortMenu=true} + TvButton((sortLabels.firstOrNull{it.first==vm.sort}?.second ?: "Title: A–Z")+" ⌄",Modifier.focusProperties{right=FocusRequester.Cancel}){sortMenu=true} } val grid=rememberLazyGridState() LaunchedEffect(grid,vm.library.size,vm.total){snapshotFlow{grid.layoutInfo.visibleItemsInfo.lastOrNull()?.index ?: 0}.collect{if(it>=vm.library.size-18&&vm.library.isNotEmpty())vm.more()}} diff --git a/app/src/main/java/tv/kaleido/app/FocusedBrowse.kt b/app/src/main/java/tv/kaleido/app/FocusedBrowse.kt index 0ee484d..66dab12 100644 --- a/app/src/main/java/tv/kaleido/app/FocusedBrowse.kt +++ b/app/src/main/java/tv/kaleido/app/FocusedBrowse.kt @@ -120,7 +120,8 @@ private suspend fun LazyListState.animateBrowseTo(index:Int) { Text(title,color=Accent,fontSize=19.sp,fontWeight=FontWeight.SemiBold,modifier=Modifier.padding(end=20.dp)) if(!home) { NavigationLabel("Discover",true,modifier=Modifier.focusRequester(navigation.section).focusProperties{up=navigation.top;down=navigation.entry},initialFocus=sectionEntry){} - NavigationLabel("Library · A–Z",false,modifier=Modifier.focusProperties{up=navigation.top;down=navigation.entry}){vm.setAll(true)} + // Nothing sits right of Library; an unbounded search would open Home from the top bar. + NavigationLabel("Library",false,modifier=Modifier.focusProperties{up=navigation.top;down=navigation.entry;right=FocusRequester.Cancel}){vm.setAll(true)} } } Spacer(Modifier.fillMaxWidth().height(if(destination=="movies")137.dp else 119.dp))