Advertisement
Guest User

Untitled

a guest
May 25th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { Font } from "expo";
  2. import PropTypes from "prop-types";
  3. import React, { Component } from "react";
  4. import {
  5.   View,
  6.   Button,
  7.   StyleSheet,
  8.   TouchableOpacity,
  9.   Text,
  10.   ImageBackground,
  11.   ScrollView,
  12.   Image
  13. } from "react-native";
  14.  
  15. // import Zone from "./components/Zone";
  16. import Loading from "./components/Loading";
  17.  
  18. // Assets
  19. import pic from "./assets/pic.jpg";
  20. import bg2 from "./assets/bg2.jpg";
  21. import Muli from "./assets/fonts/Muli-Regular.ttf";
  22. import DancingScript from "./assets/fonts/DancingScript-Regular.ttf";
  23.  
  24. export default class Home extends Component {
  25.   constructor(props) {
  26.     super(props);
  27.     this.state = { isLoading: true, data: null, error: null };
  28.   }
  29.  
  30.   componentDidMount() {
  31.     Font.loadAsync({ Muli, DancingScript });
  32.  
  33.     return fetch(
  34.       "https://us.api.battle.net/wow/zone/4131?locale=en_US&apikey=y7qqz34zvf8pa8229tbuygzggu6d4yx5"
  35.     )
  36.       .then(response => response.json())
  37.       .then(data => {
  38.         this.setState({
  39.           isLoading: false,
  40.           data
  41.         });
  42.         console.log(data.bosses);
  43.       })
  44.       .catch(error => {
  45.         this.setState({
  46.           isLoading: false,
  47.           error: true
  48.         });
  49.         console.error(error);
  50.       });
  51.   }
  52.  
  53.   render() {
  54.     const { isLoading, error, data } = this.state;
  55.     const {
  56.       navigation: { navigate }
  57.     } = this.props;
  58.  
  59.     if (isLoading) {
  60.       return <Loading />;
  61.     }
  62.  
  63.     if (error) {
  64.       // TODO: Render an error component here
  65.     }
  66.  
  67.     return (
  68.       <ImageBackground source={bg2} style={styles.pic}>
  69.         <ScrollView
  70.           horizontal={true}
  71.           style={{ display: "flex", flexDirection: "row", flexWrap: "wrap" }}
  72.         >
  73.         <TouchableOpacity style={styles.button} onPress={() => navigate('Home')}>
  74.           <Text style={styles.buttonText}>{"Magister's Terrace"}</Text>
  75.         </TouchableOpacity>
  76.           <TouchableOpacity style={styles.button} onPress={() => navigate()}>
  77.             <Text style={styles.buttonText}>{"Selin Fireheart"}</Text>
  78.           </TouchableOpacity>
  79.           <TouchableOpacity style={styles.button} onPress={() => navigate()}>
  80.             <Text style={styles.buttonText}>{"Vexallus"}</Text>
  81.           </TouchableOpacity>
  82.           <TouchableOpacity style={styles.button} onPress={() => navigate()}>
  83.             <Text style={styles.buttonText}>{"Priestess Delrissa"}</Text>
  84.           </TouchableOpacity>
  85.           <TouchableOpacity style={styles.button} onPress={() => navigate('Kael')}
  86.           >
  87.             <Text style={styles.buttonText}>{"Kael'thas Sunstrider"}</Text>
  88.           </TouchableOpacity>
  89.         </ScrollView>
  90.       </ImageBackground>
  91.     );
  92.   }
  93. }
  94.  
  95. const styles = StyleSheet.create({
  96.   button: {
  97.     height: 60,
  98.     justifyContent: "center",
  99.     marginLeft: 40,
  100.     marginRight: 40,
  101.     marginTop: 5,
  102.     marginBottom: 5,
  103.     borderRadius: 20,
  104.     backgroundColor: "rgba(225, 164, 57, 0.5)",
  105.     zIndex: 2,
  106.     padding: 20
  107.   },
  108.   buttonText: {
  109.     fontFamily: "DancingScript",
  110.     color: "white",
  111.     fontSize: 25
  112.   },
  113.   pic: {
  114.     flex: 1,
  115.     width: null,
  116.     height: null
  117.   },
  118.   pic2: {
  119.     marginLeft: 60,
  120.     marginBottom: 20,
  121.     marginTop: -40,
  122.     height: 150,
  123.     width: 300
  124.   }
  125. });
  126.  
  127. Home.propTypes = {
  128.   navigation: PropTypes.object.isRequired
  129. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement