diff --git a/README.md b/README.md
index 4a0ff34..872e00a 100644
--- a/README.md
+++ b/README.md
@@ -13,4 +13,5 @@
- [ ] 添加应用图标
- [ ] 适配 iOS 登录失败 toast
- [ ] 在启动时检测是否已登录
+- [ ] Splash 检测网络出错后在 Splash UI 中显示错误并不跳转
diff --git a/src/Router.js b/src/Router.js
index a3d81c9..32dd768 100644
--- a/src/Router.js
+++ b/src/Router.js
@@ -1,6 +1,6 @@
import React, {Component} from 'react';
import {View, Animated, Dimensions} from 'react-native';
-import {YooLogin, YooForum} from './component/index';
+import {YooLogin, YooForum, YooSplash} from './component/index';
const width = Dimensions.get('window').width;
@@ -8,20 +8,24 @@ export default class Router extends Component {
constructor(props) {
super(props);
this.state = {
- currentX: new Animated.Value(0),
- nextX: new Animated.Value(width),
+ currentPage: 'splash',
+ splashX: new Animated.Value(0),
+ loginX: new Animated.Value(width),
+ forumX: new Animated.Value(width),
};
this.gotoForum = this.gotoForum.bind(this);
+ this.gotoLogin = this.gotoLogin.bind(this);
}
- gotoForum() {
+ gotoLogin() {
+ this.setState({currentPage: 'login'});
Animated.parallel([
- Animated.timing(this.state.currentX, {
+ Animated.timing(this.state.splashX, {
toValue: -width,
duration: 500,
useNativeDriver: false,
}),
- Animated.timing(this.state.nextX, {
+ Animated.timing(this.state.loginX, {
toValue: 0,
duration: 500,
useNativeDriver: false,
@@ -29,13 +33,46 @@ export default class Router extends Component {
]).start();
}
+ gotoForum() {
+ if (this.state.currentPage === 'splash') {
+ Animated.parallel([
+ Animated.timing(this.state.splashX, {
+ toValue: -width,
+ duration: 500,
+ useNativeDriver: false,
+ }),
+ Animated.timing(this.state.forumX, {
+ toValue: 0,
+ duration: 500,
+ useNativeDriver: false,
+ }),
+ ]).start();
+ } else {
+ Animated.parallel([
+ Animated.timing(this.state.loginX, {
+ toValue: -width,
+ duration: 500,
+ useNativeDriver: false,
+ }),
+ Animated.timing(this.state.forumX, {
+ toValue: 0,
+ duration: 500,
+ useNativeDriver: false,
+ }),
+ ]).start();
+ }
+ }
+
render() {
return (