Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for generating notification icons #633

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
typing, naming
mchl18 committed Jan 16, 2025
commit aa5b6899598099deb5bef96ce1977c8377b9c2ce
12 changes: 6 additions & 6 deletions src/platforms/ios/index.ts
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ export class IosAssetGenerator extends AssetGenerator {
throw new BadPipelineError('Sharp instance not created');
}

const iosDir = project.config.ios!.path!;
const iosDir = project.config.ios?.path ?? 'App';

// Generate logos
let logos: OutputAsset[] = [];
@@ -179,7 +179,7 @@ export class IosAssetGenerator extends AssetGenerator {
throw new BadPipelineError('Sharp instance not created');
}

const iosDir = project.config.ios!.path!;
const iosDir = project.config.ios?.path ?? 'App';
const lightDefaultBackground = '#ffffff';
const generated = await Promise.all(
icons.map(async (icon) => {
@@ -242,7 +242,7 @@ export class IosAssetGenerator extends AssetGenerator {
const generated: OutputAsset[] = [];

for (const assetMeta of assetMetas) {
const iosDir = project.config.ios!.path!;
const iosDir = project.config.ios?.path ?? 'App';
const dest = join(iosDir, IOS_SPLASH_IMAGE_SET_PATH, assetMeta.name);

const outputInfo = await pipe.resize(assetMeta.width, assetMeta.height).png().toFile(dest);
@@ -273,7 +273,7 @@ export class IosAssetGenerator extends AssetGenerator {
}

private async updateIconsContentsJson(generated: OutputAsset[], project: Project) {
const assetsPath = join(project.config.ios!.path!, IOS_APP_ICON_SET_PATH);
const assetsPath = join(project.config.ios?.path ?? 'App', IOS_APP_ICON_SET_PATH);
const contentsJsonPath = join(assetsPath, 'Contents.json');
const json = await readFile(contentsJsonPath, { encoding: 'utf-8' });

@@ -304,7 +304,7 @@ export class IosAssetGenerator extends AssetGenerator {
}

private async updateSplashContentsJson(generated: OutputAsset[], project: Project) {
const contentsJsonPath = join(project.config.ios!.path!, IOS_SPLASH_IMAGE_SET_PATH, 'Contents.json');
const contentsJsonPath = join(project.config.ios?.path ?? 'App', IOS_SPLASH_IMAGE_SET_PATH, 'Contents.json');
const json = await readFile(contentsJsonPath, { encoding: 'utf-8' });

const parsed = JSON.parse(json);
@@ -334,7 +334,7 @@ export class IosAssetGenerator extends AssetGenerator {
}

private async updateSplashContentsJsonDark(generated: OutputAsset[], project: Project) {
const contentsJsonPath = join(project.config.ios!.path!, IOS_SPLASH_IMAGE_SET_PATH, 'Contents.json');
const contentsJsonPath = join(project.config.ios?.path ?? 'App', IOS_SPLASH_IMAGE_SET_PATH, 'Contents.json');
const json = await readFile(contentsJsonPath, { encoding: 'utf-8' });

const parsed = JSON.parse(json);
4 changes: 2 additions & 2 deletions src/tasks/generate.ts
Original file line number Diff line number Diff line change
@@ -93,8 +93,8 @@ async function generateAssets(assets: Assets, generators: AssetGenerator[], proj
const generated: OutputAsset[] = [];

async function generateAndCollect(asset: InputAsset) {
const g = await Promise.all(generators.map((g) => asset.generate(g, project)));
generated.push(...(g.flat().filter((f) => !!f) as OutputAsset[]));
const output = await Promise.all(generators.map((g) => asset.generate(g, project)));
generated.push(...(output.flat().filter((f) => !!f) as OutputAsset[]));
}

const assetTypes = Object.values(assets).filter((v) => !!v);