NavigationControlsViewModel

ViewModel interface that manages the visibility and state of navigation UI controls. Coordinates the display of various navigation components including dashboard, route overview, better route prompt, traffic line, speed info, and map controls (zoom, compass, my location).

Handles complex visibility logic based on:

  • Navigation state (disabled, free roam, navigation, finished)

  • Route type (car, pedestrian, bicycle, etc.)

  • UI state (dashboard collapsed/expanded, route overview shown)

  • Screen orientation and available space

Important: Call onCleared when this ViewModel is no longer needed to properly release resources and close all connections to prevent memory leaks.

Thread Safety

This ViewModel is not thread-safe and must only be accessed from the Main thread.

  • All methods must be called from the Main (UI) thread

  • All StateFlow properties emit values on the Main thread

  • Concurrent access from multiple threads may lead to undefined behavior

Inheritors

Properties

Link copied to clipboard
abstract val betterRoutePromptVisibility: StateFlow<Boolean>

Observable state indicating whether the better route prompt should be visible. Shown when a better route exists and dashboard is collapsed.

Link copied to clipboard
abstract val dashboardVisibility: StateFlow<Boolean>

Observable state indicating whether the navigation dashboard should be visible. Hidden when navigation is finished, route overview is shown, or when collapsed with better route prompt visible.

Link copied to clipboard
abstract val finishRouteVisibility: StateFlow<Boolean>

Observable state indicating whether the finish route control should be visible. Only shown when navigation state is FINISHED.

Link copied to clipboard
abstract val indoorVisibility: StateFlow<Boolean>

Observable state indicating whether indoor navigation controls should be visible. Activated when navigation detects indoor environment.

Link copied to clipboard
abstract val map: Map

The map instance used for displaying navigation.

Link copied to clipboard
abstract val mapControlsVisibility: StateFlow<Boolean>

Observable state indicating whether map controls (zoom, compass, etc.) should be visible.

Link copied to clipboard
abstract val minimapVisibility: StateFlow<Boolean>

Observable state indicating whether the minimap should be visible. Shown during navigation (not in free roam, indoor, route overview, or finished states).

Link copied to clipboard
abstract val navigatorState: StateFlow<State>

Observable state of the current navigation state. Can be DISABLED, FREE_ROAM, NAVIGATION, or FINISHED.

Link copied to clipboard
abstract val routeOverviewVisibility: StateFlow<Boolean>

Observable state indicating whether the route overview mode is active. When true, most other controls are hidden to show the full route.

Link copied to clipboard
abstract val speedVisibility: StateFlow<Boolean>

Observable state indicating whether the speed info should be visible. Shown for car, public transport, bicycle, and scooter routes.

Link copied to clipboard
abstract val trafficButtonVisibility: StateFlow<Boolean>

Observable state indicating whether the traffic button should be visible.

Link copied to clipboard
abstract val trafficLineVisibility: StateFlow<Boolean>

Observable state indicating whether the traffic line should be visible. Shown during navigation (not in free roam, indoor, route overview, or finished states).

Functions

Link copied to clipboard
abstract fun onCleared()

Cleans up all resources and cancels active coroutines. Must be called when the ViewModel is no longer needed to prevent memory leaks. This includes canceling timers, closing navigation connections, and clearing references.

Link copied to clipboard

Called when the map controls area is touched.

Link copied to clipboard
abstract fun setDashboardIsCollapsed(value: Boolean)

Updates the dashboard collapsed state. When collapsed with a better route available, the better route prompt is shown instead.

Link copied to clipboard
abstract fun setHasBetterRoute(value: Boolean)

Updates whether a better route is available. Affects dashboard and better route prompt visibility.

Link copied to clipboard
abstract fun setIsFreeRoam(value: Boolean)

Updates the free roam navigation state. In free roam mode, traffic line is hidden and specific map controls may appear.

Link copied to clipboard
abstract fun setIsMinimapVisible(value: Boolean)

Updates the minimap visibility state.

Link copied to clipboard
abstract fun setIsRouteOverview(value: Boolean)

Updates whether route overview mode is active. In route overview, most controls are hidden to show the full route.