diff --git a/app/src/main/kotlin/com/wire/android/ui/common/textfield/StateSyncingModifier.kt b/app/src/main/kotlin/com/wire/android/ui/common/textfield/StateSyncingModifier.kt index afba166ade1..f60684e46a7 100644 --- a/app/src/main/kotlin/com/wire/android/ui/common/textfield/StateSyncingModifier.kt +++ b/app/src/main/kotlin/com/wire/android/ui/common/textfield/StateSyncingModifier.kt @@ -17,8 +17,6 @@ */ package com.wire.android.ui.common.textfield -import androidx.compose.foundation.ExperimentalFoundationApi -import androidx.compose.foundation.text.input.TextFieldCharSequence import androidx.compose.foundation.text.input.TextFieldState import androidx.compose.ui.Modifier import androidx.compose.ui.node.ModifierNodeElement @@ -56,7 +54,6 @@ internal class StateSyncingModifier( override fun InspectorInfo.inspectableProperties() {} } -@OptIn(ExperimentalFoundationApi::class) @PackagePrivate internal class StateSyncingModifierNode( private val state: TextFieldState, @@ -67,12 +64,12 @@ internal class StateSyncingModifierNode( fun update(value: TextFieldValue, onValueChanged: (TextFieldValue) -> Unit) { this.onValueChanged = onValueChanged - if (value.text != state.text.toString() || value.selection != state.text.selection) { + if (value.text != state.text.toString() || value.selection != state.selection) { state.edit { if (value.text != state.text.toString()) { replace(0, length, value.text) } - if (value.selection != state.text.selection) { + if (value.selection != state.selection) { selection = value.selection } } @@ -89,9 +86,9 @@ internal class StateSyncingModifierNode( } private fun observeTextState(fireOnValueChanged: Boolean = true) { - lateinit var text: TextFieldCharSequence + lateinit var text: TextFieldState observeReads { - text = state.text + text = state } if (fireOnValueChanged) { val newValue = TextFieldValue( diff --git a/app/src/main/kotlin/com/wire/android/ui/common/textfield/WireTextField2.kt b/app/src/main/kotlin/com/wire/android/ui/common/textfield/WireTextField2.kt index 25c770f9ca0..91dc9540a92 100644 --- a/app/src/main/kotlin/com/wire/android/ui/common/textfield/WireTextField2.kt +++ b/app/src/main/kotlin/com/wire/android/ui/common/textfield/WireTextField2.kt @@ -19,7 +19,6 @@ package com.wire.android.ui.common.textfield import androidx.compose.animation.AnimatedVisibility -import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.ScrollState import androidx.compose.foundation.background import androidx.compose.foundation.border @@ -30,7 +29,6 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.BasicTextField -import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.text.input.InputTransformation import androidx.compose.foundation.text.input.TextFieldLineLimits @@ -68,7 +66,6 @@ import com.wire.android.util.ui.PreviewMultipleThemes * which take TextFieldValue or String with onValueChange callback are the previous generation ones. * This hybrid is created to allow us to still pass TextFieldValue and onValueChange callback but already use the new text input version. */ -@OptIn(ExperimentalFoundationApi::class) @Composable internal fun WireTextField2( value: TextFieldValue, @@ -88,7 +85,6 @@ internal fun WireTextField2( capitalization = KeyboardCapitalization.Sentences, autoCorrect = true ), - keyboardActions: KeyboardActions = KeyboardActions.Default, scrollState: ScrollState = rememberScrollState(), interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, textStyle: TextStyle = MaterialTheme.wireTypography.body01, @@ -116,7 +112,6 @@ internal fun WireTextField2( state = textState, textStyle = textStyle.copy(color = colors.textColor(state = state).value, textDirection = TextDirection.ContentOrLtr), keyboardOptions = keyboardOptions, - keyboardActions = keyboardActions, lineLimits = lineLimits, inputTransformation = InputTransformation.maxLength(maxTextLength), scrollState = scrollState, @@ -159,7 +154,7 @@ internal fun WireTextField2( }, onTextLayout = { it()?.let { - val lineOfText = it.getLineForOffset(textState.text.selection.end) + val lineOfText = it.getLineForOffset(textState.selection.end) val bottomYCoordinate = it.getLineBottom(lineOfText) onSelectedLineIndexChanged(lineOfText) onLineBottomYCoordinateChanged(bottomYCoordinate) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 32ae97c1b02..3f2dd503b88 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -45,8 +45,8 @@ androidx-startup = "1.1.1" # Compose composeBom = "2024.04.01" -compose-foundation = "1.7.0-alpha05" # remove when composeBom contains new stable version of BasicTextField2 -compose-material-android = "1.7.0-alpha05" # remove when composeBom contains new stable version of BasicTextField2 +compose-foundation = "1.7.0-beta01" # remove when composeBom contains new stable version of BasicTextField2 +compose-material-android = "1.7.0-beta01" # remove when composeBom contains new stable version of BasicTextField2 compose-activity = "1.8.2" compose-compiler = "1.5.11" compose-constraint = "1.0.1"