PullToRefreshViewNativeComponent.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. import type {DirectEventHandler, WithDefault} from '../../Types/CodegenTypes';
  12. import type {ColorValue} from '../../StyleSheet/StyleSheetTypes';
  13. import type {ViewProps} from '../View/ViewPropTypes';
  14. import * as React from 'react';
  15. import codegenNativeComponent from '../../Utilities/codegenNativeComponent';
  16. import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
  17. import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
  18. type NativeProps = $ReadOnly<{|
  19. ...ViewProps,
  20. /**
  21. * The color of the refresh indicator.
  22. */
  23. tintColor?: ?ColorValue,
  24. /**
  25. * Title color.
  26. */
  27. titleColor?: ?ColorValue,
  28. /**
  29. * The title displayed under the refresh indicator.
  30. */
  31. title?: WithDefault<string, null>,
  32. /**
  33. * Called when the view starts refreshing.
  34. */
  35. onRefresh?: ?DirectEventHandler<null>,
  36. /**
  37. * Whether the view should be indicating an active refresh.
  38. */
  39. refreshing: boolean,
  40. |}>;
  41. type ComponentType = HostComponent<NativeProps>;
  42. interface NativeCommands {
  43. +setNativeRefreshing: (
  44. viewRef: React.ElementRef<ComponentType>,
  45. refreshing: boolean,
  46. ) => void;
  47. }
  48. export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
  49. supportedCommands: ['setNativeRefreshing'],
  50. });
  51. export default (codegenNativeComponent<NativeProps>('PullToRefreshView', {
  52. paperComponentName: 'RCTRefreshControl',
  53. excludedPlatform: 'android',
  54. }): HostComponent<NativeProps>);