xref: /expo/home/components/RefreshControl.tsx (revision 8eba4e65)
1import { useTheme } from '@react-navigation/native';
2import * as React from 'react';
3import { RefreshControl as RNRefreshControl, Platform } from 'react-native';
4import { createNativeWrapper } from 'react-native-gesture-handler';
5
6import Colors from '../constants/Colors';
7
8type Props = React.ComponentProps<typeof RNRefreshControl>;
9
10const RNGHRefreshControl = createNativeWrapper(RNRefreshControl, {
11  disallowInterruption: true,
12  shouldCancelWhenOutside: false,
13});
14
15const RefreshControl = Platform.OS === 'android' ? RNRefreshControl : RNGHRefreshControl;
16
17export default function StyledRefreshControl(props: Props) {
18  const theme = useTheme();
19  const color = theme.dark ? Colors.dark.refreshControl : Colors.light.refreshControl;
20
21  return <RefreshControl tintColor={color} {...props} />;
22}
23