Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from "react";
- import {
- Platform,
- StyleSheet,
- Text,
- View,
- Button,
- Alert,
- Dimensions,
- Image,
- Animated,
- Easing,
- LayoutAnimation,
- NativeModules,
- TextInput
- } from "react-native";
- const { UIManager } = NativeModules;
- UIManager.setLayoutAnimationEnabledExperimental &&
- UIManager.setLayoutAnimationEnabledExperimental(true);
- let deviceWidth = Dimensions.get("window").width;
- let deviceHeight = Dimensions.get("window").height;
- export default class AppHome extends Component {
- constructor(props) {
- super(props);
- this.state = { x:null,y:null,
- size: new Animated.Value(0),
- size1: new Animated.Value(0),
- size2: new Animated.Value(0),
- sizenho: new Animated.Value(0),
- screen1: true,
- screen2:false,
- time: new Animated.Value(0),
- tab1:true,
- tab2:false };
- }
- componentDidMount() {
- const anim1 = Animated.timing(this.state.size, {
- toValue: 1,
- duration: 1000,
- easing: Easing.bounce
- }).start();
- const anim2 = Animated.timing(this.state.size1, {
- toValue: 1,
- duration: 500,
- easing: Easing.ease
- }).start();
- const animnho = Animated.timing(this.state.sizenho, {
- toValue: 1,
- duration: 1000,
- easing: Easing.bounce
- });
- animnho.start();
- //Animated.stagger(200, [anim1, anim2]).start();
- }
- onPreeScreen1 = () => {
- this.state.size.setValue(0);
- this.state.size1.setValue(0);
- this.state.sizenho.setValue(0);
- this.state.time.setValue(0);
- const ani1 = Animated.timing(this.state.size, {
- toValue: 1,
- duration: 1000,
- easing: Easing.bounce
- });
- const ani2 = Animated.timing(this.state.size1, {
- toValue: 1,
- duration: 200,
- easing: Easing.ease
- });
- Animated.timing(this.state.sizenho, {
- toValue: 1,
- duration: 1000,
- easing: Easing.bounce
- }).start();
- Animated.stagger(0, [ani1, ani2]).start();
- Animated.timing(this.state.time, {
- toValue: 1,
- duration: 1000,
- easing: Easing.bounce
- }).start();
- if (this.state.screen1 == true) {
- this.setState({
- screen1: false
- });
- } else {
- this.setState({
- screen1: true
- });
- }
- if (this.state.screen2 == true) {
- this.setState({
- screen2: false
- });
- } else {
- this.setState({
- screen2: true
- });
- }
- };
- onPreeScreen2 = () => {
- this.state.size.setValue(0);
- this.state.size1.setValue(0);
- this.state.sizenho.setValue(0);
- this.state.time.setValue(0);
- const ani1 = Animated.timing(this.state.size, {
- toValue: 1,
- duration: 500,
- easing: Easing.ease
- }).start();
- const ani2 = Animated.timing(this.state.size1, {
- toValue: 1,
- duration: 500,
- easing: Easing.ease
- }).start();
- Animated.timing(this.state.sizenho, {
- toValue: 1,
- duration: 1000,
- easing: Easing.bounce
- }).start();
- //Animated.stagger(200, [ani1, ani2]).start();
- Animated.timing(this.state.time, {
- toValue: 1,
- duration: 1000,
- easing: Easing.bounce
- }).start();
- if (this.state.screen1 == true) {
- this.setState({ screen1: false });
- } else {
- this.setState({ screen1: true });
- }
- if (this.state.screen2 == true) {
- this.setState({ screen2: false });
- } else {
- this.setState({ screen2: true });
- }
- };
- onPress(evt) {
- const { locationX, locationY } = evt.nativeEvent;
- this.setState({ x: locationX, y: locationY });
- console.log(locationX, locationY);
- }
- onMove(evt) {
- const { locationX, locationY } = evt.nativeEvent;
- const { x, y } = this.state;
- if (1.5 * (locationX - x) / deviceWidth > 0.2) {
- if(this.state.tab1=true)
- {
- this.setState({
- tab1:false,
- tab2:true
- });
- }
- }
- if (1.5 * (locationX - x) / deviceWidth < -0.2) {
- if (this.state.tab2 = true) {
- this.setState({
- tab1: true,
- tab2:false
- });
- }
- }
- }
- render() {
- const size = this.state.size.interpolate({
- inputRange: [0, 0.5, 1],
- outputRange: [110, 130, 150]
- });
- const size1width = this.state.size1.interpolate({
- inputRange: [0, 0.5, 1],
- outputRange: [200, 250, 300]
- });
- const size1height = this.state.size2.interpolate({
- inputRange: [0, 0.5, 1],
- outputRange: [10, 20, 40]
- });
- const sizenho = this.state.sizenho.interpolate({
- inputRange: [0, 0.5, 1],
- outputRange: [150, 130, 110]
- });
- const marginBottom = this.state.time.interpolate({
- inputRange: [0, 1],
- outputRange: [-2 * deviceHeight, 0]
- });
- return <View style = {
- {
- backgroundColor: "#b2d0ff",
- width: deviceWidth,
- height: deviceHeight,
- flex: 1
- }
- } >
- {this.state.screen1 ? <View style={{ alignSelf: "center", flex: 1 }}>
- <Animated.Image source={require("./image/iconmap.png")} style={{ width: size, height: size, marginTop: 50 }} />
- </View> : null}
- {this.state.screen2 ? <View style={{ alignSelf: "center", flex: 1 }}>
- <Animated.Image source={require("./image/iconmap.png")} style={{ width: sizenho, height: sizenho, marginTop: 50 }} />
- </View> : null}
- {this.state.screen1 ? <View style={{ flex: 1 }}>
- <Animated.View style={{ width: size1width, height: 40, margin: 20, alignSelf: "center" }}>
- <Button onPress={() => {
- Alert.alert("You tapped the button!");
- }} style={{ height: 40, backgroundColor: "#5a9afc", alignContent: "center" }} title="Create Account" />
- </Animated.View>
- <View style={{ flexDirection: "row", alignSelf: "center" }}>
- <View style={{ backgroundColor: "#ffffff", width: deviceWidth / 3, height: 1 }} />
- <Text style={{ color: "#ffffff", fontWeight: "bold", fontSize: 10, marginTop: -7, marginLeft: 2, marginRight: 2 }}>
- OR
- </Text>
- <View style={{ backgroundColor: "#ffffff", width: deviceWidth / 3, height: 1 }} />
- </View>
- <View style={{ margin: 10 }}>
- <Animated.View style={{ height: 40, width: size1width, marginRight: 10, marginLeft: 10, alignSelf: "center" }}>
- <Button onPress={this.onPreeScreen2} style={{ backgroundColor: "#5a9afc" }} title="Sign In" />
- </Animated.View>
- </View>
- </View> : null}
- {
- this.state.screen2 ? <Animated.View style = {
- {
- backgroundColor: "rgba(12, 6, 182, 0.3)",
- flex: 2,
- marginBottom
- }
- } >
- {this.state.tab1 ? <View
- onStartShouldSetResponder={() => true}
- onMoveShouldSetResponder={() => true}
- onResponderMove={this.onMove.bind(this)}
- onResponderGrant={this.onPress.bind(this)}
- style={{ flex: 1, margin: 10 ,backgroundColor:'red'}}>
- <TextInput
- onChangeText = {
- (value) => this.setState({
- username: value
- })
- }
- value = {
- ''+this.state.x
- }
- underlineColorAndroid="transparent" autoCapitalize="none" placeholder="User name or Email" placeholderTextColor="#ffffff" style={{ marginTop: 130, marginLeft: 10, marginRight: 10, backgroundColor: "rgba(255, 255, 255, 0.2)", height: 40 }} />
- <TextInput
- onChangeText = {
- (value) => this.setState({
- username: value
- })
- }
- value = {
- ''+this.state.x
- }
- underlineColorAndroid = "transparent"
- autoCapitalize = "none"
- placeholder = "Password"
- placeholderTextColor = "#ffffff"
- style = {
- {
- margin: 10,
- backgroundColor: "rgba(255, 255, 255, 0.2)",
- height: 40
- }
- }
- />
- <View style={{ margin: 10 }}>
- < Animated.View style = {
- {
- height: 40,
- width: size1width,
- marginRight: 10,
- marginLeft: 10,
- alignSelf: "center"
- }
- } >
- <Button onPress={this.onPreeScreen2} style={{ backgroundColor: "#5a9afc" }} title="Submit" />
- </Animated.View>
- </View>
- <Text style={{ color: "#ffffff", fontSize: 14, textAlign: "center", fontWeight: "bold",marginBottom:2 }}>
- Login With Facebook = {this.x}{this.y} !
- </Text>
- </View>:null}
- {this.state.tab2 ? <View
- onStartShouldSetResponder={() => true}
- onMoveShouldSetResponder={() => true}
- onResponderMove={this.onMove.bind(this)}
- onResponderGrant={this.onPress.bind(this)}
- style={{ flex: 1, margin: 10 ,backgroundColor:'#123'}}>
- <TextInput
- onChangeText = {
- (value) => this.setState({
- username: value
- })
- }
- value = {
- ''+this.state.x
- }
- underlineColorAndroid="transparent" autoCapitalize="none" placeholder="User name or Email" placeholderTextColor="#ffffff" style={{ marginTop: 130, marginLeft: 10, marginRight: 10, backgroundColor: "rgba(255, 255, 255, 0.2)", height: 40 }} />
- <TextInput
- onChangeText = {
- (value) => this.setState({
- username: value
- })
- }
- value = {
- ''+this.state.x
- }
- underlineColorAndroid = "transparent"
- autoCapitalize = "none"
- placeholder = "Password"
- placeholderTextColor = "#ffffff"
- style = {
- {
- margin: 10,
- backgroundColor: "rgba(255, 255, 255, 0.2)",
- height: 40
- }
- }
- />
- <View style={{ margin: 10 }}>
- < Animated.View style = {
- {
- height: 40,
- width: size1width,
- marginRight: 10,
- marginLeft: 10,
- alignSelf: "center"
- }
- } >
- <Button onPress={this.onPreeScreen2} style={{ backgroundColor: "#5a9afc" }} title="Submit" />
- </Animated.View>
- </View>
- <Text style={{ color: "#ffffff", fontSize: 14, textAlign: "center", fontWeight: "bold",marginBottom:2 }}>
- Login With Facebook = {this.x}{this.y} !
- </Text>
- </View>:null}
- </Animated.View> : null}
- </View>;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement