メインコンテンツまでスキップ

Maneuver banner customization

You can customize the maneuver banner by providing your own UI written in Jetpack Compose.

Customizing Maneuver Content

The setManeuver function in DashNavigationFragment enables you to define custom content for the maneuver display. It accepts a ManeuverUiComposer, which is a composable function with two parameters: modifier and state. The modifier is an instance of Modifier, used for layout adjustments. The state is an instance of ManeuverUiState, encapsulating the information needed to render the maneuver.

ManeuverUiState

The ManeuverUiState class provides details for rendering maneuver content. Its parameters include:

  • destination: The final destination for the current route leg.
  • maneuver: Information about the next maneuver.
  • shields: A set of RouteShield objects for visual representation.
  • stepDistance: The formatted distance to the next maneuver.

Example Usage

To set a custom maneuver implementation:

fragment.setManeuver { state, modifier ->
CustomManeuverView(state, modifier)
}

The CustomManeuverView composable defines how the maneuver is displayed using the provided ManeuverUiState.

To revert to the default implementation at runtime:

fragment.setManeuver { state, modifier ->
DefaultManeuverView(state, modifier)
}

For additional examples, refer to the Dash Android Examples repository.

この{Type}は役に立ちましたか?