@livelike/react-native
Version:
LiveLike React Native package
77 lines • 2.21 kB
JavaScript
import React from 'react';
import { StyleSheet, TouchableHighlight, View, ActivityIndicator } from 'react-native';
import { useApi, useStyles, useTheme } from '../../hooks';
import { LLText } from '../LLText';
export function LLWidgetsLoadMoreButton(_ref) {
let {
disabled,
onPress,
label = 'Load More',
styles: stylesProp
} = _ref;
const {
theme
} = useTheme();
const loadMoreButtonStyles = useStyles({
componentStylesFn: getWidgetSubmitButtonStyles,
stylesProp
});
const {
isLoading,
onApi
} = useApi(() => onPress());
const onPressHandler = () => {
onApi();
};
return /*#__PURE__*/React.createElement(View, {
style: loadMoreButtonStyles.container
}, /*#__PURE__*/React.createElement(TouchableHighlight, {
disabled: disabled || isLoading,
onPress: onPressHandler,
style: [loadMoreButtonStyles.buttonContainer, (disabled || isLoading) && loadMoreButtonStyles.disabledButtonContainer],
underlayColor: theme.primaryPressedButtonBackground,
activeOpacity: 1
}, isLoading ? /*#__PURE__*/React.createElement(ActivityIndicator, {
size: 'small',
color: theme.disabledButtonText,
style: loadMoreButtonStyles.loadingIndicator
}) : /*#__PURE__*/React.createElement(LLText, {
style: [loadMoreButtonStyles.buttonText, disabled && loadMoreButtonStyles.disabledButtonText]
}, label)));
}
const getWidgetSubmitButtonStyles = _ref2 => {
let {
theme
} = _ref2;
return StyleSheet.create({
container: {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
width: '100%',
marginVertical: 8
},
buttonContainer: {
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
width: 120,
height: 32,
borderRadius: 4,
marginLeft: 16,
marginBottom: 16,
backgroundColor: theme.primaryButtonBackground
},
disabledButtonContainer: {
backgroundColor: theme.disabledButtonBackground
},
buttonText: {
fontSize: 14
},
disabledButtonText: {
color: theme.disabledButtonText
},
loadingIndicator: {}
});
};
//# sourceMappingURL=LLWidgetsLoadMoreButton.js.map