@livelike/react-native
Version:
LiveLike React Native package
66 lines • 1.76 kB
JavaScript
import React from 'react';
import { Image, TouchableHighlight, StyleSheet } from 'react-native';
import { useWidgetOptions, useIsWidgetDisabled, useStyles, useTheme, useCheerMeterOnOptionPress } from '../../hooks';
const THROTTLE_TIME = 3000;
export function LLCheerMeterWidgetOption(_ref) {
let {
widgetId,
optionIndex,
throttleTime = THROTTLE_TIME,
styles: stylesProp
} = _ref;
const {
theme
} = useTheme();
const styles = useStyles({
componentStylesFn: getCheerMeterWidgetOptionStyles,
stylesProp
});
const widgetOptions = useWidgetOptions({
widgetId
});
const isWidgetDisabled = useIsWidgetDisabled({
widgetId
});
const widgetOption = widgetOptions === null || widgetOptions === void 0 ? void 0 : widgetOptions[optionIndex];
const onOptionPress = useCheerMeterOnOptionPress({
widgetId,
optionIndex,
throttleTime
});
if (!widgetOptions || !widgetOption || !widgetOption.image_url) {
return undefined;
}
return /*#__PURE__*/React.createElement(TouchableHighlight, {
onPress: onOptionPress,
disabled: isWidgetDisabled,
style: styles.optionContainer,
activeOpacity: 1,
underlayColor: theme.widgetSelectedOption
}, /*#__PURE__*/React.createElement(Image, {
source: {
uri: widgetOption.image_url
},
style: styles.optionImage
}));
}
const getCheerMeterWidgetOptionStyles = _ref2 => {
let {
theme
} = _ref2;
return StyleSheet.create({
optionContainer: {
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
padding: 18,
flex: 1
},
optionImage: {
width: 75,
height: 60
}
});
};
//# sourceMappingURL=LLCheerMeterWidgetOption.js.map