feat: make AppTextField stateful
This commit is contained in:
parent
3cc84e0957
commit
9b243b34f2
|
|
@ -12,10 +12,6 @@ import androidx.compose.material3.OutlinedTextField
|
|||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextFieldDefaults
|
||||
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.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.painter.Painter
|
||||
|
|
@ -35,15 +31,16 @@ fun AppTextField(
|
|||
// modifier: Modifier = Modifier,
|
||||
leadingIcon: Painter? = null,
|
||||
hint: String,
|
||||
keyboardType: KeyboardType
|
||||
keyboardType: KeyboardType,
|
||||
value: String,
|
||||
onValueChange: (String) -> Unit
|
||||
) {
|
||||
var text by remember { mutableStateOf("") }
|
||||
OutlinedTextField(
|
||||
value = text,
|
||||
onValueChange = { text = it },
|
||||
value = value,
|
||||
onValueChange = onValueChange,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp)
|
||||
.padding(horizontal = 16.dp)
|
||||
.border(BorderStroke(1.dp, LightGrey), RoundedCornerShape(8.dp)),
|
||||
leadingIcon = {
|
||||
if (leadingIcon != null) {
|
||||
|
|
@ -84,6 +81,8 @@ fun TextFieldPreview() {
|
|||
AppTextField(
|
||||
hint = "Enter Your Email",
|
||||
leadingIcon = painterResource(R.drawable.icon_email),
|
||||
keyboardType = KeyboardType.Email
|
||||
keyboardType = KeyboardType.Email,
|
||||
value = "",
|
||||
onValueChange = {}
|
||||
)
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user