RCTImageSource.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #import <Foundation/Foundation.h>
  8. #import <React/RCTConvert.h>
  9. /**
  10. * Object containing an image URL and associated metadata.
  11. */
  12. @interface RCTImageSource : NSObject
  13. @property (nonatomic, copy, readonly) NSURLRequest *request;
  14. @property (nonatomic, assign, readonly) CGSize size;
  15. @property (nonatomic, assign, readonly) CGFloat scale;
  16. /**
  17. * Create a new image source object.
  18. * Pass a size of CGSizeZero if you do not know or wish to specify the image
  19. * size. Pass a scale of zero if you do not know or wish to specify the scale.
  20. */
  21. - (instancetype)initWithURLRequest:(NSURLRequest *)request size:(CGSize)size scale:(CGFloat)scale;
  22. /**
  23. * Create a copy of the image source with the specified size and scale.
  24. */
  25. - (instancetype)imageSourceWithSize:(CGSize)size scale:(CGFloat)scale;
  26. @end
  27. @interface RCTConvert (ImageSource)
  28. + (RCTImageSource *)RCTImageSource:(id)json;
  29. + (NSArray<RCTImageSource *> *)RCTImageSourceArray:(id)json;
  30. @end