From 53196ff4ce7e0607d31d372bb9ed14c22ed72ac5 Mon Sep 17 00:00:00 2001 From: Dany Bouca Nova Date: Wed, 15 Nov 2023 11:00:56 +0100 Subject: [PATCH 1/3] [GrapesTextInput] - Possibility to change height --- .../compose/textfield/GrapesBaseTextField.kt | 2 +- .../grapes/compose/textfield/GrapesTextInput.kt | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/library-compose/src/main/java/com/spendesk/grapes/compose/textfield/GrapesBaseTextField.kt b/library-compose/src/main/java/com/spendesk/grapes/compose/textfield/GrapesBaseTextField.kt index 7c9f65b5..d9af6dee 100644 --- a/library-compose/src/main/java/com/spendesk/grapes/compose/textfield/GrapesBaseTextField.kt +++ b/library-compose/src/main/java/com/spendesk/grapes/compose/textfield/GrapesBaseTextField.kt @@ -200,7 +200,7 @@ internal fun GrapesBaseTextField( contentPadding = textPadding, ) }, - modifier = Modifier + modifier = modifier .fillMaxWidth() .defaultMinSize( minWidth = GrapesTextFieldDefaults.MinWidth, diff --git a/library-compose/src/main/java/com/spendesk/grapes/compose/textfield/GrapesTextInput.kt b/library-compose/src/main/java/com/spendesk/grapes/compose/textfield/GrapesTextInput.kt index 4c0a3683..c0b55c20 100644 --- a/library-compose/src/main/java/com/spendesk/grapes/compose/textfield/GrapesTextInput.kt +++ b/library-compose/src/main/java/com/spendesk/grapes/compose/textfield/GrapesTextInput.kt @@ -48,6 +48,7 @@ import kotlinx.coroutines.launch * @author jean-philippe * @since 05/01/2023, Thu **/ +@SuppressWarnings("LongParameterList") @ExperimentalMaterial3Api @Composable fun GrapesTextInput( @@ -62,6 +63,7 @@ fun GrapesTextInput( colors: GrapesTextFieldColors = GrapesTextFieldDefaults.textFieldColors(), isError: Boolean = false, onClick: (() -> Unit)? = null, + singleLine: Boolean = true, keyboardActions: KeyboardActions = KeyboardActions.Default, keyboardOptions: KeyboardOptions = KeyboardOptions.Default, visualTransformation: VisualTransformation = VisualTransformation.None, @@ -82,13 +84,14 @@ fun GrapesTextInput( onClick = onClick, keyboardActions = keyboardActions, keyboardOptions = keyboardOptions, - singleLine = true, + singleLine = singleLine, visualTransformation = visualTransformation, leadingIcon = leadingIcon, trailingIcon = trailingIcon ) } +@SuppressWarnings("LongParameterList") @ExperimentalMaterial3Api @Composable fun GrapesTextInput( @@ -103,6 +106,7 @@ fun GrapesTextInput( colors: GrapesTextFieldColors = GrapesTextFieldDefaults.textFieldColors(), isError: Boolean = false, onClick: (() -> Unit)? = null, + singleLine: Boolean = true, keyboardActions: KeyboardActions = KeyboardActions.Default, keyboardOptions: KeyboardOptions = KeyboardOptions.Default, visualTransformation: VisualTransformation = VisualTransformation.None, @@ -123,7 +127,7 @@ fun GrapesTextInput( onClick = onClick, keyboardActions = keyboardActions, keyboardOptions = keyboardOptions, - singleLine = true, + singleLine = singleLine, visualTransformation = visualTransformation, leadingIcon = leadingIcon, trailingIcon = trailingIcon @@ -138,6 +142,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) } @@ -262,6 +267,12 @@ fun PreviewGrapesTextField() { isChecked = isReadOnly, onCheckedChange = { isChecked -> isReadOnly = isChecked } ) + + PreviewRowOptionSwitch( + label = "SingleLIne", + isChecked = isSingleLine, + onCheckedChange = { isChecked -> isSingleLine = isChecked } + ) } ) } @@ -273,6 +284,7 @@ fun PreviewGrapesTextField() { placeholderValue = "This is a placeholder", enabled = isEnabled, readOnly = isReadOnly, + singleLine = isSingleLine, helperText = helperText, isError = isError, onValueChange = { textFieldValue = it }, From 10d634fd015fe3a15d4c6135be06aec3534ce98d Mon Sep 17 00:00:00 2001 From: Dany Bouca Nova Date: Wed, 15 Nov 2023 11:49:51 +0100 Subject: [PATCH 2/3] [GrapesTextInput] - Add min & max lines and undo modifier changes --- gradle/libs.versions.toml | 2 +- .../compose/textfield/GrapesBaseTextField.kt | 17 ++++++++++++----- .../grapes/compose/textfield/GrapesTextInput.kt | 10 +++++++++- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8d302628..32abd182 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -grapes-version = '1.18.0' +grapes-version = '1.19.0' androidMinSdk = "21" androidTargetSdk = "34" androidCompileSdk = "34" diff --git a/library-compose/src/main/java/com/spendesk/grapes/compose/textfield/GrapesBaseTextField.kt b/library-compose/src/main/java/com/spendesk/grapes/compose/textfield/GrapesBaseTextField.kt index d9af6dee..4df690c9 100644 --- a/library-compose/src/main/java/com/spendesk/grapes/compose/textfield/GrapesBaseTextField.kt +++ b/library-compose/src/main/java/com/spendesk/grapes/compose/textfield/GrapesBaseTextField.kt @@ -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 @@ -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() }, @@ -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, @@ -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() }, @@ -184,6 +189,8 @@ internal fun GrapesBaseTextField( keyboardActions = keyboardActions, interactionSource = interactionSource, singleLine = singleLine, + minLines = minLines, + maxLines = maxLines, decorationBox = @Composable { innerTextField -> GrapesBasicTextFieldDecorationBox( value = value, @@ -200,7 +207,7 @@ internal fun GrapesBaseTextField( contentPadding = textPadding, ) }, - modifier = modifier + modifier = Modifier .fillMaxWidth() .defaultMinSize( minWidth = GrapesTextFieldDefaults.MinWidth, diff --git a/library-compose/src/main/java/com/spendesk/grapes/compose/textfield/GrapesTextInput.kt b/library-compose/src/main/java/com/spendesk/grapes/compose/textfield/GrapesTextInput.kt index c0b55c20..4abf580a 100644 --- a/library-compose/src/main/java/com/spendesk/grapes/compose/textfield/GrapesTextInput.kt +++ b/library-compose/src/main/java/com/spendesk/grapes/compose/textfield/GrapesTextInput.kt @@ -64,6 +64,8 @@ fun GrapesTextInput( 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, @@ -85,6 +87,8 @@ fun GrapesTextInput( keyboardActions = keyboardActions, keyboardOptions = keyboardOptions, singleLine = singleLine, + minLines = minLines, + maxLines = maxLines, visualTransformation = visualTransformation, leadingIcon = leadingIcon, trailingIcon = trailingIcon @@ -107,6 +111,8 @@ fun GrapesTextInput( 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, @@ -125,9 +131,11 @@ fun GrapesTextInput( colors = colors, isError = isError, onClick = onClick, + singleLine = singleLine, + minLines = minLines, + maxLines = maxLines, keyboardActions = keyboardActions, keyboardOptions = keyboardOptions, - singleLine = singleLine, visualTransformation = visualTransformation, leadingIcon = leadingIcon, trailingIcon = trailingIcon From 02b2dffa39e5853acf328a0ca52ba7144ea00c43 Mon Sep 17 00:00:00 2001 From: Dany Bouca Nova Date: Wed, 15 Nov 2023 11:50:33 +0100 Subject: [PATCH 3/3] [Gradle Version] - Put back original one --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 32abd182..8d302628 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -grapes-version = '1.19.0' +grapes-version = '1.18.0' androidMinSdk = "21" androidTargetSdk = "34" androidCompileSdk = "34"