|
|
|
@ -6,13 +6,19 @@ import androidx.compose.foundation.layout.padding
|
|
|
|
|
import androidx.compose.material3.MaterialTheme
|
|
|
|
|
import androidx.compose.material3.Scaffold
|
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
|
import androidx.compose.runtime.collectAsState
|
|
|
|
|
import androidx.compose.runtime.getValue
|
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
|
|
|
import androidx.navigation.compose.NavHost
|
|
|
|
|
import androidx.navigation.compose.composable
|
|
|
|
|
import androidx.navigation.compose.rememberNavController
|
|
|
|
|
import androidx.navigation.toRoute
|
|
|
|
|
import com.example.what_the_fantasy.data.services.ServicesStub
|
|
|
|
|
import com.example.what_the_fantasy.ui.screens.*
|
|
|
|
|
import com.example.what_the_fantasy.ui.viewModels.AuthUserViewModel
|
|
|
|
|
import com.example.what_the_fantasy.ui.viewModels.CurrentUserViewModel
|
|
|
|
|
import com.example.what_the_fantasy.ui.viewModels.SignInUserViewModel
|
|
|
|
|
import kotlinx.serialization.Serializable
|
|
|
|
|
|
|
|
|
|
@Serializable
|
|
|
|
@ -63,11 +69,24 @@ fun AppNavigator() {
|
|
|
|
|
val navController = rememberNavController()
|
|
|
|
|
val services = ServicesStub()
|
|
|
|
|
|
|
|
|
|
//ViewModel pour l'authentification
|
|
|
|
|
val authUserVM : AuthUserViewModel = viewModel()
|
|
|
|
|
val authState by authUserVM.userState.collectAsState()
|
|
|
|
|
|
|
|
|
|
//ViewModel pour l'inscription
|
|
|
|
|
val signInUserVM : SignInUserViewModel = viewModel()
|
|
|
|
|
val signInState by signInUserVM.userState.collectAsState()
|
|
|
|
|
|
|
|
|
|
//ViewModel pour l'utilisateur
|
|
|
|
|
val currentUserVM : CurrentUserViewModel = viewModel()
|
|
|
|
|
val currentUserState by currentUserVM.currentUserState.collectAsState()
|
|
|
|
|
|
|
|
|
|
Scaffold(
|
|
|
|
|
modifier = Modifier.fillMaxSize(),
|
|
|
|
|
containerColor = MaterialTheme.colorScheme.onPrimary
|
|
|
|
|
) { paddingValues ->
|
|
|
|
|
Box(modifier = Modifier.padding(paddingValues)) {
|
|
|
|
|
|
|
|
|
|
NavHost(navController, startDestination = Login) {
|
|
|
|
|
composable<Login> {
|
|
|
|
|
LoginPage(
|
|
|
|
@ -77,8 +96,11 @@ fun AppNavigator() {
|
|
|
|
|
popUpTo(Login) { inclusive = true }
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
authUserVM = authUserVM,
|
|
|
|
|
authState = authState
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
composable<Accueil> {
|
|
|
|
|
val accueil: Accueil = it.toRoute()
|
|
|
|
|
AccueilPage(
|
|
|
|
@ -150,6 +172,8 @@ fun AppNavigator() {
|
|
|
|
|
popUpTo(Login) { inclusive = true }
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
signInUserVM = signInUserVM,
|
|
|
|
|
signInState = signInState
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
composable<SubmitQuote> {
|
|
|
|
|