draft: routes
This commit is contained in:
parent
7f0d5c34fc
commit
49f23426dd
5 changed files with 25 additions and 9 deletions
|
@ -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(
|
||||||
|
selected = currentRoute == HOME,
|
||||||
|
onClick = {
|
||||||
navController.navigate(HOME) { launchSingleTop = true }
|
navController.navigate(HOME) { launchSingleTop = true }
|
||||||
}, icon = { Icon(Icons.Default.Home, "Page principale") })
|
},
|
||||||
|
icon = {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Default.Home,
|
||||||
|
contentDescription = LocalContext.current.getString(R.string.home_button)
|
||||||
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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>
|
Reference in a new issue