package com.example.wabi.view.screens.signIn

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.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.domain.navigation.Routes
import com.example.wabi.domain.repository.UserData
import com.example.wabi.view.screens.signIn.states.EmailForReset
import com.example.wabi.view.screens.signIn.states.Login

@Composable
fun SignIn(navController: NavHostController, vm: SignInViewModel = hiltViewModel()) {
    val data = vm.data
    val printError = remember { mutableStateOf(false) }
    val visible = remember { mutableStateOf(true) }

    //UserData.currentScreen = Routes.SIGNIN

    Column(
        modifier = Modifier
            .fillMaxSize()
            .verticalScroll(rememberScrollState()),
        verticalArrangement = Arrangement.SpaceAround,
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        if (visible.value) {
            Login(
                navController = navController,
                printError = printError,
                visible = visible,
                data = data,
                vm = vm
            )
        } else {
            EmailForReset(data.email, vm, visible)
        }
    }
}


