@@ -2,14 +2,21 @@ package com.henrikherzig.playintegritychecker.ui.navigationbar
22
33import androidx.compose.foundation.isSystemInDarkTheme
44import androidx.compose.foundation.layout.*
5+ import androidx.compose.foundation.rememberScrollState
6+ import androidx.compose.foundation.verticalScroll
57import androidx.compose.material.*
8+ import androidx.compose.material.icons.Icons
9+ import androidx.compose.material.icons.filled.ArrowBack
610import androidx.compose.runtime.*
711import androidx.compose.runtime.livedata.observeAsState
812import androidx.compose.ui.Alignment
913import androidx.compose.ui.Modifier
1014import androidx.compose.ui.graphics.Color
1115import androidx.compose.ui.platform.LocalContext
16+ import androidx.compose.ui.res.painterResource
1217import androidx.compose.ui.res.stringResource
18+ import androidx.compose.ui.text.style.TextAlign
19+ import androidx.compose.ui.unit.dp
1320import androidx.compose.ui.unit.sp
1421import androidx.navigation.NavDestination.Companion.hierarchy
1522import androidx.navigation.NavGraph.Companion.findStartDestination
@@ -22,12 +29,14 @@ import com.henrikherzig.playintegritychecker.R
2229import com.henrikherzig.playintegritychecker.attestation.PlayIntegrityStatement
2330import com.henrikherzig.playintegritychecker.attestation.safetynet.SafetyNetStatement
2431import com.henrikherzig.playintegritychecker.dataStore
32+ import com.henrikherzig.playintegritychecker.ui.CustomCardTitle
2533import com.henrikherzig.playintegritychecker.ui.about.AboutPage
2634import com.henrikherzig.playintegritychecker.ui.playintegrity.PlayIntegrity
2735import com.henrikherzig.playintegritychecker.ui.safetynet.SafetyNet
2836import com.henrikherzig.playintegritychecker.ui.ResponseType
2937import com.henrikherzig.playintegritychecker.ui.settings.Settings
3038import com.henrikherzig.playintegritychecker.ui.CustomViewModel
39+ import com.mikepenz.aboutlibraries.ui.compose.LibrariesContainer
3140
3241@Composable
3342fun BottomNavigationBar (
@@ -47,6 +56,7 @@ fun BottomNavigationBar(
4756 BottomNavItem .Settings ,
4857 BottomNavItem .About ,
4958 )
59+ val navBackStackEntry by navController.currentBackStackEntryAsState()
5060
5161 // TODO: very ugly better solution in the future
5262 // check
@@ -87,6 +97,11 @@ fun BottomNavigationBar(
8797 }
8898 val urlValue = viewModel.stateURL.observeAsState().value
8999
100+ val appBarHorizontalPadding = 0 .dp
101+ val titleIconModifier = Modifier
102+ .fillMaxHeight()
103+ .width(72 .dp - appBarHorizontalPadding)
104+
90105 Scaffold (
91106 topBar = {
92107 TopAppBar (
@@ -95,30 +110,64 @@ fun BottomNavigationBar(
95110 * first line: short app name variant in bigger font
96111 * second line: full app name variant in smaller font
97112 */
113+ modifier= Modifier .fillMaxWidth(),
98114 title = {
99- Column (
100- modifier = Modifier .fillMaxSize(),
101- verticalArrangement = Arrangement .Center ,
102- ) {
103- Text (
104- text = stringResource(id = R .string.app_name_short),
105- style = MaterialTheme .typography.subtitle2,
106- fontSize = 18 .sp,
107- modifier = Modifier .align(Alignment .CenterHorizontally )
108- )
109- Text (
110- text = stringResource(id = R .string.app_name),
111- style = MaterialTheme .typography.caption,
112- modifier = Modifier .align(Alignment .CenterHorizontally )
113- )
115+ // TopAppBar Content
116+ Box (Modifier .height(40 .dp)) {
117+
118+ // Navigation Icon
119+ if (navBackStackEntry?.destination?.route == " licence" ) {
120+ Row (titleIconModifier, verticalAlignment = Alignment .CenterVertically ) {
121+ IconButton (
122+ onClick = { navController.navigateUp() },
123+ enabled = true ,
124+ ) {
125+ Icon (
126+ imageVector = Icons .Filled .ArrowBack ,
127+ contentDescription = " Back" ,
128+ )
129+ }
130+ }
131+ }
132+
133+ // Title
134+ Row (Modifier .fillMaxSize(),
135+ verticalAlignment = Alignment .CenterVertically ) {
136+ Column (
137+ modifier = Modifier .fillMaxSize(),
138+ verticalArrangement = Arrangement .Center ,
139+ ) {
140+ Text (
141+ text = stringResource(id = R .string.app_name_short),
142+ style = MaterialTheme .typography.subtitle2,
143+ fontSize = 18 .sp,
144+ modifier = Modifier .align(Alignment .CenterHorizontally )
145+ )
146+ Text (
147+ text = stringResource(id = R .string.app_name),
148+ style = MaterialTheme .typography.caption,
149+ modifier = Modifier .align(Alignment .CenterHorizontally )
150+ )
151+
152+ }
153+
154+ }
155+
156+ // Actions
157+ /* CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
158+ Row(
159+ Modifier.fillMaxHeight(),
160+ horizontalArrangement = Arrangement.End,
161+ verticalAlignment = Alignment.CenterVertically,
162+ ){}
163+ } */
114164 }
115165 },
116- modifier = Modifier .fillMaxWidth()
117166 )
118167 },
119168 bottomBar = {
120169 BottomNavigation {
121- val navBackStackEntry by navController.currentBackStackEntryAsState()
170+ // val navBackStackEntry by navController.currentBackStackEntryAsState()
122171 val currentDestination = navBackStackEntry?.destination
123172 appPages.forEach { screen ->
124173 BottomNavigationItem (
@@ -134,7 +183,7 @@ fun BottomNavigationBar(
134183 // Avoid multiple versions of same page
135184 launchSingleTop = true
136185 // Restore state when selecting a previous page again
137- restoreState = true
186+ // restoreState = true
138187 }
139188 }
140189 )
@@ -188,7 +237,17 @@ fun BottomNavigationBar(
188237 Settings (playServiceVersion)
189238 }
190239 composable(BottomNavItem .About .screen_route) {
191- AboutPage (playServiceVersion)
240+ AboutPage (navController)
241+ }
242+ composable(" licence" ) {
243+ // Licenses Page
244+ Column (
245+ modifier = Modifier
246+ .padding(all = 12 .dp)
247+ ) {
248+ CustomCardTitle (stringResource(id = R .string.about_licenseButton))
249+ LibrariesContainer ()
250+ }
192251 }
193252 }
194253 }
0 commit comments