You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.1 KiB
82 lines
2.1 KiB
4 years ago
|
import React, {Component} from 'react';
|
||
|
import {View, Animated, Dimensions} from 'react-native';
|
||
4 years ago
|
import {YooLogin, YooForum, YooSplash} from './component/index';
|
||
4 years ago
|
|
||
|
const width = Dimensions.get('window').width;
|
||
|
|
||
4 years ago
|
export default class YooRouter extends Component {
|
||
4 years ago
|
constructor(props) {
|
||
|
super(props);
|
||
|
this.state = {
|
||
4 years ago
|
currentPage: 'splash',
|
||
|
splashX: new Animated.Value(0),
|
||
|
loginX: new Animated.Value(width),
|
||
|
forumX: new Animated.Value(width),
|
||
4 years ago
|
};
|
||
|
this.gotoForum = this.gotoForum.bind(this);
|
||
4 years ago
|
this.gotoLogin = this.gotoLogin.bind(this);
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
gotoLogin() {
|
||
|
this.setState({currentPage: 'login'});
|
||
4 years ago
|
Animated.parallel([
|
||
4 years ago
|
Animated.timing(this.state.splashX, {
|
||
4 years ago
|
toValue: -width,
|
||
|
duration: 500,
|
||
|
useNativeDriver: false,
|
||
|
}),
|
||
4 years ago
|
Animated.timing(this.state.loginX, {
|
||
4 years ago
|
toValue: 0,
|
||
|
duration: 500,
|
||
|
useNativeDriver: false,
|
||
|
}),
|
||
|
]).start();
|
||
|
}
|
||
|
|
||
4 years ago
|
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();
|
||
|
}
|
||
|
}
|
||
|
|
||
4 years ago
|
render() {
|
||
|
return (
|
||
|
<View>
|
||
4 years ago
|
<Animated.View style={{left: this.state.splashX}}>
|
||
|
<YooSplash gotoLogin={this.gotoLogin} gotoForum={this.gotoForum} />
|
||
|
</Animated.View>
|
||
|
<Animated.View style={{left: this.state.loginX}}>
|
||
|
<YooLogin gotoForum={this.gotoForum} />
|
||
4 years ago
|
</Animated.View>
|
||
4 years ago
|
<Animated.View style={{left: this.state.forumX}}>
|
||
4 years ago
|
<YooForum />
|
||
|
</Animated.View>
|
||
|
</View>
|
||
|
);
|
||
|
}
|
||
|
}
|