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,qCAAiB,CACf,8BAA8B,EAC9B,8KAA8K,CAC/K,CAAC;KACH;IACD,IAAI,SAAS,EAAE;QACb,IAAI,cAAc,GAAc,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE,EAAE,CAAC,CAAC;QACtF,UAAU,GAAG,qBAAY,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;QAEtD,IAAI,cAAc,GAAc;YAC9B,EAAE,CAAC,EAAE,UAAU,oBAAoB,EAAE,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,WAAW,oBAAoB,EAAE,EAAE,EAAE;SACxF,CAAC;QACF,UAAU,GAAG,sBAAa,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;KACxD;IACD,IAAI,QAAQ,KAAK,cAAc,EAAE;QAC/B,IAAI,sBAAsB,GAAc;YACtC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,2BAA2B,EAAE,EAAE;SACxD,CAAC;QACF,UAAU,GAAG,sBAAa,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAC;KAChE;IAED,IAAI;QACF,MAAM,4BAAmB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAClD,MAAM,4BAAmB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;KACnD;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,IAAI,KAAK,CACb,0EAA0E,UAAU,sBAAsB,UAAU,GAAG,CACxH,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AA9CD,wDA8CC","sourcesContent":["import {\n XMLItem,\n getProjectStylesXMLPathAsync,\n readStylesXMLAsync,\n setStylesItem,\n writeStylesXMLAsync,\n} from './Styles';\nimport {\n getProjectColorsXMLPathAsync,\n readColorsXMLAsync,\n setColorItem,\n writeColorsXMLAsync,\n} from './Colors';\nimport { ExpoConfig } from '../Config.types';\nimport { addWarningAndroid } from '../WarningAggregator';\n\nconst NAVIGATION_BAR_COLOR = 'navigationBarColor';\nconst WINDOW_LIGHT_NAVIGATION_BAR = 'android:windowLightNavigationBar';\n\nexport function getNavigationBarImmersiveMode(config: ExpoConfig) {\n return config.androidNavigationBar?.visible || null;\n}\n\nexport function getNavigationBarColor(config: ExpoConfig) {\n return config.androidNavigationBar?.backgroundColor || null;\n}\n\nexport function getNavigationBarStyle(config: ExpoConfig) {\n return config.androidNavigationBar?.barStyle || 'light-content';\n}\n\nexport async function setNavigationBarConfig(config: ExpoConfig, projectDirectory: string) {\n const immersiveMode = getNavigationBarImmersiveMode(config);\n const hexString = getNavigationBarColor(config);\n const barStyle = getNavigationBarStyle(config);\n\n const stylesPath = await getProjectStylesXMLPathAsync(projectDirectory);\n const colorsPath = await getProjectColorsXMLPathAsync(projectDirectory);\n if (!colorsPath || !stylesPath) {\n return false;\n }\n\n let stylesJSON = await readStylesXMLAsync(stylesPath);\n let colorsJSON = await readColorsXMLAsync(colorsPath);\n\n if (immersiveMode) {\n // Immersive mode needs to be set programatically\n 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 let colorItemToAdd: XMLItem[] = [{ _: hexString, $: { name: NAVIGATION_BAR_COLOR } }];\n colorsJSON = setColorItem(colorItemToAdd, colorsJSON);\n\n let styleItemToAdd: XMLItem[] = [\n { _: `@color/${NAVIGATION_BAR_COLOR}`, $: { name: `android:${NAVIGATION_BAR_COLOR}` } },\n ];\n stylesJSON = setStylesItem(styleItemToAdd, stylesJSON);\n }\n if (barStyle === 'dark-content') {\n let navigationBarStyleItem: XMLItem[] = [\n { _: 'true', $: { name: WINDOW_LIGHT_NAVIGATION_BAR } },\n ];\n stylesJSON = setStylesItem(navigationBarStyleItem, stylesJSON);\n }\n\n try {\n await writeColorsXMLAsync(colorsPath, colorsJSON);\n await writeStylesXMLAsync(stylesPath, stylesJSON);\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"]}
\No newline at end of file