ImageViewNativeComponent.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. * @format
  8. * @flow strict-local
  9. */
  10. 'use strict';
  11. const requireNativeComponent = require('../ReactNative/requireNativeComponent');
  12. import type {DangerouslyImpreciseStyle} from '../StyleSheet/StyleSheet';
  13. import type {ResolvedAssetSource} from './AssetSourceResolver';
  14. import type {HostComponent} from '../Renderer/shims/ReactNativeTypes';
  15. import type {ImageProps} from './ImageProps';
  16. import type {ViewProps} from '../Components/View/ViewPropTypes';
  17. import type {ImageStyleProp} from '../StyleSheet/StyleSheet';
  18. import type {ColorValue} from '../StyleSheet/StyleSheetTypes';
  19. import ImageViewViewConfig from './ImageViewViewConfig';
  20. const ReactNativeViewConfigRegistry = require('../Renderer/shims/ReactNativeViewConfigRegistry');
  21. type NativeProps = $ReadOnly<{|
  22. ...ImageProps,
  23. ...ViewProps,
  24. style?: ImageStyleProp | DangerouslyImpreciseStyle,
  25. // iOS native props
  26. tintColor?: ColorValue,
  27. // Android native props
  28. shouldNotifyLoadEvents?: boolean,
  29. src?: ?ResolvedAssetSource | $ReadOnlyArray<{uri: string, ...}>,
  30. headers?: ?string,
  31. defaultSrc?: ?string,
  32. loadingIndicatorSrc?: ?string,
  33. |}>;
  34. let ImageViewNativeComponent;
  35. if (global.RN$Bridgeless) {
  36. ReactNativeViewConfigRegistry.register('RCTImageView', () => {
  37. return ImageViewViewConfig;
  38. });
  39. ImageViewNativeComponent = 'RCTImageView';
  40. } else {
  41. ImageViewNativeComponent = requireNativeComponent<NativeProps>(
  42. 'RCTImageView',
  43. );
  44. }
  45. // flowlint-next-line unclear-type:off
  46. export default ((ImageViewNativeComponent: any): HostComponent<NativeProps>);