2023-03-16 07:36:06 -07:00
|
|
|
package co.electriccoin.zcash.ui.design.component
|
|
|
|
|
2023-09-04 02:05:26 -07:00
|
|
|
import androidx.compose.foundation.border
|
2023-04-04 05:21:18 -07:00
|
|
|
import androidx.compose.foundation.text.KeyboardActions
|
2023-03-16 07:36:06 -07:00
|
|
|
import androidx.compose.foundation.text.KeyboardOptions
|
2023-09-04 02:05:26 -07:00
|
|
|
import androidx.compose.material3.MaterialTheme
|
2023-03-16 07:36:06 -07:00
|
|
|
import androidx.compose.material3.TextField
|
|
|
|
import androidx.compose.material3.TextFieldColors
|
|
|
|
import androidx.compose.material3.TextFieldDefaults
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
import androidx.compose.ui.graphics.Color
|
2023-04-04 05:21:18 -07:00
|
|
|
import androidx.compose.ui.graphics.Shape
|
2023-11-28 04:05:31 -08:00
|
|
|
import androidx.compose.ui.text.TextStyle
|
2023-03-16 07:36:06 -07:00
|
|
|
import androidx.compose.ui.text.input.KeyboardType
|
2023-09-04 02:05:26 -07:00
|
|
|
import androidx.compose.ui.unit.dp
|
2023-11-28 04:05:31 -08:00
|
|
|
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
|
2023-03-16 07:36:06 -07:00
|
|
|
|
|
|
|
@Suppress("LongParameterList")
|
|
|
|
@Composable
|
|
|
|
fun FormTextField(
|
|
|
|
value: String,
|
|
|
|
onValueChange: (String) -> Unit,
|
|
|
|
modifier: Modifier = Modifier,
|
2023-11-28 04:05:31 -08:00
|
|
|
textStyle: TextStyle = ZcashTheme.extendedTypography.textFieldValue,
|
2023-03-16 07:36:06 -07:00
|
|
|
label: @Composable (() -> Unit)? = null,
|
2023-03-30 00:58:20 -07:00
|
|
|
leadingIcon: @Composable (() -> Unit)? = null,
|
|
|
|
trailingIcon: @Composable (() -> Unit)? = null,
|
2023-03-16 07:36:06 -07:00
|
|
|
keyboardOptions: KeyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Text),
|
2023-12-11 01:20:32 -08:00
|
|
|
colors: TextFieldColors =
|
|
|
|
TextFieldDefaults.colors(
|
|
|
|
focusedContainerColor = Color.Transparent,
|
|
|
|
unfocusedContainerColor = Color.Transparent,
|
|
|
|
disabledContainerColor = Color.Transparent,
|
|
|
|
errorContainerColor = Color.Transparent,
|
|
|
|
),
|
2023-04-04 05:21:18 -07:00
|
|
|
keyboardActions: KeyboardActions = KeyboardActions.Default,
|
2023-09-04 02:05:26 -07:00
|
|
|
shape: Shape = TextFieldDefaults.shape,
|
2023-12-11 01:20:32 -08:00
|
|
|
// To enable border around the TextField
|
|
|
|
withBorder: Boolean = true,
|
2023-03-16 07:36:06 -07:00
|
|
|
) {
|
|
|
|
TextField(
|
|
|
|
value = value,
|
|
|
|
onValueChange = onValueChange,
|
|
|
|
label = label,
|
2023-11-28 04:05:31 -08:00
|
|
|
textStyle = textStyle,
|
2023-03-16 07:36:06 -07:00
|
|
|
keyboardOptions = keyboardOptions,
|
|
|
|
colors = colors,
|
2023-12-11 01:20:32 -08:00
|
|
|
modifier =
|
|
|
|
modifier.then(
|
|
|
|
if (withBorder) {
|
|
|
|
modifier.border(width = 1.dp, color = MaterialTheme.colorScheme.primary)
|
|
|
|
} else {
|
|
|
|
Modifier
|
|
|
|
}
|
|
|
|
),
|
2023-03-30 00:58:20 -07:00
|
|
|
leadingIcon = leadingIcon,
|
2023-04-04 05:21:18 -07:00
|
|
|
trailingIcon = trailingIcon,
|
|
|
|
keyboardActions = keyboardActions,
|
|
|
|
shape = shape
|
2023-03-16 07:36:06 -07:00
|
|
|
)
|
|
|
|
}
|