-
Notifications
You must be signed in to change notification settings - Fork 9
/
root.js
99 lines (83 loc) · 2.01 KB
/
root.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import React, { Component } from 'react';
import {
StyleSheet,
Navigator,
View,
Animated,
Text,
Platform,
} from 'react-native';
import App from './app';
const toolbarAction=[
{title:'频道订阅',icon: require('image!ic_search'),show:'always'},
{title:'我的',icon: require('image!ic_personal_normal'),show:'always'}
];
import Splash from './Splash';
import Util from './view/Util';
export default class Root extends Component{
constructor(props){
super(props);
this.state={
splashed:false,
bounceAnimValue:new Animated.Value(1.4),//初始化
};
this.onAnimEnd=this.onAnimEnd.bind(this);
}
componentDidMount(){
Animated.timing(this.state.bounceAnimValue,
{
toValue:1,
duration:400,
delay:1000,
}).start();
}
//splash 动画执行完毕回调
onAnimEnd(){
this.setState({
splashed:true
});
}
render(){
let defaultName='app';
let defaultComponent=App;
return (
<View style={styles.container}>
<View style={styles.main}>
<Animated.View
style={{
flex:1,
transform: [
{scale: this.state.bounceAnimValue},
]
}}>
<Navigator
initialRoute={{name:defaultName,component:defaultComponent}}
configureScene={()=>Navigator.SceneConfigs.PushFromRight}
renderScene={(route, navigator) => {
let Component = route.component;
return <Component {...route.params} navigator={navigator} />
}} />
</Animated.View>
</View>
{this.state.splashed?
null:
<Splash
style={{height:Util.size.height,position:'absolute'}}
onAnimEnd={this.onAnimEnd}
/>
}
</View>
);
}
}
var styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor:'#fff'
},
main:{
height:Platform.OS==='android'?Util.size.height-24:Util.size.height,
width:Util.size.width,
position:'absolute',
}
});