113c5c8bdSEvan Bacon"use strict"; 213c5c8bdSEvan Baconvar __importDefault = (this && this.__importDefault) || function (mod) { 313c5c8bdSEvan Bacon return (mod && mod.__esModule) ? mod : { "default": mod }; 413c5c8bdSEvan Bacon}; 513c5c8bdSEvan BaconObject.defineProperty(exports, "__esModule", { value: true }); 613c5c8bdSEvan Baconexports.setStrings = exports.resolveProps = exports.withAndroidUserInterfaceStyle = void 0; 713c5c8bdSEvan Baconconst assert_1 = __importDefault(require("assert")); 8*957cf079STomasz Sapetaconst config_plugins_1 = require("expo/config-plugins"); 913c5c8bdSEvan Bacon// strings.xml keys, this should not change. 1013c5c8bdSEvan Baconconst USER_INTERFACE_STYLE_KEY = 'expo_system_ui_user_interface_style'; 1113c5c8bdSEvan Baconconst withAndroidUserInterfaceStyle = (config) => { 1213c5c8bdSEvan Bacon return (0, config_plugins_1.withStringsXml)(config, (config) => { 1313c5c8bdSEvan Bacon config.modResults = setStrings(config.modResults, resolveProps(config)); 1413c5c8bdSEvan Bacon return config; 1513c5c8bdSEvan Bacon }); 1613c5c8bdSEvan Bacon}; 1713c5c8bdSEvan Baconexports.withAndroidUserInterfaceStyle = withAndroidUserInterfaceStyle; 1813c5c8bdSEvan Baconfunction resolveProps(config) { 1944e1f840SEvan Bacon const userInterfaceStyle = config.android?.userInterfaceStyle ?? config.userInterfaceStyle; 2013c5c8bdSEvan Bacon (0, assert_1.default)(!userInterfaceStyle || ['automatic', 'light', 'dark'].includes(userInterfaceStyle), `expo-system-ui: Invalid userInterfaceStyle: "${userInterfaceStyle}"`); 2113c5c8bdSEvan Bacon return { userInterfaceStyle }; 2213c5c8bdSEvan Bacon} 2313c5c8bdSEvan Baconexports.resolveProps = resolveProps; 2413c5c8bdSEvan Baconfunction setStrings(strings, { userInterfaceStyle }) { 2513c5c8bdSEvan Bacon const pairs = [[USER_INTERFACE_STYLE_KEY, userInterfaceStyle]]; 2613c5c8bdSEvan Bacon const stringItems = []; 2713c5c8bdSEvan Bacon for (const [key, value] of pairs) { 2813c5c8bdSEvan Bacon if (value == null) { 2913c5c8bdSEvan Bacon // Since we're using custom strings, we can remove them for convenience between prebuilds. 3013c5c8bdSEvan Bacon strings = config_plugins_1.AndroidConfig.Strings.removeStringItem(key, strings); 3113c5c8bdSEvan Bacon } 3213c5c8bdSEvan Bacon else { 3313c5c8bdSEvan Bacon stringItems.push(config_plugins_1.AndroidConfig.Resources.buildResourceItem({ 3413c5c8bdSEvan Bacon name: key, 3513c5c8bdSEvan Bacon value: String(value), 3613c5c8bdSEvan Bacon translatable: false, 3713c5c8bdSEvan Bacon })); 3813c5c8bdSEvan Bacon } 3913c5c8bdSEvan Bacon } 4013c5c8bdSEvan Bacon return config_plugins_1.AndroidConfig.Strings.setStringItem(stringItems, strings); 4113c5c8bdSEvan Bacon} 4213c5c8bdSEvan Baconexports.setStrings = setStrings; 43