UNPKG

@theoplayer/react-native-ui

Version:

A React Native UI for @theoplayer/react-native

70 lines (69 loc) 2.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DEFAULT_CONTROL_BAR_STYLE = exports.ControlBar = exports.CenteredControlBar = void 0; var _react = _interopRequireWildcard(require("react")); var _reactNative = require("react-native"); var _PlayerContext = require("../util/PlayerContext"); 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 control bar. */ const DEFAULT_CONTROL_BAR_STYLE = exports.DEFAULT_CONTROL_BAR_STYLE = { flexDirection: 'row', justifyContent: 'flex-end' }; /** * A control bar component that renders all children horizontally. */ const ControlBar = props => { const { style, children, pointerEvents } = props; const context = (0, _react.useContext)(_PlayerContext.PlayerContext); return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, { ...props, pointerEvents: pointerEvents ?? 'box-none', style: [DEFAULT_CONTROL_BAR_STYLE, { height: context.style.dimensions.controlBarHeight }, style], children: children }); }; exports.ControlBar = ControlBar; /** * A control bar that can only render 3 properties in the left/middle/right. This is used to create controls in the center of the player. */ const CenteredControlBar = props => { const { style, middle, left, right } = props; const context = (0, _react.useContext)(_PlayerContext.PlayerContext); return /*#__PURE__*/(0, _jsxRuntime.jsxs)(ControlBar, { style: [{ height: context.style.dimensions.centerControlBarHeight, width: '60%', justifyContent: 'space-between' }, style], children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, { style: { height: context.style.dimensions.centerControlBarHeight }, children: left }), middle, /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, { style: { height: context.style.dimensions.centerControlBarHeight }, children: right })] }); }; exports.CenteredControlBar = CenteredControlBar; //# sourceMappingURL=ControlBar.js.map