@theoplayer/react-native-ui
Version:
A React Native UI for @theoplayer/react-native
48 lines (45 loc) • 2.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.AutoFocusGuide = void 0;
var _react = _interopRequireDefault(require("react"));
var _reactNative = _interopRequireWildcard(require("react-native"));
var ReactNative = _reactNative;
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); }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const FOCUS_GUIDE_STYLE = {
width: '100%',
justifyContent: 'center',
alignItems: 'center'
};
// Make sure we just warn once for all component instances, in case the TVFocusGuideView is missing.
let hasWarnedAboutTVFocusGuideView = false;
/**
* A TV platform FocusGuide with autofocus capabilities
*/
const AutoFocusGuide = props => {
const {
style,
children
} = props;
if (_reactNative.Platform.OS === 'ios' && _reactNative.Platform.isTV) {
if (ReactNative.TVFocusGuideView) {
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ReactNative.TVFocusGuideView, {
style: [FOCUS_GUIDE_STYLE, style],
autoFocus: true,
children: children
});
}
if (!hasWarnedAboutTVFocusGuideView) {
console.warn('TVFocusGuideView not supported, a dependency on react-native-tvos is required.');
hasWarnedAboutTVFocusGuideView = true;
}
}
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
children: children
});
};
exports.AutoFocusGuide = AutoFocusGuide;
//# sourceMappingURL=AutoFocusGuide.js.map