Skip to content

Commit 96dfbad

Browse files
committed
added exit dialogue
1 parent 4b1eeb8 commit 96dfbad

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

app/src/main/java/com/secure/privacyfirst/ui/screens/WebViewScreen.kt

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import androidx.activity.compose.BackHandler
2727
import androidx.compose.foundation.layout.Box
2828
import androidx.compose.foundation.layout.fillMaxSize
2929
import androidx.compose.foundation.layout.statusBarsPadding
30+
import androidx.compose.material.icons.Icons
31+
import androidx.compose.material.icons.filled.ExitToApp
3032
import androidx.compose.runtime.Composable
3133
import androidx.compose.runtime.DisposableEffect
3234
import androidx.compose.runtime.LaunchedEffect
@@ -72,6 +74,7 @@ fun WebViewScreen() {
7274
var showCameraWarning by remember { mutableStateOf(false) }
7375
var showMicWarning by remember { mutableStateOf(false) }
7476
var showExternalAppWarning by remember { mutableStateOf(false) }
77+
var showExitDialog by remember { mutableStateOf(false) }
7578
var externalUrl by remember { mutableStateOf("") }
7679
var pendingPermissionRequest by remember { mutableStateOf<PermissionRequest?>(null) }
7780

@@ -149,8 +152,8 @@ fun WebViewScreen() {
149152
webView?.goBack()
150153
} else {
151154
// If can't go back in WebView, we're at the home page
152-
// You might want to show an exit dialog or just stay on the page
153-
Toast.makeText(context, "Already at home page", Toast.LENGTH_SHORT).show()
155+
// Show exit confirmation dialog
156+
showExitDialog = true
154157
}
155158
}
156159

@@ -631,6 +634,44 @@ fun WebViewScreen() {
631634
}
632635
)
633636
}
637+
638+
// Exit confirmation dialog
639+
if (showExitDialog) {
640+
androidx.compose.material3.AlertDialog(
641+
onDismissRequest = { showExitDialog = false },
642+
icon = {
643+
androidx.compose.material3.Icon(
644+
imageVector = androidx.compose.material.icons.Icons.Default.ExitToApp,
645+
contentDescription = "Exit App"
646+
)
647+
},
648+
title = {
649+
androidx.compose.material3.Text(text = "Exit App")
650+
},
651+
text = {
652+
androidx.compose.material3.Text(
653+
text = "Are you sure you want to exit Privacy First Browser?"
654+
)
655+
},
656+
confirmButton = {
657+
androidx.compose.material3.TextButton(
658+
onClick = {
659+
showExitDialog = false
660+
(context as? MainActivity)?.finish()
661+
}
662+
) {
663+
androidx.compose.material3.Text("Exit")
664+
}
665+
},
666+
dismissButton = {
667+
androidx.compose.material3.TextButton(
668+
onClick = { showExitDialog = false }
669+
) {
670+
androidx.compose.material3.Text("Cancel")
671+
}
672+
}
673+
)
674+
}
634675
}
635676

636677
class WebAppInterface(private val context: android.content.Context) {

0 commit comments

Comments
 (0)