1package com.navigine.examples
3import android.content.Context
4import android.view.ViewGroup
5import com.navigine.view.DefaultNavigationView
6import com.navigine.view.DefaultNavigationViewConfig
7import com.navigine.view.widgets.ZoomControls
8import com.navigine.view.widgets.ZoomControlsConfig
9import com.navigine.view.widgets.FollowMeButton
10import com.navigine.view.widgets.FollowMeButtonConfig
11import com.navigine.view.widgets.FloorSelectorView
12import com.navigine.view.widgets.FloorSelectorViewConfig
13import com.navigine.idl.java.LocationWindow
16 * DefaultNavigationView usage example for Kotlin
17 * Demonstrates config, runtime updates, and widget access
19class DefaultNavigationViewExample(private val context: Context) {
21 private var navigationView: DefaultNavigationView? = null
22 private var locationWindow: LocationWindow? = null
25 demonstrateConstructor()
26 demonstrateZoomControlsConfig()
27 demonstrateFollowMeButtonConfig()
28 demonstrateFloorSelectorViewConfig()
29 demonstrateConfigAtInit()
30 demonstrateRuntimeConfigUpdate()
31 demonstrateWidgetAccess()
35 * Demonstrate ZoomControlsConfig
37 private fun demonstrateZoomControlsConfig() {
38 // [kotlin_ZoomControlsConfig]
39 val zoomConfig = ZoomControlsConfig.builder()
40 .buttonBackgroundColor(0xF2FAFAFA.toInt())
41 .textColor(0xFF152D47.toInt())
43 .zoomControlsHeight(96f)
45 // zoomConfig.zoomInIcon(drawable); zoomConfig.zoomOutIcon(drawable)
46 // [kotlin_ZoomControlsConfig]
50 * Demonstrate FollowMeButtonConfig
52 private fun demonstrateFollowMeButtonConfig() {
53 // [kotlin_FollowMeButtonConfig]
54 val followMeConfig = FollowMeButtonConfig.builder()
55 .accentColor(0xFF30AAD9.toInt())
56 .buttonBackgroundColor(0xF2FAFAFA.toInt())
57 .textColor(0xFF152D47.toInt())
61 // followMeConfig.followMeIcon(drawable); followMeConfig.followMeIconActive(drawable)
62 // [kotlin_FollowMeButtonConfig]
66 * Demonstrate FloorSelectorViewConfig
68 private fun demonstrateFloorSelectorViewConfig() {
69 // [kotlin_FloorSelectorViewConfig]
70 val floorConfig = FloorSelectorViewConfig.builder()
71 .accentColor(0xFF30AAD9.toInt())
72 .textColor(0xFF152D47.toInt())
73 .buttonBackgroundColor(0xF2FAFAFA.toInt())
77 // [kotlin_FloorSelectorViewConfig]
81 * Demonstrate DefaultNavigationView constructor
83 private fun demonstrateConstructor() {
84 // [kotlin_DefaultNavigationView_constructor]
85 // Create with default config
86 navigationView = DefaultNavigationView(context).apply {
87 layoutParams = ViewGroup.LayoutParams(
88 ViewGroup.LayoutParams.MATCH_PARENT,
89 ViewGroup.LayoutParams.MATCH_PARENT
92 // [kotlin_DefaultNavigationView_constructor]
94 // [kotlin_DefaultNavigationView_constructor_config]
95 // Create with custom configs (configs passed directly)
96 val viewConfig = DefaultNavigationViewConfig.builder()
99 val followMeConfig = FollowMeButtonConfig.builder()
100 .accentColor(0xFF30AAD9.toInt())
102 val customView = DefaultNavigationView(context, null, viewConfig, null, followMeConfig, null)
103 // [kotlin_DefaultNavigationView_constructor_config]
107 * Demonstrate config usage at init
109 private fun demonstrateConfigAtInit() {
110 // [kotlin_DefaultNavigationView_config]
111 val viewConfig = DefaultNavigationViewConfig.builder()
112 .visibleWidgets(DefaultNavigationViewConfig.WIDGET_ZOOM_CONTROLS or DefaultNavigationViewConfig.WIDGET_FOLLOW_ME)
114 val zoomConfig = ZoomControlsConfig.builder()
115 .buttonBackgroundColor(0xF2FAFAFA.toInt())
117 val followMeConfig = FollowMeButtonConfig.builder()
118 .accentColor(0xFF30AAD9.toInt())
120 // followMeConfig.followMeIcon(drawable)
121 // zoomConfig.zoomInIcon(drawable); zoomConfig.zoomOutIcon(drawable)
122 // [kotlin_DefaultNavigationView_config]
126 * Demonstrate runtime config update
128 private fun demonstrateRuntimeConfigUpdate() {
129 // [kotlin_DefaultNavigationView_runtimeConfig]
130 navigationView?.setConfig(
131 DefaultNavigationViewConfig.builder()
132 .visibleWidgets(DefaultNavigationViewConfig.WIDGET_FOLLOW_ME)
135 FollowMeButtonConfig.builder()
136 .accentColor(0xFFFF0000.toInt())
139 ) // null = keep current
140 // [kotlin_DefaultNavigationView_runtimeConfig]
144 * Demonstrate direct widget access
146 private fun demonstrateWidgetAccess() {
147 // [kotlin_DefaultNavigationView_widgetAccess]
148 navigationView?.let { view ->
149 val zoomControls: ZoomControls? = view.zoomControls
150 val followMeButton: FollowMeButton? = view.followMeButton
151 val floorSelector: FloorSelectorView? = view.floorSelectorView
152 // Use for advanced customization (may be null if widget is hidden)
154 // [kotlin_DefaultNavigationView_widgetAccess]