Guest User

Untitled

a guest
Oct 23rd, 2019
90
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react'
  2. import { View, Text, StyleSheet } from 'react-native'
  3. import { TouchableOpacity } from 'react-native-gesture-handler'
  4.  
  5. class Home extends Component {
  6. state = {
  7. links: [
  8. { title: 'Helsinki', link: 'https://ticketmaster.fi/city/helsinki/20228' },
  9. { title: 'Tampere', link: 'https://ticketmaster.fi/city/tampere/22023' },
  10. { title: 'Turku', link: 'https://ticketmaster.fi/city/turku/22112' }
  11. ]
  12. }
  13. handleButtonPress(item) {
  14. const { title, link } = item
  15. this.props.navigation.navigate('Browser', { title, link })
  16. }
  17. render() {
  18. return (
  19. <View style={styles.container}>
  20. <View style={styles.list}>
  21. {this.state.links.map((item, index) => (
  22. <TouchableOpacity
  23. key={index}
  24. onPress={() => this.handleButtonPress(item)}
  25. style={styles.button}
  26. >
  27. <Text style={styles.text}>{item.title}</Text>
  28. </TouchableOpacity>
  29. ))}
  30. </View>
  31. </View>
  32. )
  33. }
  34. }
  35. const styles = StyleSheet.create({
  36. container: {
  37. flex: 1,
  38. backgroundColor: '#fff',
  39. alignItems: 'center',
  40. justifyContent: 'center'
  41. },
  42. buttonList: {
  43. flex: 1,
  44. justifyContent: 'center'
  45. },
  46. button: {
  47. margin: 10,
  48. backgroundColor: '#356bca',
  49. borderRadius: 5,
  50. padding: 10
  51. },
  52. text: {
  53. color: '#fff',
  54. textAlign: 'center'
  55. }
  56. })
  57. export default Home
RAW Paste Data