UNPKG

@theoplayer/react-native-ui

Version:

A React Native UI for @theoplayer/react-native

24 lines 1.1 kB
import React, { useContext } from 'react'; import { ActivityIndicator, View } from 'react-native'; import { PlayerContext } from '../util/PlayerContext'; import { FULLSCREEN_CENTER_STYLE } from '../uicontroller/UiContainer'; import { useDebouncedValue, useWaiting } from '../../hooks/barrel'; import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime"; const DEFAULT_DELAY_MS = 200; /** * The default spinner for the `react-native-theoplayer` UI. It renders an ActivityIndicator when the player's playback is stalling due * readystate changes. */ export const CenteredDelayedActivityIndicator = props => { const waiting = useWaiting(); const context = useContext(PlayerContext); const showing = useDebouncedValue(waiting, props.delay ?? DEFAULT_DELAY_MS); return showing ? /*#__PURE__*/_jsx(View, { style: [FULLSCREEN_CENTER_STYLE, props.containerStyle], children: /*#__PURE__*/_jsx(ActivityIndicator, { color: context.style.colors.icon, ...props }) }) : /*#__PURE__*/_jsx(_Fragment, {}); }; //# sourceMappingURL=CenteredDelayedActivityIndicator.js.map