@applicaster/zapp-react-native-ui-components
Version:
Applicaster Zapp React Native ui components for the Quick Brick App
71 lines (61 loc) • 1.67 kB
text/typescript
import { ORIENTATIONS } from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
export const isOrientationPortrait = (orientation: ORIENTATIONS): boolean => {
return [ORIENTATIONS.portrait, ORIENTATIONS.portraitUpsideDown].includes(
orientation
);
};
const isOrientationLandscape = (orientation: ORIENTATIONS): boolean => {
return [
ORIENTATIONS.landscapeLeft,
ORIENTATIONS.landscapeRight,
ORIENTATIONS.landscapeSensor,
].includes(orientation);
};
export const orientationWasChangedFromLandscapeToPortrait = ({
fromOrientation,
toOrientation,
}): boolean => {
return (
(isOrientationLandscape(fromOrientation) ||
ORIENTATIONS.unknown === fromOrientation) &&
isOrientationPortrait(toOrientation)
);
};
export const orientationWasChangedFromPortraitToLandscape = ({
fromOrientation,
toOrientation,
}): boolean => {
return (
(isOrientationPortrait(fromOrientation) ||
ORIENTATIONS.unknown === fromOrientation) &&
isOrientationLandscape(toOrientation)
);
};
export const showDetails = ({
isMobile,
isInline,
isDocked,
isPip,
}: {
isMobile: boolean;
isInline: boolean;
isDocked: boolean;
isPip: boolean;
}): boolean => {
if (isPip) {
return false;
}
if (isDocked) {
return false;
}
// for mobile with inline mode(rotation is portrait) we always show details.
if (isMobile && isInline) {
return true;
}
// for mobile with landscape rotation(player is fullscreen) we always hide details. Mounting of it is very heavy operation.
if (isMobile && !isInline) {
return false;
}
// for tablets we always show details
return true;
};