SearchBarState

@Stable
class SearchBarState

The state of a search bar.

Constructors

Link copied to clipboard
constructor(initialValue: SearchBarValue, animationSpecForExpand: AnimationSpec<Float>, animationSpecForCollapse: AnimationSpec<Float>)

Construct a SearchBarState.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
var collapsedCoords: LayoutCoordinates?

The layout coordinates, if available, of the search bar when it is collapsed. Used to coordinate the expansion animation.

Link copied to clipboard

Whether the search bar is currently expanded or collapsed. If the search bar is currently animating to/from the expanded state, currentValue is SearchBarValue.Expanded until the animation completes.

Link copied to clipboard

Whether the state is currently animating

Link copied to clipboard
@get:FloatRange(from = 0.0, to = 1.0)
val progress: Float

The animation progress of the search bar, where 0 represents SearchBarValue.Collapsed and 1 represents SearchBarValue.Expanded.

Link copied to clipboard

Whether the search bar is going to be expanded or collapsed.

Functions

Link copied to clipboard
suspend fun animateToCollapsed()

Animate the search bar to its collapsed state.

Link copied to clipboard
suspend fun animateToExpanded()

Animate the search bar to its expanded state.

Link copied to clipboard
suspend fun snapTo(fraction: Float)

Snap the search bar progress to the given fraction, where 0 represents SearchBarValue.Collapsed and 1 represents SearchBarValue.Expanded.