package com.example.wabi.view.screeens.logIn

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavHostController
import com.example.wabi.view.screeens.logIn.items.EmailForReset
import com.example.wabi.view.screeens.logIn.items.LogInStateDestinations
import com.example.wabi.view.screeens.logIn.items.SignIn
import com.example.wabi.view.screeens.logIn.items.SignUp

@Composable
fun LogIn(navHostController: NavHostController, vm: LogInViewModel = hiltViewModel()) {
    val printError = remember { mutableStateOf(false) }
    val loginState = remember { mutableIntStateOf(LogInStateDestinations.signIn) }

    Column(
        modifier = Modifier
            .fillMaxSize()
            .verticalScroll(rememberScrollState()),
        verticalArrangement = Arrangement.SpaceAround,
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        when (loginState.intValue) {
            LogInStateDestinations.signIn -> {
                SignIn(
                    navController = navHostController,
                    printError = printError,
                    state = loginState,
                    vm = vm
                )
            }

            LogInStateDestinations.signUp -> {
                SignUp(vm, loginState)
            }

            LogInStateDestinations.resetPassword -> {
                EmailForReset(vm, loginState)
            }
        }
    }

}