1 Star 0 Fork 53

-苏若年-/DotaVideo

forked from 0-hun/DotaVideo 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
app.js 2.53 KB
一键复制 编辑 原始数据 按行查看 历史
0-hun 提交于 2016-05-14 15:42 . 完成用户中心 和 搜索
'use strict';
var React = require('react-native');
import Home from './app/Screens/home';
import TopList from './app/Screens/topList';
import Users from './app/Screens/users';
import UserVideo from './app/Screens/userVideos';
import Video from './app/Screens/video';
import Web from './app/Screens/web';
import Login from './app/Screens/login';
import UserCenter from './app/Screens/userCenter';
import Search from './app/Screens/search';
import Main from './app/common/Main';
var {
Navigator,
AsyncStorage
} = React;
var App = React.createClass({
getInitialState:function(){
return {
userinfo:{}
}
},
renderScene(router, navigator){
var Component = null;this._navigator = navigator;
switch(router.name){
case "Home":
Component = Home;
break;
case "TopList":
Component = TopList;
break;
case "Users":
Component = Users;
break;
case "UserVideo":
Component = UserVideo;
break;
case "Video":
Component = Video;
break;
case "Web":
Component = Web;
break;
case "Login":
Component = Login;
break;
case "UserCenter":
Component = UserCenter;
break;
case "Search":
Component = Search;
break;
default: //default view
Component = Home;
}
return <Component navigator={navigator} {...router.passProps} app={this}/>
},
componentDidMount:function(){
AsyncStorage.getItem('_user',(err,res)=>{
//console.log("componentDidMount",res);
if(err!=null)
return;
this.setState({
userinfo:JSON.parse(res)
});
});
},
_render:function(){
return (
<Navigator
initialRoute={{name: 'Home'}}
userinfo={this.state.userinfo}
renderScene={this.renderScene}
configureScene={(route) => {
if (route.sceneConfig) {
return route.sceneConfig;
}
return Navigator.SceneConfigs.FadeAndroid;
}}
/>
);
},
render() {
//console.log(this.state.userinfo);
return this._render();
}
});
module.exports = App;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
NodeJS
1
https://gitee.com/dennisit/DotaVideo.git
git@gitee.com:dennisit/DotaVideo.git
dennisit
DotaVideo
DotaVideo
master

搜索帮助