import { ExpoConfig } from '@expo/config-types' ; import { createInfoPlistPlugin } from '../plugins/ios-plugins' ; import { InfoPlist , InterfaceOrientation } from './IosConfig.types' ; export const withOrientation = createInfoPlistPlugin ( setOrientation , 'withOrientation' ) ; export function getOrientation ( config ) { return config . orientation ?? null ; } export const PORTRAIT_ORIENTATIONS = [ 'UIInterfaceOrientationPortrait' , 'UIInterfaceOrientationPortraitUpsideDown' , ] ; export const LANDSCAPE_ORIENTATIONS = [ 'UIInterfaceOrientationLandscapeLeft' , 'UIInterfaceOrientationLandscapeRight' , ] ; function getUISupportedInterfaceOrientations ( orientation ) { if ( orientation === 'portrait' ) { return PORTRAIT_ORIENTATIONS ; } else if ( orientation === 'landscape' ) { return LANDSCAPE_ORIENTATIONS ; } else { return [ ... PORTRAIT_ORIENTATIONS , ... LANDSCAPE_ORIENTATIONS ] ; } } export function setOrientation ( config , infoPlist ) { const orientation = getOrientation ( config ) ; return { ... infoPlist , UISupportedInterfaceOrientations : getUISupportedInterfaceOrientations ( orientation ) } ; }