diff --git a/src/project/assets/android/generator.ts b/src/project/assets/android/generator.ts index 16dbdf5..0893047 100644 --- a/src/project/assets/android/generator.ts +++ b/src/project/assets/android/generator.ts @@ -1,6 +1,6 @@ /* eslint-disable @typescript-eslint/no-non-null-assertion */ import { mkdirp, pathExists, writeFile } from '@ionic/utils-fs'; -import { dirname, join, relative } from 'path'; +import { dirname, join } from 'path'; import type { OutputInfo, Sharp } from 'sharp'; import sharp from 'sharp'; @@ -14,7 +14,6 @@ import { AssetKind, Platform } from '../asset-types'; import type { InputAsset } from '../input-asset'; import { OutputAsset } from '../output-asset'; import type { MobileProject } from '../../project'; -import { Logger } from '../../logger'; import * as AndroidAssetTemplates from './assets'; @@ -120,70 +119,6 @@ export class AndroidAssetGenerator extends AssetGenerator { return [...foregroundImages, ...backgroundImages]; } - private async _generateSplashesFromLogo( - project: MobileProject, - asset: InputAsset, - splash: AndroidOutputAssetTemplate, - pipe: Sharp, - backgroundColor: string, - ): Promise { - // Generate light splash - const resPath = this.getResPath(project); - - let drawableDir = `drawable`; - if (splash.density) { - drawableDir = `drawable-${splash.density}`; - } - - const parentDir = join(resPath, drawableDir); - if (!(await pathExists(parentDir))) { - await mkdirp(parentDir); - } - const dest = join(resPath, drawableDir, 'splash.png'); - - const targetLogoWidthPercent = this.options.logoSplashScale ?? 0.2; - let targetWidth = this.options.logoSplashTargetWidth ?? Math.floor((splash.width ?? 0) * targetLogoWidthPercent); - - if (targetWidth > splash.width || targetWidth > splash.height) { - targetWidth = Math.floor((splash.width ?? 0) * targetLogoWidthPercent); - } - - if (targetWidth > splash.width || targetWidth > splash.height) { - Logger.warn(`Logo dimensions exceed dimensions of splash ${splash.width}x${splash.height}, using default logo size`); - targetWidth = Math.floor((splash.width ?? 0) * 0.2); - } - - const canvas = sharp({ - create: { - width: splash.width ?? 0, - height: splash.height ?? 0, - channels: 4, - background: backgroundColor, - }, - }); - - const resized = await sharp(asset.path).resize(targetWidth).toBuffer(); - - const outputInfo = await canvas - .composite([{ input: resized, gravity: sharp.gravity.center }]) - .png() - .toFile(dest); - - const splashOutput = new OutputAsset( - splash, - asset, - project, - { - [dest]: dest, - }, - { - [dest]: outputInfo, - }, - ); - - return splashOutput; - } - private async generateLegacyIcon(asset: InputAsset, project: MobileProject): Promise { const icons = Object.values(AndroidAssetTemplates).filter( (a) => a.kind === AssetKind.Icon, diff --git a/src/project/assets/asset-generator.ts b/src/project/assets/asset-generator.ts index 4b2df77..acfeacf 100644 --- a/src/project/assets/asset-generator.ts +++ b/src/project/assets/asset-generator.ts @@ -13,18 +13,6 @@ export interface AssetGeneratorOptions { iconBackgroundColor?: string; // Background color for icon generation for use in dark mode scenarios iconBackgroundColorDark?: string; - // Background color for light mode splash generation - splashBackgroundColor?: string; - // Background color for dark mode splash generation - splashBackgroundColorDark?: string; - // Path to the web app manifest - pwaManifestPath?: string; - // Whether to fetch latest device sizes from official apple site - pwaNoAppleFetch?: boolean; - // Scale amount for logo when generating splashes. Default: 0.2 (20%) - logoSplashScale?: number; - // Specific width for logo when generating splashes. (not used by default) - logoSplashTargetWidth?: number; // Android product flavor name where generated assets will be created. Default: main androidFlavor?: string; } diff --git a/src/project/assets/asset-types.ts b/src/project/assets/asset-types.ts index cf2300c..8cbd829 100644 --- a/src/project/assets/asset-types.ts +++ b/src/project/assets/asset-types.ts @@ -1,31 +1,3 @@ -import type { InputAsset } from './input-asset'; - -export interface Assets { - logo: InputAsset | null; - logoDark: InputAsset | null; - icon: InputAsset | null; - iconForeground: InputAsset | null; - iconBackground: InputAsset | null; - splash: InputAsset | null; - splashDark: InputAsset | null; - - iosIcon?: InputAsset | null; - iosSplash?: InputAsset | null; - iosSplashDark?: InputAsset | null; - - androidIcon?: InputAsset | null; - androidIconForeground?: InputAsset | null; - androidIconBackground?: InputAsset | null; - - androidSplash?: InputAsset | null; - androidSplashDark?: InputAsset | null; - androidNotificationIcon?: InputAsset | null; - - pwaIcon?: InputAsset | null; - pwaSplash?: InputAsset | null; - pwaSplashDark?: InputAsset | null; -} - export enum AssetKind { Logo = 'logo', LogoDark = 'logo-dark', @@ -33,7 +5,6 @@ export enum AssetKind { Icon = 'icon', IconForeground = 'icon-foreground', IconBackground = 'icon-background', - NotificationIcon = 'notification-icon' } export enum Platform { @@ -50,18 +21,6 @@ export enum Format { Unknown = 'unknown', } -export enum Orientation { - Default = '', - Portrait = 'portrait', - Landscape = 'landscape', -} - -export enum Theme { - Any = 'any', - Light = 'light', - Dark = 'dark', -} - export enum AndroidDensity { Default = '', Ldpi = 'ldpi', @@ -126,38 +85,9 @@ export enum IosIdiom { TV = 'tv', } -export type IosOutputAssetTemplateIcon = IosOutputAssetTemplate; -export interface IosOutputAssetTemplateSplash extends IosOutputAssetTemplate { - orientation: Orientation; - theme: Theme; -} -export interface PwaOutputAssetTemplate extends OutputAssetTemplate { - name: string; - orientation?: Orientation; - density?: string; -} - export interface AndroidOutputAssetTemplate extends OutputAssetTemplate { density: AndroidDensity; } -export interface AndroidOutputAssetTemplateSplash extends OutputAssetTemplate { - density: AndroidDensity; - orientation: Orientation; -} export interface AndroidOutputAssetTemplateAdaptiveIcon extends OutputAssetTemplate { density: AndroidDensity; } - -// Shape of the Contents.json file inside of ios app appiconset and imageset folders -export interface IosContents { - images: { - filename: string; - size: string; - scale: string; - idiom: string; - }[]; - info?: { - version: number; - author: string; - }; -} diff --git a/src/project/assets/ios/generator.ts b/src/project/assets/ios/generator.ts index ebbce7c..86fa397 100644 --- a/src/project/assets/ios/generator.ts +++ b/src/project/assets/ios/generator.ts @@ -12,8 +12,6 @@ import type { MobileProject } from '../../project'; export const IOS_APP_ICON_SET_NAME = 'AppIcon'; export const IOS_APP_ICON_SET_PATH = `App/Assets.xcassets/${IOS_APP_ICON_SET_NAME}.appiconset`; -// export const IOS_SPLASH_IMAGE_SET_NAME = 'Splash'; -// export const IOS_SPLASH_IMAGE_SET_PATH = `App/Assets.xcassets/${IOS_SPLASH_IMAGE_SET_NAME}.imageset`; export const IOS_1024_ICON: IosOutputAssetTemplate = { platform: Platform.Ios, @@ -59,8 +57,6 @@ export class IosAssetGenerator extends AssetGenerator { throw new Error('Sharp instance not created'); } - const iosDir = project.config.ios!.path!; - // Generate logos let logos: OutputAsset[] = []; if (asset.kind === AssetKind.Logo) { diff --git a/src/project/project.ts b/src/project/project.ts index 4c20845..227c56c 100644 --- a/src/project/project.ts +++ b/src/project/project.ts @@ -15,7 +15,6 @@ import { NativeIosFramework } from './frameworks/native-ios'; import { NativeAndroidFramework } from './frameworks/native-android'; import { NativeScriptFramework } from './frameworks/nativescript'; import { Logger } from './logger'; -import { Assets } from './assets/asset-types' export class MobileProject { public framework: Framework | null = null; @@ -23,7 +22,6 @@ export class MobileProject { public android: AndroidProject | null = null; vfs: VFS; - assets: Assets | null = null; directory: string | null = null; assetDir: string | null = null;