Skip to content

Commit

Permalink
Merge pull request #468 from e-hartig/expose-ontextlayout
Browse files Browse the repository at this point in the history
Allow textLayoutResult callback in RichTextEditor
  • Loading branch information
MohamedRejeb authored Dec 26, 2024
2 parents a509961 + e77d66d commit 59550be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
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

0 comments on commit 59550be

Please sign in to comment.