package com.example.tasks.navigation

import CreateProfile
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.compose.runtime.Composable
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument
import com.example.tasks.screens.EnterOTP
import com.example.tasks.screens.Load
import com.example.tasks.screens.Profile
import com.example.tasks.screens.SignIn
import com.example.tasks.screens.Start
import com.example.tasks.viewModels.AuthViewModel
import com.example.tasks.viewModels.DatabaseViewModel

@RequiresApi(Build.VERSION_CODES.O)
@Composable
fun Navigation(viewModel: AuthViewModel,databaseViewModel: DatabaseViewModel) {
    val navController = rememberNavController()
    NavHost(navController = navController, startDestination = Screen.Load.route)
    {
        composable(Screen.Load.route)
        {
            Load(viewModel,navController)
        }
        composable(Screen.Start.route)
        {
            Start(navController)
        }
        composable(Screen.SignIn.route)
        {
            SignIn(navController,viewModel)

        }
            composable(Screen.EnterOTP.route + "/{email}", arguments = listOf(
            navArgument("email") {
                type = NavType.StringType
            }
        ))
        {
            val email = it.arguments!!.getString("email")
            EnterOTP(navController = navController, email = email!!,viewModel,databaseViewModel)


        }
        composable(Screen.CreateProfile.route)
        {
            CreateProfile(navController,viewModel,databaseViewModel)

        }
        composable(Screen.Profile.route)
        {
            Profile(databaseViewModel,viewModel, navController )

        }
    }
}