package com.example.wabi.view.components.textFields

import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.shape.RoundedCornerShape
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.unit.dp
import androidx.compose.ui.unit.sp
import com.example.wabi.ui.theme.WabiTheme
import com.example.wabi.view.components.texts.AccentText

//поле ввода для обычного текста
@Composable
fun MainTextField(
    value: String,
    input: (String) -> Unit,
    lable: String = "",
    placeholder: String = "",
    trailingText: String = ""
) {
    Column() {
        AccentText(
            text = lable, isUnderline = true, modifier = Modifier.padding(50.dp, 0.dp, 0.dp, 5.dp)
        )
        OutlinedTextField(value = value, onValueChange = { input(it) }, placeholder = {
            Text(
                text = placeholder,
                color = WabiTheme.colors.translucentColor,
                style = WabiTheme.fonts.forTextField,
            )
        }, singleLine = true, shape = RoundedCornerShape(
            40.dp
        ), modifier = Modifier
            .fillMaxWidth()
            .wrapContentHeight()
            .padding(30.dp, 0.dp)
            .border(
                width = 2.dp, color = WabiTheme.colors.mainColor, shape = RoundedCornerShape(
                    40.dp
                )
            ), textStyle = WabiTheme.fonts.forTextField, colors = TextFieldDefaults.colors(
            unfocusedContainerColor = WabiTheme.colors.backgroundColor,
            focusedContainerColor = WabiTheme.colors.backgroundColor,
            unfocusedTextColor = WabiTheme.colors.mainColor,
            focusedTextColor = WabiTheme.colors.mainColor,
            cursorColor = WabiTheme.colors.mainColor
        ), trailingIcon = {
            if (trailingText.isNotEmpty()) {
                Text(
                    text = trailingText,
                    style = WabiTheme.fonts.forTextField,
                    fontSize = 30.sp,
                    modifier = Modifier.padding(0.dp, 0.dp, 10.dp, 0.dp)
                )
            }
        })
    }
}