import React from 'react'; import { ActivityIndicator, GestureResponderEvent, StyleProp, StyleSheet, TouchableOpacity, View, ViewStyle, } from 'react-native'; import { useTheme } from '../../contexts/themeContext/ThemeContext'; import { Refresh } from '../../icons'; import { ProgressIndicatorTypes } from '../../utils/utils'; const styles = StyleSheet.create({ activityIndicatorContainer: { alignItems: 'center', bottom: 0, justifyContent: 'center', left: 0, position: 'absolute', right: 0, top: 0, }, container: { alignItems: 'center', height: '100%', justifyContent: 'center', position: 'absolute', width: '100%', }, overflowHidden: { overflow: 'hidden', }, overlay: { alignItems: 'center', height: '100%', justifyContent: 'center', opacity: 0, position: 'absolute', width: '100%', }, retryButtonContainer: { alignItems: 'center', bottom: 0, justifyContent: 'center', left: 0, position: 'absolute', right: 0, top: 0, }, }); export type UploadProgressIndicatorProps = { /** Action triggered when clicked indicator */ action?: (event: GestureResponderEvent) => void; /** Boolean status of upload progress */ active?: boolean; /** style */ style?: StyleProp; /** Type of active indicator */ type?: 'in_progress' | 'retry'; }; export const UploadProgressIndicator: React.FC = (props) => { const { action, active, children, style, type } = props; const { theme: { colors: { overlay: overlayColor, white_smoke }, messageInput: { uploadProgressIndicator: { container, overlay }, }, }, } = useTheme(); return !active ? ( {children} ) : ( {children} {type === ProgressIndicatorTypes.IN_PROGRESS && ( )} {type === ProgressIndicatorTypes.RETRY && ( )} ); }; UploadProgressIndicator.displayName = 'UploadProgressIndicator{messageInput{uploadProgressIndicator}}';