react-native-fast-image 8.6.18 → 8.6.20
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 +3 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/ios/FastImage/FFFastImageView.m +23 -8
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -9,6 +9,9 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
9
|
var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
|
|
10
10
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
11
11
|
|
|
12
|
+
// from ViewStyle so the types also work with older React Native types, where
|
|
13
|
+
// it's string.
|
|
14
|
+
|
|
12
15
|
const resizeMode = {
|
|
13
16
|
contain: 'contain',
|
|
14
17
|
cover: 'cover',
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { LayoutChangeEvent, StyleProp, ViewStyle, ImageRequireSource, AccessibilityProps, ViewProps
|
|
2
|
+
import { LayoutChangeEvent, StyleProp, ViewStyle, ImageRequireSource, AccessibilityProps, ViewProps } from 'react-native';
|
|
3
|
+
declare type ColorValue = NonNullable<ViewStyle['backgroundColor']>;
|
|
3
4
|
export declare type ResizeMode = 'contain' | 'cover' | 'stretch' | 'center';
|
|
4
5
|
declare const resizeMode: {
|
|
5
6
|
readonly contain: "contain";
|
|
@@ -44,13 +45,13 @@ export interface ImageStyle extends ViewStyle {
|
|
|
44
45
|
backfaceVisibility?: 'visible' | 'hidden';
|
|
45
46
|
borderBottomLeftRadius?: number;
|
|
46
47
|
borderBottomRightRadius?: number;
|
|
47
|
-
backgroundColor?:
|
|
48
|
-
borderColor?:
|
|
48
|
+
backgroundColor?: ColorValue;
|
|
49
|
+
borderColor?: ColorValue;
|
|
49
50
|
borderWidth?: number;
|
|
50
51
|
borderRadius?: number;
|
|
51
52
|
borderTopLeftRadius?: number;
|
|
52
53
|
borderTopRightRadius?: number;
|
|
53
|
-
overlayColor?:
|
|
54
|
+
overlayColor?: ColorValue;
|
|
54
55
|
opacity?: number;
|
|
55
56
|
}
|
|
56
57
|
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,
|
|
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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AAI,CAAA;IAEhB,SAAS,CAAC,IAAI,IAAI,CAAA;IAElB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,CAAA;IAE7C;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,UAAU,CAAC,CAAA;IAE7B;;;;OAIG;IAEH,SAAS,CAAC,EAAE,UAAU,CAAA;IAEtB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC7B;AAyHD,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;AAqCzD,eAAe,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,9 @@ import _extends from '@babel/runtime/helpers/extends';
|
|
|
2
2
|
import React, { forwardRef, memo } from 'react';
|
|
3
3
|
import { NativeModules, StyleSheet, requireNativeComponent, Image, View, Platform } from 'react-native';
|
|
4
4
|
|
|
5
|
+
// from ViewStyle so the types also work with older React Native types, where
|
|
6
|
+
// it's string.
|
|
7
|
+
|
|
5
8
|
const resizeMode = {
|
|
6
9
|
contain: 'contain',
|
|
7
10
|
cover: 'cover',
|
|
@@ -236,18 +236,33 @@
|
|
|
236
236
|
|
|
237
237
|
- (void) downloadImage: (FFFastImageSource*)source options: (SDWebImageOptions)options context: (SDWebImageContext*)context {
|
|
238
238
|
__weak typeof(self) weakSelf = self; // Always use a weak reference to self in blocks
|
|
239
|
+
// Most images have no onProgress, so only ask SDWebImage for progress when
|
|
240
|
+
// there's a handler as the load starts. A handler added while loading is
|
|
241
|
+
// used from the next load.
|
|
242
|
+
SDImageLoaderProgressBlock progress = nil;
|
|
243
|
+
if (self.onFastImageProgress) {
|
|
244
|
+
progress = ^(NSInteger receivedSize, NSInteger expectedSize, NSURL* _Nullable targetURL) {
|
|
245
|
+
// SDWebImage calls this on its download queue, while React Native
|
|
246
|
+
// sets onFastImageProgress (and deallocates the view) on the main
|
|
247
|
+
// queue. Read and call it there, so it can't change or be released
|
|
248
|
+
// in between (EXC_BAD_ACCESS).
|
|
249
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
250
|
+
RCTDirectEventBlock onProgress = weakSelf.onFastImageProgress;
|
|
251
|
+
if (onProgress) {
|
|
252
|
+
onProgress(@{
|
|
253
|
+
@"loaded": @(receivedSize),
|
|
254
|
+
@"total": @(expectedSize)
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
};
|
|
259
|
+
}
|
|
239
260
|
[self sd_setImageWithURL: _source.url
|
|
240
261
|
placeholderImage: _defaultSource
|
|
241
262
|
options: options
|
|
242
263
|
context: context
|
|
243
|
-
progress:
|
|
244
|
-
|
|
245
|
-
weakSelf.onFastImageProgress(@{
|
|
246
|
-
@"loaded": @(receivedSize),
|
|
247
|
-
@"total": @(expectedSize)
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
} completed: ^(UIImage* _Nullable image,
|
|
264
|
+
progress: progress
|
|
265
|
+
completed: ^(UIImage* _Nullable image,
|
|
251
266
|
NSError* _Nullable error,
|
|
252
267
|
SDImageCacheType cacheType,
|
|
253
268
|
NSURL* _Nullable imageURL) {
|