@rnmapbox/maps 10.3.0 → 10.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/rnmapbox/rnmbx/RNMBXPackage.kt +4 -0
- package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleFactory.kt +638 -0
- package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/rain/RNMBXRain.kt +83 -0
- package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/rain/RNMBXRainManager.kt +40 -0
- package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/snow/RNMBXSnow.kt +66 -0
- package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/snow/RNMBXSnowManager.kt +40 -0
- package/ios/RNMBX/RNMBXAtmosphereComponentView.mm +2 -1
- package/ios/RNMBX/RNMBXBackgroundLayerComponentView.mm +2 -1
- package/ios/RNMBX/RNMBXBridgeManager.h +8 -0
- package/ios/RNMBX/RNMBXBridgeManager.m +16 -0
- package/ios/RNMBX/RNMBXCircleLayerComponentView.mm +2 -1
- package/ios/RNMBX/RNMBXFillExtrusionLayerComponentView.mm +2 -1
- package/ios/RNMBX/RNMBXFillLayerComponentView.mm +2 -1
- package/ios/RNMBX/RNMBXHeatmapLayerComponentView.mm +2 -1
- package/ios/RNMBX/RNMBXHillshadeLayerComponentView.mm +2 -1
- package/ios/RNMBX/RNMBXImageModule.h +1 -0
- package/ios/RNMBX/RNMBXImageModule.mm +15 -2
- package/ios/RNMBX/RNMBXImageQueue.swift +9 -1
- package/ios/RNMBX/RNMBXImages.swift +4 -0
- package/ios/RNMBX/RNMBXImagesComponentView.mm +2 -1
- package/ios/RNMBX/RNMBXLightComponentView.mm +2 -1
- package/ios/RNMBX/RNMBXLineLayerComponentView.mm +2 -1
- package/ios/RNMBX/RNMBXModelLayerComponentView.mm +2 -1
- package/ios/RNMBX/RNMBXRain.swift +92 -0
- package/ios/RNMBX/RNMBXRainComponentView.h +14 -0
- package/ios/RNMBX/RNMBXRainComponentView.mm +80 -0
- package/ios/RNMBX/RNMBXRasterLayerComponentView.mm +2 -1
- package/ios/RNMBX/RNMBXRasterParticleLayerComponentView.mm +2 -1
- package/ios/RNMBX/RNMBXSkyLayerComponentView.mm +2 -1
- package/ios/RNMBX/RNMBXSnow.swift +76 -0
- package/ios/RNMBX/RNMBXSnowComponentView.h +14 -0
- package/ios/RNMBX/RNMBXSnowComponentView.mm +80 -0
- package/ios/RNMBX/RNMBXStyle.swift +415 -9
- package/ios/RNMBX/RNMBXStyleValue.swift +7 -1
- package/ios/RNMBX/RNMBXSymbolLayerComponentView.mm +2 -1
- package/ios/RNMBX/RNMBXTerrainComponentView.mm +2 -1
- package/lib/commonjs/plugin/install.md +2 -2
- package/lib/module/Mapbox.native.js +2 -0
- package/lib/module/Mapbox.native.js.map +1 -1
- package/lib/module/components/Rain.js +19 -0
- package/lib/module/components/Rain.js.map +1 -0
- package/lib/module/components/Snow.js +19 -0
- package/lib/module/components/Snow.js.map +1 -0
- package/lib/module/specs/RNMBXRainNativeComponent.ts +13 -0
- package/lib/module/specs/RNMBXSnowNativeComponent.ts +13 -0
- package/lib/module/utils/styleMap.js +20 -0
- package/lib/module/utils/styleMap.js.map +1 -1
- package/lib/typescript/scripts/autogenHelpers/generateCodeWithEjs.d.mts +71 -2
- package/lib/typescript/scripts/autogenHelpers/generateCodeWithEjs.d.mts.map +1 -1
- package/lib/typescript/scripts/autogenHelpers/globals.d.mts +1 -1
- package/lib/typescript/scripts/autogenHelpers/globals.d.mts.map +1 -1
- package/lib/typescript/src/Mapbox.native.d.ts +2 -0
- package/lib/typescript/src/Mapbox.native.d.ts.map +1 -1
- package/lib/typescript/src/components/Callout.d.ts +3 -3
- package/lib/typescript/src/components/Rain.d.ts +17 -0
- package/lib/typescript/src/components/Rain.d.ts.map +1 -0
- package/lib/typescript/src/components/Snow.d.ts +8 -0
- package/lib/typescript/src/components/Snow.d.ts.map +1 -0
- package/lib/typescript/src/specs/RNMBXRainNativeComponent.d.ts +8 -0
- package/lib/typescript/src/specs/RNMBXRainNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/specs/RNMBXSnowNativeComponent.d.ts +8 -0
- package/lib/typescript/src/specs/RNMBXSnowNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/utils/MapboxStyles.d.ts +171 -1
- package/lib/typescript/src/utils/MapboxStyles.d.ts.map +1 -1
- package/lib/typescript/src/utils/styleMap.d.ts.map +1 -1
- package/package.json +12 -3
- package/plugin/install.md +2 -2
- package/src/Mapbox.native.ts +2 -0
- package/src/components/Rain.tsx +31 -0
- package/src/components/Snow.tsx +22 -0
- package/src/specs/RNMBXRainNativeComponent.ts +13 -0
- package/src/specs/RNMBXSnowNativeComponent.ts +13 -0
- package/src/utils/MapboxStyles.ts +191 -0
- package/src/utils/styleMap.ts +22 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
package com.rnmapbox.rnmbx.components.styles.rain
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import com.facebook.react.bridge.ReadableMap
|
|
5
|
+
import com.mapbox.maps.MapboxMap
|
|
6
|
+
import com.mapbox.maps.extension.style.precipitations.generated.Rain
|
|
7
|
+
import com.mapbox.maps.extension.style.precipitations.generated.removeRain
|
|
8
|
+
import com.rnmapbox.rnmbx.components.RemovalReason
|
|
9
|
+
import com.rnmapbox.rnmbx.components.mapview.RNMBXMapView
|
|
10
|
+
import com.rnmapbox.rnmbx.components.styles.RNMBXStyle
|
|
11
|
+
import com.rnmapbox.rnmbx.components.styles.RNMBXStyleFactory
|
|
12
|
+
import com.rnmapbox.rnmbx.components.styles.sources.AbstractSourceConsumer
|
|
13
|
+
import com.rnmapbox.rnmbx.utils.Logger
|
|
14
|
+
|
|
15
|
+
class RNMBXRain(context: Context?) : AbstractSourceConsumer(context) {
|
|
16
|
+
override var iD: String? = null
|
|
17
|
+
protected var mRain: Rain? = null
|
|
18
|
+
|
|
19
|
+
// beginregion RNMBXLayer
|
|
20
|
+
@JvmField
|
|
21
|
+
protected var mMap: MapboxMap? = null
|
|
22
|
+
|
|
23
|
+
@JvmField
|
|
24
|
+
protected var mReactStyle: ReadableMap? = null
|
|
25
|
+
|
|
26
|
+
fun setReactStyle(reactStyle: ReadableMap?) {
|
|
27
|
+
mReactStyle = reactStyle
|
|
28
|
+
if (mRain != null) {
|
|
29
|
+
addStyles()
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// endregion RNMBXLayer
|
|
33
|
+
|
|
34
|
+
override fun addToMap(mapView: RNMBXMapView) {
|
|
35
|
+
super.addToMap(mapView)
|
|
36
|
+
mMap = mapView.getMapboxMap()
|
|
37
|
+
mapView.savedStyle?.let { warnIfMeasureLightUnavailable(it) }
|
|
38
|
+
val rain = makeRain()
|
|
39
|
+
mRain = rain
|
|
40
|
+
addStyles()
|
|
41
|
+
mapView.savedStyle?.let { rain.bindTo(it) }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private fun warnIfMeasureLightUnavailable(style: com.mapbox.maps.Style) {
|
|
45
|
+
val hasLights = style.getStyleLights().isNotEmpty()
|
|
46
|
+
if (hasLights) return
|
|
47
|
+
|
|
48
|
+
val affectedProps = listOf("color", "opacity", "vignetteColor")
|
|
49
|
+
val missingProps = affectedProps.filter { mReactStyle?.hasKey(it) != true }
|
|
50
|
+
if (missingProps.isEmpty()) return
|
|
51
|
+
|
|
52
|
+
Logger.w(
|
|
53
|
+
"RNMBXRain",
|
|
54
|
+
"The current style has no 3D lights, so measure-light(\"brightness\") " +
|
|
55
|
+
"expressions used in default rain ${missingProps.joinToString(", ")} will fail. " +
|
|
56
|
+
"Use a Standard style or set explicit values for: ${missingProps.joinToString(", ")}"
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
override fun removeFromMap(mapView: RNMBXMapView, reason: RemovalReason): Boolean {
|
|
61
|
+
mapView.savedStyle?.let { it.removeRain() }
|
|
62
|
+
mRain = null
|
|
63
|
+
mMap = null
|
|
64
|
+
return super.removeFromMap(mapView, reason)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
fun makeRain(): Rain {
|
|
68
|
+
return Rain()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
fun addStyles() {
|
|
72
|
+
mRain?.also {
|
|
73
|
+
RNMBXStyleFactory.setRainLayerStyle(
|
|
74
|
+
it, RNMBXStyle(
|
|
75
|
+
context, mReactStyle,
|
|
76
|
+
mMap!!
|
|
77
|
+
)
|
|
78
|
+
)
|
|
79
|
+
} ?: run {
|
|
80
|
+
Logger.e("RNMBXRain", "mRain is null")
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
package com.rnmapbox.rnmbx.components.styles.rain
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Dynamic
|
|
4
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
5
|
+
import com.rnmapbox.rnmbx.utils.extensions.asMapOrNull
|
|
6
|
+
import com.facebook.react.uimanager.ViewGroupManager
|
|
7
|
+
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
8
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
9
|
+
import com.facebook.react.viewmanagers.RNMBXRainManagerDelegate
|
|
10
|
+
import com.facebook.react.viewmanagers.RNMBXRainManagerInterface
|
|
11
|
+
|
|
12
|
+
class RNMBXRainManager : ViewGroupManager<RNMBXRain>(), RNMBXRainManagerInterface<RNMBXRain> {
|
|
13
|
+
|
|
14
|
+
private val mDelegate: ViewManagerDelegate<RNMBXRain>
|
|
15
|
+
|
|
16
|
+
init {
|
|
17
|
+
mDelegate = RNMBXRainManagerDelegate(this)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override fun getDelegate(): ViewManagerDelegate<RNMBXRain> {
|
|
21
|
+
return mDelegate
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
override fun getName(): String {
|
|
25
|
+
return REACT_CLASS
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
override fun createViewInstance(reactContext: ThemedReactContext): RNMBXRain {
|
|
29
|
+
return RNMBXRain(reactContext)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@ReactProp(name = "reactStyle")
|
|
33
|
+
override fun setReactStyle(rain: RNMBXRain, reactStyle: Dynamic) {
|
|
34
|
+
rain.setReactStyle(reactStyle.asMapOrNull())
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
companion object {
|
|
38
|
+
const val REACT_CLASS = "RNMBXRain"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
package com.rnmapbox.rnmbx.components.styles.snow
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import com.facebook.react.bridge.ReadableMap
|
|
5
|
+
import com.mapbox.maps.MapboxMap
|
|
6
|
+
import com.mapbox.maps.extension.style.precipitations.generated.Snow
|
|
7
|
+
import com.mapbox.maps.extension.style.precipitations.generated.removeSnow
|
|
8
|
+
import com.rnmapbox.rnmbx.components.RemovalReason
|
|
9
|
+
import com.rnmapbox.rnmbx.components.mapview.RNMBXMapView
|
|
10
|
+
import com.rnmapbox.rnmbx.components.styles.RNMBXStyle
|
|
11
|
+
import com.rnmapbox.rnmbx.components.styles.RNMBXStyleFactory
|
|
12
|
+
import com.rnmapbox.rnmbx.components.styles.sources.AbstractSourceConsumer
|
|
13
|
+
import com.rnmapbox.rnmbx.utils.Logger
|
|
14
|
+
|
|
15
|
+
class RNMBXSnow(context: Context?) : AbstractSourceConsumer(context) {
|
|
16
|
+
override var iD: String? = null
|
|
17
|
+
protected var mSnow: Snow? = null
|
|
18
|
+
|
|
19
|
+
// beginregion RNMBXLayer
|
|
20
|
+
@JvmField
|
|
21
|
+
protected var mMap: MapboxMap? = null
|
|
22
|
+
|
|
23
|
+
@JvmField
|
|
24
|
+
protected var mReactStyle: ReadableMap? = null
|
|
25
|
+
|
|
26
|
+
fun setReactStyle(reactStyle: ReadableMap?) {
|
|
27
|
+
mReactStyle = reactStyle
|
|
28
|
+
if (mSnow != null) {
|
|
29
|
+
addStyles()
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// endregion RNMBXLayer
|
|
33
|
+
|
|
34
|
+
override fun addToMap(mapView: RNMBXMapView) {
|
|
35
|
+
super.addToMap(mapView)
|
|
36
|
+
mMap = mapView.getMapboxMap()
|
|
37
|
+
val snow = makeSnow()
|
|
38
|
+
mSnow = snow
|
|
39
|
+
addStyles()
|
|
40
|
+
mapView.savedStyle?.let { snow.bindTo(it) }
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
override fun removeFromMap(mapView: RNMBXMapView, reason: RemovalReason): Boolean {
|
|
44
|
+
mapView.savedStyle?.let { it.removeSnow() }
|
|
45
|
+
mSnow = null
|
|
46
|
+
mMap = null
|
|
47
|
+
return super.removeFromMap(mapView, reason)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
fun makeSnow(): Snow {
|
|
51
|
+
return Snow()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
fun addStyles() {
|
|
55
|
+
mSnow?.also {
|
|
56
|
+
RNMBXStyleFactory.setSnowLayerStyle(
|
|
57
|
+
it, RNMBXStyle(
|
|
58
|
+
context, mReactStyle,
|
|
59
|
+
mMap!!
|
|
60
|
+
)
|
|
61
|
+
)
|
|
62
|
+
} ?: run {
|
|
63
|
+
Logger.e("RNMBXSnow", "mSnow is null")
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
package com.rnmapbox.rnmbx.components.styles.snow
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Dynamic
|
|
4
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
5
|
+
import com.rnmapbox.rnmbx.utils.extensions.asMapOrNull
|
|
6
|
+
import com.facebook.react.uimanager.ViewGroupManager
|
|
7
|
+
import com.facebook.react.uimanager.ViewManagerDelegate
|
|
8
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
9
|
+
import com.facebook.react.viewmanagers.RNMBXSnowManagerDelegate
|
|
10
|
+
import com.facebook.react.viewmanagers.RNMBXSnowManagerInterface
|
|
11
|
+
|
|
12
|
+
class RNMBXSnowManager : ViewGroupManager<RNMBXSnow>(), RNMBXSnowManagerInterface<RNMBXSnow> {
|
|
13
|
+
|
|
14
|
+
private val mDelegate: ViewManagerDelegate<RNMBXSnow>
|
|
15
|
+
|
|
16
|
+
init {
|
|
17
|
+
mDelegate = RNMBXSnowManagerDelegate(this)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
override fun getDelegate(): ViewManagerDelegate<RNMBXSnow> {
|
|
21
|
+
return mDelegate
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
override fun getName(): String {
|
|
25
|
+
return REACT_CLASS
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
override fun createViewInstance(reactContext: ThemedReactContext): RNMBXSnow {
|
|
29
|
+
return RNMBXSnow(reactContext)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@ReactProp(name = "reactStyle")
|
|
33
|
+
override fun setReactStyle(snow: RNMBXSnow, reactStyle: Dynamic) {
|
|
34
|
+
snow.setReactStyle(reactStyle.asMapOrNull())
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
companion object {
|
|
38
|
+
const val REACT_CLASS = "RNMBXSnow"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#import "RNMBXFabricHelpers.h"
|
|
4
4
|
|
|
5
5
|
#import <React/RCTBridge+Private.h>
|
|
6
|
+
#import "RNMBXBridgeManager.h"
|
|
6
7
|
#import <React/RCTConversions.h>
|
|
7
8
|
#import <React/RCTFabricComponentsPlugins.h>
|
|
8
9
|
|
|
@@ -40,7 +41,7 @@ using namespace facebook::react;
|
|
|
40
41
|
- (void)prepareView
|
|
41
42
|
{
|
|
42
43
|
_view = [[RNMBXAtmosphere alloc] init];
|
|
43
|
-
_view.bridge = [
|
|
44
|
+
_view.bridge = [RNMBXBridgeManager currentBridge];
|
|
44
45
|
|
|
45
46
|
self.contentView = _view;
|
|
46
47
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#import "RNMBXFabricHelpers.h"
|
|
4
4
|
|
|
5
5
|
#import <React/RCTBridge+Private.h>
|
|
6
|
+
#import "RNMBXBridgeManager.h"
|
|
6
7
|
#import <React/RCTConversions.h>
|
|
7
8
|
#import <React/RCTFabricComponentsPlugins.h>
|
|
8
9
|
|
|
@@ -40,7 +41,7 @@ using namespace facebook::react;
|
|
|
40
41
|
- (void)prepareView
|
|
41
42
|
{
|
|
42
43
|
_view = [[RNMBXBackgroundLayer alloc] init];
|
|
43
|
-
_view.bridge = [
|
|
44
|
+
_view.bridge = [RNMBXBridgeManager currentBridge];
|
|
44
45
|
self.contentView = _view;
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#import "RNMBXBridgeManager.h"
|
|
2
|
+
#import <React/RCTBridge+Private.h>
|
|
3
|
+
|
|
4
|
+
static __weak RCTBridge *_rnmbxBridge = nil;
|
|
5
|
+
|
|
6
|
+
@implementation RNMBXBridgeManager
|
|
7
|
+
|
|
8
|
+
+ (void)setBridge:(RCTBridge *)bridge {
|
|
9
|
+
_rnmbxBridge = bridge;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
+ (RCTBridge *)currentBridge {
|
|
13
|
+
return [RCTBridge currentBridge] ?: _rnmbxBridge;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@end
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#import <React/RCTConversions.h>
|
|
6
6
|
#import <React/RCTFabricComponentsPlugins.h>
|
|
7
7
|
#import <React/RCTBridge+Private.h>
|
|
8
|
+
#import "RNMBXBridgeManager.h"
|
|
8
9
|
|
|
9
10
|
#import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
|
|
10
11
|
#import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
|
|
@@ -40,7 +41,7 @@ using namespace facebook::react;
|
|
|
40
41
|
- (void)prepareView
|
|
41
42
|
{
|
|
42
43
|
_view = [[RNMBXCircleLayer alloc] init];
|
|
43
|
-
_view.bridge = [
|
|
44
|
+
_view.bridge = [RNMBXBridgeManager currentBridge];
|
|
44
45
|
self.contentView = _view;
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#import <React/RCTConversions.h>
|
|
6
6
|
#import <React/RCTFabricComponentsPlugins.h>
|
|
7
7
|
#import <React/RCTBridge+Private.h>
|
|
8
|
+
#import "RNMBXBridgeManager.h"
|
|
8
9
|
|
|
9
10
|
#import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
|
|
10
11
|
#import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
|
|
@@ -40,7 +41,7 @@ using namespace facebook::react;
|
|
|
40
41
|
- (void)prepareView
|
|
41
42
|
{
|
|
42
43
|
_view = [[RNMBXFillExtrusionLayer alloc] init];
|
|
43
|
-
_view.bridge = [
|
|
44
|
+
_view.bridge = [RNMBXBridgeManager currentBridge];
|
|
44
45
|
self.contentView = _view;
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#import <React/RCTConversions.h>
|
|
6
6
|
#import <React/RCTFabricComponentsPlugins.h>
|
|
7
7
|
#import <React/RCTBridge+Private.h>
|
|
8
|
+
#import "RNMBXBridgeManager.h"
|
|
8
9
|
|
|
9
10
|
#import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
|
|
10
11
|
#import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
|
|
@@ -40,7 +41,7 @@ using namespace facebook::react;
|
|
|
40
41
|
- (void)prepareView
|
|
41
42
|
{
|
|
42
43
|
_view = [[RNMBXFillLayer alloc] init];
|
|
43
|
-
_view.bridge = [
|
|
44
|
+
_view.bridge = [RNMBXBridgeManager currentBridge];
|
|
44
45
|
self.contentView = _view;
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#import <React/RCTConversions.h>
|
|
6
6
|
#import <React/RCTFabricComponentsPlugins.h>
|
|
7
7
|
#import <React/RCTBridge+Private.h>
|
|
8
|
+
#import "RNMBXBridgeManager.h"
|
|
8
9
|
|
|
9
10
|
#import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
|
|
10
11
|
#import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
|
|
@@ -40,7 +41,7 @@ using namespace facebook::react;
|
|
|
40
41
|
- (void)prepareView
|
|
41
42
|
{
|
|
42
43
|
_view = [[RNMBXHeatmapLayer alloc] init];
|
|
43
|
-
_view.bridge = [
|
|
44
|
+
_view.bridge = [RNMBXBridgeManager currentBridge];
|
|
44
45
|
self.contentView = _view;
|
|
45
46
|
}
|
|
46
47
|
#pragma mark - RCTComponentViewProtocol
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#import <React/RCTConversions.h>
|
|
6
6
|
#import <React/RCTFabricComponentsPlugins.h>
|
|
7
7
|
#import <React/RCTBridge+Private.h>
|
|
8
|
+
#import "RNMBXBridgeManager.h"
|
|
8
9
|
|
|
9
10
|
#import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
|
|
10
11
|
#import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
|
|
@@ -40,7 +41,7 @@ using namespace facebook::react;
|
|
|
40
41
|
- (void)prepareView
|
|
41
42
|
{
|
|
42
43
|
_view = [[RNMBXHillshadeLayer alloc] init];
|
|
43
|
-
_view.bridge = [
|
|
44
|
+
_view.bridge = [RNMBXBridgeManager currentBridge];
|
|
44
45
|
self.contentView = _view;
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -4,15 +4,28 @@
|
|
|
4
4
|
|
|
5
5
|
#import "RNMBXImageModule.h"
|
|
6
6
|
#import "RNMBXImageComponentView.h"
|
|
7
|
+
#import "RNMBXBridgeManager.h"
|
|
7
8
|
|
|
8
9
|
#import "rnmapbox_maps-Swift.pre.h"
|
|
9
10
|
|
|
10
|
-
@implementation RNMBXImageModule
|
|
11
|
+
@implementation RNMBXImageModule {
|
|
12
|
+
id _bridgeBacking;
|
|
13
|
+
}
|
|
11
14
|
|
|
12
15
|
RCT_EXPORT_MODULE();
|
|
13
16
|
|
|
14
17
|
@synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED;
|
|
15
|
-
|
|
18
|
+
|
|
19
|
+
- (void)setBridge:(RCTBridge *)bridge {
|
|
20
|
+
_bridgeBacking = bridge;
|
|
21
|
+
if (bridge != nil) {
|
|
22
|
+
[RNMBXBridgeManager setBridge:bridge];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
- (RCTBridge *)bridge {
|
|
27
|
+
return _bridgeBacking;
|
|
28
|
+
}
|
|
16
29
|
|
|
17
30
|
- (dispatch_queue_t)methodQueue
|
|
18
31
|
{
|
|
@@ -67,7 +67,15 @@ class RNMBXImageQueueOperation : Operation {
|
|
|
67
67
|
|
|
68
68
|
DispatchQueue.global(qos: .default).async {
|
|
69
69
|
if let weakSelf = weakSelf {
|
|
70
|
-
let
|
|
70
|
+
guard let bridge = weakSelf.bridge else {
|
|
71
|
+
Logger.log(level: .error, message: "RNMBXImageQueue: bridge is nil, cannot load image")
|
|
72
|
+
if let completionHandler = weakSelf.completionHandler {
|
|
73
|
+
completionHandler(NSError(domain: "RNMBXImageQueue", code: 1, userInfo: [NSLocalizedDescriptionKey: "bridge is nil"]), nil)
|
|
74
|
+
}
|
|
75
|
+
_ = weakSelf.setState(state:.Finished, except:.Finished)
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
let loader : RCTImageLoaderProtocol = bridge.module(forName: "ImageLoader", lazilyLoadIfNecessary: true) as! RCTImageLoaderProtocol
|
|
71
79
|
|
|
72
80
|
let cancellationBlock = loader.loadImage(with: weakSelf.urlRequest, size: .zero, scale: CGFloat(weakSelf.scale), clipped: true, resizeMode: .stretch, progressBlock: { _,_ in }, partialLoad: { _ in }) { error, image in
|
|
73
81
|
if let completionHandler = weakSelf.completionHandler {
|
|
@@ -130,6 +130,10 @@ open class RNMBXImages : UIView, RNMBXMapComponent {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
if missingImages.count > 0 {
|
|
133
|
+
guard let bridge = bridge else {
|
|
134
|
+
Logger.log(level: .error, message: "RNMBXImages: bridge is nil, cannot fetch images. Use nativeAssetImages instead.")
|
|
135
|
+
return
|
|
136
|
+
}
|
|
133
137
|
RNMBXUtils.fetchImages(bridge, style: style, objects: missingImages, forceUpdate: true) { name, image in
|
|
134
138
|
self.loadedImages.insert(name)
|
|
135
139
|
self.imageManager?.resolve(name: name, image: image)
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#include "RNMBXImageComponentView.h"
|
|
6
6
|
|
|
7
7
|
#import <React/RCTBridge+Private.h>
|
|
8
|
+
#import "RNMBXBridgeManager.h"
|
|
8
9
|
#import <React/RCTConversions.h>
|
|
9
10
|
#import <React/RCTFabricComponentsPlugins.h>
|
|
10
11
|
|
|
@@ -42,7 +43,7 @@ using namespace facebook::react;
|
|
|
42
43
|
- (void)prepareView
|
|
43
44
|
{
|
|
44
45
|
_view = [[RNMBXImages alloc] init];
|
|
45
|
-
_view.bridge = [
|
|
46
|
+
_view.bridge = [RNMBXBridgeManager currentBridge];
|
|
46
47
|
|
|
47
48
|
// capture weak self reference to prevent retain cycle
|
|
48
49
|
__weak __typeof__(self) weakSelf = self;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#import "RNMBXFabricHelpers.h"
|
|
4
4
|
|
|
5
5
|
#import <React/RCTBridge+Private.h>
|
|
6
|
+
#import "RNMBXBridgeManager.h"
|
|
6
7
|
#import <React/RCTConversions.h>
|
|
7
8
|
#import <React/RCTFabricComponentsPlugins.h>
|
|
8
9
|
|
|
@@ -40,7 +41,7 @@ using namespace facebook::react;
|
|
|
40
41
|
- (void)prepareView
|
|
41
42
|
{
|
|
42
43
|
_view = [[RNMBXLight alloc] init];
|
|
43
|
-
_view.bridge = [
|
|
44
|
+
_view.bridge = [RNMBXBridgeManager currentBridge];
|
|
44
45
|
self.contentView = _view;
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#import <React/RCTConversions.h>
|
|
6
6
|
#import <React/RCTFabricComponentsPlugins.h>
|
|
7
7
|
#import <React/RCTBridge+Private.h>
|
|
8
|
+
#import "RNMBXBridgeManager.h"
|
|
8
9
|
|
|
9
10
|
#import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
|
|
10
11
|
#import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
|
|
@@ -40,7 +41,7 @@ using namespace facebook::react;
|
|
|
40
41
|
- (void)prepareView
|
|
41
42
|
{
|
|
42
43
|
_view = [[RNMBXLineLayer alloc] init];
|
|
43
|
-
_view.bridge = [
|
|
44
|
+
_view.bridge = [RNMBXBridgeManager currentBridge];
|
|
44
45
|
self.contentView = _view;
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#import <React/RCTConversions.h>
|
|
6
6
|
#import <React/RCTFabricComponentsPlugins.h>
|
|
7
7
|
#import <React/RCTBridge+Private.h>
|
|
8
|
+
#import "RNMBXBridgeManager.h"
|
|
8
9
|
|
|
9
10
|
#import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
|
|
10
11
|
#import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
|
|
@@ -40,7 +41,7 @@ using namespace facebook::react;
|
|
|
40
41
|
- (void)prepareView
|
|
41
42
|
{
|
|
42
43
|
_view = [[RNMBXModelLayer alloc] init];
|
|
43
|
-
_view.bridge = [
|
|
44
|
+
_view.bridge = [RNMBXBridgeManager currentBridge];
|
|
44
45
|
self.contentView = _view;
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
@_spi(Experimental) import MapboxMaps
|
|
2
|
+
|
|
3
|
+
@objc(RNMBXRain)
|
|
4
|
+
public class RNMBXRain : RNMBXSingletonLayer, RNMBXMapComponent, RNMBXSourceConsumer {
|
|
5
|
+
var rain : Rain? = nil
|
|
6
|
+
|
|
7
|
+
func makeRain() -> Rain {
|
|
8
|
+
return Rain()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public func addToMap(_ map: RNMBXMapView, style: Style) {
|
|
12
|
+
self.map = map
|
|
13
|
+
self.style = style
|
|
14
|
+
|
|
15
|
+
warnIfMeasureLightUnavailable(style: style)
|
|
16
|
+
|
|
17
|
+
let rain = self.makeRain()
|
|
18
|
+
self.rain = rain
|
|
19
|
+
addStylesAndUpdate()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private func warnIfMeasureLightUnavailable(style: Style) {
|
|
23
|
+
let hasLights = !style.allLightIdentifiers.isEmpty
|
|
24
|
+
if hasLights { return }
|
|
25
|
+
|
|
26
|
+
let affectedProps = ["color", "opacity", "vignetteColor"]
|
|
27
|
+
let missingProps = affectedProps.filter { reactStyle?[$0] == nil }
|
|
28
|
+
if missingProps.isEmpty { return }
|
|
29
|
+
|
|
30
|
+
Logger.log(level: .warn, message: "RNMBXRain: The current style has no 3D lights, so " +
|
|
31
|
+
"measure-light(\"brightness\") expressions used in default rain " +
|
|
32
|
+
"\(missingProps.joined(separator: ", ")) will fail. Use a Standard style or set " +
|
|
33
|
+
"explicit values for: \(missingProps.joined(separator: ", "))")
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public func removeFromMap(_ map: RNMBXMapView, reason _: RemovalReason) -> Bool {
|
|
37
|
+
self.map = nil
|
|
38
|
+
|
|
39
|
+
guard let mapboxMap = map.mapboxMap else {
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let style = mapboxMap.style
|
|
44
|
+
removeFromMap(map, style: style)
|
|
45
|
+
return true
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public func waitForStyleLoad() -> Bool {
|
|
49
|
+
return true
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
func removeFromMap(_ map: RNMBXMapView, style: Style) {
|
|
53
|
+
logged("RNMBXRain.removeFromMap") {
|
|
54
|
+
try style.removeRain()
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
override func addStylesAndUpdate() {
|
|
59
|
+
guard rain != nil else {
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
super.addStylesAndUpdate()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
override func addStyles() {
|
|
67
|
+
if let style : Style = self.style,
|
|
68
|
+
let reactStyle = self.reactStyle {
|
|
69
|
+
let styler = RNMBXStyle(style: style)
|
|
70
|
+
styler.bridge = self.bridge
|
|
71
|
+
|
|
72
|
+
if var rain = rain {
|
|
73
|
+
styler.rainLayer(
|
|
74
|
+
layer: &rain,
|
|
75
|
+
reactStyle: reactStyle,
|
|
76
|
+
oldReactStyle: oldReactStyle,
|
|
77
|
+
applyUpdater: { (updater) in fatalError("Rain: TODO - implement apply updater")},
|
|
78
|
+
isValid: { fatalError("Rain: TODO - no isValid") }
|
|
79
|
+
)
|
|
80
|
+
self.rain = rain
|
|
81
|
+
} else {
|
|
82
|
+
fatalError("[xxx] rain is nil \(optional: self.rain)")
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
override func apply(style : Style) throws {
|
|
88
|
+
if let rain = rain {
|
|
89
|
+
try style.setRain(rain)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#ifdef __cplusplus
|
|
2
|
+
|
|
3
|
+
#import <UIKit/UIKit.h>
|
|
4
|
+
|
|
5
|
+
#import <React/RCTUIManager.h>
|
|
6
|
+
#import <React/RCTViewComponentView.h>
|
|
7
|
+
|
|
8
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
9
|
+
|
|
10
|
+
@interface RNMBXRainComponentView : RCTViewComponentView
|
|
11
|
+
@end
|
|
12
|
+
|
|
13
|
+
NS_ASSUME_NONNULL_END
|
|
14
|
+
#endif // __cplusplus
|