-
Notifications
You must be signed in to change notification settings - Fork 1
/
TextInput.kt
56 lines (54 loc) · 1.97 KB
/
TextInput.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.dluvian.voyage.ui.components.text
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
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.text.input.TextFieldValue
import com.dluvian.voyage.ui.theme.light
@Composable
fun TextInput(
value: TextFieldValue,
onValueChange: (TextFieldValue) -> Unit,
placeholder: String,
modifier: Modifier = Modifier,
isSingleLine: Boolean = false,
style: TextStyle = LocalTextStyle.current,
imeAction: ImeAction = ImeAction.Default,
keyboardType: KeyboardType = KeyboardType.Text
) {
val transparentTextFieldColor = TextFieldDefaults.colors(
focusedIndicatorColor = Color.Transparent,
unfocusedIndicatorColor = Color.Transparent,
focusedContainerColor = Color.Transparent,
unfocusedContainerColor = Color.Transparent
)
TextField(
modifier = modifier.fillMaxWidth(),
value = value,
onValueChange = onValueChange,
colors = transparentTextFieldColor,
textStyle = style,
singleLine = isSingleLine,
keyboardOptions = KeyboardOptions(
keyboardType = keyboardType,
imeAction = imeAction
),
placeholder = {
Text(
text = placeholder,
style = style,
fontWeight = FontWeight.Bold,
color = MaterialTheme.colorScheme.onBackground.light()
)
})
}