UNPKG

@livelike/react-native

Version:

LiveLike React Native package

73 lines (72 loc) 2.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LLCheerMeterWidgetOption = LLCheerMeterWidgetOption; var _react = _interopRequireDefault(require("react")); var _reactNative = require("react-native"); var _hooks = require("../../hooks"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const THROTTLE_TIME = 3000; function LLCheerMeterWidgetOption(_ref) { let { widgetId, optionIndex, throttleTime = THROTTLE_TIME, styles: stylesProp } = _ref; const { theme } = (0, _hooks.useTheme)(); const styles = (0, _hooks.useStyles)({ componentStylesFn: getCheerMeterWidgetOptionStyles, stylesProp }); const widgetOptions = (0, _hooks.useWidgetOptions)({ widgetId }); const isWidgetDisabled = (0, _hooks.useIsWidgetDisabled)({ widgetId }); const widgetOption = widgetOptions === null || widgetOptions === void 0 ? void 0 : widgetOptions[optionIndex]; const onOptionPress = (0, _hooks.useCheerMeterOnOptionPress)({ widgetId, optionIndex, throttleTime }); if (!widgetOptions || !widgetOption || !widgetOption.image_url) { return undefined; } return /*#__PURE__*/_react.default.createElement(_reactNative.TouchableHighlight, { onPress: onOptionPress, disabled: isWidgetDisabled, style: styles.optionContainer, activeOpacity: 1, underlayColor: theme.widgetSelectedOption }, /*#__PURE__*/_react.default.createElement(_reactNative.Image, { source: { uri: widgetOption.image_url }, style: styles.optionImage })); } const getCheerMeterWidgetOptionStyles = _ref2 => { let { theme } = _ref2; return _reactNative.StyleSheet.create({ optionContainer: { display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center', padding: 18, flex: 1 }, optionImage: { width: 75, height: 60 } }); }; //# sourceMappingURL=LLCheerMeterWidgetOption.js.map