Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react';
  2. import { View, StyleSheet, Text, ScrollView, TextInput, TouchableOpacity, TouchableHighlight, Modal, ImageBackground, Image, Alert } from 'react-native';
  3. import Constants from 'expo-constants'
  4. import { LinearGradient } from 'expo-linear-gradient';
  5. import MapView, { PROVIDER_GOOGLE } from 'react-native-maps'
  6. import { activateKeepAwake, deactivateKeepAwake } from 'expo-keep-awake';
  7. import * as MediaLibrary from 'expo-media-library';
  8. import * as TaskManager from 'expo-task-manager';
  9. import * as Location from 'expo-location';
  10. import * as Permissions from 'expo-permissions'
  11. import SwipeUpDown from 'react-native-swipe-up-down';
  12. import { Ionicons, AntDesign, EvilIcons, MaterialCommunityIcons, MaterialIcons, Feather } from '@expo/vector-icons';
  13. import { Stopwatch } from 'react-native-stopwatch-timer'
  14. import ViewShot from "react-native-view-shot";
  15. import haversine from 'haversine'
  16. import pick from 'lodash/pick'
  17.  
  18. const customData = require('./components/map.json')
  19.  
  20. const LOCATION_TASK_NAME = 'background-location-task';
  21.  
  22. test = []
  23.  
  24. export default class App extends Component {
  25.  
  26.   constructor(props) {
  27.     super(props)
  28.     this.state = {
  29.       mapRegion: null,
  30.       hasLocationPermissions: false,
  31.       locationResult: null,
  32.       position: {
  33.         latitude: 51.5033640,
  34.         longitude: -0.1276250
  35.       },
  36.       pets: {
  37.         pet: ''
  38.       },
  39.       checks: {
  40.  
  41.       },
  42.       once: false,
  43.       stopped: false,
  44.       ended: true,
  45.       switched: true,
  46.       checkin: false,
  47.       info: false,
  48.       checked: false,
  49.       start: true,
  50.       locked: false,
  51.       clues: [],
  52.       notes: '',
  53.       timeIn: null,
  54.       timeOut: null,
  55.       routeCoordinates: [],
  56.       distanceTravelled: 0,
  57.       prevLatLng: {},
  58.       modalVisible: false,
  59.       countDown: false,
  60.       remainingSeconds: 0,
  61.       interval: null,
  62.       rollGranted: false,
  63.       cameraGranted: false,
  64.       viewShot2: null,
  65.       Screeny: false
  66.     };
  67.   }
  68.  
  69.   handleAwake = () => {
  70.     activateKeepAwake();
  71.   }
  72.  
  73.   handleSleep = () => {
  74.     deactivateKeepAwake();
  75.   }
  76.  
  77.   handleStart() {
  78.     var ival = setInterval(() => {
  79.       if ((this.state.remainingSeconds > -1) && this.state.countDown) {
  80.         this.setState(prevState => {
  81.           return { remainingSeconds: prevState.remainingSeconds + 1 };
  82.         });
  83.       }
  84.     }, 1000);
  85.  
  86.     this.setState(prevState => {
  87.       return {
  88.         remainingSeconds: prevState.remainingSeconds,
  89.         countDown: true,
  90.         interval: ival,
  91.       };
  92.     });
  93.   }
  94.  
  95.   handleStop() {
  96.     clearInterval(this.state.interval);
  97.     this.setState(prevState => {
  98.       return {
  99.         remainingSeconds: prevState.remainingSeconds,
  100.         countDown: false,
  101.         interval: null,
  102.       };
  103.     });
  104.   }
  105.  
  106.   handleReset() {
  107.     clearInterval(this.state.interval);
  108.     this.setState(() => {
  109.       return {
  110.         remainingSeconds: 0,
  111.         countDown: false,
  112.       };
  113.     });
  114.   }
  115.  
  116.   onSomeInputChange(text, item) {
  117.     const pet = {
  118.       [item]: text
  119.     };
  120.     this.setState({ pets: [...this.state.pets, pet] });
  121.   }
  122.  
  123.   formatRemainingSeconds(remainingSeconds) {
  124.     let numMinutes = Math.floor(remainingSeconds / 60);
  125.     let numSeconds = remainingSeconds % 60;
  126.     let formattedTime = "";
  127.  
  128.     if (numMinutes.toString().length == 1) {
  129.       formattedTime += '0';
  130.       formattedTime += numMinutes.toString();
  131.     } else {
  132.       formattedTime += numMinutes.toString();
  133.     }
  134.  
  135.     formattedTime += ":";
  136.  
  137.     if (numSeconds.toString().length == 1) {
  138.       formattedTime += '0';
  139.       formattedTime += numSeconds.toString();
  140.     } else {
  141.       formattedTime += numSeconds.toString();
  142.     }
  143.  
  144.     return formattedTime;
  145.   }
  146.  
  147.   setModalVisible(visible) {
  148.     this.setState({ modalVisible: visible });
  149.   }
  150.  
  151.   componentDidMount() {
  152.     this._getLocationAsync();
  153.     this.getCameraPermissions()
  154.   }
  155.  
  156.   async getCameraPermissions() {
  157.     const { status } = await Permissions.askAsync(Permissions.CAMERA);
  158.     if (status === 'granted') {
  159.       this.setState({ cameraGranted: true });
  160.     } else {
  161.       this.setState({ cameraGranted: false });
  162.       console.log('Uh oh! The user has not granted us permission.');
  163.     }
  164.     this.getCameraRollPermissions();
  165.   }
  166.  
  167.   async getCameraRollPermissions() {
  168.     const { status } = await Permissions.askAsync(Permissions.CAMERA_ROLL);
  169.     if (status === 'granted') {
  170.       this.setState({ rollGranted: true })
  171.     } else {
  172.       console.log('Uh oh! The user has not granted us permission.');
  173.       this.setState({ rollGranted: false });
  174.     }
  175.   }
  176.  
  177.   async takePictureAndCreateAlbum() {
  178.     this.refs.viewShot.capture().then(uri => {
  179.       MediaLibrary.createAssetAsync(uri)
  180.       .then(() => {
  181.         this.returned()
  182.       })
  183.     })
  184.   }
  185.  
  186.   async takePictureAndCreateAlbum2() {
  187.     this.refs.viewShot2.capture().then(uri => {
  188.       this.setState({ viewShot2: uri })
  189.     }).catch((error) => {
  190.       console.warn(error)
  191.     })
  192.   }
  193.  
  194.   async ham(uri) {
  195.     const asset = await MediaLibrary.createAssetAsync(uri);
  196.   }
  197.  
  198.   calcDistance(newLatLng) {
  199.     const { prevLatLng } = this.state
  200.     return (haversine(prevLatLng, newLatLng) || 0)
  201.   }
  202.  
  203.   handleLocationChange(position) {
  204.    
  205.     const { routeCoordinates, distanceTravelled } = this.state
  206.     const newLatLngs = { latitude: position.coords.latitude, longitude: position.coords.longitude }
  207.     const positionLatLngs = pick(position.coords, ['latitude', 'longitude'])
  208.  
  209.     if (this.state.start == false) {
  210.       this.setState({
  211.         position: {
  212.           latitude: position.coords.latitude,
  213.           longitude: position.coords.longitude
  214.         },
  215.         routeCoordinates: routeCoordinates.concat(positionLatLngs),
  216.         distanceTravelled: distanceTravelled + this.calcDistance(newLatLngs),
  217.         prevLatLng: newLatLngs
  218.       })
  219.     } else {
  220.       this.setState({
  221.         position: {
  222.           latitude: position.coords.latitude,
  223.           longitude: position.coords.longitude
  224.         }
  225.       })
  226.     }
  227.   }
  228.  
  229.   _getLocationAsync = async () => {
  230.     let { status } = await Permissions.askAsync(Permissions.LOCATION);
  231.     if (status !== 'granted') {
  232.       alert('Location not allowed')
  233.       this.setState({
  234.         locationResult: 'Permission to access location was denied',
  235.       });
  236.     } else {
  237.  
  238.       this.setState({ hasLocationPermissions: true });
  239.     }
  240.  
  241.  
  242.     let location = await Location.getCurrentPositionAsync({ accuracy: Location.Accuracy.Balanced, timeout: 20000, maximumAge: 1000 })
  243.     this.setState({ locationResult: JSON.stringify(location) })
  244.  
  245.  
  246.  
  247.     Location.startLocationUpdatesAsync(LOCATION_TASK_NAME,{
  248.       accuracy: Location.Accuracy.Highest,
  249.       timeInterval: 300,
  250.       distanceInterval: 1
  251.     });
  252.  
  253.  
  254.     // Center the map on the location we just fetched.
  255.     if (this.state.once == false) {
  256.       this.setState({
  257.         mapRegion: {
  258.           latitude: location.coords.latitude,
  259.           longitude: location.coords.longitude,
  260.           latitudeDelta: 0.0222,
  261.           longitudeDelta: 0.0121,
  262.         }, position: {
  263.           latitude: location.coords.latitude,
  264.           longitude: location.coords.longitude
  265.         },
  266.         once: true
  267.       });
  268.       this.setState({
  269.         mapRegion2: {
  270.           latitude: 51.5033640,
  271.           longitude: -0.1276250,
  272.           latitudeDelta: 0.0222,
  273.           longitudeDelta: 0.0121,
  274.         }
  275.       })
  276.     }
  277.   };
  278.  
  279.   items = () => {
  280.     const { navigation } = this.props
  281.  
  282.     return this.state.clues.map((int, item) => {
  283.  
  284.       return (
  285.         <View key={'id1' + item} style={{ flexDirection: 'row', borderBottomColor: '#ddd', borderBottomWidth: 1 }}>
  286.           <View style={{ flex: 0.5, paddingLeft: 20, paddingVertical: 20, justifyContent: 'center' }}>
  287.             <Text style={{ fontSize: 10, color: '#333' }}>Pet Name</Text>
  288.             <TextInput
  289.               onChangeText={(text) => {
  290.                 let pets = this.state.pets
  291.                 pets['pet' + item] = text
  292.                 this.setState({ pets });
  293.               }}
  294.               value={this.state.pets['pet' + item]}
  295.               style={{ fontSize: 18, color: '#333' }} placeholder={'Enter Name'} numberOfLines={1} />
  296.           </View>
  297.           <View style={{ flex: 0.5, justifyContent: 'center', alignItems: 'center', flexDirection: 'row' }}>
  298.             <View style={{ flex: 1, flexDirection: 'row', alignItems: 'center' }}>
  299.               <Text style={{ fontSize: 26 }}> 💩 </Text>
  300.               <TouchableOpacity style={{ borderWidth: 3, borderColor: '#333', height: 25, width: 25, borderRadius: 3, alignItems: 'center', justifyContent: 'center' }}
  301.                 onPress={
  302.                   () => {
  303.                     this.setState({ ['checkin' + (item + 1)]: !this.state['checkin' + (item + 1)] })
  304.                   }
  305.                 }>
  306.                 <Feather name={'check'} size={25} color={'#333'} style={{ display: this.state['checkin' + (item + 1)] == true ? 'flex' : 'none' }} />
  307.               </TouchableOpacity>
  308.             </View>
  309.             <View style={{ flex: 1, flexDirection: 'row', alignItems: 'center' }}>
  310.               <Text style={{ fontSize: 26 }}> 💧 </Text>
  311.               <TouchableOpacity style={{ borderWidth: 3, borderColor: '#333', height: 25, width: 25, borderRadius: 3, alignItems: 'center', justifyContent: 'center' }}
  312.                 onPress={
  313.                   () => {
  314.                     this.setState({ ['checked' + (item + 1)]: !this.state['checked' + (item + 1)] });
  315.                   }
  316.                 }>
  317.                 <Feather name={'check'} size={25} color={'#333'} style={{ display: this.state['checked' + (item + 1)] == true ? 'flex' : 'none' }} />
  318.               </TouchableOpacity>
  319.             </View>
  320.           </View>
  321.         </View>
  322.       )
  323.     })
  324.   }
  325.  
  326.   formatAMPM(date) {
  327.     var hours = date.getHours();
  328.     var minutes = date.getMinutes();
  329.     var ampm = hours >= 12 ? 'pm' : 'am';
  330.     hours = hours % 12;
  331.     hours = hours ? hours : 12; // the hour '0' should be '12'
  332.     minutes = minutes < 10 ? '0' + minutes : minutes;
  333.     var strTime = hours + ':' + minutes + ' ' + ampm;
  334.     return strTime;
  335.   }
  336.  
  337.   returned = () => {
  338.     this.handleSleep()
  339.     this.setState({
  340.       pets: {
  341.         pet: ''
  342.       },
  343.       checks: {
  344.  
  345.       },
  346.       once: false,
  347.       stopped: false,
  348.       ended: true,
  349.       switched: true,
  350.       checkin: false,
  351.       checked: false,
  352.       start: true,
  353.       clues: [],
  354.       notes: '',
  355.       locked: false,
  356.       timeIn: null,
  357.       timeOut: null,
  358.       routeCoordinates: [],
  359.       distanceTravelled: 0,
  360.       prevLatLng: {},
  361.       modalVisible: false,
  362.       countDown: false,
  363.       remainingSeconds: 0,
  364.       interval: null,
  365.       Screeny: false
  366.     })
  367.   }
  368.  
  369.   finishUp = () => {
  370.     this.handleReset()
  371.     this.setModalVisible(false)
  372.     this.setState({ timeOut: this.formatAMPM(new Date()) })
  373.     //this.takePictureAndCreateAlbum()
  374.     this.setState({
  375.       Screeny: true
  376.     })
  377.  
  378.   }
  379.  
  380.   ItemFull() {
  381.  
  382.     return (
  383.       <ScrollView style={{ margin: 10, borderRadius: 15, flex: 1, elevation: 5, marginHorizontal: 10, backgroundColor: '#fff' }} contentContainerStyle={{ paddingBottom: 200 }}>
  384.         <View style={{ flexDirection: 'row', borderBottomColor: '#ddd', borderBottomWidth: 1 }}>
  385.           <View style={{ flex: 1, paddingLeft: 20, paddingVertical: 20, justifyContent: 'center' }}>
  386.             <Text style={{ fontSize: 10, color: '#333' }}>Today's Date</Text>
  387.            <Text style={{ fontSize: 18, color: '#333' }}>{new Date().getMonth() + 1 + '/' + new Date().getDate() + '/' + new Date().getFullYear()}</Text>
  388.          </View>
  389.  
  390.          <TouchableOpacity style={{ flex: 1, paddingRight: 20, paddingVertical: 20, justifyContent: 'center', alignItems: 'flex-end' }} onPress={() => { this.setModalVisible(false), this.setState({ info: false }) }}>
  391.            <AntDesign name={'closecircleo'} size={40} color={'#333'} />
  392.          </TouchableOpacity>
  393.  
  394.        </View>
  395.        <View style={{ flex: 1, display: this.state.stopped == true ? 'flex' : 'none', paddingLeft: 20, paddingVertical: 20, justifyContent: 'center', borderBottomColor: '#ddd', borderBottomWidth: 1 }}>
  396.          <Text style={{ fontSize: 10, color: '#333' }}>Total Time</Text>
  397.          <Text style={{ fontSize: 18, color: '#333' }} >{this.formatRemainingSeconds(this.state.remainingSeconds)}</Text>
  398.        </View>
  399.        <View style={{ flex: 1, paddingLeft: 20, paddingVertical: 20, justifyContent: 'center', borderBottomColor: '#ddd', borderBottomWidth: 1 }}>
  400.          <Text style={{ fontSize: 10, color: '#333' }}>Client Name</Text>
  401.          <TextInput
  402.            onChangeText={(client) => this.setState({ client })}
  403.            value={this.state.client}
  404.            style={{ fontSize: 18, color: '#333' }} placeholder={'Enter Name'} numberOfLines={1} />
  405.        </View>
  406.  
  407.        <View style={{ flexDirection: 'row', borderBottomColor: '#ddd', borderBottomWidth: 1 }}>
  408.          <View style={{ flex: 0.5, paddingLeft: 20, paddingVertical: 20, justifyContent: 'center' }}>
  409.            <Text style={{ fontSize: 10, color: '#333' }}>Pet Name</Text>
  410.            <TextInput
  411.              onChangeText={(text) => {
  412.                let pets = this.state.pets
  413.                pets['pet'] = text
  414.                this.setState({ pets });
  415.              }}
  416.              value={this.state.pets['pet']}
  417.              style={{ fontSize: 18, color: '#333' }} placeholder={'Enter Name'} numberOfLines={1} />
  418.          </View>
  419.          <View style={{ flex: 0.5, justifyContent: 'center', alignItems: 'center', flexDirection: 'row' }}>
  420.            <View style={{ flex: 1, flexDirection: 'row', alignItems: 'center' }}>
  421.              <Text style={{ fontSize: 26 }}> 💩 </Text>
  422.              <TouchableOpacity style={{ borderWidth: 3, borderColor: '#333', height: 25, width: 25, borderRadius: 3, alignItems: 'center', justifyContent: 'center' }}
  423.                onPress={
  424.                  () => {
  425.                    this.setState({ ['checkin0']: !this.state['checkin0'] });
  426.                  }}
  427.              >
  428.                <Feather name={'check'} size={25} color={'#333'} style={{ display: this.state['checkin0'] == true ? 'flex' : 'none' }} />
  429.              </TouchableOpacity>
  430.            </View>
  431.            <View style={{ flex: 1, flexDirection: 'row', alignItems: 'center' }}>
  432.              <Text style={{ fontSize: 26 }}> 💧 </Text>
  433.              <TouchableOpacity style={{ borderWidth: 3, borderColor: '#333', height: 25, width: 25, borderRadius: 3, alignItems: 'center', justifyContent: 'center' }}
  434.                onPress={
  435.                  () => {
  436.                    this.setState({ ['checked0']: !this.state['checked0'] });
  437.                  }}
  438.              >
  439.                <Feather name={'check'} size={25} color={'#333'} style={{ display: this.state['checked0'] == true ? 'flex' : 'none' }} />
  440.              </TouchableOpacity>
  441.            </View>
  442.          </View>
  443.        </View>
  444.  
  445.        {this.items()}
  446.  
  447.        <View style={{ flex: 1, alignItems: 'center' }}>
  448.          <TouchableOpacity style={{ flex: 1, width: 160, height: 50, paddingVertical: 20, justifyContent: 'center', alignItems: 'center', margin: 20, borderRadius: 15, backgroundColor: '#008eff' }} onPress={() => this.setState({ clues: [...this.state.clues, 'item'] })}>
  449.            <Text style={{ fontSize: 18, color: '#fff' }} >Add Pet</Text>
  450.          </TouchableOpacity>
  451.        </View>
  452.  
  453.        <View style={{ padding: 10 }}>
  454.          <Text style={{ fontSize: 10, color: '#333' }}>Notes:</Text>
  455.          <TextInput style={{ fontSize: 16, color: '#333', justifyContent: 'flex-start' }} value={this.state.notes} onChangeText={(text) => this.setState({ notes: text })} placeholder={'Enter Notes'} multiline={true} />
  456.        </View>
  457.        {this.state.stopped == true ? (
  458.          <View style={{ flexDirection: 'row' }}>
  459.            <TouchableOpacity
  460.              style={{
  461.                flex: 1,
  462.                width: '90%',
  463.                paddingVertical: 20,
  464.                justifyContent: 'center',
  465.                alignItems: 'center',
  466.                margin: 20,
  467.                borderRadius: 15,
  468.                backgroundColor: 'red'
  469.              }}
  470.              onPress={
  471.                () => { this.finishUp() }
  472.              }>
  473.              <Text style={{ fontSize: 18, color: '#fff', fontWeight: 'bold' }} >Save</Text>
  474.            </TouchableOpacity>
  475.          </View>
  476.  
  477.        ) : this.state.info == false ? (
  478.          <TouchableOpacity
  479.            style={{
  480.              flex: 1,
  481.              paddingVertical: 20,
  482.              justifyContent: 'center',
  483.              alignItems: 'center',
  484.              margin: 20,
  485.              borderRadius: 15,
  486.              backgroundColor: '#58c751'
  487.            }}
  488.            onPress={
  489.              () => { this.handleStart(), this.setModalVisible(false), this.handleAwake(), this.setState({ start: false, timeIn: this.formatAMPM(new Date()) }) }
  490.            }>
  491.            <Text style={{ fontSize: 18, color: '#fff', fontWeight: 'bold' }} >Start Visit</Text>
  492.          </TouchableOpacity>
  493.        ) : null}
  494.  
  495.      </ScrollView>
  496.    )
  497.  }
  498.  
  499.  locked() {
  500.    return (
  501.      <View style={{ flex: 1, backgroundColor: '#00000080', justifyContent: 'center', alignItems: 'center' }}>
  502.        <TouchableOpacity onPress={() => { this.setState({ locked: false }), this.setModalVisible(false) }} >
  503.          <Feather name={'unlock'} size={30} color={'#fff'} />
  504.        </TouchableOpacity>
  505.      </View>
  506.    )
  507.  }
  508.  
  509.  getPets = () => {
  510.    const pets = this.state.pets
  511.    return Object.keys(pets).map((key, index) => {
  512.      return (
  513.        <View key={'ii' + index} style={{ justifyContent: 'center', height: 30, width: '100%', flexDirection: 'row' }}>
  514.          <View style={{ height: 30, width: '30%' }}>
  515.            <Text style={{ color: '#fff', fontSize: 23 }}>{pets[key]}</Text>
  516.          </View>
  517.          <View style={{ height: 30, width: '40%' }}>
  518.            <View style={{ width: '100%', justifyContent: 'center', alignItems: 'center', flexDirection: 'row' }}>
  519.              <View style={{ flex: 1, flexDirection: 'row', alignItems: 'center' }}>
  520.                <Text style={{ fontSize: 26 }}> 💩 </Text>
  521.                <View style={{ borderWidth: 3, borderColor: '#fff', height: 25, width: 25, borderRadius: 3, alignItems: 'center', justifyContent: 'center' }}>
  522.                  <Feather name={'check'} size={25} color={'#fff'} style={{ display: this.undefinedToNull(this.state['checkin' + index]) == true ? 'flex' : 'none' }} />
  523.                </View>
  524.              </View>
  525.              <View style={{ flex: 1, flexDirection: 'row', alignItems: 'center' }}>
  526.                <Text style={{ fontSize: 26 }}> 💧 </Text>
  527.                <View style={{ borderWidth: 3, borderColor: '#fff', height: 25, width: 25, borderRadius: 3, alignItems: 'center', justifyContent: 'center' }}>
  528.                  <Feather name={'check'} size={25} color={'#fff'} style={{ display: this.undefinedToNull(this.state['checked' + index]) == true ? 'flex' : 'none' }} />
  529.                </View>
  530.              </View>
  531.            </View>
  532.          </View>
  533.        </View>
  534.      )
  535.    })
  536.  }
  537.  
  538.  undefinedToNull = (item) => {
  539.    if (item == true) {
  540.      return true
  541.    } else {
  542.      return false
  543.    }
  544.  }
  545.  
  546.  render() {
  547.    const ItemMini = () => (
  548.      <View style={{ paddingHorizontal: 20 }}>
  549.        <Text style={{ fontSize: 20, color: '#333', marginBottom: 10, }}>Current Visit</Text>
  550.        <View style={{ flexDirection: 'row', height: 70 }}>
  551.          <View style={{ flex: 1, }}>
  552.            <Text style={{ fontSize: 30, color: '#333', fontWeight: 'bold' }}>{parseFloat(this.state.distanceTravelled * 1.609).toFixed(2)}<Text style={{ fontSize: 16, fontWeight: '400' }}>mi</Text></Text>
  553.            <Text style={{ fontSize: 10, color: '#565252' }}>Distance</Text>
  554.          </View>
  555.          <View style={{ flex: 1, alignItems: 'flex-end' }}>
  556.            <Text style={{ fontSize: 30, color: '#333', fontWeight: 'bold' }}>{this.formatRemainingSeconds(this.state.remainingSeconds)}</Text>
  557.  
  558.  
  559.            <Text style={{ fontSize: 10, color: '#565252' }}>Time</Text>
  560.          </View>
  561.  
  562.        </View>
  563.  
  564.        {this.state.start == true ? (
  565.          <View style={{ alignItems: 'center', justifyContent: 'center' }}>
  566.            <TouchableOpacity style={{ marginHorizontal: 20, width: '90%', height: 70, borderRadius: 15, backgroundColor: '#008eff', justifyContent: 'center', alignItems: 'center' }} onPress={() => { this.setModalVisible(true) }}>
  567.              <Text style={{ color: '#fff', fontWeight: 'bold', fontSize: 18 }}>Open Form</Text>
  568.            </TouchableOpacity>
  569.          </View>
  570.        ) : (
  571.            <View style={{ alignItems: 'center', justifyContent: 'center' }}>
  572.              <TouchableOpacity style={{ marginHorizontal: 20, width: '90%', height: 70, borderRadius: 15, backgroundColor: '#f44336', justifyContent: 'center', alignItems: 'center' }} onPress={() => { this.takePictureAndCreateAlbum2().then(this.setModalVisible(true), this.handleStop(), this.setState({ stopped: true })) }}>
  573.                <Text style={{ color: '#fff', fontWeight: 'bold', fontSize: 18 }}>End Visit</Text>
  574.              </TouchableOpacity>
  575.            </View>
  576.          )}
  577.  
  578.  
  579.  
  580.      </View>
  581.    )
  582.  
  583.  
  584.  
  585.    return (
  586.      <View style={styles.container}>
  587.        {this.state.Screeny == true ? (
  588.          <ViewShot ref="viewShot" options={{ format: "jpg", quality: 0.9 }} style={{
  589.            width: 540,
  590.            height: 960,
  591.            zIndex: 2
  592.          }}>
  593.            <TouchableHighlight style={{ flex: 1 }} onPress={() => this.takePictureAndCreateAlbum()}>
  594.              <ImageBackground
  595.                source={require('./assets/bg-repeat.png')}
  596.                style={{ flex: 1 }}
  597.                resizeMode={'repeat'}
  598.              >
  599.                <View style={{ height: '100%', width: '100%', justifyContent: 'center', alignItems: 'center', padding: 70 }}>
  600.                  <View style={{ flex: 1, height: '100%', width: '100%', alignItems: 'center', backgroundColor: '#000000C0', padding: 10, borderRadius: 15 }}>
  601.  
  602.                    <View style={{ height: 160, width: '100%', flexDirection: 'row', justifyContent: 'center' }}>
  603.                      <View style={{ alignItems: 'flex-start', justifyContent: 'center', height: 160, width: 120 }}>
  604.                        <Image source={require('./assets/logoprint.png')} resizeMode={'contain'} style={{ width: '100%', }} />
  605.                      </View>
  606.                        <View style={{ alignItems: 'center', justifyContent: 'center', height: 160, paddingLeft: 20 }}>
  607.                          <Text style={{ color: '#fff', fontSize: 30 }}>Visit Summary</Text>
  608.                          <Text style={{ color: '#fff', fontSize: 30 }}>{new Date().getMonth() + 1 + '/' + new Date().getDate() + '/' + new Date().getFullYear()}</Text>
  609.                          <Text style={{ color: '#fff', fontSize: 30 }}>{this.state.client}</Text>
  610.                        </View>
  611.                        
  612.                    </View>
  613.  
  614.                    <View style={{ alignItems: 'center', justifyContent: 'center', height: 100, width: '100%', flexDirection: 'row' }}>
  615.                          <View style={{ alignItems: 'center', justifyContent: 'center', width: '50%' }}>
  616.                            <Text style={{ color: '#fff', fontSize: 23 }}>Time In</Text>
  617.                            <Text style={{ color: '#fff', fontSize: 23 }}>{this.state.timeIn}</Text>
  618.                          </View>
  619.                          <View style={{ alignItems: 'center', justifyContent: 'center', width: '50%' }}>
  620.                            <Text style={{ color: '#fff', fontSize: 23 }}>Time Out</Text>
  621.                            <Text style={{ color: '#fff', fontSize: 23 }}>{this.state.timeOut}</Text>
  622.                          </View>
  623.  
  624.                        </View>
  625.                    <View style={{ alignItems: 'center', justifyContent: 'center', height: 100, width: '100%' }}>
  626.                      {this.getPets()}
  627.                    </View>
  628.                    <View style={{ alignItems: 'center', justifyContent: 'center', height: 180, width: '90%' }}>
  629.                      <Text style={{ color: '#fff', fontSize: 23 }}>{this.state.notes}</Text>
  630.                    </View>
  631.                    <View style={{ alignItems: 'center', justifyContent: 'center', height: 260, width: '100%', backgroundColor: '#000', borderRadius: 15, overflow: 'hidden' }}>
  632.                      <Image source={{ uri: this.state.viewShot2 }} resizeMode={'cover'} style={{ width: '100%', height: '100%' }} />
  633.                      <View style={{ width: 80, height: 45, position: 'absolute', top: 0, right: 0, backgroundColor: '#fff', borderBottomLeftRadius: 15, borderColor: '#333', borderBottomWidth: 1, borderLeftWidth: 1, justifyContent: 'center', alignItems: 'center' }}>
  634.                        <Text style={{ color: '#888', fontSize: 18 }}>{parseFloat(this.state.distanceTravelled / 1.609).toFixed(2)} mi</Text>
  635.                      </View>
  636.                    </View>
  637.  
  638.  
  639.                  </View>
  640.                </View>
  641.              </ImageBackground>
  642.            </TouchableHighlight>
  643.          </ViewShot>
  644.        ) : (
  645.            <View style={{ flex: 1, width: '100%', height: '100%' }}>
  646.              <Modal animationType="slide"
  647.                transparent={this.state.locked}
  648.                visible={this.state.modalVisible}>
  649.                {this.state.locked == true ? (
  650.                  this.locked()
  651.                ) : (
  652.                    this.ItemFull()
  653.                  )}
  654.              </Modal>
  655.  
  656.              <View style={{ position: 'absolute', zIndex: 2, left: 0, bottom: 10, right: 0 }}>
  657.                <ItemMini />
  658.              </View>
  659.              <ViewShot ref="viewShot2" options={{ format: "jpg", quality: 0.9 }} style={{ flex: 1 }}>
  660.                <MapView
  661.                  provider={PROVIDER_GOOGLE}
  662.                  customMapStyle={customData}
  663.                  style={{ alignSelf: 'stretch', height: '100%' }}
  664.                  region={this.state.switched == true ? this.state.mapRegion : this.state.mapRegion2}
  665.                  onRegionChangeComplete={(nonn) => { this.setState({ mapRegion: nonn }) }}
  666.                >
  667.                  <MapView.Polyline
  668.                    coordinates={this.state.routeCoordinates}
  669.                    strokeWidth={5}
  670.                    strokeColor={'#19B5FE'}
  671.                  />
  672.                  {true && (
  673.                    <MapView.Circle
  674.                      center={this.state.position}
  675.                      radius={40}
  676.                      strokeColor={'transparent'}
  677.                      fillColor={'#00a5ff40'}
  678.                    />
  679.                  )}
  680.                  {true && (
  681.                    <MapView.Circle
  682.                      center={this.state.position}
  683.                      radius={12}
  684.                      strokeColor={'transparent'}
  685.                      fillColor={'#00a5ff'}
  686.                    />
  687.                  )}
  688.  
  689.                </MapView>
  690.              </ViewShot>
  691.              <TouchableOpacity onPress={() => { this.setModalVisible(true), this.setState({ info: true }) }} style={{ position: 'absolute', top: 60, right: 30 }} >
  692.                <Feather name={'info'} size={40} color={'#f44336'} />
  693.              </TouchableOpacity>
  694.              <TouchableOpacity onPress={() => { console.warn(test) }} style={{ position: 'absolute', top: 60, left: 30 }} >
  695.                <Feather name={'lock'} size={40} color={'#333'} />
  696.              </TouchableOpacity>
  697.              <LinearGradient colors={['#ffffff00', '#ffffff']} style={{ position: 'absolute', bottom: 0, left: 0, right: 0, height: 500 }} />
  698.            </View>
  699.          )}
  700.      </View>
  701.    );
  702.  }
  703. }
  704.  
  705. TaskManager.defineTask(LOCATION_TASK_NAME, ({ data, error }) => {
  706.  if (error) {
  707.    // Error occurred - check `error.message` for more details.
  708.    return;
  709.  }
  710.  if (position) {
  711.    App = new App
  712.  
  713.    App.handleLocationChange(position)
  714.    // do something with the locations captured in the background
  715.  }
  716. });
  717.  
  718.  
  719. const styles = StyleSheet.create({
  720.  container: {
  721.    flex: 1,
  722.    alignItems: 'center',
  723.    justifyContent: 'center',
  724.    backgroundColor: '#ecf0f1',
  725.  },
  726.  paragraph: {
  727.    margin: 24,
  728.    fontSize: 18,
  729.    fontWeight: 'bold',
  730.    textAlign: 'center',
  731.    color: '#34495e',
  732.  },
  733. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement