import React, { ReactElement } from 'react'; import Style from '@localTypes/style'; import { callUIFunction } from '../modules/ui-manager-module'; interface RefreshWrapperProps { bounceTime?: number; onRefresh?(): void; getRefresh?(): ReactElement; } interface RefreshWrapperItemViewProps { style: Style[]; } /** * Simply to implement the drag down to refresh feature. * @noInheritDoc */ class RefreshWrapper extends React.Component { private instance: HTMLDivElement | null = null; private getRefresh(): ReactElement | null { const { getRefresh } = this.props; if (typeof getRefresh === 'function') { return getRefresh() || null; } return null; } /** * Call native for start refresh. */ public startRefresh() { callUIFunction(this.instance, 'startRefresh', null); } /** * Call native that data is refreshed */ public refreshComplected() { callUIFunction(this.instance, 'refreshComplected', null); } /** * @ignore */ public render() { const { children, ...nativeProps } = this.props; return (
{ this.instance = ref; }} {...nativeProps}>
{ this.getRefresh() }
{ children }
); } } export default RefreshWrapper;