Skip to content

Instantly share code, notes, and snippets.

@artyorsh
Last active January 10, 2022 02:54
Show Gist options
  • Save artyorsh/d9ec1a1acaecc1a762a14dedcc207e52 to your computer and use it in GitHub Desktop.
Save artyorsh/d9ec1a1acaecc1a762a14dedcc207e52 to your computer and use it in GitHub Desktop.
UI Kitten - Spinner Refresh Control
import * as React from 'react';
import {
RefreshControl as RNRefreshControl,
RefreshControlProps as RNRefreshControlProps,
StyleSheet,
View,
ViewProps,
} from 'react-native';
import {
Spinner,
SpinnerProps,
} from 'react-native-ui-kitten';
export interface RefreshControlProps extends Omit<RNRefreshControlProps, 'size'>, SpinnerProps {
}
export type RefreshControlElement = React.ReactElement<RefreshControlProps>;
const NATIVE_REFRESH_CONTROL_COLOR: string = 'transparent';
export class RefreshControl extends React.Component<RefreshControlProps> {
public render(): React.ReactElement<ViewProps> {
const { style, refreshing, status, size, animating, ...restProps } = this.props;
return (
<RNRefreshControl
{...restProps}
style={styles.container}
refreshing={refreshing}
tintColor={NATIVE_REFRESH_CONTROL_COLOR}
colors={[NATIVE_REFRESH_CONTROL_COLOR]}>
<View style={[styles.spinnerContainer, style]}>
<Spinner
status={status}
size={size}
animating={animating}
/>
</View>
</RNRefreshControl>
);
}
}
const styles = StyleSheet.create({
container: {
height: 0,
},
spinnerContainer: {
width: '100%',
alignItems: 'center',
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment