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.navigation.customers.AppNavigationCustomers
import com.example.tasks.navigation.sellers.AppNavigationSellers
import com.example.tasks.screens.AddProducts
import com.example.tasks.screens.Card
import com.example.tasks.screens.EnterOTP
import com.example.tasks.screens.Load
import com.example.tasks.screens.ProfileSeller
import com.example.tasks.screens.SignIn
import com.example.tasks.screens.SignInWithPassword
import com.example.tasks.screens.SignUpWithPassword
import com.example.tasks.screens.Start
import com.example.tasks.viewModels.AuthViewModel
import com.example.tasks.viewModels.CardViewModel
import com.example.tasks.viewModels.DatabaseViewModel

@RequiresApi(Build.VERSION_CODES.O)
@Composable
fun Navigation(viewModel: AuthViewModel,databaseViewModel: DatabaseViewModel, viewModelCard: CardViewModel) {
    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.SignUpPassword.route)
        {
            SignUpWithPassword(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.AppNavigationCustomers.route)
        {
            AppNavigationCustomers(viewModel, databaseViewModel,navController)

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

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

        }
        composable(Screen.SignInPassword.route)
        {
            SignInWithPassword(navController = navController, viewModel = viewModel, viewModelDatabase =  databaseViewModel)

        }
        composable(Screen.AddProduct.route)
        {
            AddProducts(navController = navController, viewModel = databaseViewModel)

        }
        composable(Screen.Card.route)
        {
            Card(navController = navController, viewModel = databaseViewModel, viewModelCard = viewModelCard)

        }
    }
}