package com.example.mystictale.resources.components

import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.mystictale.ui.theme.DarkPurple
import com.example.mystictale.ui.theme.Grey
import com.example.mystictale.ui.theme.OpenSans

@Composable
fun ProfileTextField(
    value: String,
    onValue: (String) -> Unit,
    placeholder: String,
    keyboardType: KeyboardType,
    flag: Boolean,
    isEnable: Boolean
) {
    OutlinedTextField(
        value = value,
        onValueChange = onValue,
        singleLine = true,
        keyboardOptions = KeyboardOptions(
            keyboardType = keyboardType,
            imeAction = ImeAction.Done
        ),
        shape = RoundedCornerShape(10.dp),
        colors = TextFieldDefaults.colors(
            unfocusedTextColor = Color.White,
            unfocusedPlaceholderColor = Grey,
            unfocusedContainerColor = DarkPurple,
            focusedTextColor = Color.White,
            focusedContainerColor = DarkPurple,
            focusedPlaceholderColor = Color.White,
            focusedIndicatorColor = Color.Transparent,
            unfocusedIndicatorColor = Color.Transparent,
            errorContainerColor = DarkPurple,
            errorTextColor = Color.White,
            errorPlaceholderColor = Color.White,
            disabledTextColor = Color.White,
            disabledContainerColor = DarkPurple,
            disabledPlaceholderColor = Color.White
        ),
        isError = flag,

        placeholder = {
            Text(
                text = placeholder,
                fontFamily = OpenSans,
                fontWeight = FontWeight.Normal,
                fontSize = 14.sp,
            )
        },
        maxLines = 1,
        textStyle = TextStyle(
            fontFamily = OpenSans,
            fontWeight = FontWeight.Normal,
            fontSize = 14.sp,
        ),
        enabled = isEnable,
        modifier = Modifier
            .fillMaxWidth()
            .height(52.dp)


    )
}