Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate RNMBXPointAnnotation to new arch #3130

Merged
merged 11 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion android/src/main/java/com/rnmapbox/rnmbx/RNMBXPackage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import com.facebook.react.uimanager.ViewManager
import com.rnmapbox.rnmbx.components.annotation.RNMBXCalloutManager
import com.rnmapbox.rnmbx.components.annotation.RNMBXMarkerViewManager
import com.rnmapbox.rnmbx.components.annotation.RNMBXPointAnnotationManager
import com.rnmapbox.rnmbx.components.annotation.RNMBXPointAnnotationModule
import com.rnmapbox.rnmbx.components.camera.RNMBXCameraManager
import com.rnmapbox.rnmbx.components.images.RNMBXImageManager
import com.rnmapbox.rnmbx.components.images.RNMBXImagesManager
import com.rnmapbox.rnmbx.components.location.RNMBXNativeUserLocationManager
import com.rnmapbox.rnmbx.components.mapview.NativeMapViewModule
import com.rnmapbox.rnmbx.components.mapview.RNMBXAndroidTextureMapViewManager
import com.rnmapbox.rnmbx.components.mapview.RNMBXMapView
import com.rnmapbox.rnmbx.components.mapview.RNMBXMapViewManager
import com.rnmapbox.rnmbx.components.styles.RNMBXStyleImportManager
import com.rnmapbox.rnmbx.components.styles.atmosphere.RNMBXAtmosphereManager
Expand Down Expand Up @@ -69,6 +69,7 @@ class RNMBXPackage : TurboReactPackage() {
RNMBXLogging.REACT_CLASS -> return RNMBXLogging(reactApplicationContext)
NativeMapViewModule.NAME -> return NativeMapViewModule(reactApplicationContext, getViewTagResolver(reactApplicationContext))
RNMBXShapeSourceModule.NAME -> return RNMBXShapeSourceModule(reactApplicationContext, getViewTagResolver(reactApplicationContext))
RNMBXPointAnnotationModule.NAME -> return RNMBXPointAnnotationModule(reactApplicationContext, getViewTagResolver(reactApplicationContext))
}
return null
}
Expand Down Expand Up @@ -187,6 +188,15 @@ class RNMBXPackage : TurboReactPackage() {
false, // isCxxModule
isTurboModule // isTurboModule
)
moduleInfos[RNMBXPointAnnotationModule.NAME] = ReactModuleInfo(
RNMBXPointAnnotationModule.NAME,
RNMBXPointAnnotationModule.NAME,
false, // canOverrideExistingModule
false, // needsEagerInit
false, // hasConstants
false, // isCxxModule
isTurboModule // isTurboModule
)
moduleInfos
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,4 @@ public void setAnchor(RNMBXPointAnnotation annotation, ReadableMap map) {
public void setDraggable(RNMBXPointAnnotation annotation, Boolean draggable) {
annotation.setDraggable(draggable);
}

@Override
public void receiveCommand(RNMBXPointAnnotation annotation, int commandID, @Nullable ReadableArray args) {
switch (commandID) {
case METHOD_REFRESH:
annotation.refresh();
break;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.rnmapbox.rnmbx.components.annotation

import com.facebook.react.bridge.Promise
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactMethod
import com.facebook.react.module.annotations.ReactModule
import com.rnmapbox.rnmbx.NativeRNMBXPointAnnotationModuleSpec
import com.rnmapbox.rnmbx.utils.ViewTagResolver

@ReactModule(name = RNMBXPointAnnotationModule.NAME)
class RNMBXPointAnnotationModule(reactContext: ReactApplicationContext?, private val viewTagResolver: ViewTagResolver) :
NativeRNMBXPointAnnotationModuleSpec(reactContext) {

companion object {
const val NAME = "RNMBXPointAnnotationModule"
}

private fun withPointAnnotationOnUIThread(viewRef: Double?, reject: Promise, fn: (RNMBXPointAnnotation) -> Unit) {
if (viewRef == null) {
reject.reject(Exception("viewRef is null for RNMBXPointAnnotation"))
} else {
viewTagResolver.withViewResolved(viewRef.toInt(), reject, fn)
}
}

@ReactMethod
override fun refresh(viewRef: Double?, promise: Promise) {
withPointAnnotationOnUIThread(viewRef, promise) {
it.refresh()
promise.resolve(null)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GeneratePropsJavaDelegate.js
*/

package com.facebook.react.viewmanagers;

import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.DynamicFromObject;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;

public class RNMBXPointAnnotationManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & RNMBXPointAnnotationManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public RNMBXPointAnnotationManagerDelegate(U viewManager) {
super(viewManager);
}
@Override
public void setProperty(T view, String propName, @Nullable Object value) {
switch (propName) {
case "coordinate":
mViewManager.setCoordinate(view, new DynamicFromObject(value));
break;
case "draggable":
mViewManager.setDraggable(view, new DynamicFromObject(value));
break;
case "id":
mViewManager.setId(view, new DynamicFromObject(value));
break;
case "anchor":
mViewManager.setAnchor(view, new DynamicFromObject(value));
break;
default:
super.setProperty(view, propName, value);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GeneratePropsJavaInterface.js
*/

package com.facebook.react.viewmanagers;

import android.view.View;
import com.facebook.react.bridge.Dynamic;

public interface RNMBXPointAnnotationManagerInterface<T extends View> {
void setCoordinate(T view, Dynamic value);
void setDraggable(T view, Dynamic value);
void setId(T view, Dynamic value);
void setAnchor(T view, Dynamic value);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateModuleJavaSpec.js
*
* @nolint
*/

package com.rnmapbox.rnmbx;

import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReactModuleWithSpec;
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public abstract class NativeRNMBXPointAnnotationModuleSpec extends ReactContextBaseJavaModule implements ReactModuleWithSpec, TurboModule {
public static final String NAME = "RNMBXPointAnnotationModule";

public NativeRNMBXPointAnnotationModuleSpec(ReactApplicationContext reactContext) {
super(reactContext);
}

@Override
public @Nonnull String getName() {
return NAME;
}

@ReactMethod
@DoNotStrip
public abstract void refresh(@Nullable Double viewRef, Promise promise);
}
36 changes: 20 additions & 16 deletions fabricexample/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ PODS:
- hermes-engine/Pre-built (= 0.72.4)
- hermes-engine/Pre-built (0.72.4)
- libevent (2.1.12)
- MapboxCommon (23.8.0)
- MapboxCoreMaps (10.16.0):
- MapboxCommon (23.8.3)
- MapboxCoreMaps (10.16.1):
- MapboxCommon (~> 23.8)
- MapboxMaps (10.16.0):
- MapboxCommon (= 23.8.0)
- MapboxCoreMaps (= 10.16.0)
- MapboxMaps (10.16.1):
- MapboxCommon (= 23.8.3)
- MapboxCoreMaps (= 10.16.1)
- MapboxMobileEvents (= 1.0.10)
- Turf (~> 2.0)
- MapboxMobileEvents (1.0.10)
Expand Down Expand Up @@ -1074,23 +1074,27 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- rnmapbox-maps (10.1.0-beta.9):
- MapboxMaps (~> 10.16.0)
- rnmapbox-maps (10.1.0-beta.14):
- MapboxMaps (~> 10.16.1)
- React
- React-Core
- rnmapbox-maps/DynamicLibrary (= 10.1.0-beta.9)
- rnmapbox-maps/DynamicLibrary (= 10.1.0-beta.14)
- Turf
- rnmapbox-maps/DynamicLibrary (10.1.0-beta.9):
- MapboxMaps (~> 10.16.0)
- rnmapbox-maps/DynamicLibrary (10.1.0-beta.14):
- hermes-engine
- MapboxMaps (~> 10.16.1)
- RCT-Folly
- RCTRequired
- RCTTypeSafety
- React
- React-Codegen
- React-Core
- React-NativeModulesApple
- React-RCTFabric
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Turf
- Yoga
- RNScreens (3.25.0):
- RCT-Folly
- RCTRequired
Expand Down Expand Up @@ -1158,7 +1162,7 @@ PODS:
- ReactCommon/turbomodule/core
- Yoga
- SocketRocket (0.6.1)
- Turf (2.6.1)
- Turf (2.7.0)
- Yoga (1.14.0)

DEPENDENCIES:
Expand Down Expand Up @@ -1332,9 +1336,9 @@ SPEC CHECKSUMS:
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
hermes-engine: 81191603c4eaa01f5e4ae5737a9efcf64756c7b2
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
MapboxCommon: 8592a003eae487508461d452d62cfc5906a9682a
MapboxCoreMaps: faa14a797417dc32088c98019a3ce72e46cda5cd
MapboxMaps: f10aecadbfb7cf96368852ca313101eb4171da53
MapboxCommon: b2c348867dfed7d7a23545e6c2024d712bfda10f
MapboxCoreMaps: c66f482b5ea983cf873122853c4ee94c159bec43
MapboxMaps: fdbe05e3899abd24f31a7f91789586e44e57f7fc
MapboxMobileEvents: de50b3a4de180dd129c326e09cd12c8adaaa46d6
RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1
RCTRequired: c0569ecc035894e4a68baecb30fe6a7ea6e399f9
Expand Down Expand Up @@ -1374,12 +1378,12 @@ SPEC CHECKSUMS:
React-utils: b79f2411931f9d3ea5781404dcbb2fa8a837e13a
ReactCommon: 4b2bdcb50a3543e1c2b2849ad44533686610826d
RNCAsyncStorage: 2b77010cff31de7199eb7f65c59ae35abf9970b1
rnmapbox-maps: efdc7b17ad07f7e077f56b1ad06e474ea6293db2
rnmapbox-maps: 04deea8b9ece57dc06b7f31acf9085c47f65d06a
RNScreens: cba72a26a6c967765a8388fe85f78e7771012ca1
RNSVG: df9aaada196f6a61c8e30dc55d41e6c108a954e7
RNVectorIcons: 61c44830bebe662f0bcb40aad2e6a31a34c8d8ba
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Turf: 469ce2c3d22e5e8e4818d5a3b254699a5c89efa4
Turf: 13d1a92d969ca0311bbc26e8356cca178ce95da2
Yoga: 3efc43e0d48686ce2e8c60f99d4e6bd349aff981

PODFILE CHECKSUM: ddac4d16bae15c3a589d18f707074a66b448710a
Expand Down
1 change: 0 additions & 1 deletion ios/RNMBX/RNMBXMapViewComponentView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ - (void)prepareView
std::dynamic_pointer_cast<const facebook::react::RNMBXMapViewEventEmitter>(strongSelf->_eventEmitter)->onMapChange({type, json});
}
}];

self.contentView = _view;
}

Expand Down
Loading
Loading