UNPKG

@theoplayer/react-native-ui

Version:

A React Native UI for @theoplayer/react-native

80 lines (78 loc) 3.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MenuView = exports.DEFAULT_MENU_VIEW_STYLE = void 0; var _react = _interopRequireWildcard(require("react")); var _PlayerContext = require("../../util/PlayerContext"); var _reactNative = require("react-native"); var _ControlBar = require("../../controlbar/ControlBar"); var _UiContainer = require("../../uicontroller/UiContainer"); var _BackSvg = require("../../button/svg/BackSvg"); var _ActionButton = require("../../button/actionbutton/ActionButton"); var _jsxRuntime = require("react/jsx-runtime"); function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); } /** * The default style for the menu view. */ const DEFAULT_MENU_VIEW_STYLE = exports.DEFAULT_MENU_VIEW_STYLE = { flex: 1, flexDirection: 'row', left: 0, right: 0, top: 0, bottom: 0, paddingVertical: 20, paddingLeft: 50, paddingRight: 40 }; /** * A component to render a fullscreen menu with a title and back button for the `react-native-theoplayer` UI. */ const MenuView = props => { const { menu, style } = props; const context = (0, _react.useContext)(_PlayerContext.PlayerContext); const onClose = () => { context.ui.closeCurrentMenu_(); }; return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, { style: _reactNative.StyleSheet.absoluteFill, children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_ControlBar.ControlBar, { style: _UiContainer.TOP_UI_CONTAINER_STYLE, children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, { style: { flexDirection: 'row' }, children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, { style: { flexDirection: 'row' }, onPress: onClose, children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ActionButton.ActionButton, { touchable: false, svg: /*#__PURE__*/(0, _jsxRuntime.jsx)(_BackSvg.BackSvg, {}) }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, { style: { color: context.style.colors.text, fontSize: 16, lineHeight: 30 }, children: context.locale.backButton })] }) }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, { style: { flexGrow: 1 } })] }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, { style: [DEFAULT_MENU_VIEW_STYLE, style], children: menu })] }); }; exports.MenuView = MenuView; //# sourceMappingURL=MenuView.js.map