expo-image 1.3.0 → 1.3.2

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/CHANGELOG.md CHANGED
@@ -10,6 +10,18 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 1.3.2 — 2023-07-12
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - [iOS] Fixed `tintColor` prop not working for SVGs. ([#23418](https://github.com/expo/expo/pull/23418) by [@tsapeta](https://github.com/tsapeta))
18
+
19
+ ## 1.3.1 — 2023-06-29
20
+
21
+ ### 🐛 Bug fixes
22
+
23
+ - Fixed an issue where recyclingKey would reset the image source on mount. ([#23187](https://github.com/expo/expo/pull/23187) by [@hirbod](https://github.com/hirbod))
24
+
13
25
  ## 1.3.0 — 2023-06-13
14
26
 
15
27
  ### 🎉 New features
@@ -50,7 +50,7 @@ android {
50
50
  minSdkVersion safeExtGet("minSdkVersion", 21)
51
51
  targetSdkVersion safeExtGet("targetSdkVersion", 33)
52
52
  versionCode 1
53
- versionName "1.3.0"
53
+ versionName "1.3.2"
54
54
  }
55
55
  lintOptions {
56
56
  abortOnError false
@@ -151,7 +151,7 @@ class ExpoImageViewWrapper(context: Context, appContext: AppContext) : ExpoView(
151
151
 
152
152
  var recyclingKey: String? = null
153
153
  set(value) {
154
- clearViewBeforeChangingSource = value != null && value != field
154
+ clearViewBeforeChangingSource = field != null && value != null && value != field
155
155
  field = value
156
156
  }
157
157
 
@@ -54,7 +54,7 @@ public final class ImageModule: Module {
54
54
  }
55
55
 
56
56
  Prop("tintColor") { (view, tintColor: UIColor?) in
57
- view.imageTintColor = tintColor ?? .clear
57
+ view.imageTintColor = tintColor
58
58
  }
59
59
 
60
60
  Prop("priority") { (view, priority: ImagePriority?) in
@@ -37,13 +37,13 @@ public final class ImageView: ExpoView {
37
37
 
38
38
  var blurRadius: CGFloat = 0.0
39
39
 
40
- var imageTintColor: UIColor = .clear
40
+ var imageTintColor: UIColor?
41
41
 
42
42
  var cachePolicy: ImageCachePolicy = .disk
43
43
 
44
44
  var recyclingKey: String? {
45
45
  didSet {
46
- if recyclingKey != oldValue {
46
+ if oldValue != nil && recyclingKey != oldValue {
47
47
  sdImageView.image = nil
48
48
  }
49
49
  }
@@ -128,6 +128,18 @@ public final class ImageView: ExpoView {
128
128
  // incorrectly rendered images for resize modes that don't scale (`center` and `repeat`).
129
129
  context[.imageScaleFactor] = source.scale
130
130
 
131
+ // It seems that `UIImageView` can't tint some vector graphics. If the `tintColor` prop is specified,
132
+ // we tell the SVG coder to decode to a bitmap instead. This will become useless when we switch to SVGNative coder.
133
+ if imageTintColor != nil {
134
+ context[.imageDecodeOptions] = [
135
+ SDImageCoderOption.webImageContext: [
136
+ "svgPrefersBitmap": true,
137
+ "svgImageSize": sdImageView.bounds.size,
138
+ "svgImagePreserveAspectRatio": true
139
+ ]
140
+ ]
141
+ }
142
+
131
143
  if source.isCachingAllowed {
132
144
  let sdCacheType = cachePolicy.toSdCacheType().rawValue
133
145
  context[.originalQueryCacheType] = sdCacheType
@@ -297,15 +309,14 @@ public final class ImageView: ExpoView {
297
309
  guard isViewEmpty || !hasAnySource, let placeholder = placeholderImage else {
298
310
  return
299
311
  }
300
- setImage(placeholder, contentFit: placeholderContentFit)
312
+ setImage(placeholder, contentFit: placeholderContentFit, isPlaceholder: true)
301
313
  }
302
314
 
303
315
  // MARK: - Processing
304
316
 
305
317
  private func createTransformPipeline() -> SDImagePipelineTransformer {
306
318
  let transformers: [SDImageTransformer] = [
307
- SDImageBlurTransformer(radius: blurRadius),
308
- SDImageTintTransformer(color: imageTintColor)
319
+ SDImageBlurTransformer(radius: blurRadius)
309
320
  ]
310
321
  return SDImagePipelineTransformer(transformers: transformers)
311
322
  }
@@ -338,17 +349,24 @@ public final class ImageView: ExpoView {
338
349
 
339
350
  UIView.transition(with: sdImageView, duration: seconds, options: options) { [weak self] in
340
351
  if let self = self {
341
- self.setImage(image, contentFit: self.contentFit)
352
+ self.setImage(image, contentFit: self.contentFit, isPlaceholder: false)
342
353
  }
343
354
  }
344
355
  } else {
345
- setImage(image, contentFit: contentFit)
356
+ setImage(image, contentFit: contentFit, isPlaceholder: false)
346
357
  }
347
358
  }
348
359
 
349
- private func setImage(_ image: UIImage?, contentFit: ContentFit) {
360
+ private func setImage(_ image: UIImage?, contentFit: ContentFit, isPlaceholder: Bool) {
350
361
  sdImageView.contentMode = contentFit.toContentMode()
351
- sdImageView.image = image
362
+
363
+ if let imageTintColor, !isPlaceholder {
364
+ sdImageView.tintColor = imageTintColor
365
+ sdImageView.image = image?.withRenderingMode(.alwaysTemplate)
366
+ } else {
367
+ sdImageView.tintColor = nil
368
+ sdImageView.image = image
369
+ }
352
370
 
353
371
  if enableLiveTextInteraction {
354
372
  analyzeImage()
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "expo-image",
3
3
  "title": "Expo Image",
4
- "version": "1.3.0",
4
+ "version": "1.3.2",
5
5
  "description": "A cross-platform, performant image component for React Native and Expo with Web support",
6
6
  "main": "build/index.js",
7
7
  "types": "build/index.d.ts",
@@ -33,5 +33,5 @@
33
33
  "peerDependencies": {
34
34
  "expo": "*"
35
35
  },
36
- "gitHead": "3ccd2edee9cbfed217557675cb50f0ba5e55a9e4"
36
+ "gitHead": "8fdc53c90c52242a80ea511ee3073d9ab950bc68"
37
37
  }