UNPKG

@livelike/react-native

Version:

LiveLike React Native package

72 lines 2.02 kB
import React, { useCallback, useState } from 'react'; import { StyleSheet, TouchableHighlight, View } from 'react-native'; import { useStyles, useTheme } from '../../hooks'; import { LLText } from '../LLText'; export function LLLoadActionButtonComponent(_ref) { let { onPress, label, actionInProgressLabel, styles: stylesProp } = _ref; const loadMoreStyles = useStyles({ componentStylesFn: getLoadMoreButtonStyles, stylesProp }); const { theme } = useTheme(); const [isLoading, setIsLoading] = useState(false); const onLoad = useCallback(() => { setIsLoading(true); onPress().finally(() => { setIsLoading(false); }); }, [setIsLoading, onPress]); return /*#__PURE__*/React.createElement(View, { style: loadMoreStyles.buttonContainer }, /*#__PURE__*/React.createElement(TouchableHighlight, { disabled: isLoading, onPress: onLoad, style: [loadMoreStyles.button, isLoading && loadMoreStyles.disabledbutton], underlayColor: theme.primaryPressedButtonBackground, activeOpacity: 1 }, /*#__PURE__*/React.createElement(LLText, { style: [loadMoreStyles.buttonText, isLoading && loadMoreStyles.disabledButtonText] }, isLoading ? actionInProgressLabel : label))); } const getLoadMoreButtonStyles = _ref2 => { let { theme } = _ref2; return StyleSheet.create({ buttonContainer: { display: 'flex', justifyContent: 'center', width: '100%', alignItems: 'center' }, button: { display: 'flex', justifyContent: 'center', alignItems: 'center', width: 190, height: 40, borderRadius: 8, marginBottom: 16, backgroundColor: theme.primaryButtonBackground }, disabledbutton: { backgroundColor: theme.disabledButtonBackground, width: 210 }, buttonText: { fontSize: 14, color: theme.text }, disabledButtonText: { color: theme.disabledButtonText } }); }; //# sourceMappingURL=LLLoadActionButton.js.map