mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-17 15:32:01 +00:00
feat: exit handler
This commit is contained in:
parent
457d95e918
commit
823716b175
4 changed files with 41 additions and 2 deletions
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.nuvio.app.core.ui
|
||||||
|
|
||||||
|
import android.os.Process
|
||||||
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
|
actual fun platformExitApp() {
|
||||||
|
Process.killProcess(Process.myPid())
|
||||||
|
exitProcess(0)
|
||||||
|
}
|
||||||
|
|
@ -80,7 +80,9 @@ import com.nuvio.app.core.sync.SyncManager
|
||||||
import com.nuvio.app.core.ui.NuvioNavigationBar
|
import com.nuvio.app.core.ui.NuvioNavigationBar
|
||||||
import com.nuvio.app.core.ui.NuvioContinueWatchingActionSheet
|
import com.nuvio.app.core.ui.NuvioContinueWatchingActionSheet
|
||||||
import com.nuvio.app.core.ui.NuvioPosterActionSheet
|
import com.nuvio.app.core.ui.NuvioPosterActionSheet
|
||||||
|
import com.nuvio.app.core.ui.NuvioStatusModal
|
||||||
import com.nuvio.app.core.ui.PlatformBackHandler
|
import com.nuvio.app.core.ui.PlatformBackHandler
|
||||||
|
import com.nuvio.app.core.ui.platformExitApp
|
||||||
import com.nuvio.app.core.ui.configurePlatformImageLoader
|
import com.nuvio.app.core.ui.configurePlatformImageLoader
|
||||||
import com.nuvio.app.core.ui.NuvioToastHost
|
import com.nuvio.app.core.ui.NuvioToastHost
|
||||||
import com.nuvio.app.core.ui.NuvioToastController
|
import com.nuvio.app.core.ui.NuvioToastController
|
||||||
|
|
@ -421,6 +423,7 @@ private fun MainAppContent(
|
||||||
val hapticFeedback = LocalHapticFeedback.current
|
val hapticFeedback = LocalHapticFeedback.current
|
||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
var selectedTab by rememberSaveable { mutableStateOf(AppScreenTab.Home) }
|
var selectedTab by rememberSaveable { mutableStateOf(AppScreenTab.Home) }
|
||||||
|
var showExitConfirmation by rememberSaveable { mutableStateOf(false) }
|
||||||
var selectedPosterForActions by remember { mutableStateOf<MetaPreview?>(null) }
|
var selectedPosterForActions by remember { mutableStateOf<MetaPreview?>(null) }
|
||||||
var selectedContinueWatchingForActions by remember { mutableStateOf<ContinueWatchingItem?>(null) }
|
var selectedContinueWatchingForActions by remember { mutableStateOf<ContinueWatchingItem?>(null) }
|
||||||
var showLibraryListPicker by remember { mutableStateOf(false) }
|
var showLibraryListPicker by remember { mutableStateOf(false) }
|
||||||
|
|
@ -827,8 +830,14 @@ private fun MainAppContent(
|
||||||
) {
|
) {
|
||||||
composable<TabsRoute> {
|
composable<TabsRoute> {
|
||||||
PlatformBackHandler(
|
PlatformBackHandler(
|
||||||
enabled = selectedTab != AppScreenTab.Home,
|
enabled = true,
|
||||||
onBack = { selectedTab = AppScreenTab.Home },
|
onBack = {
|
||||||
|
if (selectedTab != AppScreenTab.Home) {
|
||||||
|
selectedTab = AppScreenTab.Home
|
||||||
|
} else {
|
||||||
|
showExitConfirmation = !showExitConfirmation
|
||||||
|
}
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
BoxWithConstraints(modifier = Modifier.fillMaxSize()) {
|
BoxWithConstraints(modifier = Modifier.fillMaxSize()) {
|
||||||
|
|
@ -1673,6 +1682,21 @@ private fun MainAppContent(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
NuvioStatusModal(
|
||||||
|
title = "Exit app",
|
||||||
|
message = "Do you want to exit the app?",
|
||||||
|
isVisible = showExitConfirmation,
|
||||||
|
confirmText = "Yes",
|
||||||
|
dismissText = "No",
|
||||||
|
onConfirm = {
|
||||||
|
showExitConfirmation = false
|
||||||
|
platformExitApp()
|
||||||
|
},
|
||||||
|
onDismiss = {
|
||||||
|
showExitConfirmation = false
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
androidx.compose.animation.AnimatedVisibility(
|
androidx.compose.animation.AnimatedVisibility(
|
||||||
visible = !initialHomeReady || profileSwitchLoading,
|
visible = !initialHomeReady || profileSwitchLoading,
|
||||||
enter = fadeIn(),
|
enter = fadeIn(),
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.nuvio.app.core.ui
|
||||||
|
|
||||||
|
expect fun platformExitApp()
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
package com.nuvio.app.core.ui
|
||||||
|
|
||||||
|
actual fun platformExitApp() = Unit
|
||||||
Loading…
Reference in a new issue