react-native-fast-image 8.6.20 → 8.6.22
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/dist/index.cjs.js +39 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -5
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -51,7 +51,29 @@ const resolveDefaultSource = defaultSource => {
|
|
|
51
51
|
|
|
52
52
|
|
|
53
53
|
return defaultSource;
|
|
54
|
-
};
|
|
54
|
+
}; // Finds tintColor in a style prop, where the last style that sets it wins, as
|
|
55
|
+
// with StyleSheet.flatten, but without flattening (which allocates a merged
|
|
56
|
+
// object for an array style on every render).
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
function tintColorFromStyle(style) {
|
|
60
|
+
if (Array.isArray(style)) {
|
|
61
|
+
for (let i = style.length - 1; i >= 0; i--) {
|
|
62
|
+
const found = tintColorFromStyle(style[i]);
|
|
63
|
+
if (found !== undefined) return found;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (typeof style === 'number') {
|
|
70
|
+
// A registered style from StyleSheet.create on older React Native.
|
|
71
|
+
const flattened = reactNative.StyleSheet.flatten(style);
|
|
72
|
+
return flattened ? flattened.tintColor : undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return style && typeof style === 'object' ? style.tintColor : undefined;
|
|
76
|
+
}
|
|
55
77
|
|
|
56
78
|
function FastImageBase({
|
|
57
79
|
source,
|
|
@@ -84,7 +106,10 @@ function FastImageBase({
|
|
|
84
106
|
const wrapperProps = {
|
|
85
107
|
onLayout,
|
|
86
108
|
onClick
|
|
87
|
-
};
|
|
109
|
+
}; // tintColor can also be set in style, as with React Native's Image. The
|
|
110
|
+
// prop wins.
|
|
111
|
+
|
|
112
|
+
const resolvedTintColor = tintColor != null ? tintColor : tintColorFromStyle(style);
|
|
88
113
|
|
|
89
114
|
if (fallback) {
|
|
90
115
|
// Remove `cache`, which React Native's Image doesn't support. A
|
|
@@ -98,8 +123,8 @@ function FastImageBase({
|
|
|
98
123
|
}, wrapperProps, {
|
|
99
124
|
ref: forwardedRef
|
|
100
125
|
}), /*#__PURE__*/React__default['default'].createElement(reactNative.Image, _extends__default['default']({}, props, {
|
|
101
|
-
style: [
|
|
102
|
-
tintColor
|
|
126
|
+
style: [styles.fallbackImage, {
|
|
127
|
+
tintColor: resolvedTintColor
|
|
103
128
|
}],
|
|
104
129
|
source: resolvedSource,
|
|
105
130
|
defaultSource: defaultSource,
|
|
@@ -119,7 +144,7 @@ function FastImageBase({
|
|
|
119
144
|
}, wrapperProps, {
|
|
120
145
|
ref: forwardedRef
|
|
121
146
|
}), /*#__PURE__*/React__default['default'].createElement(FastImageView, _extends__default['default']({}, props, {
|
|
122
|
-
tintColor:
|
|
147
|
+
tintColor: resolvedTintColor,
|
|
123
148
|
style: reactNative.StyleSheet.absoluteFill,
|
|
124
149
|
source: resolvedSource,
|
|
125
150
|
defaultSource: resolvedDefaultSource,
|
|
@@ -149,6 +174,15 @@ FastImage.clearMemoryCache = () => reactNative.NativeModules.FastImageView.clear
|
|
|
149
174
|
FastImage.clearDiskCache = () => reactNative.NativeModules.FastImageView.clearDiskCache();
|
|
150
175
|
|
|
151
176
|
const styles = reactNative.StyleSheet.create({
|
|
177
|
+
// React Native's Image sizes itself from a require()d source's width and
|
|
178
|
+
// height unless the style sets them, which would override absoluteFill.
|
|
179
|
+
fallbackImage: {
|
|
180
|
+
position: 'absolute',
|
|
181
|
+
top: 0,
|
|
182
|
+
left: 0,
|
|
183
|
+
width: '100%',
|
|
184
|
+
height: '100%'
|
|
185
|
+
},
|
|
152
186
|
imageContainer: {
|
|
153
187
|
overflow: 'hidden'
|
|
154
188
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -52,6 +52,7 @@ export interface ImageStyle extends ViewStyle {
|
|
|
52
52
|
borderTopLeftRadius?: number;
|
|
53
53
|
borderTopRightRadius?: number;
|
|
54
54
|
overlayColor?: ColorValue;
|
|
55
|
+
tintColor?: ColorValue;
|
|
55
56
|
opacity?: number;
|
|
56
57
|
}
|
|
57
58
|
export interface FastImageProps extends AccessibilityProps, ViewProps {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAA;AAC/C,OAAO,EAMH,iBAAiB,EACjB,SAAS,EACT,SAAS,EACT,kBAAkB,EAElB,kBAAkB,EAClB,SAAS,EACZ,MAAM,cAAc,CAAA;AAKrB,aAAK,UAAU,GAAG,WAAW,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAA;AAE3D,oBAAY,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAA;AAEnE,QAAA,MAAM,UAAU;;;;;CAKN,CAAA;AAEV,oBAAY,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAA;AAEhD,QAAA,MAAM,QAAQ;;;;CAIJ,CAAA;AAEV,oBAAY,KAAK,GAAG,WAAW,GAAG,KAAK,GAAG,WAAW,CAAA;AAErD,QAAA,MAAM,YAAY;;;;CAOR,CAAA;AAEV,oBAAY,MAAM,GAAG;IACjB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IACnC,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,KAAK,CAAC,EAAE,KAAK,CAAA;CAChB,CAAA;AAED,MAAM,WAAW,WAAW;IACxB,WAAW,EAAE;QACT,KAAK,EAAE,MAAM,CAAA;QACb,MAAM,EAAE,MAAM,CAAA;QAGd,MAAM,CAAC,EAAE,MAAM,CAAA;KAClB,CAAA;C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M,CAAA;IAEf;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC7B;AAuJD,MAAM,WAAW,yBAAyB;IACtC,UAAU,EAAE,OAAO,UAAU,CAAA;IAC7B,QAAQ,EAAE,OAAO,QAAQ,CAAA;IACzB,YAAY,EAAE,OAAO,YAAY,CAAA;IACjC,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IACpC,gBAAgB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IACrC,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CACtC;AAED,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,GAChD,yBAAqD,CAAA;AA8CzD,eAAe,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -44,7 +44,29 @@ const resolveDefaultSource = defaultSource => {
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
return defaultSource;
|
|
47
|
-
};
|
|
47
|
+
}; // Finds tintColor in a style prop, where the last style that sets it wins, as
|
|
48
|
+
// with StyleSheet.flatten, but without flattening (which allocates a merged
|
|
49
|
+
// object for an array style on every render).
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
function tintColorFromStyle(style) {
|
|
53
|
+
if (Array.isArray(style)) {
|
|
54
|
+
for (let i = style.length - 1; i >= 0; i--) {
|
|
55
|
+
const found = tintColorFromStyle(style[i]);
|
|
56
|
+
if (found !== undefined) return found;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (typeof style === 'number') {
|
|
63
|
+
// A registered style from StyleSheet.create on older React Native.
|
|
64
|
+
const flattened = StyleSheet.flatten(style);
|
|
65
|
+
return flattened ? flattened.tintColor : undefined;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return style && typeof style === 'object' ? style.tintColor : undefined;
|
|
69
|
+
}
|
|
48
70
|
|
|
49
71
|
function FastImageBase({
|
|
50
72
|
source,
|
|
@@ -77,7 +99,10 @@ function FastImageBase({
|
|
|
77
99
|
const wrapperProps = {
|
|
78
100
|
onLayout,
|
|
79
101
|
onClick
|
|
80
|
-
};
|
|
102
|
+
}; // tintColor can also be set in style, as with React Native's Image. The
|
|
103
|
+
// prop wins.
|
|
104
|
+
|
|
105
|
+
const resolvedTintColor = tintColor != null ? tintColor : tintColorFromStyle(style);
|
|
81
106
|
|
|
82
107
|
if (fallback) {
|
|
83
108
|
// Remove `cache`, which React Native's Image doesn't support. A
|
|
@@ -91,8 +116,8 @@ function FastImageBase({
|
|
|
91
116
|
}, wrapperProps, {
|
|
92
117
|
ref: forwardedRef
|
|
93
118
|
}), /*#__PURE__*/React.createElement(Image, _extends({}, props, {
|
|
94
|
-
style: [
|
|
95
|
-
tintColor
|
|
119
|
+
style: [styles.fallbackImage, {
|
|
120
|
+
tintColor: resolvedTintColor
|
|
96
121
|
}],
|
|
97
122
|
source: resolvedSource,
|
|
98
123
|
defaultSource: defaultSource,
|
|
@@ -112,7 +137,7 @@ function FastImageBase({
|
|
|
112
137
|
}, wrapperProps, {
|
|
113
138
|
ref: forwardedRef
|
|
114
139
|
}), /*#__PURE__*/React.createElement(FastImageView, _extends({}, props, {
|
|
115
|
-
tintColor:
|
|
140
|
+
tintColor: resolvedTintColor,
|
|
116
141
|
style: StyleSheet.absoluteFill,
|
|
117
142
|
source: resolvedSource,
|
|
118
143
|
defaultSource: resolvedDefaultSource,
|
|
@@ -142,6 +167,15 @@ FastImage.clearMemoryCache = () => NativeModules.FastImageView.clearMemoryCache(
|
|
|
142
167
|
FastImage.clearDiskCache = () => NativeModules.FastImageView.clearDiskCache();
|
|
143
168
|
|
|
144
169
|
const styles = StyleSheet.create({
|
|
170
|
+
// React Native's Image sizes itself from a require()d source's width and
|
|
171
|
+
// height unless the style sets them, which would override absoluteFill.
|
|
172
|
+
fallbackImage: {
|
|
173
|
+
position: 'absolute',
|
|
174
|
+
top: 0,
|
|
175
|
+
left: 0,
|
|
176
|
+
width: '100%',
|
|
177
|
+
height: '100%'
|
|
178
|
+
},
|
|
145
179
|
imageContainer: {
|
|
146
180
|
overflow: 'hidden'
|
|
147
181
|
}
|