-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNavigateCard.js
108 lines (101 loc) · 3.67 KB
/
NavigateCard.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
import {
View,
Text,
SafeAreaView,
StyleSheet,
TouchableOpacity,
} from 'react-native'
import React from 'react'
import tw from 'twrnc'
import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete'
import { GOOGLE_MAPS_APIKEY } from '@env'
import { useDispatch, useSelector } from 'react-redux'
import { useNavigation } from '@react-navigation/native'
import { Icon } from 'react-native-elements'
import { setDestination, selectDestination } from '../slices/navSlice'
import NavFavourites from './NavFavourites'
const NavigateCard = () => {
const dispatch = useDispatch()
const destination = useSelector(selectDestination)
const navigation = useNavigation()
return (
<SafeAreaView style={tw`bg-white flex-1`}>
<Text style={tw`text-center py-4 text-xl`}>Hello, Thunder!</Text>
<View style={tw`flex-shrink`}>
<View>
<GooglePlacesAutocomplete
styles={toInputBoxStyle}
placeholder="Where to?"
fetchDetails={true}
enablePoweredByContainer={false}
nearbyPlacesAPI="GooglePlacesSearch"
returnKeyType={'search'}
debounce={400}
minLength={2}
onPress={(data, details = null) => {
dispatch(
setDestination({
location: details.geometry.location,
description: data.description,
})
)
navigation.navigate('RideOptionsCard')
}}
query={{
key: GOOGLE_MAPS_APIKEY,
language: 'en',
}}
/>
</View>
<NavFavourites />
</View>
<View
style={tw`flex-row bg-white justify-evenly py-2 mt-auto border-t border-gray-100`}
>
<TouchableOpacity
disabled={!destination}
style={tw`flex flex-row justify-between bg-black ${
!destination && 'bg-gray-300'
} w-24 px-4 py-3 rounded-full`}
onPress={() => navigation.navigate('RideOptionsCard')}
>
<Icon
name="car"
type="font-awesome"
color="white"
size={16}
/>
<Text style={tw`text-white text-center`}>Rides</Text>
</TouchableOpacity>
<TouchableOpacity
style={tw`flex flex-row justify-between border border-black w-24 px-4 py-3 rounded-full`}
>
<Icon
name="fast-food-outline"
type="ionicon"
color="black"
size={16}
/>
<Text style={tw`text-black text-center`}>Eats</Text>
</TouchableOpacity>
</View>
</SafeAreaView>
)
}
export default NavigateCard
const toInputBoxStyle = StyleSheet.create({
container: {
flex: 0,
paddingTop: 5,
backgroundColor: '#fff',
},
textInput: {
backgroundColor: '#DDDDDF',
borderRadius: 0,
fontSize: 16,
},
textInputContainer: {
paddingHorizontal: 20,
paddingBottom: 0,
},
})