-
-
Notifications
You must be signed in to change notification settings - Fork 853
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: migrate components to new arch (#3136)
* feat: migrate js code of components * feat: migrate Android code of components * feat: migrate iOS code of components * fix: remove mapFeature and duplicate manager * feat: add Image module and fix tests
- Loading branch information
Showing
72 changed files
with
1,219 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
android/src/main/java/com/rnmapbox/rnmbx/components/images/RNMBXImageModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.rnmapbox.rnmbx.components.images | ||
|
||
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.NativeRNMBXImageModuleSpec | ||
import com.rnmapbox.rnmbx.utils.ViewTagResolver | ||
|
||
@ReactModule(name = RNMBXImageModule.NAME) | ||
class RNMBXImageModule(reactContext: ReactApplicationContext?, private val viewTagResolver: ViewTagResolver) : | ||
NativeRNMBXImageModuleSpec(reactContext) { | ||
|
||
companion object { | ||
const val NAME = "RNMBXImageModule" | ||
} | ||
|
||
private fun withImageOnUIThread(viewRef: Double?, reject: Promise, fn: (RNMBXImage) -> Unit) { | ||
if (viewRef == null) { | ||
reject.reject(Exception("viewRef is null for RNMBXImage")) | ||
} else { | ||
viewTagResolver.withViewResolved(viewRef.toInt(), reject, fn) | ||
} | ||
} | ||
|
||
@ReactMethod | ||
override fun refresh(viewRef: Double?, promise: Promise) { | ||
withImageOnUIThread(viewRef, promise) { | ||
it.refresh() | ||
promise.resolve(null) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 11 additions & 4 deletions
15
...id/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXNativeUserLocationManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 0 additions & 25 deletions
25
android/src/main/java/com/rnmapbox/rnmbx/components/styles/light/RNMBXLightManager.java
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
android/src/main/java/com/rnmapbox/rnmbx/components/styles/light/RNMBXLightManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.rnmapbox.rnmbx.components.styles.light | ||
|
||
import com.facebook.react.bridge.Dynamic | ||
import com.facebook.react.uimanager.ThemedReactContext | ||
import com.facebook.react.uimanager.ViewGroupManager | ||
import com.facebook.react.uimanager.annotations.ReactProp | ||
import com.facebook.react.viewmanagers.RNMBXLightManagerInterface | ||
|
||
class RNMBXLightManager : ViewGroupManager<RNMBXLight>(), | ||
RNMBXLightManagerInterface<RNMBXLight> { | ||
override fun getName(): String { | ||
return REACT_CLASS | ||
} | ||
|
||
override fun createViewInstance(reactContext: ThemedReactContext): RNMBXLight { | ||
return RNMBXLight(reactContext) | ||
} | ||
|
||
@ReactProp(name = "reactStyle") | ||
override fun setReactStyle(light: RNMBXLight, reactStyle: Dynamic) { | ||
light.setReactStyle(reactStyle.asMap()) | ||
} | ||
|
||
companion object { | ||
const val REACT_CLASS = "RNMBXLight" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
android/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXImageManagerDelegate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* 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 RNMBXImageManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & RNMBXImageManagerInterface<T>> extends BaseViewManagerDelegate<T, U> { | ||
public RNMBXImageManagerDelegate(U viewManager) { | ||
super(viewManager); | ||
} | ||
@Override | ||
public void setProperty(T view, String propName, @Nullable Object value) { | ||
switch (propName) { | ||
case "stretchX": | ||
mViewManager.setStretchX(view, new DynamicFromObject(value)); | ||
break; | ||
case "stretchY": | ||
mViewManager.setStretchY(view, new DynamicFromObject(value)); | ||
break; | ||
case "content": | ||
mViewManager.setContent(view, new DynamicFromObject(value)); | ||
break; | ||
case "sdf": | ||
mViewManager.setSdf(view, new DynamicFromObject(value)); | ||
break; | ||
case "name": | ||
mViewManager.setName(view, new DynamicFromObject(value)); | ||
break; | ||
case "scale": | ||
mViewManager.setScale(view, new DynamicFromObject(value)); | ||
break; | ||
default: | ||
super.setProperty(view, propName, value); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
android/src/main/old-arch/com/facebook/react/viewmanagers/RNMBXImageManagerInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* 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 RNMBXImageManagerInterface<T extends View> { | ||
void setStretchX(T view, Dynamic value); | ||
void setStretchY(T view, Dynamic value); | ||
void setContent(T view, Dynamic value); | ||
void setSdf(T view, Dynamic value); | ||
void setName(T view, Dynamic value); | ||
void setScale(T view, Dynamic value); | ||
} |
Oops, something went wrong.