draft: routes

This commit is contained in:
Mylloon 2023-11-27 07:10:06 +01:00
parent 7f0d5c34fc
commit 49f23426dd
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
5 changed files with 25 additions and 9 deletions

View file

@ -10,15 +10,16 @@ import androidx.compose.material.BottomNavigationItem
import androidx.compose.material.Icon import androidx.compose.material.Icon
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Home import androidx.compose.material.icons.filled.Home
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface import androidx.compose.material3.Surface
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import androidx.navigation.NavHostController import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost import androidx.navigation.compose.NavHost
@ -68,6 +69,8 @@ fun MainScreen() {
modifier = Modifier.padding(padding) modifier = Modifier.padding(padding)
) { ) {
composable(HOME) { HomeScreen(padding) } composable(HOME) { HomeScreen(padding) }
composable(MODIFY_SET) { ModifySetScreen(padding, navController) }
composable(PLAY) { PlayScreen(padding, navController) }
} }
} }
} }
@ -75,9 +78,9 @@ fun MainScreen() {
@OptIn(ExperimentalMaterial3Api::class) @OptIn(ExperimentalMaterial3Api::class)
@Composable @Composable
fun TopBar() = fun TopBar() =
TopAppBar(title = { CenterAlignedTopAppBar(title = {
Text( Text(
"Projet", text = LocalContext.current.getString(R.string.app_name),
style = MaterialTheme.typography.displayMedium style = MaterialTheme.typography.displayMedium
) )
}) })
@ -88,7 +91,15 @@ fun BottomBar(navController: NavHostController) =
val navBackStackEntry by navController.currentBackStackEntryAsState() val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentRoute = navBackStackEntry?.destination?.route val currentRoute = navBackStackEntry?.destination?.route
BottomNavigationItem(selected = currentRoute == HOME, onClick = { BottomNavigationItem(
navController.navigate(HOME) { launchSingleTop = true } selected = currentRoute == HOME,
}, icon = { Icon(Icons.Default.Home, "Page principale") }) onClick = {
navController.navigate(HOME) { launchSingleTop = true }
},
icon = {
Icon(
imageVector = Icons.Default.Home,
contentDescription = LocalContext.current.getString(R.string.home_button)
)
})
} }

View file

@ -2,8 +2,9 @@ package fr.uparis.diamantkennel.memorisationapplication
import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.navigation.NavController
@Composable @Composable
fun ModifySetScreen(padding: PaddingValues) { fun ModifySetScreen(padding: PaddingValues, navController: NavController) {
} }

View file

@ -2,8 +2,9 @@ package fr.uparis.diamantkennel.memorisationapplication
import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.navigation.NavController
@Composable @Composable
fun PlayScreen(padding: PaddingValues) { fun PlayScreen(padding: PaddingValues, navController: NavController) {
} }

View file

@ -1,3 +1,5 @@
package fr.uparis.diamantkennel.memorisationapplication package fr.uparis.diamantkennel.memorisationapplication
const val HOME = "home" const val HOME = "home"
const val MODIFY_SET = "modify_set"
const val PLAY = "play"

View file

@ -1,3 +1,4 @@
<resources> <resources>
<string name="app_name">MemorisationApplication</string> <string name="app_name">Memorisation</string>
<string name="home_button">Page principale</string>
</resources> </resources>