UiText

sealed interface UiText(source)

A string that has not been resolved yet — either a literal the host supplied, or a resource the library will resolve against the current configuration.

Every user-facing string in the library flows through this type. That keeps the components free of hardcoded English while still letting a host override any title, subtitle or message with a plain String at the call site:

CountrySelector(
label = UiText.of("Nationality"), // literal
placeholder = UiText.resource(Res.string.pick_market), // host Compose resource
)

Resources are Compose Multiplatform resources, so the same call works from common code on every platform. On Android, UiText.resource(R.string.pick_market) with a classic @StringRes id is also accepted (see the Android source set), for hosts whose strings live in res/values.

Inheritors

Types

Link copied to clipboard
object Companion
Link copied to clipboard
abstract class Custom : UiText

A string from a source the library does not know about, resolved by the subclass during composition.

Link copied to clipboard
data class Literal(val value: String) : UiText

A literal the caller already resolved.

Link copied to clipboard
data class Plural(val resource: PluralStringResource, val count: Int, val args: List<Any> = listOf(count)) : UiText

A plurals resource selected by count.

Link copied to clipboard
data class Resource(val resource: StringResource, val args: List<Any> = emptyList()) : UiText

A string resource, optionally with format arguments.

Functions

Link copied to clipboard

Resolves this UiText against the current composition's resources.