Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GrapesTextInput] - Possibility to change height #297

Merged
merged 3 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.OutlinedTextFieldDefaults
import androidx.compose.material3.Text
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
Expand Down Expand Up @@ -56,12 +55,14 @@ internal fun GrapesBaseTextField(
enabled: Boolean = true,
readOnly: Boolean = false,
textStyle: TextStyle = GrapesTheme.typography.bodyRegular,
singleLine: Boolean = false,
maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE,
minLines: Int = 1,
textPadding: PaddingValues = GrapesTextFieldDefaults.textFieldPadding(),
isError: Boolean = false,
onClick: (() -> Unit)? = null,
keyboardActions: KeyboardActions = KeyboardActions.Default,
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
singleLine: Boolean = false,
colors: GrapesTextFieldColors = GrapesTextFieldDefaults.textFieldColors(),
visualTransformation: VisualTransformation = VisualTransformation.None,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
Expand Down Expand Up @@ -118,11 +119,13 @@ internal fun GrapesBaseTextField(
readOnly = readOnly,
textStyle = textStyle,
textPadding = textPadding,
singleLine = singleLine,
minLines = minLines,
maxLines = maxLines,
isError = isError,
onClick = onClick,
keyboardActions = keyboardActions,
keyboardOptions = keyboardOptions,
singleLine = singleLine,
colors = colors,
visualTransformation = visualTransformation,
interactionSource = interactionSource,
Expand All @@ -145,10 +148,12 @@ internal fun GrapesBaseTextField(
textStyle: TextStyle = GrapesTheme.typography.bodyRegular,
textPadding: PaddingValues = GrapesTextFieldDefaults.textFieldPadding(),
isError: Boolean = false,
singleLine: Boolean = false,
maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE,
minLines: Int = 1,
onClick: (() -> Unit)? = null,
keyboardActions: KeyboardActions = KeyboardActions.Default,
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
singleLine: Boolean = false,
colors: GrapesTextFieldColors = GrapesTextFieldDefaults.textFieldColors(),
visualTransformation: VisualTransformation = VisualTransformation.None,
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
Expand Down Expand Up @@ -184,6 +189,8 @@ internal fun GrapesBaseTextField(
keyboardActions = keyboardActions,
interactionSource = interactionSource,
singleLine = singleLine,
minLines = minLines,
maxLines = maxLines,
decorationBox = @Composable { innerTextField ->
GrapesBasicTextFieldDecorationBox(
value = value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import kotlinx.coroutines.launch
* @author jean-philippe
* @since 05/01/2023, Thu
**/
@SuppressWarnings("LongParameterList")
@ExperimentalMaterial3Api
@Composable
fun GrapesTextInput(
Expand All @@ -62,6 +63,9 @@ fun GrapesTextInput(
colors: GrapesTextFieldColors = GrapesTextFieldDefaults.textFieldColors(),
isError: Boolean = false,
onClick: (() -> Unit)? = null,
singleLine: Boolean = true,
maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE,
minLines: Int = 1,
keyboardActions: KeyboardActions = KeyboardActions.Default,
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
visualTransformation: VisualTransformation = VisualTransformation.None,
Expand All @@ -82,13 +86,16 @@ fun GrapesTextInput(
onClick = onClick,
keyboardActions = keyboardActions,
keyboardOptions = keyboardOptions,
singleLine = true,
singleLine = singleLine,
minLines = minLines,
maxLines = maxLines,
visualTransformation = visualTransformation,
leadingIcon = leadingIcon,
trailingIcon = trailingIcon
)
}

@SuppressWarnings("LongParameterList")
@ExperimentalMaterial3Api
@Composable
fun GrapesTextInput(
Expand All @@ -103,6 +110,9 @@ fun GrapesTextInput(
colors: GrapesTextFieldColors = GrapesTextFieldDefaults.textFieldColors(),
isError: Boolean = false,
onClick: (() -> Unit)? = null,
singleLine: Boolean = true,
maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE,
minLines: Int = 1,
keyboardActions: KeyboardActions = KeyboardActions.Default,
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
visualTransformation: VisualTransformation = VisualTransformation.None,
Expand All @@ -121,9 +131,11 @@ fun GrapesTextInput(
colors = colors,
isError = isError,
onClick = onClick,
singleLine = singleLine,
minLines = minLines,
maxLines = maxLines,
keyboardActions = keyboardActions,
keyboardOptions = keyboardOptions,
singleLine = true,
visualTransformation = visualTransformation,
leadingIcon = leadingIcon,
trailingIcon = trailingIcon
Expand All @@ -138,6 +150,7 @@ fun GrapesTextInput(
fun PreviewGrapesTextField() {

var isEnabled by remember { mutableStateOf(true) }
var isSingleLine by remember { mutableStateOf(false) }
var isReadOnly by remember { mutableStateOf(false) }
var showLeadingIcon by remember { mutableStateOf(false) }
var showTrailingIcon by remember { mutableStateOf(false) }
Expand Down Expand Up @@ -262,6 +275,12 @@ fun PreviewGrapesTextField() {
isChecked = isReadOnly,
onCheckedChange = { isChecked -> isReadOnly = isChecked }
)

PreviewRowOptionSwitch(
label = "SingleLIne",
isChecked = isSingleLine,
onCheckedChange = { isChecked -> isSingleLine = isChecked }
)
}
)
}
Expand All @@ -273,6 +292,7 @@ fun PreviewGrapesTextField() {
placeholderValue = "This is a placeholder",
enabled = isEnabled,
readOnly = isReadOnly,
singleLine = isSingleLine,
helperText = helperText,
isError = isError,
onValueChange = { textFieldValue = it },
Expand Down