import { ExpoConfig } from '@expo/config-types' ; import { createInfoPlistPlugin } from '../plugins/ios-plugins' ; import { gteSdkVersion } from '../utils/versions' ; import { addWarningIOS } from '../utils/warnings' ; import { InfoPlist } from './IosConfig.types' ; export const withRequiresFullScreen = createInfoPlistPlugin ( setRequiresFullScreen , 'withRequiresFullScreen' ) ; export function getRequiresFullScreen ( config ) { if ( config . ios ?. hasOwnProperty ( 'requireFullScreen' ) ) { return ! ! config . ios . requireFullScreen ; } else { if ( gteSdkVersion ( config , '43.0.0' ) ) { return false ; } return true ; } } const iPadInterfaceKey = 'UISupportedInterfaceOrientations~ipad' ; const requiredIPadInterface = [ 'UIInterfaceOrientationPortrait' , 'UIInterfaceOrientationPortraitUpsideDown' , 'UIInterfaceOrientationLandscapeLeft' , 'UIInterfaceOrientationLandscapeRight' , ] ; function isStringArray ( value ) { return Array . isArray ( value ) && value . every ( value => typeof value === 'string' ) ; } function hasMinimumOrientations ( masks ) { return requiredIPadInterface . every ( mask => masks . includes ( mask ) ) ; } param interfaceOrientations returns function resolveExistingIpadInterfaceOrientations ( interfaceOrientations ) { if ( isStringArray ( interfaceOrientations ) && interfaceOrientations . length && ! hasMinimumOrientations ( interfaceOrientations ) ) { const existingList = interfaceOrientations ! . join ( ', ' ) ; addWarningIOS ( 'ios.requireFullScreen' , `iPad multitasking requires all \`${ iPadInterfaceKey }\` orientations to be defined in the Info.plist. The Info.plist currently defines values that are incompatible with multitasking, these will be overwritten to prevent submission failure. Existing: ${ existingList }` ) ; return interfaceOrientations ; } return [ ] ; } export function setRequiresFullScreen ( config , infoPlist ) { const requiresFullScreen = getRequiresFullScreen ( config ) ; if ( ! requiresFullScreen ) { const existing = resolveExistingIpadInterfaceOrientations ( infoPlist [ iPadInterfaceKey ] ) ; infoPlist [ iPadInterfaceKey ] = [ ... new Set ( existing . concat ( requiredIPadInterface ) ) ] ; } return { ... infoPlist , UIRequiresFullScreen : requiresFullScreen } ; }