const Base = require('yeoman-generator').Base;
const imageGenerator = require('./imageGenerator');

class ResourcesGenerator extends Base {
  constructor(...args) {
    super(...args);
    this.option('icon', {
      desc: 'Icon source',
    });
    this.option('splash', {
      desc: 'Splashscreen source',
    });
    this.option('android', {
      desc: 'Build for Android',
    });
    this.option('iOS', {
      desc: 'Build for iOS',
    });
  }

  prompting() {
    return this.prompt([{
      type: 'input',
      name: 'projectName',
      message: 'Name of your react-native project',
      required: true,
    }]).then((answers) => {
      this.answers = answers;
    });
  }

  checkOSToBuildFor() {
    this.android = this.options.android || !this.options.ios;
    this.ios = this.options.ios || !this.options.android;
  }

  setupIosIcons() {
    if (!this.ios || !this.options.icon) return;

    const iosIconFolder = `ios/${this.answers.projectName}/Images.xcassets/AppIcon.appiconset`;

    this.fs.copyTpl(
      this.templatePath('AppIconsetContents.json'),
      this.destinationPath(`${iosIconFolder}/Contents.json`)
    );

    imageGenerator.generateIosIcons(
      this.options.icon,
      iosIconFolder
    );
  }

  setupAndroidIcons() {
    if (!this.android || !this.options.icon) return;
    imageGenerator.generateAndroidIcons(this.options.icon);
  }

  setupIosSplashScreen() {
    if (!this.ios || !this.options.splash) return;

    const iosSplashFolder = `ios/${this.answers.projectName}/Images.xcassets/LaunchImage.launchimage`;

    this.fs.copyTpl(
      this.templatePath('LaunchImageLaunchimageContents.json'),
      `${iosSplashFolder}/Contents.json`
    );

    imageGenerator.generateIosSplashScreen(
      this.options.splash,
      iosSplashFolder
    );
  }

  setupAndroidSplashScreen() {
    if (!this.android || !this.options.splash) return;
    imageGenerator.generateAndroidSplashScreen(this.options.splash);
  }
}

module.exports = ResourcesGenerator;

@@ -684,16 +684,197 @@
 %0A  %7D%0A%0A  
+writing() %7B%0A    this._checkOSToBuildFor();%0A    this._setupIosIcons();%0A    this._setupAndroidIcons();%0A    this._setupIosSplashScreen();%0A    this._setupAndroidSplashScreen();%0A  %7D%0A%0A  _
 checkOST
@@ -883,24 +883,24 @@
 uildFor() %7B%0A
-
     this.and
@@ -1006,32 +1006,33 @@
 android;%0A  %7D%0A%0A  
+_
 setupIosIcons() 
@@ -1410,32 +1410,33 @@
 r%0A    );%0A  %7D%0A%0A  
+_
 setupAndroidIcon
@@ -1557,24 +1557,25 @@
 on);%0A  %7D%0A%0A  
+_
 setupIosSpla
@@ -1982,18 +1982,19 @@
 );%0A  %7D%0A%0A
-
   
+_
 setupAnd

Switch to Yeoman hooks for assets generator