({
androidOutputPath,
props,
}: {
androidOutputPath: string;
props: Props;
})
| 435 | export type Props = Awaited<ReturnType<typeof transformProps>>; |
| 436 | |
| 437 | export const writeAndroidAssets = async ({ |
| 438 | androidOutputPath, |
| 439 | props, |
| 440 | }: { |
| 441 | androidOutputPath: string; |
| 442 | props: Props; |
| 443 | }) => { |
| 444 | const { logo, logoSizeExceeded } = props; |
| 445 | |
| 446 | log.title("🤖", "Android"); |
| 447 | hfs.ensureDir(androidOutputPath); |
| 448 | |
| 449 | if (logoSizeExceeded) { |
| 450 | return log.warn( |
| 451 | "Logo exceeds 192x192dp and will be cropped by Android. Skipping its generation.", |
| 452 | ); |
| 453 | } |
| 454 | |
| 455 | if (logo.width > 134 || logo.height > 134) { |
| 456 | log.warn("Logo exceeds 134x134dp. It might be cropped by Android."); |
| 457 | } |
| 458 | |
| 459 | await Promise.all( |
| 460 | [ |
| 461 | { ratio: 1, suffix: "mdpi" }, |
| 462 | { ratio: 1.5, suffix: "hdpi" }, |
| 463 | { ratio: 2, suffix: "xhdpi" }, |
| 464 | { ratio: 3, suffix: "xxhdpi" }, |
| 465 | { ratio: 4, suffix: "xxxhdpi" }, |
| 466 | ].map(({ ratio, suffix }) => { |
| 467 | const drawableDirPath = path.resolve( |
| 468 | androidOutputPath, |
| 469 | `drawable-${suffix}`, |
| 470 | ); |
| 471 | |
| 472 | hfs.ensureDir(drawableDirPath); |
| 473 | |
| 474 | // https://developer.android.com/develop/ui/views/launch/splash-screen#dimensions |
| 475 | const canvasSize = 288 * ratio; |
| 476 | |
| 477 | // https://sharp.pixelplumbing.com/api-constructor |
| 478 | const canvas = sharp({ |
| 479 | create: { |
| 480 | width: canvasSize, |
| 481 | height: canvasSize, |
| 482 | channels: 4, |
| 483 | background: { |
| 484 | r: 255, |
| 485 | g: 255, |
| 486 | b: 255, |
| 487 | alpha: 0, |
| 488 | }, |
| 489 | }, |
| 490 | }); |
| 491 | |
| 492 | const filePath = path.resolve(drawableDirPath, "bootsplash_logo.png"); |
| 493 | |
| 494 | return logo.image |
no outgoing calls
no test coverage detected
searching dependent graphs…