-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch
196 lines (177 loc) · 11.1 KB
/
search
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/**
* @author Arun Kukkudapu <[email protected]>
* @version 1.0.0
* @summary Its a details screen show the details of selected store
*/
import React, { Component } from 'react';
import { StyleSheet, Text, TextInput, View, Dimensions, TouchableOpacity, FlatList, Alert, Image, Platform, Linking, ScrollView } from 'react-native';
import MapView, { PROVIDER_GOOGLE } from 'react-native-maps';
import { SearchBar, Icon } from 'react-native-elements';
import { Toolbar } from "../components";
import { navigateBack, navigateTo } from "../helpers";
import LinearGradient from "react-native-linear-gradient";
import styles from './../styles';
const { width, height } = Dimensions.get('window');
const aspectRatio = width / height
const LATITUDE_DELTA = 0.0922
const LONGITUDE_DELTA = LATITUDE_DELTA * aspectRatio
/**
* Represents Component.
* @class StoreLocator
* @extends Component
*/
class StoreDetails extends Component {
constructor(props) {
super(props);
this.state = {
lat: 12.9428,
lng: 77.6966,
markercoords: {
latitude: 12.951902,
longitude: 77.698961
},
data: [],
stationdata: [
{
"name": "ESSO",
"address": "Marnixstraat 250, 1016 TL Amsterdam",
"Houres": "opening hours: 7:00 AM - 11:00 PM",
"fuelType": "fuelType :",
"type": "Super Gasocline / Diesel",
"Distance": "0.16 km",
}
],
iconName: 'search',
textInputValue: ''
}
}
componentDidMount() {
navigator.geolocation.getCurrentPosition((position) => {
this.setState({
lat: position.coords.latitude,
lng: position.coords.longitude,
});
});
}
/**
* distanceButtonTapped function is invoked when user press on distance button and this will open external maps app with respect to there platform
*/
distanceButtonTapped = () => {
const scheme = Platform.select({ ios: 'maps:0,0?q=', android: 'geo:0,0?q=' });
const latLng = `${this.state.markercoords.latitude},${this.state.markercoords.longitude}`;
const label = 'Custom Label';
const url = Platform.select({
ios: `${scheme}${label}@${latLng}`,
android: `${scheme}${latLng}(${label}`
});
Linking.openURL(url);
var dataList = [...this.state.stationdata]
Alert.alert('Distance Button Tapped');
console.log('data after:: ', this.state.stationdata);
}
/**
* @function render
* React render method for rendering the native elements
*/
render() {
return (
<View style={styles.mapContainer}>
<Toolbar
style={styles.noBorderToolbar}
onClickLeftIcon={navigateBack}
iconName="back-arrow"
title="Station Details" />
<View style={{ flex: 3 }}>
<MapView style={{ width: Dimensions.get('window').width, height: Dimensions.get('window').height / 2, left: 0, right: 0, top: 0, bottom: 0, position: 'absolute' }}
provider={PROVIDER_GOOGLE}
showsUserLocation={true}
showsMyLocationButton={true}
region={{
latitude: this.state.lat,
longitude: this.state.lng,
latitudeDelta: 0.0900,
longitudeDelta: 0.0500,
}}>
{/**
Marker is to show a location with a marker.
*/}
<MapView.Marker
coordinate={{ latitude: this.state.markercoords.latitude, longitude: this.state.markercoords.longitude }} title={this.state.address}
description={this.state.address}
>
<Image style={{ width: 20, height: 30, alignSelf: 'center' }} source={require('../assets/images/rectangle.png')} />
</MapView.Marker>
</MapView>
</View>
<View style={{ flex: 3, flexDirection: 'row-reverse', alignSelf: 'flex-end', marginTop: 300, marginLeft: 10 }}>
<View>
<TouchableOpacity style={{ alignSelf: 'flex-end', zIndex: 2, marginRight: 10, marginBottom: 30 }} onPress={this.getCurrentLocation}>
<View style={{ backgroundColor: 'white', width: 45, height: 45, borderRadius: 50, justifyContent: 'center', zIndex: 2 }}>
<Icon name="my-location" size={25} color='rgb(141,198,63)' />
</View>
<View>
</View>
</TouchableOpacity>
</View>
</View>
<View style={{ width: Dimensions.get('window').width, height: Dimensions.get('window').height / 2 }}>
{/**
This List is dispalyed when user select any of the store from list
*/}
<FlatList
data={this.state.stationdata}
keyExtractor={(item, index) => index.toString()}
ref={(ref) => { this.flatListRef = ref; }}
ItemSeparatorComponent={() => <View style={{ marginLeft: 0, marginRight: 0, height: 0.5, backgroundColor: 'gray' }} />}
renderItem={({ item, index }) =>
<View style={{ flex: 1, backgroundColor: 'rgb(255, 255, 255)', marginTop: 60 }}>
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center', marginTop: 20 }}>
<Text style={{ width: 100, height: 10, backgroundColor: 'rgb(244,244,244)', borderRadius: 10 }}></Text>
</View>
<View style={{ flexDirection: 'row', marginTop: 10, marginLeft: 15, marginRight: 15, backgroundColor: 'rgb(244,244,244)' }}>
<View style={{ width: 300 }}>
<SearchBar
round
lightTheme
containerStyle={false}
inputStyle={{ backgroundColor: 'rgb(244,244,244)' }}
placeholder='Search...'
clearIcon={{ color: 'gray' }}
icon={{ type: 'font-awesome', color: 'gray' }}
cancelIcon={{ type: 'font-awesome', name: 'chevron-left' }}
/>
</View>
<View tyle={{ backgroundColor: 'rgb(244,244,244)', width: 30, height: 60 }}>
<TouchableOpacity onPress={alert} style={{marginTop:20}}>
<Icon name="filter-outline" size={30} color='rgb(97,97,97)' type="material-community" />
</TouchableOpacity>
</View>
</View>
<View style={{ marginTop: 10 }}>
<Text style={{ marginLeft: 15, marginBottom: 2, fontSize: 14, fontWeight: 'bold' }}>STATIONS NEAR YOU</Text>
</View>
<View style={styles.preferedTextName}>
<View style={{ flexDirection: 'row', marginTop: 10 }}>
<View style={{ alignItems: 'flex-start' }}>
<Image style={{ marginLeft: 15, width: 20, height: 20 }} source={require('../assets/images/Logo_1.png')} />
</View>
<View style={{ alignItems: 'flex-start', marginLeft: 5 }}>
<Text style={{ marginLeft: 5, marginBottom: 2, fontSize: 16, fontWeight: 'bold' }}>{item.name}</Text>
</View>
</View>
<Text style={{ marginLeft: 43, marginBottom: 5, color: 'rgb(123, 122, 118)', fontSize: 12 }}>{item.address}</Text>
<Text style={{ marginLeft: 43, marginBottom: 5, color: 'rgb(123, 122, 118)', fontSize: 12, fontWeight: 'bold' }}>{item.Houres}</Text>
<View style={{ flexDirection: 'row' }}>
<Text style={{ marginLeft: 43, marginBottom: 5, color: 'rgb(123, 122, 118)', fontSize: 12 }}>{item.fuelType}</Text>
<Text style={{ marginLeft: 2, marginBottom: 5, color: '#0f71b8', fontSize: 12 }}>{item.type}</Text>
</View>
</View>
</View>
}
/>
</View>
</View>
);
}
}
export default StoreDetails;