package com.example.development.mainActivity.components

import android.widget.ScrollView
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
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.lazy.LazyColumn
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
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 UserProfile(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.fillMaxSize(), verticalArrangement = Arrangement.Top, horizontalAlignment = Alignment.CenterHorizontally)
        {
            Row(modifier = Modifier
                .padding(top = 50.dp)
                .background(color = Color(230, 235, 239, 50))
                .fillMaxWidth(),
                horizontalArrangement = Arrangement.SpaceAround)
            {
                Text("Имя Фамилия",
                    color = Color.White,
                    modifier = Modifier.padding(),
                    fontSize = 30.sp,
                    fontWeight = FontWeight.Bold,
                    fontFamily = OldStandart
                )
                Image(
                    painter = painterResource(id = R.drawable.profile),
                    contentDescription = "",
                    contentScale = ContentScale.FillWidth,
                    modifier = Modifier
                        .width(100.dp)
                        .height(100.dp)
                )
            }
            Row(modifier = Modifier
                .padding()
                .background(color = Color(230, 235, 239, 50))
                .fillMaxWidth(),
                horizontalArrangement = Arrangement.SpaceAround)
            {
                Button(
                    modifier = Modifier
                        .padding(0.dp),
                    onClick = {},
                    colors = ButtonDefaults.buttonColors(
                        containerColor = Color(255, 215, 0),
                        contentColor = Color.Gray
                    ),
                    border = BorderStroke(0.dp, color = Color(255, 215, 0))
                )
                {
                    Text(
                        "Персональные данные",
                        fontSize = 16.sp,
                        color = Color.White,
                        fontWeight = FontWeight.Normal,
                        textAlign = TextAlign.Center,
                        fontFamily = OldStandart
                    )
                }
                Button(
                    modifier = Modifier
                        .padding(0.dp),
                    onClick = {},
                    colors = ButtonDefaults.buttonColors(
                        containerColor = Color(230, 235, 239, 0),
                        contentColor = Color.Gray
                    ),
                    border = BorderStroke(0.dp, color = Color(230, 235, 239, 0))
                )
                {
                    Text(
                        "История бронирования",
                        fontSize = 16.sp,
                        color = Color.White,
                        fontWeight = FontWeight.Normal,
                        textAlign = TextAlign.Center,
                        fontFamily = OldStandart
                    )
                }
            }
            Column(modifier = Modifier.fillMaxSize(), verticalArrangement = Arrangement.Top, horizontalAlignment = Alignment.CenterHorizontally)
            {
                Text(
                    "Имя",
                    fontSize = 16.sp,
                    color = Color.White,
                    fontWeight = FontWeight.Normal,
                    fontFamily = OldStandart
                )
                TextField(
                    value = "",
                    onValueChange = {},
                    Modifier.padding(bottom = 5.dp).width(280.dp)
                )
                Text(
                    "Фамилия",
                    fontSize = 16.sp,
                    color = Color.White,
                    fontWeight = FontWeight.Normal,
                    fontFamily = OldStandart
                )
                TextField(
                    value = "",
                    onValueChange = {},
                    Modifier.padding(bottom = 5.dp).width(280.dp)
                )
                Text(
                    "E-mail",
                    fontSize = 16.sp,
                    color = Color.White,
                    fontWeight = FontWeight.Normal,
                    fontFamily = OldStandart
                )
                TextField(
                    value = "",
                    onValueChange = {},
                    Modifier.padding(bottom = 5.dp).width(280.dp)
                )
                Text(
                    "Номер телефона",
                    fontSize = 16.sp,
                    color = Color.White,
                    fontWeight = FontWeight.Normal,
                    fontFamily = OldStandart
                )
                TextField(
                    value = "",
                    onValueChange = {},
                    Modifier.padding(bottom = 5.dp).width(280.dp)
                )
                Button(
                    modifier = Modifier
                        .padding(0.dp)
                        .width(280.dp),
                    onClick = {},
                    colors = ButtonDefaults.buttonColors(
                        containerColor = Color(230, 235, 239, 50),
                        contentColor = Color.Gray
                    ),
                    border = BorderStroke(0.dp, color = Color(230, 235, 239, 50))
                )
                {
                    Text(
                        "Сменить пароль",
                        fontSize = 16.sp,
                        color = Color.White,
                        fontWeight = FontWeight.Normal,
                        fontFamily = OldStandart
                    )
                }
                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 UserProfile2(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.fillMaxSize(), verticalArrangement = Arrangement.Top, horizontalAlignment = Alignment.CenterHorizontally)
        {
            Row(
                modifier = Modifier
                    .padding(top = 50.dp)
                    .background(color = Color(230, 235, 239, 50))
                    .fillMaxWidth(),
                horizontalArrangement = Arrangement.SpaceAround
            )
            {
                Text(
                    "Имя Фамилия",
                    color = Color.White,
                    modifier = Modifier.padding(),
                    fontSize = 30.sp,
                    fontWeight = FontWeight.Bold,
                    fontFamily = OldStandart
                )
                Image(
                    painter = painterResource(id = R.drawable.profile),
                    contentDescription = "",
                    contentScale = ContentScale.FillWidth,
                    modifier = Modifier
                        .width(100.dp)
                        .height(100.dp)
                )
            }
            Row(
                modifier = Modifier
                    .padding()
                    .background(color = Color(230, 235, 239, 50))
                    .fillMaxWidth(),
                horizontalArrangement = Arrangement.SpaceAround
            )
            {
                Button(
                    modifier = Modifier
                        .padding(0.dp),
                    onClick = {},
                    colors = ButtonDefaults.buttonColors(
                        containerColor = Color(230, 235, 239, 0),
                        contentColor = Color.Gray
                    ),
                    border = BorderStroke(0.dp, color = Color(230, 235, 239, 0))
                )
                {
                    Text(
                        "Персональные\nданные",
                        fontSize = 16.sp,
                        color = Color.White,
                        fontWeight = FontWeight.Normal,
                        textAlign = TextAlign.Center,
                        fontFamily = OldStandart
                    )
                }
                Button(
                    modifier = Modifier
                        .padding(0.dp),
                    onClick = {},
                    colors = ButtonDefaults.buttonColors(
                        containerColor = Color(255, 215, 0),
                        contentColor = Color.Gray
                    ),
                    border = BorderStroke(0.dp, color = Color(255, 215, 0))
                )
                {
                    Text(
                        "История\nбронирования",
                        fontSize = 16.sp,
                        color = Color.White,
                        fontWeight = FontWeight.Normal,
                        textAlign = TextAlign.Center,
                        fontFamily = OldStandart
                    )
                }
            }
        }
    }
}

@Composable
fun UserProfileForUnauthorizedUser()
{
    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.fillMaxSize(),
            verticalArrangement = Arrangement.Center,
            horizontalAlignment = Alignment.CenterHorizontally,
            )
        {
            Text("Похоже, вы не вошли в систему\nАвторизируйтесь или создайте аккаунт для использования всех функций приложения",
                fontSize = 18.sp,
                color = Color.White,
                fontWeight = FontWeight.Normal,
                fontFamily = OldStandart,
                softWrap = true,
                textAlign = TextAlign.Center)
            Button(
                modifier = Modifier
                    .padding(top = 20.dp),
                onClick = {},
                colors = ButtonDefaults.buttonColors(
                    containerColor = Color(255, 215, 0),
                    contentColor = Color.Gray
                ),
                border = BorderStroke(0.dp, color = Color(255, 215, 0))
            )
            {
                Text(
                    "РЕГИСТРАЦИЯ",
                    fontSize = 18.sp,
                    color = Color.White,
                    fontWeight = FontWeight.Normal,
                    textAlign = TextAlign.Center,
                    fontFamily = OldStandart
                )
            }
            Button(
                modifier = Modifier
                    .padding(0.dp),
                onClick = {},
                colors = ButtonDefaults.buttonColors(
                    containerColor = Color(255, 215, 0),
                    contentColor = Color.Gray
                ),
                border = BorderStroke(0.dp, color = Color(255, 215, 0))
            )
            {
                Text(
                    "АВТОРИЗАЦИЯ",
                    fontSize = 18.sp,
                    color = Color.White,
                    fontWeight = FontWeight.Normal,
                    textAlign = TextAlign.Center,
                    fontFamily = OldStandart
                )
            }
        }
    }
}