package com.example.dtf.widgets

import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.material.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

@Composable
fun MyTextField(value: MutableState<TextFieldValue>, placeholder: String, onChanged: (TextFieldValue) -> Unit, modifier: Modifier, backgroundColor: Color = Color(0xFFF2F2F2), singleLine: Boolean = true) {
    TextField(
        value.value, onChanged,
        shape = RoundedCornerShape(size = 15.dp),
        colors = TextFieldDefaults.textFieldColors(
            backgroundColor = backgroundColor,
            disabledTextColor = Color.Transparent,
            focusedIndicatorColor = Color.Transparent,
            unfocusedIndicatorColor = Color.Transparent,
            disabledIndicatorColor = Color.Transparent,
        ),
        placeholder = {
            Text(
                text=placeholder,
                fontSize = 16.sp,
                color = Color(0xFFAAAAAA)
            )
        },
        singleLine = singleLine,
        textStyle = TextStyle(
            fontSize = 16.sp
        ),
        modifier = modifier
                   .background(color = backgroundColor, shape = RoundedCornerShape(size = 15.dp))
                   .border(width = 1.dp, color = Color(0xFFC7C7C7), shape = RoundedCornerShape(size = 15.dp))
    )
}