@rnmapbox/maps 10.2.3 → 10.2.5

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.
@@ -2,11 +2,28 @@ package com.rnmapbox.rnmbx.components.annotation
2
2
 
3
3
  import android.content.Context
4
4
  import android.view.View.MeasureSpec
5
+ import android.view.ViewGroup
5
6
  import com.facebook.react.views.view.ReactViewGroup
6
7
 
7
8
  class RNMBXMarkerViewContent(context: Context): ReactViewGroup(context) {
8
-
9
9
  var inAdd: Boolean = false
10
+
11
+ init {
12
+ allowRenderingOutside()
13
+ }
14
+
15
+ override fun onAttachedToWindow() {
16
+ super.onAttachedToWindow()
17
+ configureParentClipping()
18
+ }
19
+
20
+ private fun configureParentClipping() {
21
+ val parent = parent
22
+ if (parent is android.view.ViewGroup) {
23
+ parent.allowRenderingOutside()
24
+ }
25
+ }
26
+
10
27
  // see https://github.com/rnmapbox/maps/pull/3235
11
28
  override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
12
29
  if (inAdd) {
@@ -25,6 +42,10 @@ class RNMBXMarkerViewContent(context: Context): ReactViewGroup(context) {
25
42
  super.onMeasure(widthMeasureSpec, heightMeasureSpec)
26
43
  }
27
44
  }
45
+ }
28
46
 
47
+ private fun ViewGroup.allowRenderingOutside() {
48
+ this.clipChildren = false
49
+ this.clipToPadding = false
29
50
  }
30
51
 
@@ -83,6 +83,10 @@ class RNMBXStyleValue(config: ReadableMap) {
83
83
  for (i in 0 until arr.size()) {
84
84
  val item = arr.getMap(i)
85
85
  if (item != null) {
86
+ if (item.getString("type") != "number") {
87
+ Logger.e("RNMBXStyleValue", "getFloatArray: invalid type for item: $i ${item.getString("type")} expected to be number")
88
+ continue
89
+ }
86
90
  result.add(item.getDouble("value"))
87
91
  } else {
88
92
  Logger.e("RNMBXStyleValue", "getFloatArray: null value for item: $i")
@@ -110,6 +114,10 @@ class RNMBXStyleValue(config: ReadableMap) {
110
114
  val item = arr.getMap(i)
111
115
  val value = item?.getString("value")
112
116
  if (value != null) {
117
+ if (item.getString("type") != "string") {
118
+ Logger.e("RNMBXStyleValue", "getStringArray: invalid type for item: $i ${item.getString("type")} expected to be string")
119
+ continue
120
+ }
113
121
  result.add(value)
114
122
  } else {
115
123
  Logger.e("RNMBXStyleValue", "getStringArray: null value for item: $i")
@@ -221,20 +229,44 @@ class RNMBXStyleValue(config: ReadableMap) {
221
229
  }
222
230
  if (!isAddImage) {
223
231
  val dynamic = mPayload!!.getDynamic("value")
224
- if (dynamic.type == ReadableType.Array) {
225
- val array = dynamic.asArray()
226
- if (array == null) {
227
- Logger.e("RNMBXStyleValue", "value array is null")
228
- } else {
229
- if (array.size() > 0 && mPayload.getString("type") == "array") {
230
- val map = array.getMap(0)
231
- if (map != null && map.getString("type") == "string") {
232
- isExpression = true
233
- mExpression = ExpressionParser.fromTyped(mPayload)
234
- }
235
- }
236
- }
232
+ if (isExpression(dynamic)) {
233
+ isExpression = true
234
+ mExpression = ExpressionParser.fromTyped(mPayload)
235
+ }
236
+ }
237
+ }
238
+
239
+ private fun isExpression(payload: Dynamic): Boolean {
240
+ if (payload.type != ReadableType.Array) {
241
+ return false
242
+ }
243
+
244
+ var potentialExpression = payload.asArray()
245
+ ?: return false
246
+
247
+ while (
248
+ potentialExpression.size() > 0 &&
249
+ potentialExpression.getType(0) == ReadableType.Map
250
+ ) {
251
+ val firstElementMap = potentialExpression.getMap(0)
252
+ ?: return false
253
+
254
+ if (firstElementMap.getString("type") == "array") {
255
+ potentialExpression = firstElementMap.getArray("value")
256
+ ?: return false
257
+ } else {
258
+ break
237
259
  }
238
260
  }
261
+
262
+ if (potentialExpression.size() == 0 || potentialExpression.getType(0) != ReadableType.Map) {
263
+ return false
264
+ }
265
+
266
+ val firstElementMap = potentialExpression.getMap(0)
267
+ ?: return false
268
+
269
+ // A valid expression starts with an operator, which is identified by its type being "string".
270
+ return firstElementMap.getString("type") == "string"
239
271
  }
240
- }
272
+ }
@@ -11,6 +11,8 @@
11
11
  #import <react/renderer/components/rnmapbox_maps_specs/Props.h>
12
12
  #import <react/renderer/components/rnmapbox_maps_specs/RCTComponentViewHelpers.h>
13
13
 
14
+ #import "RNMBXFabricPropConvert.h"
15
+
14
16
  using namespace facebook::react;
15
17
 
16
18
  @interface RNMBXPointAnnotationComponentView () <RCTRNMBXPointAnnotationViewProtocol>
@@ -40,9 +42,9 @@ using namespace facebook::react;
40
42
  - (void)prepareView
41
43
  {
42
44
  _view = [[RNMBXPointAnnotation alloc] init];
43
-
45
+
44
46
  self.contentView = _view;
45
-
47
+
46
48
  // capture weak self reference to prevent retain cycle
47
49
  __weak __typeof__(self) weakSelf = self;
48
50
 
@@ -122,24 +124,14 @@ using namespace facebook::react;
122
124
 
123
125
  - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
124
126
  {
125
- const auto &newProps = static_cast<const RNMBXPointAnnotationProps &>(*props);
126
- id coordinate = RNMBXConvertFollyDynamicToId(newProps.coordinate);
127
- if (coordinate != nil) {
128
- _view.coordinate = coordinate;
129
- }
130
- id draggable = RNMBXConvertFollyDynamicToId(newProps.draggable);
131
- if (draggable != nil) {
132
- _view.draggable = draggable;
133
- }
134
- id idx = RNMBXConvertFollyDynamicToId(newProps.id);
135
- if (idx != nil) {
136
- _view.id = idx;
137
- }
138
- id anchor = RNMBXConvertFollyDynamicToId(newProps.anchor);
139
- if (anchor != nil) {
140
- _view.anchor = anchor;
141
- }
142
-
127
+ const auto &oldViewProps = static_cast<const RNMBXPointAnnotationProps &>(*oldProps);
128
+ const auto &newViewProps = static_cast<const RNMBXPointAnnotationProps &>(*props);
129
+
130
+ RNMBX_OPTIONAL_PROP_NSString(coordinate)
131
+ RNMBX_OPTIONAL_PROP_BOOL(draggable)
132
+ RNMBX_OPTIONAL_PROP_NSString(id)
133
+ RNMBX_OPTIONAL_PROP_NSDictionary(anchor)
134
+
143
135
  [super updateProps:props oldProps:oldProps];
144
136
  }
145
137
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnmapbox/maps",
3
- "version": "10.2.3",
3
+ "version": "10.2.5",
4
4
  "description": "Community-supported, open-source React Native library for building maps using Mapbox native maps SDK for iOS and Android",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.native.d.ts",