mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-08-04 02:28:36 +00:00
feat: implement PlatformBackHandler for back navigation support across platforms
This commit is contained in:
parent
fc6bbf31f5
commit
8ea6658491
4 changed files with 37 additions and 0 deletions
|
|
@ -0,0 +1,12 @@
|
|||
package com.nuvio.app.core.ui
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
actual fun PlatformBackHandler(
|
||||
enabled: Boolean,
|
||||
onBack: () -> Unit,
|
||||
) {
|
||||
BackHandler(enabled = enabled, onBack = onBack)
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.nuvio.app.core.ui
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
expect fun PlatformBackHandler(
|
||||
enabled: Boolean,
|
||||
onBack: () -> Unit,
|
||||
)
|
||||
|
|
@ -33,6 +33,7 @@ import androidx.compose.ui.text.font.FontWeight
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.max
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.nuvio.app.core.ui.PlatformBackHandler
|
||||
import com.nuvio.app.core.ui.NuvioScreen
|
||||
import com.nuvio.app.core.ui.NuvioScreenHeader
|
||||
import com.nuvio.app.features.addons.AddonRepository
|
||||
|
|
@ -61,6 +62,12 @@ fun SettingsScreen(
|
|||
|
||||
var currentPage by rememberSaveable { mutableStateOf(SettingsPage.Root.name) }
|
||||
val page = remember(currentPage) { SettingsPage.valueOf(currentPage) }
|
||||
val previousPage = page.previousPage()
|
||||
|
||||
PlatformBackHandler(
|
||||
enabled = previousPage != null,
|
||||
onBack = { previousPage?.let { currentPage = it.name } },
|
||||
)
|
||||
|
||||
if (maxWidth >= 768.dp) {
|
||||
TabletSettingsScreen(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
package com.nuvio.app.core.ui
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
|
||||
@Composable
|
||||
actual fun PlatformBackHandler(
|
||||
enabled: Boolean,
|
||||
onBack: () -> Unit,
|
||||
) = Unit
|
||||
Loading…
Reference in a new issue