UNPKG

@livelike/react-native

Version:

LiveLike React Native package

77 lines (76 loc) 2.61 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LLCheerMeterWidgetBody = LLCheerMeterWidgetBody; var _react = _interopRequireDefault(require("react")); var _reactNative = require("react-native"); var _hooks = require("../../hooks"); var _LLCheerMeterWidgetOption = require("./LLCheerMeterWidgetOption"); var _LLCheerMeterWidgetResult = require("./LLCheerMeterWidgetResult"); var _LLCheerMeterWidgetCheerCount = require("./LLCheerMeterWidgetCheerCount"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function LLCheerMeterWidgetBody(_ref) { let { widgetId, ResultComponent = _LLCheerMeterWidgetResult.LLCheerMeterWidgetResult, OptionComponent = _LLCheerMeterWidgetOption.LLCheerMeterWidgetOption, CheerCountComponent = _LLCheerMeterWidgetCheerCount.LLCheerMeterWidgetCheerCount, ResultComponentStyles, OptionComponentStyles, CheerCountComponentStyles, styles: stylesProp } = _ref; const styles = (0, _hooks.useStyles)({ componentStylesFn: getCheerMeterWidgetBodyStyles, stylesProp }); const widgetOptions = (0, _hooks.useWidgetOptions)({ widgetId }); if (!(widgetOptions !== null && widgetOptions !== void 0 && widgetOptions.length)) { return undefined; } const totalCheerCount = widgetOptions.reduce((total, _ref2) => { let { vote_count } = _ref2; return total + vote_count; }, 0); return /*#__PURE__*/_react.default.createElement(_reactNative.View, { style: styles.bodyContainer }, /*#__PURE__*/_react.default.createElement(ResultComponent, { widgetId: widgetId, widgetOptions: widgetOptions, styles: ResultComponentStyles }), /*#__PURE__*/_react.default.createElement(_reactNative.View, { style: styles.optionContainer }, widgetOptions.map((option, index) => /*#__PURE__*/_react.default.createElement(OptionComponent, { key: option.id, widgetId: widgetId, optionIndex: index, styles: OptionComponentStyles })), /*#__PURE__*/_react.default.createElement(CheerCountComponent, { styles: CheerCountComponentStyles, totalCheerCount: totalCheerCount }))); } const getCheerMeterWidgetBodyStyles = _ref3 => { let { theme } = _ref3; return _reactNative.StyleSheet.create({ bodyContainer: { display: 'flex', flexDirection: 'column', marginHorizontal: 16, marginBottom: 8 }, optionContainer: { display: 'flex', flexDirection: 'row', position: 'relative' } }); }; //# sourceMappingURL=LLCheerMeterWidgetBody.js.map