Skip to content

Commit

Permalink
fix: onBackPressed not worked.
Browse files Browse the repository at this point in the history
  • Loading branch information
oxyroid committed Jan 28, 2024
1 parent 76d668b commit ad4c193
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 3 additions & 1 deletion androidApp/src/main/java/com/m3u/androidApp/ui/App.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.m3u.androidApp.ui

import androidx.activity.compose.LocalOnBackPressedDispatcherOwner
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
Expand All @@ -19,6 +20,7 @@ fun App(
viewModel: AppViewModel = hiltViewModel(),
) {
val helper = LocalHelper.current
val onBackPressedDispatcherOwner = LocalOnBackPressedDispatcherOwner.current

val navController = rememberNavController()
val entry by navController.currentBackStackEntryAsState()
Expand All @@ -42,7 +44,7 @@ fun App(
val deep by viewModel.deep.collectAsStateWithLifecycle()

val onBackPressed: (() -> Unit)? = {
navController.popBackStack()
onBackPressedDispatcherOwner?.onBackPressedDispatcher?.onBackPressed()
Unit
}.takeIf { deep > 0 }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ fun TextPreference(
},
modifier = modifier,
trailing = {

if (!isTelevision()) {
Text(
text = trailing.uppercase(),
Expand Down

0 comments on commit ad4c193

Please sign in to comment.