@livelike/react-native
Version:
LiveLike React Native package
84 lines (83 loc) • 2.53 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.LLWidgetsLoadMoreButton = LLWidgetsLoadMoreButton;
var _react = _interopRequireDefault(require("react"));
var _reactNative = require("react-native");
var _hooks = require("../../hooks");
var _LLText = require("../LLText");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function LLWidgetsLoadMoreButton(_ref) {
let {
disabled,
onPress,
label = 'Load More',
styles: stylesProp
} = _ref;
const {
theme
} = (0, _hooks.useTheme)();
const loadMoreButtonStyles = (0, _hooks.useStyles)({
componentStylesFn: getWidgetSubmitButtonStyles,
stylesProp
});
const {
isLoading,
onApi
} = (0, _hooks.useApi)(() => onPress());
const onPressHandler = () => {
onApi();
};
return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
style: loadMoreButtonStyles.container
}, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableHighlight, {
disabled: disabled || isLoading,
onPress: onPressHandler,
style: [loadMoreButtonStyles.buttonContainer, (disabled || isLoading) && loadMoreButtonStyles.disabledButtonContainer],
underlayColor: theme.primaryPressedButtonBackground,
activeOpacity: 1
}, isLoading ? /*#__PURE__*/_react.default.createElement(_reactNative.ActivityIndicator, {
size: 'small',
color: theme.disabledButtonText,
style: loadMoreButtonStyles.loadingIndicator
}) : /*#__PURE__*/_react.default.createElement(_LLText.LLText, {
style: [loadMoreButtonStyles.buttonText, disabled && loadMoreButtonStyles.disabledButtonText]
}, label)));
}
const getWidgetSubmitButtonStyles = _ref2 => {
let {
theme
} = _ref2;
return _reactNative.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