1"use strict"; 2var __importDefault = (this && this.__importDefault) || function (mod) { 3 return (mod && mod.__esModule) ? mod : { "default": mod }; 4}; 5Object.defineProperty(exports, "__esModule", { value: true }); 6exports.getRootViewBackgroundColor = exports.setRootViewBackgroundColor = exports.withIosRootViewBackgroundColor = void 0; 7// @ts-ignore: uses flow 8const normalize_color_1 = __importDefault(require("@react-native/normalize-color")); 9const config_plugins_1 = require("expo/config-plugins"); 10// Maps to the template AppDelegate.m 11const BACKGROUND_COLOR_KEY = 'RCTRootViewBackgroundColor'; 12const debug = require('debug')('expo:system-ui:plugin:ios'); 13const withIosRootViewBackgroundColor = (config) => { 14 config = (0, config_plugins_1.withInfoPlist)(config, (config) => { 15 config.modResults = setRootViewBackgroundColor(config, config.modResults); 16 return config; 17 }); 18 return config; 19}; 20exports.withIosRootViewBackgroundColor = withIosRootViewBackgroundColor; 21function setRootViewBackgroundColor(config, infoPlist) { 22 const backgroundColor = getRootViewBackgroundColor(config); 23 if (!backgroundColor) { 24 delete infoPlist[BACKGROUND_COLOR_KEY]; 25 } 26 else { 27 let color = (0, normalize_color_1.default)(backgroundColor); 28 if (!color) { 29 throw new Error('Invalid background color on iOS'); 30 } 31 color = ((color << 24) | (color >>> 8)) >>> 0; 32 infoPlist[BACKGROUND_COLOR_KEY] = color; 33 debug(`Convert color: ${backgroundColor} -> ${color}`); 34 } 35 return infoPlist; 36} 37exports.setRootViewBackgroundColor = setRootViewBackgroundColor; 38function getRootViewBackgroundColor(config) { 39 return config.ios?.backgroundColor || config.backgroundColor || null; 40} 41exports.getRootViewBackgroundColor = getRootViewBackgroundColor; 42