Skip to content

Commit

Permalink
Add splash for iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
race604 committed Oct 11, 2015
1 parent d30b3e6 commit 1412cc4
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 17 deletions.
2 changes: 2 additions & 0 deletions SplashScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ var styles = StyleSheet.create({
right: 0,
bottom: 30,
height: 54,
backgroundColor: 'transparent',
},
text: {
flex: 1,
Expand All @@ -106,6 +107,7 @@ var styles = StyleSheet.create({
left: 0,
right: 0,
bottom: 10,
backgroundColor: 'transparent',
}
});

Expand Down
20 changes: 20 additions & 0 deletions android/app/src/main/assets/index.android.bundle

Large diffs are not rendered by default.

55 changes: 41 additions & 14 deletions index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,49 @@ var {
View,
} = React;

var TimerMixin = require('react-timer-mixin');

var SplashScreen = require('./SplashScreen');

var RCTZhiHuDaily = 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.ios.js
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'\n'}
Cmd+D or shake for dev menu
</Text>
</View>
mixins: [TimerMixin],

getInitialState: function() {
return {
splashed: false,
};
},

componentDidMount: function() {
this.setTimeout(
() => {
this.setState({splashed: true});
},
2000,
);
},

render: function() {
if (this.state.splashed) {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.ios.js
</Text>
<Text style={styles.instructions}>
Press Cmd+R to reload,{'\n'}
Cmd+D or shake for dev menu
</Text>
</View>
);
} else {
return (
<SplashScreen />
);
}
}
});

Expand Down
1 change: 1 addition & 0 deletions ios/RCTZhiHuDaily.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEAD_CODE_STRIPPING = NO;
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
Expand Down
2 changes: 1 addition & 1 deletion ios/RCTZhiHuDaily/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
* on the same Wi-Fi network.
*/

jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"];
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];

/**
* OPTION 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"idiom" : "iphone",
"filename" : "ic_launcher.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"idiom" : "iphone",
"filename" : "ic_launcher-1.png",
"scale" : "3x"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions ios/RCTZhiHuDaily/Images.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
21 changes: 21 additions & 0 deletions ios/RCTZhiHuDaily/Images.xcassets/splash.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "splash.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "splash_logo.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions ios/main.jsbundle
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Offline JS
// To re-generate the offline bundle, run this from the root of your project:
//
// $ react-native bundle --minify
//
// See http://facebook.github.io/react-native/docs/runningondevice.html for more details.

throw new Error('Offline JS file is empty. See iOS/main.jsbundle for instructions');
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
},
"dependencies": {
"react-native": "^0.12.0",
"react-native-drawer": "^1.4.2",
"react-native-viewpager": "^0.1.0",
"react-timer-mixin": "^0.13.3"
}
Expand Down

0 comments on commit 1412cc4

Please sign in to comment.