feat: implement PlatformBackHandler for back navigation support across platforms

This commit is contained in:
tapframe 2026-03-11 22:50:12 +05:30
parent fc6bbf31f5
commit 8ea6658491
4 changed files with 37 additions and 0 deletions

View file

@ -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)
}

View file

@ -0,0 +1,9 @@
package com.nuvio.app.core.ui
import androidx.compose.runtime.Composable
@Composable
expect fun PlatformBackHandler(
enabled: Boolean,
onBack: () -> Unit,
)

View file

@ -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(

View file

@ -0,0 +1,9 @@
package com.nuvio.app.core.ui
import androidx.compose.runtime.Composable
@Composable
actual fun PlatformBackHandler(
enabled: Boolean,
onBack: () -> Unit,
) = Unit