Skip to content

Commit

Permalink
Release v.1.5.2 (#174)
Browse files Browse the repository at this point in the history
Grapes compose:
- Adds readOnly property on GrapesTextInput

Grapes:
- Fixes Search bottom sheet bottom insets with keyboard
  • Loading branch information
kelianClerc authored Mar 13, 2023
2 parents 1fabab6 + 792db27 commit da8bf71
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 87 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
buildscript {

ext {
grapes_version = '1.5.1'
grapes_version = '1.5.2'

kotlin_version = '1.7.10'
firebase_app_distribution_version = '2.1.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.spendesk.grapes.compose.textfield

import androidx.compose.foundation.background
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.IntrinsicSize
Expand Down Expand Up @@ -48,8 +49,10 @@ internal fun GrapesBaseTextField(
modifier: Modifier = Modifier,
helperText: String? = null,
enabled: Boolean = true,
readOnly: Boolean = false,
textStyle: TextStyle = GrapesTheme.typography.bodyRegular,
isError: Boolean = false,
onClick: (() -> Unit)? = null,
keyboardActions: KeyboardActions = KeyboardActions.Default,
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
singleLine: Boolean = false,
Expand Down Expand Up @@ -100,6 +103,7 @@ internal fun GrapesBaseTextField(
modifier = modifier,
helperText = helperText,
enabled = enabled,
readOnly = readOnly,
textStyle = textStyle,
isError = isError,
keyboardActions = keyboardActions,
Expand All @@ -122,8 +126,10 @@ internal fun GrapesBaseTextField(
modifier: Modifier = Modifier,
helperText: String? = null,
enabled: Boolean = true,
readOnly: Boolean = false,
textStyle: TextStyle = GrapesTheme.typography.bodyRegular,
isError: Boolean = false,
onClick: (() -> Unit)? = null,
keyboardActions: KeyboardActions = KeyboardActions.Default,
keyboardOptions: KeyboardOptions = KeyboardOptions.Default,
singleLine: Boolean = false,
Expand All @@ -137,6 +143,11 @@ internal fun GrapesBaseTextField(
val textColor = colors.textColor(enabled).value
val mergedTextStyle = textStyle.merge(TextStyle(color = textColor))

val isClickable = onClick != null && readOnly
if (isClickable && interactionSource.collectIsPressedAsState().value) {
onClick?.invoke()
}

Column(
modifier = modifier.width(IntrinsicSize.Min)
) {
Expand All @@ -146,6 +157,7 @@ internal fun GrapesBaseTextField(
modifier = Modifier,
onValueChange = onValueChange,
enabled = enabled,
readOnly = readOnly,
textStyle = mergedTextStyle,
isError = isError,
keyboardActions = keyboardActions,
Expand Down Expand Up @@ -210,6 +222,7 @@ private fun GrapesCoreTextField(
onValueChange: (TextFieldValue) -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
readOnly: Boolean = false,
textStyle: TextStyle = TextStyle.Default,
isError: Boolean = false,
keyboardActions: KeyboardActions = KeyboardActions.Default,
Expand Down Expand Up @@ -237,6 +250,7 @@ private fun GrapesCoreTextField(
shape = GrapesTextFieldDefaults.TextFieldShape
),
enabled = enabled,
readOnly = readOnly,
value = value,
onValueChange = onValueChange,
textStyle = textStyle,
Expand Down
Loading

0 comments on commit da8bf71

Please sign in to comment.