Advertisement
Guest User

DetailsScreen.js

a guest
Apr 23rd, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. import React from 'react';
  2. import { Button, Text, View, SafeAreaView, Linking, ImageBackground } from 'react-native';
  3. import { Ionicons } from '@expo/vector-icons'; // 6.2.2
  4. import { StackNavigator, TabNavigator, TabBarBottom } from 'react-navigation';
  5. import Touchable from 'react-native-platform-touchable';
  6.  
  7.  
  8. import styles from '.././styles/styles';
  9.  
  10. /* Class is used for Maps Details screen */
  11.  
  12. export default class DetailsScreen extends React.Component {
  13.  
  14. static navigationOptions = ({ navigation }) => {
  15. const { params } = navigation.state;
  16.  
  17. return {
  18. tabBarLabel: '',
  19. headerTitle: <Text style={styles.headertitle}>{params ? params.title : 'null'}</Text>,
  20. headerStyle: {
  21. elevation: 0.4,
  22. shadowOpacity: 0.4
  23. }
  24. };
  25. };
  26.  
  27. //params ? params.title.length <= 30 ? params.title : params.title.substring(0, 31)+ "..."
  28.  
  29. /*static navigationOptions = {
  30. tabBarLabel: '',
  31. headerTitle: <Text style={ styles.headertitle }>Details</Text>,
  32. headerStyle: {
  33. elevation: 0.4,
  34. shadowOpacity: 0.4
  35. }
  36. };*/
  37.  
  38. render() {
  39. const { params } = this.props.navigation.state;
  40. const title = params ? params.title : null;
  41. const location = params ? params.location : null;
  42. const description = params ? params.description : null;
  43. const image = params ? params.image : null;
  44.  
  45. return (
  46. <View style={{ backgroundColor: 'white', paddingTop: 20, flex: 1, flexDirection: 'column', justifyContent: 'flex-start' }}>
  47. <Text style={styles.cardtitleBlack}>{location}</Text>
  48. <ImageBackground
  49. style={{ flex: 1, margin: 10, marginTop: 20 }}
  50. source={image}
  51. >
  52. <View style={{ flex: 1 }} />
  53. </ImageBackground>
  54. <Text style={[styles.cardtitleBlack, { marginTop: 20 }]}>{description}</Text>
  55. <View style={{ backgroundColor: 'white', paddingTop: 20, flex: 1, flexDirection: 'column', justifyContent: 'flex-end' }}>
  56. <Touchable
  57. onPress={() => { Linking.openURL(`https://www.google.com/maps/dir/?api=1&origin&destination=${description}`); }}
  58. style={[styles.button, { backgroundColor: '#888888' }]}
  59. >
  60. <View>
  61. <Text style={styles.cardtext}>
  62. Open in Google Maps
  63. </Text>
  64. </View>
  65. </Touchable>
  66. </View>
  67. </View>
  68. );
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement