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.setStrings = exports.resolveProps = exports.withAndroidUserInterfaceStyle = void 0; 7const assert_1 = __importDefault(require("assert")); 8const config_plugins_1 = require("expo/config-plugins"); 9// strings.xml keys, this should not change. 10const USER_INTERFACE_STYLE_KEY = 'expo_system_ui_user_interface_style'; 11const withAndroidUserInterfaceStyle = (config) => { 12 return (0, config_plugins_1.withStringsXml)(config, (config) => { 13 config.modResults = setStrings(config.modResults, resolveProps(config)); 14 return config; 15 }); 16}; 17exports.withAndroidUserInterfaceStyle = withAndroidUserInterfaceStyle; 18function resolveProps(config) { 19 const userInterfaceStyle = config.android?.userInterfaceStyle ?? config.userInterfaceStyle; 20 (0, assert_1.default)(!userInterfaceStyle || ['automatic', 'light', 'dark'].includes(userInterfaceStyle), `expo-system-ui: Invalid userInterfaceStyle: "${userInterfaceStyle}"`); 21 return { userInterfaceStyle }; 22} 23exports.resolveProps = resolveProps; 24function setStrings(strings, { userInterfaceStyle }) { 25 const pairs = [[USER_INTERFACE_STYLE_KEY, userInterfaceStyle]]; 26 const stringItems = []; 27 for (const [key, value] of pairs) { 28 if (value == null) { 29 // Since we're using custom strings, we can remove them for convenience between prebuilds. 30 strings = config_plugins_1.AndroidConfig.Strings.removeStringItem(key, strings); 31 } 32 else { 33 stringItems.push(config_plugins_1.AndroidConfig.Resources.buildResourceItem({ 34 name: key, 35 value: String(value), 36 translatable: false, 37 })); 38 } 39 } 40 return config_plugins_1.AndroidConfig.Strings.setStringItem(stringItems, strings); 41} 42exports.setStrings = setStrings; 43