11package com.darkrockstudios.app.securecamera.navigation
22
3+ import android.os.Build
4+ import android.view.RoundedCorner
5+ import androidx.compose.animation.*
36import androidx.compose.foundation.layout.Box
47import androidx.compose.foundation.layout.PaddingValues
58import androidx.compose.foundation.layout.fillMaxSize
9+ import androidx.compose.foundation.shape.RoundedCornerShape
610import androidx.compose.material3.SnackbarHostState
711import androidx.compose.material3.Text
812import androidx.compose.runtime.*
913import androidx.compose.ui.Alignment
1014import androidx.compose.ui.Modifier
15+ import androidx.compose.ui.draw.clip
16+ import androidx.compose.ui.platform.LocalDensity
17+ import androidx.compose.ui.platform.LocalView
1118import androidx.compose.ui.res.stringResource
12- import androidx.navigation3.runtime.NavBackStack
13- import androidx.navigation3.runtime.NavKey
14- import androidx.navigation3.runtime.entryProvider
19+ import androidx.compose.ui.unit.Dp
20+ import androidx.compose.ui.unit.dp
21+ import androidx.navigation3.runtime.*
1522import androidx.navigation3.ui.NavDisplay
1623import com.darkrockstudios.app.securecamera.R
1724import com.darkrockstudios.app.securecamera.about.AboutContent
@@ -27,6 +34,26 @@ import com.darkrockstudios.app.securecamera.settings.SettingsContent
2734import com.darkrockstudios.app.securecamera.viewphoto.ViewPhotoContent
2835import kotlin.io.encoding.ExperimentalEncodingApi
2936
37+ @Composable
38+ private fun rememberScreenCornerRadius (): Dp {
39+ val view = LocalView .current
40+ val density = LocalDensity .current
41+ return remember {
42+ val radius = 16 .dp
43+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .S ) {
44+ val insets = view.rootWindowInsets
45+ val corner = insets?.getRoundedCorner(RoundedCorner .POSITION_TOP_LEFT )
46+ if (corner != null ) {
47+ with (density) { corner.radius.toDp() }
48+ } else {
49+ radius
50+ }
51+ } else {
52+ radius
53+ }
54+ }
55+ }
56+
3057@OptIn(ExperimentalEncodingApi ::class )
3158@Composable
3259fun AppNavHost (
@@ -43,10 +70,39 @@ fun AppNavHost(
4370
4471 LaunchedEffect (Unit ) { authManager.checkSessionValidity() }
4572
73+ val cornerRadius = rememberScreenCornerRadius()
74+ val roundedCornerDecorator = remember(cornerRadius) {
75+ NavEntryDecorator <Any > { entry ->
76+ Box (
77+ modifier = Modifier
78+ .fillMaxSize()
79+ .clip(RoundedCornerShape (cornerRadius))
80+ ) {
81+ entry.Content ()
82+ }
83+ }
84+ }
85+
4686 NavDisplay (
4787 backStack = backStack,
4888 onBack = { if (backStack.isNotEmpty()) backStack.removeAt(backStack.lastIndex) },
4989 modifier = modifier,
90+ entryDecorators = listOf (
91+ rememberSaveableStateHolderNavEntryDecorator(),
92+ roundedCornerDecorator,
93+ ),
94+ transitionSpec = {
95+ (slideInHorizontally { it } + fadeIn()) togetherWith
96+ (slideOutHorizontally { - it } + fadeOut())
97+ },
98+ popTransitionSpec = {
99+ (slideInHorizontally { - it } + fadeIn()) togetherWith
100+ (slideOutHorizontally { it } + fadeOut())
101+ },
102+ predictivePopTransitionSpec = {
103+ (slideInHorizontally { - it / 10 } + fadeIn()) togetherWith
104+ (scaleOut(targetScale = 0.9f ) + fadeOut())
105+ },
50106 entryProvider = entryProvider {
51107 entry<Introduction > {
52108 IntroductionContent (
0 commit comments