All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.io.github.lyxnx.compose.ui.text.InlineTextContent.kt Maven / Gradle / Ivy

There is a newer version: 2.2.20
Show newest version
package io.github.lyxnx.compose.ui.text

import androidx.compose.foundation.text.InlineTextContent
import androidx.compose.foundation.text.appendInlineContent
import androidx.compose.runtime.Composable
import androidx.compose.ui.text.Placeholder
import androidx.compose.ui.text.PlaceholderVerticalAlign
import androidx.compose.ui.unit.TextUnit

/**
 * Convenience function for creating an [InlineTextContent] using a single function
 *
 * @param width the width of the placeholder, it must be specified in sp or em. [TextUnit.Unspecified] is not allowed.
 * @param height the height of the placeholder, it must be specified in sp or em. [TextUnit.Unspecified] is not allowed.
 * @param placeholderVerticalAlign the vertical alignment of the placeholder within the text line.
 * Check [PlaceholderVerticalAlign] for more information.
 * @param content the composable to be inserted into the text layout. The string parameter passed to it will the
 * alternateText given to [appendInlineContent].
 *
 * @throws IllegalArgumentException if [TextUnit.Unspecified] is passed to [width] or [height].
 *
 * @see Placeholder
 * @see InlineTextContent
 */
public fun InlineTextContent(
    width: TextUnit,
    height: TextUnit,
    placeholderVerticalAlign: PlaceholderVerticalAlign,
    content: @Composable (String) -> Unit
): InlineTextContent = InlineTextContent(
    placeholder = Placeholder(
        width = width,
        height = height,
        placeholderVerticalAlign = placeholderVerticalAlign
    ),
    children = content
)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy