package com.shoyoo.react.anavi.navi import com.amap.api.navi.model.NaviLatLng import com.amap.api.navi.model.NaviPoi import com.facebook.react.uimanager.annotations.ReactProp import com.shoyoo.react.anavi.toBitmap @Suppress("unused") class ADriveNaviViewManager() : ANaviViewManager() { override fun getName(): String { return "ADriveNaviView" } @ReactProp(name = "autoChangeZoom") fun setIsAutoChangeZoom(view: ANaviView, isAutoChangeZoom: Boolean) { view.viewOptions.apply { setAutoChangeZoom(isAutoChangeZoom) view.viewOptions = this } } @ReactProp(name = "autoDayNightMode") fun setAutoNaviViewNightMode(view: ANaviView, isAutoNaviViewNightMode: Boolean) { view.viewOptions.apply { setAutoNaviViewNightMode(isAutoNaviViewNightMode) view.viewOptions = this } } @ReactProp(name = "cameraBubbleVisible") fun setCameraBubbleShow(view: ANaviView, cameraBubbleShow: Boolean) { view.viewOptions.apply { isCameraBubbleShow = cameraBubbleShow view.viewOptions = this } } @ReactProp(name = "trafficBarVisible") fun setTrafficBarEnabled(view: ANaviView, enabled: Boolean) { view.viewOptions.apply { isTrafficBarEnabled = enabled view.viewOptions = this } } @ReactProp(name = "trafficButtonVisible") fun setTrafficLayerEnabled(view: ANaviView, enabled: Boolean) { view.viewOptions.apply { isTrafficLayerEnabled = enabled view.viewOptions = this } } @ReactProp(name = "trafficLineVisible") fun setTrafficLine(view: ANaviView, enabled: Boolean) { view.viewOptions.apply { isTrafficLine = enabled view.viewOptions = this } } @ReactProp(name = "wayMarkerIcon") fun setWayPointBitmap(view: ANaviView, icon: String) { view.viewOptions.apply { setWayPointBitmap(icon.toBitmap()) view.viewOptions = this } } override fun calculateRoute(from: Any?, to: Any, wayPoints: List?, strategy: Int) { when (to) { is String -> { calculateDriveRoute(from as? String, to, wayPoints as? List, strategy) } is NaviLatLng -> { calculateDriveRoute(from as? NaviLatLng, to, wayPoints as? List, strategy) } is NaviPoi -> { calculateDriveRoute(from as NaviPoi, to, wayPoints as? List, strategy) } else -> { throw java.lang.IllegalArgumentException("The type of parameter to must be String, NaviLatLog or NaviPoi") } } } }