mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-12 03:21:08 +00:00
ui: preserve rail focus on components
This commit is contained in:
1 parent
2ba872e7f7
commit
2b1ef0d3e6
3 files changed
+15
-9
No files matched your search
@@ -101,6 +101,7 @@ class MainActivity : ComponentActivity() {
|
||||
private var showProtons by mutableStateOf(false)
|
||||
// Components page: FEX / DXVK / VKD3D-Proton per Proton (ComponentsManager).
|
||||
private var showComponents by mutableStateOf(false)
|
||||
private var focusComponentsContent by mutableStateOf(true)
|
||||
private var compSnapshot by mutableStateOf<ComponentsManager.Snapshot?>(null)
|
||||
private var compCatalog by mutableStateOf<List<ComponentsManager.CatalogItem>>(emptyList())
|
||||
private var compCatalogAt by mutableStateOf(0L)
|
||||
@@ -348,7 +349,7 @@ class MainActivity : ComponentActivity() {
|
||||
frameGenLabel = FrameGen.label(this)
|
||||
},
|
||||
onProtons = { openProtons() },
|
||||
onComponents = { openComponents() },
|
||||
onComponents = { focusContent -> openComponents(focusContent) },
|
||||
onPerformance = { refreshCores(); showProtons = false; showComponents = false; showMapping = false; showPerformance = true },
|
||||
onRoms = { showRoms = true },
|
||||
onFiles = { startActivity(Intent(this, com.droiddeck.launcher.files.FileManagerActivity::class.java)) },
|
||||
@@ -669,7 +670,8 @@ class MainActivity : ComponentActivity() {
|
||||
)
|
||||
}
|
||||
|
||||
private fun openComponents() {
|
||||
private fun openComponents(focusContent: Boolean = true) {
|
||||
focusComponentsContent = focusContent
|
||||
settingsMode = null
|
||||
showPerformance = false
|
||||
showProtons = false
|
||||
@@ -755,6 +757,7 @@ class MainActivity : ComponentActivity() {
|
||||
checking = compChecking,
|
||||
busy = compBusy,
|
||||
downloads = compDownloads,
|
||||
requestInitialFocus = focusComponentsContent,
|
||||
onProton = { compProton = it },
|
||||
onComp = { compComp = it },
|
||||
onSwap = { file -> compProton?.let { pid -> componentAction("Swapping") { ComponentsManager.swap(this, pid, file) } } },
|
||||
|
||||
@@ -101,6 +101,7 @@ fun ComponentsPage(
|
||||
onRefresh: () -> Unit,
|
||||
onImport: () -> Unit,
|
||||
onBack: () -> Unit,
|
||||
requestInitialFocus: Boolean = true,
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
@@ -207,7 +208,9 @@ fun ComponentsPage(
|
||||
val storedNames = snapshot.packages.map { it.file }.toSet()
|
||||
val available = catalog.filter { it.comp == comp && ComponentsManager.safeName(it.file) !in storedNames }
|
||||
val first = remember { FocusRequester() }
|
||||
LaunchedEffect(p.id, comp) { runCatching { first.requestFocus() } }
|
||||
LaunchedEffect(p.id, comp, requestInitialFocus) {
|
||||
if (requestInitialFocus) runCatching { first.requestFocus() }
|
||||
}
|
||||
|
||||
val installed: @Composable () -> Unit = {
|
||||
SettingsGroup("Installed · ${rows.size}") {
|
||||
|
||||
@@ -222,7 +222,7 @@ class FrontEndActions(
|
||||
val onFrameGenPick: (engine: String, multiplier: Int) -> Unit,
|
||||
val onProtons: () -> Unit,
|
||||
/** The Components page: FEX / DXVK / VKD3D-Proton per Proton. */
|
||||
val onComponents: () -> Unit,
|
||||
val onComponents: (focusContent: Boolean) -> Unit,
|
||||
val onPerformance: () -> Unit,
|
||||
val onRoms: () -> Unit,
|
||||
val onFiles: () -> Unit,
|
||||
@@ -431,20 +431,20 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com
|
||||
}
|
||||
// Bumped each time a rail item is picked, so a controller moves on into the new page.
|
||||
var railPicks by remember { mutableStateOf(0) }
|
||||
val showRailPage: (String) -> Unit = { key ->
|
||||
val showRailPage: (String, Boolean) -> Unit = { key, focusContent ->
|
||||
// Components is a full page like Protons or Performance, opened over the current rail
|
||||
// selection rather than replacing it.
|
||||
if (key == "components") a.onComponents()
|
||||
if (key == "components") a.onComponents(focusContent)
|
||||
else {
|
||||
if (s.pageKey != null) a.onPageBack()
|
||||
selected = key
|
||||
}
|
||||
}
|
||||
val onRailFocus: (String) -> Unit = { key ->
|
||||
if (key != railSelection) showRailPage(key)
|
||||
if (key != railSelection) showRailPage(key, false)
|
||||
}
|
||||
val onRailSelect: (String) -> Unit = { key ->
|
||||
showRailPage(key)
|
||||
showRailPage(key, true)
|
||||
railPicks++
|
||||
}
|
||||
val inputModeManager = LocalInputModeManager.current
|
||||
@@ -1474,7 +1474,7 @@ private fun LaunchSettings(s: FrontEndState, a: FrontEndActions, host: MenuHost)
|
||||
val columns = if (LocalNarrowPane.current) 2 else 3
|
||||
val controller = a.controller
|
||||
val cards = buildList<@Composable (Modifier) -> Unit> {
|
||||
add { m -> SettingCard("Compatibility", "Proton & components", "card:components", m, a.onComponents) }
|
||||
add { m -> SettingCard("Compatibility", "Proton & components", "card:components", m) { a.onComponents(true) } }
|
||||
add { m ->
|
||||
Box(m) {
|
||||
SettingCard("Frame generation", s.frameGenLabel, "card:fg", Modifier.fillMaxSize()) {
|
||||
|
||||
Reference in new issue
Block a user