package com.example.development.mainActivity.components

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxHeight
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.layout.width
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.ContentScale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.NavHostController
import com.example.development.R
import com.example.development.mainActivity.MainViewModel
import com.example.development.ui.theme.OldStandart

@Composable
fun PasswordRecovery(navController: NavHostController, viewModel: MainViewModel)
{
    Box(
        contentAlignment = Alignment.TopCenter,
        modifier = Modifier
            .fillMaxSize()
    )
    {
        Image(
            painter = painterResource(id = R.drawable.fone),
            contentDescription = "",
            contentScale = ContentScale.FillWidth,
            modifier = Modifier.fillMaxWidth().fillMaxHeight()
        )
        Column(
            modifier = Modifier
                .padding(),
            verticalArrangement = Arrangement.Center,
            horizontalAlignment = Alignment.CenterHorizontally
        )
        {
            Text("ВОССТАНОВЛЕНИЕ ПАРОЛЯ",
                color = Color.White,
                modifier = Modifier.padding(top = 150.dp, bottom = 60.dp),
                fontSize = 30.sp,
                fontWeight = FontWeight.Bold,
                fontFamily = OldStandart,
                softWrap = true,
                textAlign = TextAlign.Center
            )
            TextField(
                value = "Адрес электронной почты",
                onValueChange = {},
                Modifier.padding(bottom = 30.dp).width(280.dp)
            )
            Button(modifier = Modifier
                .width(width = 270.dp)
                .height(height = 40.dp),
                onClick = {},
                shape = RoundedCornerShape(23.dp),
                border = BorderStroke(0.dp, Color(0xFFEBEBEB)),
                colors = ButtonDefaults.buttonColors(
                    containerColor = Color(255,215,0),
                    contentColor = Color.White)
            )
            {
                Text("ПОЛУЧИТЬ КОД",
                    fontFamily = OldStandart)
            }
        }
    }
}

@Composable
fun PasswordRecovery2(navController: NavHostController, viewModel: MainViewModel)
{
    Box(
        contentAlignment = Alignment.TopCenter,
        modifier = Modifier
            .fillMaxSize()
    )
    {
        Image(
            painter = painterResource(id = R.drawable.fone),
            contentDescription = "",
            contentScale = ContentScale.FillWidth,
            modifier = Modifier.fillMaxWidth().fillMaxHeight()
        )
        Column(
            modifier = Modifier
                .padding(),
            verticalArrangement = Arrangement.Center,
            horizontalAlignment = Alignment.CenterHorizontally
        )
        {
            Text("ВОССТАНОВЛЕНИЕ ПАРОЛЯ",
                color = Color.White,
                modifier = Modifier.padding(top = 150.dp, bottom = 60.dp),
                fontSize = 30.sp,
                fontWeight = FontWeight.Bold,
                fontFamily = OldStandart,
                softWrap = true,
                textAlign = TextAlign.Center
            )
            Column(verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.Start)
            {
                Text(
                    "Введите код из e-mail",
                    color = Color.White,
                    modifier = Modifier.padding(bottom = 60.dp),
                    fontSize = 18.sp,
                    fontWeight = FontWeight.Normal,
                    softWrap = true,
                    textAlign = TextAlign.Start,
                    fontFamily = OldStandart
                )
                TextField(
                    value = "",
                    onValueChange = {},
                    Modifier.padding(bottom = 30.dp).width(280.dp)
                )
                Button(
                    modifier = Modifier
                        .width(width = 270.dp)
                        .height(height = 40.dp),
                    onClick = {},
                    shape = RoundedCornerShape(23.dp),
                    border = BorderStroke(0.dp, Color(0xFFEBEBEB)),
                    colors = ButtonDefaults.buttonColors(
                        containerColor = Color(255, 215, 0),
                        contentColor = Color.White
                    )
                )
                {
                    Text("ПОДТВЕРДИТЬ",
                        color = Color.White,
                        modifier = Modifier.padding(),
                        fontSize = 18.sp,
                        fontWeight = FontWeight.Normal,
                        fontFamily = OldStandart
                    )
                }
            }
        }
    }
}

@Composable
fun PasswordRecovery3(navController: NavHostController, viewModel: MainViewModel)
{
    Box(
        contentAlignment = Alignment.TopCenter,
        modifier = Modifier
            .fillMaxSize()
    )
    {
        Image(
            painter = painterResource(id = R.drawable.fone),
            contentDescription = "",
            contentScale = ContentScale.FillWidth,
            modifier = Modifier.fillMaxWidth().fillMaxHeight()
        )
        Column(
            modifier = Modifier
                .padding(),
            verticalArrangement = Arrangement.Center,
            horizontalAlignment = Alignment.CenterHorizontally
        )
        {
            Text("ВОССТАНОВЛЕНИЕ ПАРОЛЯ",
                color = Color.White,
                modifier = Modifier.padding(top = 150.dp, bottom = 60.dp),
                fontSize = 30.sp,
                fontWeight = FontWeight.Bold,
                fontFamily = FontFamily.Cursive,
                softWrap = true,
                textAlign = TextAlign.Center
            )
            Column(verticalArrangement = Arrangement.Center, horizontalAlignment = Alignment.Start)
            {
                Text(
                    "Придумайте новый пароль",
                    color = Color.White,
                    modifier = Modifier.padding(bottom = 60.dp),
                    fontSize = 18.sp,
                    fontWeight = FontWeight.Normal,
                    softWrap = true,
                    textAlign = TextAlign.Start
                )
                Column(modifier = Modifier
                    .padding(top= 0.dp)
                )
                {
                    var passwordVisibility: Boolean by remember { mutableStateOf(false) }
                    TextField( value = "Пароль",
                        visualTransformation = if (passwordVisibility) VisualTransformation.None else PasswordVisualTransformation(),
                        leadingIcon = {
                            IconButton(onClick = {
                                passwordVisibility = !passwordVisibility
                            }) {
                                if(passwordVisibility) {
                                    Icon(
                                        painter = painterResource(id = R.drawable.eye_close),
                                        contentDescription = ""
                                    )
                                }
                                else {
                                    Icon(
                                        painter = painterResource(id = R.drawable.eye_open),
                                        contentDescription = ""
                                    )
                                }
                            }
                        },
                        onValueChange = {})
                    Column(modifier = Modifier
                        .padding(top = 5.dp, bottom = 10.dp))
                    {
                        TextField(
                            value = "Повторите пароль",
                            visualTransformation = if (passwordVisibility) VisualTransformation.None else PasswordVisualTransformation(),
                            leadingIcon = {
                                IconButton(onClick = {
                                    passwordVisibility = !passwordVisibility
                                }) {
                                    if (passwordVisibility) {
                                        Icon(
                                            painter = painterResource(id = R.drawable.eye_close),
                                            contentDescription = ""
                                        )
                                    } else {
                                        Icon(
                                            painter = painterResource(id = R.drawable.eye_open),
                                            contentDescription = ""
                                        )
                                    }
                                }
                            },
                            onValueChange = {},
                        )
                    }
                }
                Button(
                    modifier = Modifier
                        .width(width = 270.dp)
                        .height(height = 40.dp),
                    onClick = {},
                    shape = RoundedCornerShape(23.dp),
                    border = BorderStroke(0.dp, Color(0xFFEBEBEB)),
                    colors = ButtonDefaults.buttonColors(
                        containerColor = Color(255, 215, 0),
                        contentColor = Color.White
                    )
                )
                {
                    Text("СОХРАНИТЬ",
                        color = Color.White,
                        modifier = Modifier.padding(),
                        fontSize = 20.sp,
                        fontWeight = FontWeight.Normal
                    )
                }
            }
        }
    }
}