PositionIndicator

Functions summary

Unit
@Composable
PositionIndicator(
    scalingLazyListState: ScalingLazyListState,
    modifier: Modifier,
    reverseDirection: Boolean
)

This function is deprecated. This overload is provided for backwards compatibility with Compose for Wear OS 1.1.A newer overload is available which uses ScalingLazyListState from androidx.wear.compose.foundation.lazy package

Unit
@Composable
PositionIndicator(
    lazyListState: LazyListState,
    modifier: Modifier,
    reverseDirection: Boolean,
    fadeInAnimationSpec: AnimationSpec<Float>,
    fadeOutAnimationSpec: AnimationSpec<Float>,
    positionAnimationSpec: AnimationSpec<Float>
)

Creates an PositionIndicator based on the values in a LazyListState object that a androidx.compose.foundation.lazy.LazyColumn uses.

Unit
@Composable
PositionIndicator(
    scalingLazyListState: ScalingLazyListState,
    modifier: Modifier,
    reverseDirection: Boolean,
    fadeInAnimationSpec: AnimationSpec<Float>,
    fadeOutAnimationSpec: AnimationSpec<Float>,
    positionAnimationSpec: AnimationSpec<Float>
)

Creates an PositionIndicator based on the values in a ScalingLazyListState object that a ScalingLazyColumn uses.

Unit
@Composable
PositionIndicator(
    scrollState: ScrollState,
    modifier: Modifier,
    reverseDirection: Boolean,
    fadeInAnimationSpec: AnimationSpec<Float>,
    fadeOutAnimationSpec: AnimationSpec<Float>,
    positionAnimationSpec: AnimationSpec<Float>
)

Creates an PositionIndicator based on the values in a ScrollState object. e.g. a Column implementing androidx.compose.foundation.verticalScroll provides a ScrollState.

Unit
@Composable
PositionIndicator(
    value: () -> Float,
    modifier: Modifier,
    range: ClosedFloatingPointRange<Float>,
    color: Color,
    reverseDirection: Boolean,
    position: PositionIndicatorAlignment,
    fadeInAnimationSpec: AnimationSpec<Float>,
    fadeOutAnimationSpec: AnimationSpec<Float>,
    positionAnimationSpec: AnimationSpec<Float>
)

Creates a PositionIndicator for controls like rotating side button, rotating bezel or slider.

Unit
@Composable
PositionIndicator(
    state: PositionIndicatorState,
    indicatorHeight: Dp,
    indicatorWidth: Dp,
    paddingHorizontal: Dp,
    modifier: Modifier,
    background: Color,
    color: Color,
    reverseDirection: Boolean,
    position: PositionIndicatorAlignment,
    fadeInAnimationSpec: AnimationSpec<Float>,
    fadeOutAnimationSpec: AnimationSpec<Float>,
    positionAnimationSpec: AnimationSpec<Float>
)

An indicator on one side of the screen to show the current PositionIndicatorState.

Functions

PositionIndicator

@Composable
fun PositionIndicator(
    scalingLazyListState: ScalingLazyListState,
    modifier: Modifier = Modifier,
    reverseDirection: Boolean = false
): Unit

Creates an PositionIndicator based on the values in a ScalingLazyListState object that a ScalingLazyColumn uses.

For more information, see the Scroll indicators guide.

Parameters
scalingLazyListState: ScalingLazyListState

the ScalingLazyListState to use as the basis for the PositionIndicatorState.

modifier: Modifier = Modifier

The modifier to be applied to the component

reverseDirection: Boolean = false

Reverses direction of PositionIndicator if true

PositionIndicator

@Composable
fun PositionIndicator(
    lazyListState: LazyListState,
    modifier: Modifier = Modifier,
    reverseDirection: Boolean = false,
    fadeInAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec,
    fadeOutAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec,
    positionAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.positionAnimationSpec
): Unit

Creates an PositionIndicator based on the values in a LazyListState object that a androidx.compose.foundation.lazy.LazyColumn uses.

For more information, see the Scroll indicators guide.

Parameters
lazyListState: LazyListState

the LazyListState to use as the basis for the PositionIndicatorState.

modifier: Modifier = Modifier

The modifier to be applied to the component

reverseDirection: Boolean = false

Reverses direction of PositionIndicator if true

fadeInAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec

AnimationSpec for fade-in animation. Fade-in animation is triggered when the PositionIndicator becomes visible - either when state.visibility changes to Show, or state.visibility is AutoHide and state.positionFraction/state.sizeFraction are changed. To disable this animation snap AnimationSpec should be passed instead.

fadeOutAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec

AnimationSpec for fade-out animation. The Fade-out animation is used for hiding the PositionIndicator and making it invisible. PositionIndicator will be hidden after a specified delay if no changes in state.positionFraction or state.sizeFraction were detected. If fadeOutAnimationSpec is snap, then after a delay it will be instantly hidden.

positionAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.positionAnimationSpec

AnimationSpec for position animation. The Position animation is used for animating changes between state.positionFraction and state.sizeFraction of PositionIndicatorState. To disable this animation snap AnimationSpec should be passed instead.

PositionIndicator

@Composable
fun PositionIndicator(
    scalingLazyListState: ScalingLazyListState,
    modifier: Modifier = Modifier,
    reverseDirection: Boolean = false,
    fadeInAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec,
    fadeOutAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec,
    positionAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.positionAnimationSpec
): Unit

Creates an PositionIndicator based on the values in a ScalingLazyListState object that a ScalingLazyColumn uses.

For more information, see the Scroll indicators guide.

Parameters
scalingLazyListState: ScalingLazyListState

the ScalingLazyListState to use as the basis for the PositionIndicatorState.

modifier: Modifier = Modifier

The modifier to be applied to the component

reverseDirection: Boolean = false

Reverses direction of PositionIndicator if true

fadeInAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec

AnimationSpec for fade-in animation. Fade-in animation is triggered when the PositionIndicator becomes visible - either when state.visibility changes to Show, or state.visibility is AutoHide and state.positionFraction/state.sizeFraction are changed. To disable this animation snap AnimationSpec should be passed instead.

fadeOutAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec

AnimationSpec for fade-out animation. The Fade-out animation is used for hiding the PositionIndicator and making it invisible. PositionIndicator will be hidden after a specified delay if no changes in state.positionFraction or state.sizeFraction were detected. If fadeOutAnimationSpec is snap, then after a delay it will be instantly hidden.

positionAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.positionAnimationSpec

AnimationSpec for position animation. The Position animation is used for animating changes between state.positionFraction and state.sizeFraction of PositionIndicatorState. To disable this animation snap AnimationSpec should be passed instead.

PositionIndicator

@Composable
fun PositionIndicator(
    scrollState: ScrollState,
    modifier: Modifier = Modifier,
    reverseDirection: Boolean = false,
    fadeInAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec,
    fadeOutAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec,
    positionAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.positionAnimationSpec
): Unit

Creates an PositionIndicator based on the values in a ScrollState object. e.g. a Column implementing androidx.compose.foundation.verticalScroll provides a ScrollState.

For more information, see the Scroll indicators guide.

Parameters
scrollState: ScrollState

The scrollState to use as the basis for the PositionIndicatorState.

modifier: Modifier = Modifier

The modifier to be applied to the component

reverseDirection: Boolean = false

Reverses direction of PositionIndicator if true

fadeInAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec

AnimationSpec for fade-in animation. Fade-in animation is triggered when the PositionIndicator becomes visible - either when state.visibility changes to Show, or state.visibility is AutoHide and state.positionFraction/state.sizeFraction are changed. To disable this animation snap AnimationSpec should be passed instead.

fadeOutAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec

AnimationSpec for fade-out animation. The Fade-out animation is used for hiding the PositionIndicator and making it invisible. PositionIndicator will be hidden after a specified delay if no changes in state.positionFraction or state.sizeFraction were detected. If fadeOutAnimationSpec is snap, then after a delay it will be instantly hidden.

positionAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.positionAnimationSpec

AnimationSpec for position animation. The Position animation is used for animating changes between state.positionFraction and state.sizeFraction of PositionIndicatorState. To disable this animation snap AnimationSpec should be passed instead.

PositionIndicator

@Composable
fun PositionIndicator(
    value: () -> Float,
    modifier: Modifier = Modifier,
    range: ClosedFloatingPointRange<Float> = 0f..1f,
    color: Color = MaterialTheme.colors.onBackground,
    reverseDirection: Boolean = false,
    position: PositionIndicatorAlignment = PositionIndicatorAlignment.OppositeRsb,
    fadeInAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec,
    fadeOutAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec,
    positionAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.positionAnimationSpec
): Unit

Creates a PositionIndicator for controls like rotating side button, rotating bezel or slider.

For more information, see the Scroll indicators guide.

Parameters
value: () -> Float

Value of the indicator in the range where 1 represents the maximum value. E.g. If displaying a volume value from 0..11 then the value will be volume/11.

modifier: Modifier = Modifier

Modifier to be applied to the component

range: ClosedFloatingPointRange<Float> = 0f..1f

range of values that value can take

color: Color = MaterialTheme.colors.onBackground

Color to draw the indicator on.

reverseDirection: Boolean = false

Reverses direction of PositionIndicator if true

position: PositionIndicatorAlignment = PositionIndicatorAlignment.OppositeRsb

indicates where to put the PositionIndicator in the screen, default is PositionIndicatorPosition#OppositeRsb

fadeInAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec

AnimationSpec for fade-in animation. Fade-in animation is triggered when the PositionIndicator becomes visible - either when state.visibility changes to Show, or state.visibility is AutoHide and state.positionFraction/state.sizeFraction are changed. To disable this animation snap AnimationSpec should be passed instead.

fadeOutAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec

AnimationSpec for fade-out animation. The Fade-out animation is used for hiding the PositionIndicator and making it invisible. PositionIndicator will be hidden after a specified delay if no changes in state.positionFraction or state.sizeFraction were detected. If fadeOutAnimationSpec is snap, then after a delay it will be instantly hidden.

positionAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.positionAnimationSpec

AnimationSpec for position animation. The Position animation is used for animating changes between state.positionFraction and state.sizeFraction of PositionIndicatorState. To disable this animation snap AnimationSpec should be passed instead.

PositionIndicator

@Composable
fun PositionIndicator(
    state: PositionIndicatorState,
    indicatorHeight: Dp,
    indicatorWidth: Dp,
    paddingHorizontal: Dp,
    modifier: Modifier = Modifier,
    background: Color = MaterialTheme.colors.onBackground.copy(alpha = 0.3f),
    color: Color = MaterialTheme.colors.onBackground,
    reverseDirection: Boolean = false,
    position: PositionIndicatorAlignment = PositionIndicatorAlignment.End,
    fadeInAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec,
    fadeOutAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec,
    positionAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.positionAnimationSpec
): Unit

An indicator on one side of the screen to show the current PositionIndicatorState.

Typically used with the Scaffold but can be used to decorate any full screen situation.

This composable should only be used to fill the whole screen as Wear Material Design language requires the placement of the position indicator to be right center of the screen as the indicator is curved on circular devices.

It detects if the screen is round or square and draws itself as a curve or line.

Note that the composable will take the whole screen, but it will be drawn with the given dimensions indicatorHeight and indicatorWidth, and position with respect to the edge of the screen according to paddingHorizontal

This PositionIndicator has 3 separate animation specs to control different animations.

For performance reasons and for UX consistency, when PositionIndicator is used with scrollable list, we recommend to switch off fade-in and position animations by passing snap spec into fadeInAnimationSpec and positionAnimationSpec parameters. If PositionIndicator is used as a standalone indicator, for example as volume control, then we recommend to have all 3 animations turned on.

If color of PositionIndicator is not white and position animation is enabled - a short highlight animation will be triggered on any position change. This is a short animation accenting PositionIndicator with white color with 33% opacity.

For more information, see the Scroll indicators guide.

Parameters
state: PositionIndicatorState

the PositionIndicatorState of the state we are displaying.

indicatorHeight: Dp

the height of the position indicator in Dp.

indicatorWidth: Dp

the width of the position indicator in Dp.

paddingHorizontal: Dp

the padding to apply between the indicator and the border of the screen.

modifier: Modifier = Modifier

The modifier to be applied to the component.

background: Color = MaterialTheme.colors.onBackground.copy(alpha = 0.3f)

the color to draw the non-active part of the position indicator.

color: Color = MaterialTheme.colors.onBackground

the color to draw the active part of the indicator in.

reverseDirection: Boolean = false

Reverses direction of PositionIndicator if true.

position: PositionIndicatorAlignment = PositionIndicatorAlignment.End

indicates where to put the PositionIndicator on the screen, default is PositionIndicatorPosition#End

fadeInAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec

AnimationSpec for fade-in animation. Fade-in animation is triggered when the PositionIndicator becomes visible - either when state.visibility changes to Show, or state.visibility is AutoHide and state.positionFraction/state.sizeFraction are changed. To disable this animation snap AnimationSpec should be passed instead.

fadeOutAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.visibilityAnimationSpec

AnimationSpec for fade-out animation. The Fade-out animation is used for hiding the PositionIndicator and making it invisible. PositionIndicator will be hidden after a specified delay if no changes in state.positionFraction or state.sizeFraction were detected. If fadeOutAnimationSpec is snap, then after a delay it will be instantly hidden.

positionAnimationSpec: AnimationSpec<Float> = PositionIndicatorDefaults.positionAnimationSpec

AnimationSpec for position animation. The Position animation is used for animating changes between state.positionFraction and state.sizeFraction of PositionIndicatorState. To disable animation snap should be passed.