Release React Native for Android

This is an early release and there are several things that are known
not to work if you're porting your iOS app to Android.

See the Known Issues guide on the website.

We will work with the community to reach platform parity with iOS.
This commit is contained in:
Martin Konicek
2015-09-14 15:35:58 +01:00
parent c372dab213
commit 42eb5464fd
571 changed files with 44550 additions and 116 deletions

View File

@@ -7,9 +7,29 @@ module.exports = yeoman.generators.NamedBase.extend({
constructor: function() {
yeoman.generators.NamedBase.apply(this, arguments);
this.composeWith('react:ios', {args: [this.name]}, {
local: require.resolve(path.resolve(__dirname, '..', 'generator-ios'))
this.option('skip-ios', {
desc: 'Skip generating iOS files',
type: Boolean,
defaults: false
});
this.option('skip-android', {
desc: 'Skip generating Android files',
type: Boolean,
defaults: false
});
// this passes command line arguments down to the composed generators
var args = arguments[0];
if (!this.options['skip-ios']) {
this.composeWith('react:ios', {args: args}, {
local: require.resolve(path.resolve(__dirname, '..', 'generator-ios'))
});
}
if (!this.options['skip-android']) {
this.composeWith('react:android', {args: args}, {
local: require.resolve(path.resolve(__dirname, '..', 'generator-android'))
});
}
},
configuring: function() {
@@ -28,10 +48,19 @@ module.exports = yeoman.generators.NamedBase.extend({
},
writing: function() {
this.fs.copyTpl(
this.templatePath('index.ios.js'),
this.destinationPath('index.ios.js'),
{name: this.name}
);
if (!this.options['skip-ios']) {
this.fs.copyTpl(
this.templatePath('index.ios.js'),
this.destinationPath('index.ios.js'),
{name: this.name}
);
}
if (!this.options['skip-android']) {
this.fs.copyTpl(
this.templatePath('index.android.js'),
this.destinationPath('index.android.js'),
{name: this.name}
);
}
}
});

View File

@@ -0,0 +1,52 @@
/**
* Sample React Native App
* https://github.com/facebook/react-native
*/
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
} = React;
var <%= name %> = React.createClass({
render: function() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.android.js
</Text>
<Text style={styles.instructions}>
Shake or press menu button for dev menu
</Text>
</View>
);
}
});
var styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('<%= name %>', () => <%= name %>);