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,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC;YACpD,mBAAa,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC;SACrD,CAAC,CAAC;KACJ;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CACb,0EAA0E,UAAU,sBAAsB,UAAU,GAAG,CACxH,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AA1DD,wDA0DC","sourcesContent":["import { ExpoConfig } from '@expo/config-types';\n\nimport { ConfigPlugin } from '../Plugin.types';\nimport { withDangerousMod } from '../plugins/core-plugins';\nimport { writeXMLAsync } from '../utils/XML';\nimport * as WarningAggregator from '../utils/warnings';\nimport { getProjectColorsXMLPathAsync, setColorItem } from './Colors';\nimport { buildResourceItem, readResourcesXMLAsync } from './Resources';\nimport { getProjectStylesXMLPathAsync, setStylesItem } from './Styles';\n\nconst NAVIGATION_BAR_COLOR = 'navigationBarColor';\nconst WINDOW_LIGHT_NAVIGATION_BAR = 'android:windowLightNavigationBar';\n\nexport const withNavigationBar: ConfigPlugin = config => {\n return withDangerousMod(config, [\n 'android',\n async config => {\n await setNavigationBarConfig(config, config.modRequest.projectRoot);\n return config;\n },\n ]);\n};\n\nexport function getNavigationBarImmersiveMode(config: Pick) {\n return config.androidNavigationBar?.visible || null;\n}\n\nexport function getNavigationBarColor(config: Pick) {\n return config.androidNavigationBar?.backgroundColor || null;\n}\n\nexport function getNavigationBarStyle(config: Pick) {\n return config.androidNavigationBar?.barStyle || 'light-content';\n}\n\nexport async function setNavigationBarConfig(\n config: Pick,\n projectRoot: string\n) {\n const immersiveMode = getNavigationBarImmersiveMode(config);\n const hexString = getNavigationBarColor(config);\n const barStyle = getNavigationBarStyle(config);\n\n const stylesPath = await getProjectStylesXMLPathAsync(projectRoot);\n const colorsPath = await getProjectColorsXMLPathAsync(projectRoot);\n\n let stylesJSON = await readResourcesXMLAsync({ path: stylesPath });\n let colorsJSON = await readResourcesXMLAsync({ path: colorsPath });\n\n if (immersiveMode) {\n // Immersive mode needs to be set programatically\n WarningAggregator.addWarningAndroid(\n 'androidNavigationBar.visible',\n 'Hiding the navigation bar must be done programmatically. Refer to the Android documentation - https://developer.android.com/training/system-ui/immersive - for instructions.'\n );\n }\n if (hexString) {\n const colorItemToAdd = buildResourceItem({ name: NAVIGATION_BAR_COLOR, value: hexString });\n colorsJSON = setColorItem(colorItemToAdd, colorsJSON);\n\n const styleItemToAdd = buildResourceItem({\n name: `android:${NAVIGATION_BAR_COLOR}`,\n value: `@color/${NAVIGATION_BAR_COLOR}`,\n });\n stylesJSON = setStylesItem({\n item: styleItemToAdd,\n xml: stylesJSON,\n parent: { name: 'AppTheme', parent: 'Theme.AppCompat.Light.NoActionBar' },\n });\n }\n if (barStyle === 'dark-content') {\n const navigationBarStyleItem = buildResourceItem({\n name: WINDOW_LIGHT_NAVIGATION_BAR,\n value: 'true',\n });\n stylesJSON = setStylesItem({\n item: navigationBarStyleItem,\n xml: stylesJSON,\n parent: { name: 'AppTheme', parent: 'Theme.AppCompat.Light.NoActionBar' },\n });\n }\n\n try {\n await Promise.all([\n writeXMLAsync({ path: colorsPath, xml: colorsJSON }),\n writeXMLAsync({ path: stylesPath, xml: stylesJSON }),\n ]);\n } catch (e) {\n throw new Error(\n `Error setting Android navigation bar color. Cannot write colors.xml to ${colorsPath}, or styles.xml to ${stylesPath}.`\n );\n }\n return true;\n}\n"]}