@rnmapbox/maps 10.0.7-rc.0 → 10.0.7-rc.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.
@@ -2,21 +2,41 @@ import MapboxMaps
2
2
 
3
3
  class RCTMGLImage : UIView {
4
4
  @objc
5
- var name: String = ""
5
+ var name: String = "" {
6
+ didSet {
7
+ _addImageToStyle()
8
+ }
9
+ }
6
10
 
7
11
  var image: UIImage? = nil
8
12
 
9
13
  @objc
10
- var sdf: Bool = false
14
+ var sdf: Bool = false {
15
+ didSet {
16
+ _addImageToStyle()
17
+ }
18
+ }
11
19
 
12
20
  @objc
13
- var stretchX: [[NSNumber]] = []
21
+ var stretchX: [[NSNumber]] = [] {
22
+ didSet {
23
+ _addImageToStyle()
24
+ }
25
+ }
14
26
 
15
27
  @objc
16
- var stretchY: [[NSNumber]] = []
28
+ var stretchY: [[NSNumber]] = [] {
29
+ didSet {
30
+ _addImageToStyle()
31
+ }
32
+ }
17
33
 
18
34
  @objc
19
- var content: [NSNumber]? = nil
35
+ var content: [NSNumber]? = nil {
36
+ didSet {
37
+ _addImageToStyle()
38
+ }
39
+ }
20
40
 
21
41
  weak var images: RCTMGLImageSetter? = nil {
22
42
  didSet {
@@ -48,12 +68,17 @@ class RCTMGLImage : UIView {
48
68
 
49
69
  // MARK: - view shnapshot
50
70
 
51
- func changeImage(_ image: UIImage, name: String) {
52
- if let images = images {
53
- let _ = images.addImage(name: name, image: image, sdf: sdf, stretchX:stretchX, stretchY:stretchY, content:content, log: "RCTMGLImage.addImage")
71
+ func _addImageToStyle() {
72
+ if let image = self.image, let images = images {
73
+ let _ = images.addImage(name: name, image: image, sdf: sdf, stretchX:stretchX, stretchY:stretchY, content:content, log: "RCTMGLImage._addImageToStyle")
54
74
  }
55
75
  }
56
76
 
77
+ func changeImage(_ image: UIImage, name: String) {
78
+ self.image = image
79
+ _addImageToStyle()
80
+ }
81
+
57
82
  func setImage() {
58
83
  if let image = _createViewSnapshot() {
59
84
  changeImage(image, name: name)
@@ -118,29 +118,34 @@ class RCTMGLImages : UIView, RCTMGLMapComponent {
118
118
  }
119
119
  }
120
120
 
121
- static func convert(stretch: [[NSNumber]], scale: Float = 1.0) -> [(from: Float, to: Float)] {
121
+ static func convert(stretch: [[NSNumber]], scale: CGFloat = 1.0) -> [(from: Float, to: Float)] {
122
122
  return stretch.map{ pair in
123
- return (from: pair[0].floatValue * scale, to: pair[1].floatValue * scale)
123
+ return (from: pair[0].floatValue * Float(scale), to: pair[1].floatValue * Float(scale))
124
124
  }
125
125
  }
126
126
 
127
- static func convert(stretch: [(from: Float, to: Float)]) -> [ImageStretches] {
128
- return stretch.map { v in ImageStretches(first: v.from, second: v.to) }
127
+ static func convert(stretch: [(from: Float, to: Float)], scale: CGFloat = 1.0) -> [ImageStretches] {
128
+ return stretch.map { v in ImageStretches(first: v.from * Float(scale), second: v.to * Float(scale)) }
129
129
  }
130
130
 
131
- static func convert(stretch: [[NSNumber]], scale: Float = 1.0) -> [ImageStretches] {
131
+ static func convert(stretch: [[NSNumber]], scale: CGFloat = 1.0) -> [ImageStretches] {
132
132
  return convert(stretch: convert(stretch: stretch, scale: scale))
133
133
  }
134
+
135
+ static func convert(stretch: [[NSNumber]], scale: Float = 1.0) -> [ImageStretches] {
136
+ return convert(stretch: stretch, scale: CGFloat(scale))
137
+ }
138
+
134
139
 
135
- static func convert(content: (left:Float, top:Float, right:Float, bottom:Float)?) -> ImageContent? {
140
+ static func convert(content: (left:Float, top:Float, right:Float, bottom:Float)?, scale: CGFloat) -> ImageContent? {
136
141
  guard let content = content else {
137
142
  return nil
138
143
  }
139
144
 
140
- return ImageContent(left:content.left, top:content.top, right:content.right, bottom:content.bottom)
145
+ return ImageContent(left:content.left*Float(scale), top:content.top*Float(scale), right:content.right*Float(scale), bottom:content.bottom*Float(scale))
141
146
  }
142
147
 
143
- static func convert(content: [NSNumber]?, scale: Float = 1.0) -> (left:Float,top:Float,right:Float,bottom:Float)? {
148
+ static func convert(content: [NSNumber]?, scale: CGFloat = 1.0) -> (left:Float,top:Float,right:Float,bottom:Float)? {
144
149
  guard let content = content else {
145
150
  return nil
146
151
  }
@@ -149,15 +154,15 @@ class RCTMGLImages : UIView, RCTMGLMapComponent {
149
154
  return nil
150
155
  }
151
156
  return (
152
- left: content[0].floatValue*scale,
153
- top: content[1].floatValue*scale,
154
- right: content[2].floatValue*scale,
155
- bottom: content[3].floatValue*scale
157
+ left: content[0].floatValue*Float(scale),
158
+ top: content[1].floatValue*Float(scale),
159
+ right: content[2].floatValue*Float(scale),
160
+ bottom: content[3].floatValue*Float(scale)
156
161
  )
157
162
  }
158
163
 
159
- static func convert(content: [NSNumber]?, scale: Float = 1.0) -> ImageContent? {
160
- return convert(content: convert(content: content, scale: scale))
164
+ static func convert(content: [NSNumber]?, scale: CGFloat = 1.0) -> ImageContent? {
165
+ return convert(content: convert(content: content, scale: scale), scale: 1.0)
161
166
  }
162
167
 
163
168
  func decodeImage(_ imageNameOrInfo: Any) -> NativeImageInfo? {
@@ -202,9 +207,9 @@ class RCTMGLImages : UIView, RCTMGLMapComponent {
202
207
  if let image = UIImage(named: imageName) {
203
208
  logged("RCTMGLImage.addNativeImage: \(imageName)") {
204
209
  try style.addImage(image, id: imageName, sdf: imageInfo.sdf,
205
- stretchX: RCTMGLImages.convert(stretch: imageInfo.stretchX),
206
- stretchY: RCTMGLImages.convert(stretch: imageInfo.stretchY),
207
- content: RCTMGLImages.convert(content: imageInfo.content)
210
+ stretchX: RCTMGLImages.convert(stretch: imageInfo.stretchX, scale: image.scale),
211
+ stretchY: RCTMGLImages.convert(stretch: imageInfo.stretchY, scale: image.scale),
212
+ content: RCTMGLImages.convert(content: imageInfo.content, scale: image.scale)
208
213
  )
209
214
  }
210
215
  } else {
@@ -230,9 +235,9 @@ extension RCTMGLImages : RCTMGLImageSetter {
230
235
  try style.addImage(image,
231
236
  id:name,
232
237
  sdf: sdf ?? false,
233
- stretchX: RCTMGLImages.convert(stretch: stretchX),
234
- stretchY: RCTMGLImages.convert(stretch: stretchY),
235
- content: RCTMGLImages.convert(content: content)
238
+ stretchX: RCTMGLImages.convert(stretch: stretchX, scale: image.scale),
239
+ stretchY: RCTMGLImages.convert(stretch: stretchY, scale: image.scale),
240
+ content: RCTMGLImages.convert(content: content, scale: image.scale)
236
241
  )
237
242
  return true
238
243
  } else {
@@ -33,10 +33,10 @@ class RCTMGLUtils {
33
33
  let scale = (image["scale"] as? NSNumber)?.floatValue ?? 1.0
34
34
  let sdf = (image["sdf"] as? NSNumber)?.boolValue ?? false
35
35
  let imageStretchX = image["stretchX"] as? [[NSNumber]]
36
- let stretchX: [ImageStretches] = imageStretchX != nil ? RCTMGLImages.convert(stretch: imageStretchX!, scale: scale) : []
36
+ let stretchX: [ImageStretches] = imageStretchX != nil ? RCTMGLImages.convert(stretch: imageStretchX!, scale: CGFloat(scale)) : []
37
37
  let imageStretchY = image["stretchY"] as? [[NSNumber]]
38
- let stretchY: [ImageStretches] = imageStretchY != nil ? RCTMGLImages.convert(stretch: imageStretchY!, scale: scale) : []
39
- let content: ImageContent? = RCTMGLImages.convert(content: image["content"] as? [NSNumber], scale: scale)
38
+ let stretchY: [ImageStretches] = imageStretchY != nil ? RCTMGLImages.convert(stretch: imageStretchY!, scale: CGFloat(scale)) : []
39
+ let content: ImageContent? = RCTMGLImages.convert(content: image["content"] as? [NSNumber], scale: CGFloat(scale))
40
40
 
41
41
  RCTMGLImageQueue.sharedInstance.addImage(objects[imageName], scale: Double(scale), bridge:bridge) {
42
42
  (error,image) in
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rnmapbox/maps",
3
3
  "description": "A Mapbox react native module for creating custom maps",
4
- "version": "10.0.7-rc.0",
4
+ "version": "10.0.7-rc.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -92,11 +92,11 @@ end
92
92
  case $RNMapboxMapsImpl
93
93
  when 'mapbox'
94
94
  rnMapboxMapsTargetsToChangeToDynamic = ['MapboxMobileEvents', 'Turf', 'MapboxMaps', 'MapboxCoreMaps', 'MapboxCommon']
95
- MapboxImplVersion = $RNMapboxMapsVersion || rnMapboxMapsDefaultMapboxVersion
95
+ $MapboxImplVersion = $RNMapboxMapsVersion || rnMapboxMapsDefaultMapboxVersion
96
96
  when 'mapbox-gl'
97
97
  puts 'WARNING: mapbox-gl in @rnmapbox/maps is deprecated. Set $RNMapboxMapsImpl=mapbox in your Podfile. See https://github.com/rnmapbox/maps/wiki/Deprecated-RNMapboxImpl-Maplibre#ios'
98
98
  rnMapboxMapsTargetsToChangeToDynamic = ['MapboxMobileEvents']
99
- MapboxImplVersion = $RNMapboxMapsVersion || rnMapboxMapsDefaultMapboxGLVersion
99
+ $MapboxImplVersion = $RNMapboxMapsVersion || rnMapboxMapsDefaultMapboxGLVersion
100
100
  when 'maplibre'
101
101
  puts 'WARNING: maplibre in @rnmapbox/maps is deprecated. Set $RNMapboxMapsImpl=mapbox in your Podfile. See https://github.com/rnmapbox/maps/wiki/Deprecated-RNMapboxImpl-MapboxGL#ios'
102
102
  rnMapboxMapsTargetsToChangeToDynamic = ['MapboxMobileEvents']
@@ -239,11 +239,11 @@ Pod::Spec.new do |s|
239
239
  unless $RNMapboxMapsSwiftPackageManager
240
240
  case $RNMapboxMapsImpl
241
241
  when 'mapbox'
242
- s.dependency 'MapboxMaps', MapboxImplVersion
242
+ s.dependency 'MapboxMaps', $MapboxImplVersion
243
243
  s.dependency 'Turf'
244
244
  s.swift_version = '5.0'
245
245
  when 'mapbox-gl'
246
- s.dependency 'Mapbox-iOS-SDK', MapboxImplVersion
246
+ s.dependency 'Mapbox-iOS-SDK', $MapboxImplVersion
247
247
  when 'maplibre'
248
248
  fail "internal error: maplibre requires $RNMapboxMapsSwiftPackageManager"
249
249
  else