react-native-fast-image 9.2.2 → 9.3.0

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.
@@ -224,7 +224,7 @@ static UIImage* FFFBlurredImage(UIImage* image, CGFloat scale, CGFloat radius, B
224
224
  }
225
225
  }
226
226
 
227
- - (void) setResizeMode: (RCTResizeMode)resizeMode {
227
+ - (void) setResizeMode: (FFFResizeMode)resizeMode {
228
228
  if (_resizeMode != resizeMode) {
229
229
  BOOL repeated = _resizeMode == RCTResizeModeRepeat;
230
230
  _resizeMode = resizeMode;
@@ -242,10 +242,13 @@ static UIImage* FFFBlurredImage(UIImage* image, CGFloat scale, CGFloat radius, B
242
242
  // view down to fit, as React Native's Image and Android do (#866); only a
243
243
  // smaller one is shown at its own size. UIViewContentModeCenter alone showed
244
244
  // large images at full size, cropped. So it depends on the image and the
245
- // view's size.
245
+ // view's size. `none` is the image at its own size, centered, whatever its
246
+ // size (cropped by the view).
246
247
  - (void) updateContentMode {
247
248
  UIViewContentMode contentMode = (UIViewContentMode) _resizeMode;
248
- if (_resizeMode == RCTResizeModeRepeat) {
249
+ if (_resizeMode == FFFResizeModeNone) {
250
+ contentMode = UIViewContentModeCenter;
251
+ } else if (_resizeMode == RCTResizeModeRepeat) {
249
252
  // The tiled image (see tiledImage:) fills the view.
250
253
  contentMode = UIViewContentModeScaleToFill;
251
254
  } else if (_resizeMode == RCTResizeModeCenter) {
@@ -803,9 +806,10 @@ NSString *FFFErrorMessage(NSError *error)
803
806
  // Whether images are decoded at about the view's size (downsample, from
804
807
  // SDWebImage 5.19, and always for photo library images, which are large and
805
808
  // usually shown small: Photos makes them at the size asked for, on any
806
- // version). Not for `repeat`, which tiles the image at its own size.
809
+ // version). Not for `repeat`, which tiles the image at its own size, or
810
+ // `none`, which shows it at its own size.
807
811
  - (BOOL) downsamples {
808
- if (_resizeMode == RCTResizeModeRepeat) {
812
+ if (_resizeMode == RCTResizeModeRepeat || _resizeMode == FFFResizeModeNone) {
809
813
  return NO;
810
814
  }
811
815
  return [_source isPhotoLibrary] || (_downsample && [FFFDownsampledImage isSupported]);
@@ -1009,6 +1013,7 @@ NSString *FFFErrorMessage(NSError *error)
1009
1013
  // Only on disk, also when it comes from there.
1010
1014
  context[SDWebImageContextStoreCacheType] = @(SDImageCacheTypeDisk);
1011
1015
  }
1016
+ [FFFDownsampledImage forgetSmallerFullSizeImageForURL: source.url context: context];
1012
1017
  return context;
1013
1018
  }
1014
1019
  [FFFDownsampledImage addToContext: context box: box cover: cover];
@@ -103,7 +103,7 @@ RCT_EXPORT_MODULE(FastImageView)
103
103
  RCT_EXPORT_VIEW_PROPERTY(source, FFFastImageSource)
104
104
  RCT_EXPORT_VIEW_PROPERTY(sources, FFFastImageSourceArray)
105
105
  RCT_EXPORT_VIEW_PROPERTY(defaultSource, UIImage)
106
- RCT_EXPORT_VIEW_PROPERTY(resizeMode, RCTResizeMode)
106
+ RCT_EXPORT_VIEW_PROPERTY(resizeMode, FFFResizeMode)
107
107
  RCT_EXPORT_VIEW_PROPERTY(recyclingKey, NSString)
108
108
  RCT_EXPORT_VIEW_PROPERTY(loopCount, NSInteger)
109
109
  RCT_EXPORT_VIEW_PROPERTY(imageRendering, NSString)
@@ -288,6 +288,8 @@ RCT_EXPORT_METHOD(preload:(nonnull NSArray<FFFastImageSource *> *)sources
288
288
  [results addObject:[NSNull null]];
289
289
  SDWebImageOptions options = FFFPreloadOptions(source);
290
290
  SDWebImageMutableContext *context = FFFPreloadContext(source);
291
+ // It looks in the memory cache first, for the full-size image.
292
+ [FFFDownsampledImage forgetSmallerFullSizeImageForURL:source.url context:context];
291
293
  if (!source.memoryCache) {
292
294
  // Not decoded (only its header is read, for the size), and not
293
295
  // kept in memory, also when it comes from the disk cache.
@@ -1,9 +1,12 @@
1
1
  #import <React/RCTConvert.h>
2
2
 
3
+ #import "FFFastImageView.h"
4
+
3
5
  @class FFFastImageSource;
4
6
 
5
7
  @interface RCTConvert (FFFastImage)
6
8
 
9
+ + (FFFResizeMode)FFFResizeMode:(id)json;
7
10
  + (FFFastImageSource *)FFFastImageSource:(id)json;
8
11
  + (NSArray<FFFastImageSource *> *)FFFastImageSourceArray:(id)json;
9
12
 
@@ -3,6 +3,17 @@
3
3
 
4
4
  @implementation RCTConvert (FFFastImage)
5
5
 
6
+ RCT_ENUM_CONVERTER(FFFResizeMode, (@{
7
+ @"cover": @(RCTResizeModeCover),
8
+ @"contain": @(RCTResizeModeContain),
9
+ @"stretch": @(RCTResizeModeStretch),
10
+ @"center": @(RCTResizeModeCenter),
11
+ // objectFit="scale-down": as center on iOS.
12
+ @"scale-down": @(RCTResizeModeCenter),
13
+ @"repeat": @(RCTResizeModeRepeat),
14
+ @"none": @(FFFResizeModeNone),
15
+ }), RCTResizeModeCover, integerValue);
16
+
6
17
  RCT_ENUM_CONVERTER(FFFPriority, (@{
7
18
  @"low": @(FFFPriorityLow),
8
19
  @"normal": @(FFFPriorityNormal),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-fast-image",
3
- "version": "9.2.2",
3
+ "version": "9.3.0",
4
4
  "description": "FastImage, performant React Native image component.",
5
5
  "keywords": [
6
6
  "cache",