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

Allow textLayoutResult callback in RichTextEditor #468

Merged
merged 1 commit into from
Dec 26, 2024
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 @@ -15,6 +15,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.takeOrElse
import androidx.compose.ui.text.TextLayoutResult
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
Expand Down Expand Up @@ -100,6 +101,7 @@ public fun RichTextEditor(
minLines: Int = 1,
maxLength: Int = Int.MAX_VALUE,
onRichTextChangedListener: RichTextChangedListener? = null,
onTextLayout: (TextLayoutResult) -> Unit = {},
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
shape: Shape =
MaterialTheme.shapes.small.copy(bottomEnd = ZeroCornerSize, bottomStart = ZeroCornerSize),
Expand Down Expand Up @@ -127,6 +129,7 @@ public fun RichTextEditor(
cursorBrush = SolidColor(colors.cursorColor(isError).value),
keyboardOptions = keyboardOptions,
keyboardActions = keyboardActions,
onTextLayout = onTextLayout,
interactionSource = interactionSource,
singleLine = singleLine,
maxLines = maxLines,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.compose.ui.graphics.takeOrElse
import androidx.compose.ui.layout.*
import androidx.compose.ui.layout.layoutId
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.text.TextLayoutResult
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
Expand Down Expand Up @@ -104,6 +105,7 @@ public fun RichTextEditor(
maxLines: Int = if (singleLine) 1 else Int.MAX_VALUE,
minLines: Int = 1,
maxLength: Int = Int.MAX_VALUE,
onTextLayout: (TextLayoutResult) -> Unit = {},
interactionSource: MutableInteractionSource = remember { MutableInteractionSource() },
shape: Shape = RichTextEditorDefaults.filledShape,
colors: RichTextEditorColors = RichTextEditorDefaults.richTextEditorColors(),
Expand Down Expand Up @@ -137,6 +139,7 @@ public fun RichTextEditor(
maxLines = maxLines,
minLines = minLines,
maxLength = maxLength,
onTextLayout = onTextLayout,
interactionSource = interactionSource,
cursorBrush = SolidColor(colors.cursorColor(isError).value),
decorationBox = @Composable { innerTextField ->
Expand Down