package com.shoyoo.react.anavi.paths import android.graphics.Color import com.amap.api.services.core.LatLonPoint import com.facebook.react.bridge.ReadableArray import com.facebook.react.bridge.ReadableMap import com.facebook.react.common.MapBuilder import com.facebook.react.uimanager.SimpleViewManager import com.facebook.react.uimanager.annotations.ReactProp import com.shoyoo.react.anavi.toLatLng import com.shoyoo.react.anavi.toLatLngPointList abstract class AMapPathManager : SimpleViewManager() { override fun getExportedCustomDirectEventTypeConstants(): Map { return MapBuilder.of( "onSearchStart", MapBuilder.of("registrationName", "onAMapSearchStart"), "onSearchComplete", MapBuilder.of("registrationName", "onAMapSearchComplete") ) } @ReactProp(name = "drawPath") fun setDrawPath(view: AMapPath, drawPath: Boolean) { view.drawPath = drawPath } @ReactProp(name = "startPoint") fun setStart(view: AMapPath, start: ReadableMap) { view.startPoint = start.toLatLng() } @ReactProp(name = "endPoint") fun setEnd(view: AMapPath, end: ReadableMap) { view.endPoint = end.toLatLng() } @ReactProp(name = "pathWidth") fun setPathWidth(view: AMapPath, pathWidth: Float) { view.pathWidth = pathWidth } @ReactProp(name = "pathColor") fun setPathColor(view: AMapPath, color: String) { view.pathColor = Color.parseColor(color) } @ReactProp(name = "nodeVisible") fun setNodeVisible(view: AMapPath, visible: Boolean) { view.nodeVisible = visible } @ReactProp(name = "startMarkerTitle") fun setStartTitle(view: AMapPath, title: String) { view.startTitle = title } @ReactProp(name = "endMarkerTitle") fun setEndTitle(view: AMapPath, title: String) { view.endTitle = title } @ReactProp(name = "startMarkerIcon") fun setStartBitmapDescriptor(view: AMapPath, icon: ReadableMap) { view.startMarkerIcon = icon } @ReactProp(name = "endMarkerIcon") fun setEndBitmapDescriptor(view: AMapPath, icon: ReadableMap) { view.endMarkerIcon = icon } @ReactProp(name = "nodeMarkerIcon") fun setNodeBitmapDescriptor(view: AMapPath, icon: ReadableMap) { view.nodeMarkerIcon = icon } @ReactProp(name = "throughMarkerIcon") fun setThroughPointBitmapDescriptor(view: AMapPath, icon: ReadableMap) { view.throughPointMarkerIcon = icon } @ReactProp(name = "wayPoints") fun setWayPoints(view: AMapPath, points: ReadableArray) { view.wayPoints = points.toLatLngPointList() } @ReactProp(name = "avoidRegions") fun setAvoidRegions(view: AMapPath, regions: ReadableArray) { view.avoidRegions = ArrayList>((0 until regions.size()).map { regions.getArray(it)?.toLatLngPointList() }) } @ReactProp(name = "avoidRoad") fun setAvoidRoad(view: AMapPath, avoidRoad: String) { view.avoidRoad = avoidRoad } @ReactProp(name = "throughPoints") fun setThroughPoints(view: AMapPath, throughPoints: ReadableArray) { view.throughPoints = throughPoints.toLatLngPointList() } @ReactProp(name = "throughMarkerVisible") fun setThroughPointMarkerVisible(view: AMapPath, visible: Boolean) { view.throughPointMarkerVisible = visible } @ReactProp(name = "searchMode") fun setMode(view: AMapPath, searchMode: Int) { view.mode = searchMode } @ReactProp(name = "normalPathColor") fun setNormalColor(view: AMapPath, color: String) { view.normalColor = Color.parseColor(color) } @ReactProp(name = "slowlyPathColor") fun setSlowlyColor(view: AMapPath, color: String) { view.slowlyColor = Color.parseColor(color) } @ReactProp(name = "blockedPathColor") fun setBlockedColor(view: AMapPath, color: String) { view.blockedColor = Color.parseColor(color) } @ReactProp(name = "severeBlockedPathColor") fun setSevereBlockedColor(view: AMapPath, color: String) { view.severeBlockedColor = Color.parseColor(color) } }