@expo/prebuild-config
Advanced tools
Comparing version 8.0.15 to 8.0.16
@@ -37,4 +37,4 @@ import { AndroidConfig, ConfigPlugin } from '@expo/config-plugins'; | ||
*/ | ||
export declare function configureAdaptiveIconAsync(projectRoot: string, foregroundImage: string, backgroundImage: string | null, backgroundColor: string | null, monochromeImage: string | null, isAdaptive: boolean): Promise<void>; | ||
export declare function configureAdaptiveIconAsync(projectRoot: string, foregroundImage: string, backgroundImage: string | null, monochromeImage: string | null, isAdaptive: boolean): Promise<void>; | ||
export declare const createAdaptiveIconXmlString: (backgroundImage: string | null, monochromeImage: string | null) => string; | ||
export {}; |
@@ -75,4 +75,4 @@ "use strict"; | ||
}; | ||
const ICON_BASELINE_PIXEL_SIZE = 48; | ||
const FOREGROUND_BASELINE_PIXEL_SIZE = 108; | ||
const LEGACY_BASELINE_PIXEL_SIZE = 48; | ||
const ADAPTIVE_BASELINE_PIXEL_SIZE = 108; | ||
const ANDROID_RES_PATH = exports.ANDROID_RES_PATH = 'android/app/src/main/res/'; | ||
@@ -163,3 +163,3 @@ const MIPMAP_ANYDPI_V26 = 'mipmap-anydpi-v26'; | ||
} | ||
await configureAdaptiveIconAsync(projectRoot, icon, backgroundImage, backgroundColor, monochromeImage, isAdaptive); | ||
await configureAdaptiveIconAsync(projectRoot, icon, backgroundImage, monochromeImage, isAdaptive); | ||
return true; | ||
@@ -192,3 +192,4 @@ } | ||
imageCacheFolder: 'android-standard-circle', | ||
backgroundImageCacheFolder: 'android-standard-round-background' | ||
backgroundImageCacheFolder: 'android-standard-round-background', | ||
isAdaptive: false | ||
}); | ||
@@ -203,3 +204,3 @@ } | ||
*/ | ||
async function configureAdaptiveIconAsync(projectRoot, foregroundImage, backgroundImage, backgroundColor, monochromeImage, isAdaptive) { | ||
async function configureAdaptiveIconAsync(projectRoot, foregroundImage, backgroundImage, monochromeImage, isAdaptive) { | ||
if (monochromeImage) { | ||
@@ -213,3 +214,3 @@ await generateMonochromeImageAsync(projectRoot, { | ||
await generateMultiLayerImageAsync(projectRoot, { | ||
backgroundColor, | ||
backgroundColor: 'transparent', | ||
backgroundImage, | ||
@@ -220,3 +221,4 @@ backgroundImageCacheFolder: 'android-adaptive-background', | ||
imageCacheFolder: 'android-adaptive-foreground', | ||
backgroundImageFileName: IC_LAUNCHER_BACKGROUND_WEBP | ||
backgroundImageFileName: IC_LAUNCHER_BACKGROUND_WEBP, | ||
isAdaptive: true | ||
}); | ||
@@ -238,3 +240,3 @@ | ||
const createAdaptiveIconXmlString = (backgroundImage, monochromeImage) => { | ||
const background = backgroundImage ? `@drawable/ic_launcher_background` : `@color/iconBackground`; | ||
const background = backgroundImage ? `@mipmap/ic_launcher_background` : `@color/iconBackground`; | ||
const iconElements = [`<background android:drawable="${background}"/>`, '<foreground android:drawable="@mipmap/ic_launcher_foreground"/>']; | ||
@@ -274,3 +276,4 @@ if (monochromeImage) { | ||
outputImageFileName, | ||
backgroundImageFileName | ||
backgroundImageFileName, | ||
isAdaptive | ||
}) { | ||
@@ -285,5 +288,6 @@ await iterateDpiValues(projectRoot, async ({ | ||
scale, | ||
backgroundColor: backgroundColor ?? 'transparent', | ||
// backgroundImage overrides backgroundColor | ||
backgroundColor: backgroundImage ? 'transparent' : backgroundColor ?? 'transparent', | ||
borderRadiusRatio, | ||
imageStlye: getImageStyle(outputImageFileName) | ||
isAdaptive | ||
}); | ||
@@ -295,4 +299,5 @@ if (backgroundImage) { | ||
scale, | ||
backgroundColor: backgroundColor ?? 'transparent', | ||
borderRadiusRatio | ||
backgroundColor: 'transparent', | ||
borderRadiusRatio, | ||
isAdaptive | ||
}); | ||
@@ -328,3 +333,4 @@ if (backgroundImageFileName) { | ||
scale, | ||
backgroundColor: 'transparent' | ||
backgroundColor: 'transparent', | ||
isAdaptive: true | ||
}); | ||
@@ -354,11 +360,6 @@ await _fsExtra().default.ensureDir(dpiFolder); | ||
borderRadiusRatio, | ||
imageStlye | ||
isAdaptive | ||
}) { | ||
const isForegound = imageStlye === 'foreground'; | ||
const baseline = isForegound ? FOREGROUND_BASELINE_PIXEL_SIZE : ICON_BASELINE_PIXEL_SIZE; | ||
const bgIconSizePx = Math.round(baseline * scale); | ||
const iconSizePx = Math.round(bgIconSizePx * getImageScale(imageStlye ?? 'background')); | ||
const { | ||
source: foreground | ||
} = await (0, _imageUtils().generateImageAsync)({ | ||
const iconSizePx = (isAdaptive ? ADAPTIVE_BASELINE_PIXEL_SIZE : LEGACY_BASELINE_PIXEL_SIZE) * scale; | ||
return (await (0, _imageUtils().generateImageAsync)({ | ||
projectRoot, | ||
@@ -368,49 +369,9 @@ cacheType | ||
src, | ||
resizeMode: 'cover', | ||
width: iconSizePx, | ||
height: iconSizePx | ||
}); | ||
const background = await (0, _imageUtils().generateImageBackgroundAsync)({ | ||
width: bgIconSizePx, | ||
height: bgIconSizePx, | ||
backgroundColor: isForegound ? 'transparent' : backgroundColor, | ||
height: iconSizePx, | ||
resizeMode: 'cover', | ||
borderRadius: borderRadiusRatio ? bgIconSizePx * borderRadiusRatio : undefined | ||
}); | ||
const x = Math.round((bgIconSizePx - iconSizePx) / 2); | ||
const y = x; | ||
return (0, _imageUtils().compositeImagesAsync)({ | ||
background, | ||
foreground, | ||
x, | ||
y | ||
}); | ||
backgroundColor, | ||
borderRadius: borderRadiusRatio ? iconSizePx * borderRadiusRatio : undefined | ||
})).source; | ||
} | ||
function getImageStyle(outputFileName) { | ||
switch (outputFileName) { | ||
case IC_LAUNCHER_WEBP: | ||
return 'legacy'; | ||
case IC_LAUNCHER_BACKGROUND_WEBP: | ||
return 'background'; | ||
case IC_LAUNCHER_FOREGROUND_WEBP: | ||
return 'foreground'; | ||
case IC_LAUNCHER_ROUND_WEBP: | ||
return 'rounded'; | ||
case IC_LAUNCHER_MONOCHROME_WEBP: | ||
return 'monochrome'; | ||
} | ||
return 'background'; | ||
} | ||
function getImageScale(imageStyle) { | ||
switch (imageStyle) { | ||
case 'legacy': | ||
case 'rounded': | ||
return 0.9; | ||
case 'foreground': | ||
case 'background': | ||
return 0.7; | ||
case 'monochrome': | ||
return 1; | ||
} | ||
} | ||
//# sourceMappingURL=withAndroidIcons.js.map |
@@ -59,3 +59,3 @@ "use strict"; | ||
// Add Constraints | ||
// Remove Constraints | ||
getAbsoluteConstraints(IMAGE_ID, CONTAINER_ID).forEach(constraint => { | ||
@@ -67,7 +67,8 @@ // <constraint firstItem="EXPO-SplashScreen" firstAttribute="top" secondItem="EXPO-ContainerView" secondAttribute="top" id="2VS-Uz-0LU"/> | ||
// Add resource | ||
// Remove resource | ||
xml.document.resources[0].image = xml.document.resources[0].image ?? []; | ||
const imageSection = xml.document.resources[0].image; | ||
const existingImageIndex = imageSection.findIndex(image => image.$.name === imageName); | ||
if (existingImageIndex > -1) { | ||
imageSection.splice(existingImageIndex, 1); | ||
if (existingImageIndex && existingImageIndex > -1) { | ||
imageSection?.splice(existingImageIndex, 1); | ||
} | ||
@@ -74,0 +75,0 @@ return xml; |
{ | ||
"name": "@expo/prebuild-config", | ||
"version": "8.0.15", | ||
"version": "8.0.16", | ||
"description": "Get the prebuild config", | ||
@@ -55,3 +55,3 @@ "main": "build/index.js", | ||
}, | ||
"gitHead": "563c85837bc5055672846887f70f3daf5763b16d" | ||
"gitHead": "b7b95a93855cb4863b626c4524fc6e8b3a2305eb" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
420213
4459