SpeedText

fun SpeedText(speed: Speed, modifier: Modifier = Modifier, maxLines: Int = 1, format: SpeedFormat = SpeedFormat.Short, locale: Locale = Locale.current, unit: SpeedUnit = speedUnitForLocale(locale), style: TextStyle = TextStyle.Default)

Displays a formatted speed as text, adapting to the specified locale, unit system, and format style.

This composable renders a textual representation of a given speed value, with options for different units, formats, locales, and text styles. It automatically determines the SpeedUnit based on the locale if not explicitly provided.

Parameters

speed

The Speed value to be displayed.

modifier

Modifier to be applied to the underlying Text element.

maxLines

The maximum number of lines for the text. Defaults to 1.

format

Defines the format style for the speed text.

  • SpeedFormat.Long: Displays in a detailed format (e.g., "60 miles per hour", "20 kilometers per hour").

  • SpeedFormat.Short: Displays in a concise format (e.g., "60 mph", "20 km/h"). This setting controls the level of verbosity in the speed representation.

locale

The Locale to use for determining language and unit system (imperial or metric). Defaults to the current locale.

unit

The SpeedUnit for the speed representation. By default, it is auto-selected based on the specified or current locale.

style

Text style applied to the Text element displaying the speed.


fun SpeedText(speed: Speed, unit: SpeedUnit, language: String, modifier: Modifier = Modifier, maxLines: Int = 1, format: SpeedFormat = SpeedFormat.Short, style: TextStyle = TextStyle.Default)

Displays a formatted speed as text, with explicit control over unit and language.

This composable renders a textual representation of a given speed value using the specified SpeedUnit, language, and formatting style. Unlike the higher-level variant, this function requires you to explicitly define the unit and language, providing more control over localization.

Parameters

speed

The Speed value to be displayed.

unit

The SpeedUnit for the speed representation (e.g., meters per second, kilometers per hour, miles per hour).

language

The language code (e.g., "en", "fr") to use for localizing the speed value and unit.

modifier

Modifier to be applied to the underlying Text element.

maxLines

The maximum number of lines for the text. Defaults to 1.

format

Defines the format style for the speed text.

  • SpeedFormat.Long: Displays in a detailed format (e.g., "60 miles per hour", "20 kilometers per hour").

  • SpeedFormat.Short: Displays in a concise format (e.g., "60 mph", "20 km/h"). This setting controls the level of verbosity in the speed representation.

style

Text style applied to the Text element displaying the speed.