|
|
|
@ -12,11 +12,15 @@ import androidx.compose.foundation.layout.wrapContentHeight
|
|
|
|
|
import androidx.compose.foundation.layout.wrapContentWidth
|
|
|
|
|
import androidx.compose.material.BottomNavigation
|
|
|
|
|
import androidx.compose.material.BottomNavigationItem
|
|
|
|
|
import androidx.compose.material.icons.Icons
|
|
|
|
|
import androidx.compose.material.icons.filled.Favorite
|
|
|
|
|
import androidx.compose.material3.Button
|
|
|
|
|
import androidx.compose.material3.Icon
|
|
|
|
|
import androidx.compose.material3.Scaffold
|
|
|
|
|
import androidx.compose.material3.Surface
|
|
|
|
|
import androidx.compose.material3.Text
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
import androidx.compose.runtime.getValue
|
|
|
|
|
import androidx.compose.ui.Alignment
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
|
@ -26,42 +30,64 @@ import androidx.compose.ui.text.font.FontWeight
|
|
|
|
|
import androidx.compose.ui.tooling.preview.Preview
|
|
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
|
|
import androidx.navigation.NavDestination.Companion.hierarchy
|
|
|
|
|
import androidx.navigation.NavGraph.Companion.findStartDestination
|
|
|
|
|
import androidx.navigation.compose.NavHost
|
|
|
|
|
import androidx.navigation.compose.composable
|
|
|
|
|
import androidx.navigation.compose.currentBackStackEntryAsState
|
|
|
|
|
import androidx.navigation.compose.rememberNavController
|
|
|
|
|
import sae.android.sae_2a.R
|
|
|
|
|
import sae.android.sae_2a.game.VocabularyScreen
|
|
|
|
|
@Preview
|
|
|
|
|
|
|
|
|
|
val items = listOf(
|
|
|
|
|
Screen.VocabularyList,
|
|
|
|
|
Screen.Game
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Preview
|
|
|
|
|
@Composable
|
|
|
|
|
fun MyApp() {
|
|
|
|
|
val navController = rememberNavController()
|
|
|
|
|
/* Scaffold(
|
|
|
|
|
Scaffold(
|
|
|
|
|
bottomBar = {
|
|
|
|
|
BottomNavigation {
|
|
|
|
|
BottomNavigationItem(selected = , onClick = { /*TODO*/ }, icon = { /*TODO*/ }){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
BottomNavigation {
|
|
|
|
|
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
|
|
|
|
val currentDestination = navBackStackEntry?.destination
|
|
|
|
|
items.forEach { screen ->
|
|
|
|
|
BottomNavigationItem(
|
|
|
|
|
label = { Text(stringResource(screen.resourceId)) },
|
|
|
|
|
selected = currentDestination?.hierarchy?.any { it.route == screen.route } == true,
|
|
|
|
|
onClick = {
|
|
|
|
|
navController.navigate(screen.route) {
|
|
|
|
|
popUpTo(navController.graph.findStartDestination().id) {
|
|
|
|
|
saveState = true
|
|
|
|
|
}
|
|
|
|
|
launchSingleTop = true
|
|
|
|
|
restoreState = true
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
icon = {
|
|
|
|
|
Icon(
|
|
|
|
|
Icons.Filled.Favorite, contentDescription = null
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)*/
|
|
|
|
|
NavHost(navController, startDestination = "HomeScreen") {
|
|
|
|
|
composable("HomeScreen") { HomeScreen( NavigateToRegister = { navController.navigate("RegisterScreen")} ,NavigateToLogin = { navController.navigate("GameScreen") }) }
|
|
|
|
|
composable("VocabularyScreen") { VocabularyScreen(onNavigateToList = { navController.popBackStack() }) }
|
|
|
|
|
composable("RegisterScreen") { RegisterScreen(NavigateToApp = { navController.navigate("VocabularyScreen") }) }
|
|
|
|
|
composable("GameScreen"){ GameScreen() {
|
|
|
|
|
//
|
|
|
|
|
}
|
|
|
|
|
){ innerPadding ->
|
|
|
|
|
NavHost(navController, startDestination = Screen.Home.route, Modifier.padding(innerPadding)) {
|
|
|
|
|
composable(Screen.Home.route) { HomeScreen( NavigateToRegister = { navController.navigate(Screen.Register.route)} ,NavigateToLogin = { navController.navigate(Screen.Game.route) }) }
|
|
|
|
|
composable(Screen.VocabularyList.route) { VocabularyScreen(onNavigateToList = { navController.popBackStack() }) }
|
|
|
|
|
composable(Screen.Register.route) { RegisterScreen(NavigateToApp = { navController.navigate(Screen.VocabularyList.route) }) }
|
|
|
|
|
composable(Screen.Game.route){ GameScreen() {
|
|
|
|
|
} }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@Composable
|
|
|
|
|
fun BottomNav(){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Composable
|
|
|
|
|
fun HomeScreen(NavigateToRegister: () -> Unit,NavigateToLogin: () -> Unit ){
|
|
|
|
|
|
|
|
|
@ -89,18 +115,18 @@ fun HomeScreen(NavigateToRegister: () -> Unit,NavigateToLogin: () -> Unit ){
|
|
|
|
|
.align(alignment = Alignment.CenterHorizontally))
|
|
|
|
|
|
|
|
|
|
Button( onClick = { NavigateToLogin() }, modifier = Modifier
|
|
|
|
|
.padding(10.dp)
|
|
|
|
|
.width(500.dp)
|
|
|
|
|
.height(80.dp)
|
|
|
|
|
.align(alignment = Alignment.CenterHorizontally)) {
|
|
|
|
|
.padding(10.dp)
|
|
|
|
|
.width(500.dp)
|
|
|
|
|
.height(80.dp)
|
|
|
|
|
.align(alignment = Alignment.CenterHorizontally)) {
|
|
|
|
|
Text(text = stringResource(id = R.string.logIn), fontSize = 20.sp)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
Button(onClick = { NavigateToRegister() },modifier = Modifier
|
|
|
|
|
.width(500.dp)
|
|
|
|
|
.padding(10.dp)
|
|
|
|
|
.height(80.dp)
|
|
|
|
|
.align(alignment = Alignment.CenterHorizontally)) {
|
|
|
|
|
.width(500.dp)
|
|
|
|
|
.padding(10.dp)
|
|
|
|
|
.height(80.dp)
|
|
|
|
|
.align(alignment = Alignment.CenterHorizontally)) {
|
|
|
|
|
Text(text = stringResource(id = R.string.signIn), fontSize = 20.sp)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|