package com.rtnmapsgl import com.facebook.react.bridge.ReactApplicationContext import com.facebook.react.module.annotations.ReactModule import com.facebook.react.uimanager.SimpleViewManager import com.facebook.react.uimanager.ThemedReactContext import com.facebook.react.uimanager.ViewManagerDelegate import com.facebook.react.uimanager.annotations.ReactProp import com.facebook.react.viewmanagers.RTNMapsGLManagerInterface import com.facebook.react.viewmanagers.RTNMapsGLManagerDelegate import com.facebook.react.bridge.ReadableMap import com.facebook.react.bridge.ReadableArray import com.rtnmapsgl.MapsGLView // Use the static NAME property from the shared implementation @ReactModule(name = MapsGLManager.NAME) class MapsGLManager(context: ReactApplicationContext) : SimpleViewManager(), RTNMapsGLManagerInterface { private val delegate: ViewManagerDelegate = RTNMapsGLManagerDelegate(this) override fun getDelegate(): ViewManagerDelegate = delegate override fun getName(): String = MapsGLManagerImpl.NAME public override fun createViewInstance(context: ThemedReactContext): MapsGLView = MapsGLManagerImpl.createViewInstance(context) @ReactProp(name = "aerisId") fun setAerisId(view, MapsGLView, aerisId: String?) { // view.aerisId = aerisId // Call the corresponding update function in MapsGLManagerImpl if needed MapsGLManagerImpl.setAerisId(view, aerisId) } @ReactProp(name = "aerisSecretKey") fun setAerisSecretKey(view, MapsGLView, aerisSecretKey: String?) { // view.aerisSecretKey = aerisSecretKey // Call the corresponding update function in MapsGLManagerImpl if needed MapsGLManagerImpl.setAerisSecretKey(view, aerisSecretKey) } @ReactProp(name = "mapboxAccessToken") fun setMapboxAccessToken(view, MapsGLView, mapboxAccessToken: String?) { // view.mapboxAccessToken = mapboxAccessToken // Call the corresponding update function in MapsGLManagerImpl if needed MapsGLManagerImpl.setMapboxAccessToken(view, mapboxAccessToken) } @ReactProp(name = "mapLayerState") fun setMapLayerState(view, MapsGLView, mapLayerState: ReadableMap?) { // Convert the ReadableMap to a suitable object and update view.mapLayerState // Call the corresponding update function in MapsGLManagerImpl if needed } @ReactProp(name = "selectedPin") fun setSelectedPin(view, MapsGLView, selectedPin: ReadableMap?) { // Convert the ReadableMap to a suitable object and update view.selectedPin // Call the corresponding update function in MapsGLManagerImpl if needed } @ReactProp(name = "pins") fun updatePins(view, MapsGLView, pins: ReadableArray?) { // Convert the ReadableMap to a suitable object and update view.pins // Call the corresponding update function in MapsGLManagerImpl if needed } @ReactProp(name = "styleUrl") fun setStyleUrl(view, MapsGLView, styleUrl: String?) { // view.styleUrl = styleUrl // Call the corresponding update function in MapsGLManagerImpl if needed MapsGLManagerImpl.setStyleUrl(view, styleUrl) } @ReactProp(name = "userLocation") fun setUserLocation(view, MapsGLView, userLocation: ReadableArray?) { // Convert the ReadableArray to a suitable object and update view.userLocation // Call the corresponding update function in MapsGLManagerImpl if needed } @ReactProp(name = "onMapsglViewDidLoad") fun setOnMapsglViewDidLoad(view, MapsGLView, listener: Boolean) { // Implement the logic to handle onMapsglViewDidLoad event // You can use the view reference to access the MapsGL instance and other relevant data // Example: Emit a corresponding event to React Native side // val event = Arguments.createMap() // val nativeEvent = Arguments.createMap() // val mapView = Arguments.createMap() // // Populate the mapView properties with relevant data // // mapView.putXXX("property", value) // nativeEvent.putMap("mapView", mapView) // event.putMap("nativeEvent", nativeEvent) // view.emitEvent("onMapsglViewDidLoad", event) } @ReactProp(name = "onMapsglViewDidMove") fun setOnMapsglViewDidMove(view, MapsGLView, listener: Boolean) { // Implement the logic to handle onMapsglViewDidMove event // You can use the view reference to access the MapsGL instance and other relevant data // Example: Emit a corresponding event to React Native side // val event = Arguments.createMap() // val nativeEvent = Arguments.createMap() // val mapView = Arguments.createMap() // // Populate the mapView properties with relevant data // // mapView.putXXX("property", value) // nativeEvent.putMap("mapView", mapView) // event.putMap("nativeEvent", nativeEvent) // view.emitEvent("onMapsglViewDidMove", event) } @ReactProp(name = "onSelectWaterbody") fun setOnSelectWaterbody(view, MapsGLView, listener: Boolean) { // Implement the logic to handle onSelectWaterbody event // You can use the view reference to access the MapsGL instance and other relevant data // Example: Emit a corresponding event to React Native side // val event = Arguments.createMap() // val nativeEvent = Arguments.createMap() // val waterbody = Arguments.createMap() // // Populate the waterbody properties with relevant data // // waterbody.putXXX("property", value) // nativeEvent.putMap("waterbody", waterbody) // event.putMap("nativeEvent", nativeEvent) // view.emitEvent("onSelectWaterbody", event) } companion object { const val NAME = "RTNMapsGL" } }