StringResource

class StringResource(@StringRes val resId: Int, val args: Any) : UiText

Represents a localized string resource with optional formatting arguments.

Use this for:

  • All user-facing static text

  • Error messages that should be localized

  • Labels, titles, descriptions

  • Any text that needs translation

Examples

// Simple string resource
UiText.StringResource(R.string.app_name)

// With single argument
UiText.StringResource(R.string.welcome_user, userName)

// With multiple arguments
UiText.StringResource(
R.string.items_count_format, // "%d of %d items"
currentCount,
totalCount
)

Constructors

Link copied to clipboard
constructor(@StringRes resId: Int, vararg args: Any)

Properties

Link copied to clipboard
val args: Array<out Any>

Optional formatting arguments for string placeholders (%s, %d, etc.).

Link copied to clipboard
val resId: Int

The string resource ID from R.string.

Functions

Link copied to clipboard

Resolves this UiText to a String within a Composable context.

fun asString(context: Context): String

Resolves this UiText to a String using an Android Context.