package com.example.tasks.screens

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonColors
import androidx.compose.material3.Text
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.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavController
import com.example.tasks.components.CustomEmail
import com.example.tasks.navigation.Screen
import com.example.tasks.viewModels.AuthViewModel

@Composable
fun SignIn(navController: NavController, viewModel: AuthViewModel) {
    val context = LocalContext.current
    val email = remember { mutableStateOf("") }
    Column(
        modifier = Modifier
            .fillMaxSize()
            .padding(10.dp),
        verticalArrangement = Arrangement.Center,
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        CustomEmail(search = email.value, onValueChange = { email.value = it })
        Spacer(Modifier.height(30.dp))
        Button(
            onClick = {
                viewModel.onSignInEmailCode(context, email.value)
                navController.navigate(Screen.EnterOTP.withArg(email.value))
            },
            Modifier
                .fillMaxWidth()
                .height(50.dp),
            shape = RoundedCornerShape(20),
            colors = ButtonColors(
                contentColor = Color.White,
                containerColor = Color.Blue,
                disabledContentColor = Color.White,
                disabledContainerColor = Color.Gray
            )
        ) {
            Text(text = "Далее", fontSize = 14.sp)

        }

    }
}