TtButtonViewModel

data class TtButtonViewModel(image: DrawableResolver?, text: StringResolver?, actionType: TtButton.ActionType, isEnabled: Boolean, isActivated: Boolean, isVisible: Boolean, isBadgeVisible: Boolean, drawableTintMatchesTextColor: Boolean, @IdRes tag: Int?, onClick: () -> Unit, onClickWhileDisabled: () -> Unit) : VisibilityProvider

Convenience class to provide common properties for buttons with a single reference. In addition to the look & feel of the button (such as image, text, actionType, etc.) and its behavior (such as onClick), it supports specifying a custom tag that makes it easily identifiable in tests.

Parameters

image

The image to show next to the text within the button.

text

The text to show within the button.

actionType

The ActionType which determines the appearance of the button.

isEnabled

Indicates whether the button is enabled.

isActivated

Indicates whether the button is activated. This can be used for toggle buttons.

isVisible

Indicates if the button is visible. If no value is provided, the button is visible only if it has an image and/or text.

isBadgeVisible

Indicates if a badge should be shown on top of the button. The badge signifies that there is update relevant to the user that can be accessed by clicking the button.

drawableTintMatchesTextColor

If true the image tint color matches the text color of the ActionType.

tag

An ID to tag the button with, which can be used to identify it later. This is useful, for example, during tests in combination with the withIdTag matcher.

onClick

Callback function for when the button is clicked.

onClickWhileDisabled

Callback function for when the button is clicked when in disabled state.

Constructors

Link copied to clipboard
fun TtButtonViewModel(image: DrawableResolver? = null, text: StringResolver? = null, actionType: TtButton.ActionType = TtButton.DEFAULT_ACTION_TYPE, isEnabled: Boolean = TtButton.DEFAULT_ENABLED, isActivated: Boolean = TtButton.DEFAULT_ACTIVATED, isVisible: Boolean = image != null || text != null, isBadgeVisible: Boolean = TtButton.DEFAULT_BADGE_VISIBLE, drawableTintMatchesTextColor: Boolean = TtButton.DEFAULT_DRAWABLE_TINT_MATCHES_TEXT_COLOR, @IdRes tag: Int? = null, onClick: () -> Unit = { }, onClickWhileDisabled: () -> Unit = { })

Properties

Link copied to clipboard
val actionType: TtButton.ActionType
Link copied to clipboard
val drawableTintMatchesTextColor: Boolean
Link copied to clipboard
val image: DrawableResolver? = null
Link copied to clipboard
val isActivated: Boolean
Link copied to clipboard
val isBadgeVisible: Boolean
Link copied to clipboard
val isEnabled: Boolean
Link copied to clipboard
open override val isVisible: Boolean
Link copied to clipboard
val onClick: () -> Unit
Link copied to clipboard
val onClickWhileDisabled: () -> Unit
Link copied to clipboard
val tag: Int? = null
Link copied to clipboard
val text: StringResolver? = null