-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcaptain.js
145 lines (125 loc) · 3.25 KB
/
captain.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import React, { Component } from "react";
import {
View,
Text,
StyleSheet,
Alert,
TouchableHighlight,
ActivityIndicator,
Image
} from "react-native";
import MapView, { PROVIDER_GOOGLE } from 'react-native-maps';
import {Marker} from 'react-native-maps';
import firebase from 'firebase';
import PassengerView from './passengerview';
import {createStackNavigator,createAppContainer} from 'react-navigation';
class CaptainPage extends Component {
constructor(props)
{
super(props);
this.state={
loading: true,
stores: []
}
}
markerClick()
{
console.log("Marker pressed");
Alert.alert("Marker Clicked");
}
componentDidMount() {
var recentPostsRef = firebase.database().ref('markers/');
recentPostsRef.once('value').then(snapshot => {
this.setState({ stores: snapshot.val() })
if(this.state.stores.longitude==0)
{
this.setState({loading:true})
}
else
{
this.setState({loading:false})
}
})
}
markerClick =() =>{
this.props.navigation.navigate('Pass',{
id: this.state.stores.id
})
}
render() {
if(this.state.loading)
{
return(
<View style={styles.containers}>
<Text>Searching for Passengers, Please wait. You will be automatically logged out after 5 minutes if no passenger is available.</Text>
<ActivityIndicator size="large" />
</View>
)
}
return (
<View style={styles.container}>
<MapView
provider={PROVIDER_GOOGLE}
showsUserLocation={true}
showsMyLocationButton={true}
zoomEnabled = {true}
style={styles.map}
initialRegion={{
latitude: 24.814646,
longitude: 67.079811,
latitudeDelta: 0.0151,
longitudeDelta: 0.0121
}}
>
<MapView.Marker
coordinate={{
latitude: this.state.stores.latitude,
longitude: this.state.stores.longitude
}}
onPress={this.markerClick}
>
<Image source={require('./man.png')} style={{height: 40, width:40, }} />
{/* <MapView.Callout tooltip >
<TouchableHighlight onPress={this.markerClick}
title="Chat with Lucy"
underlayColor='#dddddd'>
<Text>We must go derper</Text>
</TouchableHighlight>
</MapView.Callout> */}
</MapView.Marker>
</MapView>
</View>
);
}
}
const Apps = createStackNavigator(
{
CaptainPage: CaptainPage,
Pass: PassengerView
},
{
headerMode: 'none'
},
{
initialRouteName: 'CaptainPage'
}
)
export default createAppContainer(Apps);
const styles = StyleSheet.create({
container: {
...StyleSheet.absoluteFillObject,
height: '100%',
width: '100%',
justifyContent: 'flex-end',
alignItems: 'center',
},containers: {
...StyleSheet.absoluteFillObject,
height: 400,
width: 400,
justifyContent: 'flex-end',
alignItems: 'center',
},
map: {
...StyleSheet.absoluteFillObject,
}
});