expo-image 1.12.8 → 1.12.10
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 +12 -0
- package/android/build.gradle +1 -1
- package/ios/ExpoImage.podspec +7 -0
- package/ios/ImageUtils.swift +1 -1
- package/ios/Tests/ImageResizingSpec.swift +130 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,18 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 1.12.10 — 2024-06-05
|
|
14
|
+
|
|
15
|
+
### 💡 Others
|
|
16
|
+
|
|
17
|
+
- Pin @react-native subpackage versions to 0.74.83. ([#29441](https://github.com/expo/expo/pull/29441) by [@kudo](https://github.com/kudo))
|
|
18
|
+
|
|
19
|
+
## 1.12.9 — 2024-05-09
|
|
20
|
+
|
|
21
|
+
### 💡 Others
|
|
22
|
+
|
|
23
|
+
- Added setup for native unit tests. ([#28678](https://github.com/expo/expo/pull/28678) by [@tsapeta](https://github.com/tsapeta))
|
|
24
|
+
|
|
13
25
|
## 1.12.8 — 2024-05-06
|
|
14
26
|
|
|
15
27
|
_This version does not introduce any user-facing changes._
|
package/android/build.gradle
CHANGED
|
@@ -18,7 +18,7 @@ android {
|
|
|
18
18
|
namespace "expo.modules.image"
|
|
19
19
|
defaultConfig {
|
|
20
20
|
versionCode 1
|
|
21
|
-
versionName "1.12.
|
|
21
|
+
versionName "1.12.10"
|
|
22
22
|
consumerProguardFiles("proguard-rules.pro")
|
|
23
23
|
|
|
24
24
|
buildConfigField("boolean", "ALLOW_GLIDE_LOGS", project.properties.get("EXPO_ALLOW_GLIDE_LOGS", "false"))
|
package/ios/ExpoImage.podspec
CHANGED
package/ios/ImageUtils.swift
CHANGED
|
@@ -58,7 +58,7 @@ func imageFormatToMediaType(_ format: SDImageFormat) -> String? {
|
|
|
58
58
|
/**
|
|
59
59
|
Calculates the ideal size that fills in the container size while maintaining the source aspect ratio.
|
|
60
60
|
*/
|
|
61
|
-
func idealSize(contentPixelSize: CGSize, containerSize: CGSize, scale: Double, contentFit: ContentFit) -> CGSize {
|
|
61
|
+
func idealSize(contentPixelSize: CGSize, containerSize: CGSize, scale: Double = 1.0, contentFit: ContentFit) -> CGSize {
|
|
62
62
|
switch contentFit {
|
|
63
63
|
case .contain:
|
|
64
64
|
let aspectRatio = min(containerSize.width / contentPixelSize.width, containerSize.height / contentPixelSize.height)
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import ExpoModulesTestCore
|
|
2
|
+
|
|
3
|
+
@testable import ExpoModulesCore
|
|
4
|
+
@testable import ExpoImage
|
|
5
|
+
|
|
6
|
+
class ImageResizingSpec: ExpoSpec {
|
|
7
|
+
override class func spec() {
|
|
8
|
+
describe("ideal size") {
|
|
9
|
+
// For simplicity use the same container size for all tests
|
|
10
|
+
let containerSize = CGSize(width: 150, height: 100)
|
|
11
|
+
|
|
12
|
+
context("content size is 300x200") {
|
|
13
|
+
let contentSize = CGSize(width: 300, height: 200)
|
|
14
|
+
let aspectRatio = contentSize.width / contentSize.height
|
|
15
|
+
|
|
16
|
+
it("contains") {
|
|
17
|
+
let size = idealSize(contentPixelSize: contentSize, containerSize: containerSize, contentFit: .contain)
|
|
18
|
+
expect(size.width) == containerSize.width // 150
|
|
19
|
+
expect(size.height) == containerSize.height // 100
|
|
20
|
+
expect(size.width / size.height) == aspectRatio // 1.5
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
it("covers") {
|
|
24
|
+
let size = idealSize(contentPixelSize: contentSize, containerSize: containerSize, contentFit: .cover)
|
|
25
|
+
expect(size.width) == containerSize.width // 150
|
|
26
|
+
expect(size.height) == containerSize.height // 100
|
|
27
|
+
expect(size.width / size.height) == aspectRatio // 1.5
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
it("fills") {
|
|
31
|
+
let size = idealSize(contentPixelSize: contentSize, containerSize: containerSize, contentFit: .fill)
|
|
32
|
+
expect(size.width) == containerSize.width // 150
|
|
33
|
+
expect(size.height) == containerSize.height // 100
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
it("scales down") {
|
|
37
|
+
// Behaves like 'contain' content fit
|
|
38
|
+
let size = idealSize(contentPixelSize: contentSize, containerSize: containerSize, contentFit: .scaleDown)
|
|
39
|
+
expect(size.width) == containerSize.width // 150
|
|
40
|
+
expect(size.height) == containerSize.height // 100
|
|
41
|
+
expect(size.width / size.height) == aspectRatio // 1.5
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
it("doesn't resize") {
|
|
45
|
+
let size = idealSize(contentPixelSize: contentSize, containerSize: containerSize, contentFit: .none)
|
|
46
|
+
expect(size.width) == contentSize.width // 300
|
|
47
|
+
expect(size.height) == contentSize.height // 200
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
context("content size is 168x412") {
|
|
52
|
+
let contentSize = CGSize(width: 168, height: 412)
|
|
53
|
+
let aspectRatio = contentSize.width / contentSize.height
|
|
54
|
+
|
|
55
|
+
it("contains") {
|
|
56
|
+
let size = idealSize(contentPixelSize: contentSize, containerSize: containerSize, contentFit: .contain)
|
|
57
|
+
expect(size.width) == (expected: containerSize.height * aspectRatio, delta: 0.0001) // ~40.77
|
|
58
|
+
expect(size.height) == containerSize.height // 100
|
|
59
|
+
expect(size.width / size.height) == (expected: aspectRatio, delta: 0.0001) // ~0.40
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
it("covers") {
|
|
63
|
+
let size = idealSize(contentPixelSize: contentSize, containerSize: containerSize, contentFit: .cover)
|
|
64
|
+
expect(size.width) == containerSize.width // 150
|
|
65
|
+
expect(size.height) == (expected: containerSize.width / aspectRatio, delta: 0.0001) // ~367.85
|
|
66
|
+
expect(size.width / size.height) == aspectRatio // ~0.40
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
it("fills") {
|
|
70
|
+
let size = idealSize(contentPixelSize: contentSize, containerSize: containerSize, contentFit: .fill)
|
|
71
|
+
expect(size.width) == containerSize.width // 150
|
|
72
|
+
expect(size.height) == containerSize.height // 100
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
it("scales down") {
|
|
76
|
+
// Behaves like 'contain' content fit
|
|
77
|
+
let size = idealSize(contentPixelSize: contentSize, containerSize: containerSize, contentFit: .scaleDown)
|
|
78
|
+
expect(size.width) == (expected: containerSize.height * aspectRatio, delta: 0.0001) // ~40.77
|
|
79
|
+
expect(size.height) == containerSize.height // 100
|
|
80
|
+
expect(size.width / size.height) == (expected: aspectRatio, delta: 0.0001) // ~0.40
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
it("doesn't resize") {
|
|
84
|
+
let size = idealSize(contentPixelSize: contentSize, containerSize: containerSize, contentFit: .none)
|
|
85
|
+
expect(size.width) == contentSize.width // 168
|
|
86
|
+
expect(size.height) == contentSize.height // 412
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
context("content size is 37x21") {
|
|
91
|
+
let contentSize = CGSize(width: 37, height: 21)
|
|
92
|
+
let aspectRatio = contentSize.width / contentSize.height
|
|
93
|
+
|
|
94
|
+
it("contains") {
|
|
95
|
+
let size = idealSize(contentPixelSize: contentSize, containerSize: containerSize, contentFit: .contain)
|
|
96
|
+
expect(size.width) == containerSize.width // 150
|
|
97
|
+
expect(size.height) == (expected: containerSize.width / aspectRatio, delta: 0.0001) // ~85.13
|
|
98
|
+
expect(size.width / size.height) == (expected: aspectRatio, delta: 0.0001) // ~1.76
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
it("covers") {
|
|
102
|
+
let size = idealSize(contentPixelSize: contentSize, containerSize: containerSize, contentFit: .cover)
|
|
103
|
+
expect(size.width) == containerSize.height * aspectRatio // ~176.19
|
|
104
|
+
expect(size.height) == containerSize.height // 100
|
|
105
|
+
expect(size.width / size.height) == aspectRatio // ~1.76
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
it("fills") {
|
|
109
|
+
let size = idealSize(contentPixelSize: contentSize, containerSize: containerSize, contentFit: .fill)
|
|
110
|
+
expect(size.width) == containerSize.width // 150
|
|
111
|
+
expect(size.height) == containerSize.height // 100
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
it("scales down") {
|
|
115
|
+
// Behaves like `none` content fit
|
|
116
|
+
let size = idealSize(contentPixelSize: contentSize, containerSize: containerSize, contentFit: .scaleDown)
|
|
117
|
+
expect(size.width) == contentSize.width // 37
|
|
118
|
+
expect(size.height) == contentSize.height // 21
|
|
119
|
+
expect(size.width / size.height) == aspectRatio // ~1.76
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
it("doesn't resize") {
|
|
123
|
+
let size = idealSize(contentPixelSize: contentSize, containerSize: containerSize, contentFit: .none)
|
|
124
|
+
expect(size.width) == contentSize.width // 37
|
|
125
|
+
expect(size.height) == contentSize.height // 21
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-image",
|
|
3
3
|
"title": "Expo Image",
|
|
4
|
-
"version": "1.12.
|
|
4
|
+
"version": "1.12.10",
|
|
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",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"author": "650 Industries, Inc.",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@react-native/assets-registry": "
|
|
30
|
+
"@react-native/assets-registry": "0.74.83"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"expo-module-scripts": "^3.0.0"
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"expo": "*"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "01afaad3852d3af00238b2e28ea6e13db6f0a1f8"
|
|
39
39
|
}
|