Skip to content

Commit

Permalink
Updates ios generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo Quevedo committed May 25, 2019
1 parent dc4f5f4 commit ecb1556
Show file tree
Hide file tree
Showing 5 changed files with 147 additions and 139 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

/resources/*/
/android/*/
/ios/*/

# system
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion src/copy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const copyAndroid = require('./platforms/android/index')
const copyIOS = require('./platforms/ios/index')
const { log } = console

module.exports = async () => {
module.exports = () => {
return new Promise((resolve, reject) => {
copyAndroid()
.then(() => {
Expand Down
6 changes: 3 additions & 3 deletions src/copy/platforms/android/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ const copyAndroidSplashes = async () => {
}

module.exports = () =>
new Promise((resolve, reject) => {
new Promise(async (resolve, reject) => {
try {
if (fs.existsSync(androidIconsDestination)) {
copyAndroidIcons()
copyAndroidSplashes()
await copyAndroidIcons()
await copyAndroidSplashes()
resolve()
} else {
resolve()
Expand Down
52 changes: 21 additions & 31 deletions src/copy/platforms/ios/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ const path = require('path')
const rootPath = path.resolve(__dirname, '../../../../')

const iosIconsOrigin = path.join(rootPath, 'resources', 'ios', 'icon')
const iosIconsDestination = path.join(rootPath, 'ios', 'app', 'src', 'main', 'res')
const iosIconsDestination = path.join(rootPath, 'ios', 'App/App/Assets.xcassets/AppIcon.appiconset')

const iosSplashesOrigin = path.join(rootPath, 'resources', 'ios', 'splash')
const iosSplashesDestination = path.join(rootPath, 'ios', 'app', 'src', 'main', 'res')
const iosSplashOrigin = path.join(rootPath, 'resources', 'splash.png')
const iosSplashesDestination = path.join(rootPath, 'ios', 'App/App/Assets.xcassets/Splash.imageset')

const getIOSIcons = () => {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -47,44 +47,34 @@ const copyIOSIcons = async () => {
)
}

const getIOSSplashes = () => {
return new Promise((resolve, reject) => {
const copyIOSSplash = async () => {
new Promise((resolve, reject) => {
try {
const files = klawSync(iosSplashesOrigin)
.map(file => file.path.replace(iosSplashesOrigin, ''))
.filter(filePath => filePath && filePath.indexOf('.') > -1)
resolve(files)
fs.copyFileSync(
path.join(iosSplashOrigin),
path.join(iosSplashesDestination, 'splash-2732x2732.png')
)
fs.copyFileSync(
path.join(iosSplashOrigin),
path.join(iosSplashesDestination, 'splash-2732x2732-1.png')
)
fs.copyFileSync(
path.join(iosSplashOrigin),
path.join(iosSplashesDestination, 'splash-2732x2732-2.png')
)
resolve()
} catch (e) {
reject(e)
}
})
}

const copyIOSSplashes = async () => {
const splashes = await getIOSSplashes()
return Promise.all(
splashes.map(splashPath => {
new Promise((resolve, reject) => {
try {
fs.copyFileSync(
path.join(iosSplashesOrigin, splashPath),
path.join(iosSplashesDestination, splashPath.replace('-screen.png', '/splash.png'))
)
resolve()
} catch (e) {
reject(e)
}
})
})
)
}

module.exports = () =>
new Promise((resolve, reject) => {
new Promise(async (resolve, reject) => {
try {
if (fs.existsSync(iosIconsDestination)) {
copyIOSIcons()
copyIOSSplashes()
await copyIOSIcons()
await copyIOSSplash()
resolve()
} else {
resolve()
Expand Down
224 changes: 120 additions & 104 deletions src/generate/platforms/icons/ios.js
Original file line number Diff line number Diff line change
@@ -1,105 +1,121 @@
module.exports = {
platform: 'ios',
type: 'icon',
path: 'ios/icon',
definitions: [{
name: 'icon.png',
size: 57,
comment: 'Default icon (avoid Apple submit error ITMS-90032)'
},
{
name: '[email protected]',
size: 114,
comment: 'iPhone / iPod Touch'
},
// iOS 6.1, Spotlight Icon
{
name: 'icon-40.png',
size: 40,
comment: 'iOS 6.1, Spotlight Icon'
},
{
name: '[email protected]',
size: 80,
comment: 'iOS 6.1, Spotlight Icon'
},
{
name: '[email protected]',
size: 120,
comment: 'iOS 6.1, Spotlight Icon'
},
// iPad Spotlight and Settings Icon
{
name: 'icon-50.png',
size: 50,
comment: 'iPad Spotlight and Settings Icon'
},
{
name: '[email protected]',
size: 100,
comment: 'iPad Spotlight and Settings Icon'
},
// iOS 7.0+, iPhone / iPod Touch
{
name: 'icon-60.png',
size: 60,
comment: 'iOS 7.0+, iPhone / iPod Touch'
},
// iPhone 6s, iPhone 6, iPhone SE
{
name: '[email protected]',
size: 120,
comment: 'iPhone 6s, iPhone 6, iPhone SE'
},
// iOS 8.0+, iPhone 6s Plus, iPhone 6 Plus
{
name: '[email protected]',
size: 180,
comment: 'iOS 8.0+, iPhone 6s Plus, iPhone 6 Plus'
},
// iPad
{
name: 'icon-72.png',
size: 72,
comment: 'iPad'
},
{
name: '[email protected]',
size: 144,
comment: 'iPad'
},
{
name: 'icon-76.png',
size: 76,
comment: 'iPad'
},
// iPad, iPad mini
{
name: '[email protected]',
size: 152,
comment: 'iPad, iPad mini'
},
// iPad Pro
{
name: '[email protected]',
size: 167,
comment: 'iPad Pro'
},
// iPhone Spotlight and Settings Icon
{
name: 'icon-small.png',
size: 29,
comment: 'iPhone Spotlight and Settings Icon'
},
{
name: '[email protected]',
size: 58,
comment: 'iPhone Spotlight and Settings Icon'
},
{
name: '[email protected]',
size: 87,
comment: 'iPhone Spotlight and Settings Icon'
}
]
};
platform: 'ios',
type: 'icon',
path: 'ios/icon',
definitions: [
{
size: 20,
idiom: 'iphone',
name: '[email protected]',
scale: '2x'
},
{
size: 40,
idiom: 'iphone',
name: '[email protected]',
scale: '2x'
},
{
size: 60,
idiom: 'iphone',
name: '[email protected]',
scale: '3x'
},
{
size: 58,
idiom: 'iphone',
name: '[email protected]',
scale: '2x'
},
{
size: 87,
idiom: 'iphone',
name: '[email protected]',
scale: '3x'
},
{
size: 80,
idiom: 'iphone',
name: '[email protected]',
scale: '2x'
},
{
size: 120,
idiom: 'iphone',
name: '[email protected]',
scale: '3x'
},
{
size: 120,
idiom: 'iphone',
name: '[email protected]',
scale: '2x'
},
{
size: 180,
idiom: 'iphone',
name: '[email protected]',
scale: '3x'
},
{
size: 20,
idiom: 'ipad',
name: '[email protected]',
scale: '1x'
},
{
size: 40,
idiom: 'ipad',
name: '[email protected]',
scale: '2x'
},
{
size: 29,
idiom: 'ipad',
name: '[email protected]',
scale: '1x'
},
{
size: 58,
idiom: 'ipad',
name: '[email protected]',
scale: '2x'
},
{
size: 40,
idiom: 'ipad',
name: '[email protected]',
scale: '1x'
},
{
size: 80,
idiom: 'ipad',
name: '[email protected]',
scale: '2x'
},
{
size: 76,
idiom: 'ipad',
name: '[email protected]',
scale: '1x'
},
{
size: 152,
idiom: 'ipad',
name: '[email protected]',
scale: '2x'
},
{
size: 167,
idiom: 'ipad',
name: '[email protected]',
scale: '2x'
},
{
size: 1024,
idiom: 'ios-marketing',
name: '[email protected]',
scale: '1x'
}
]
}

0 comments on commit ecb1556

Please sign in to comment.