-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNavBar.js
61 lines (56 loc) · 1.87 KB
/
NavBar.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
import React, { useRef } from 'react';
import { StyleSheet, View, PanResponder, Dimensions } from 'react-native';
import EmergencyBut from './EmergencyBut';
const { height } = Dimensions.get('window');
import Route from './Route';
export default function NavBar({ onSubmit }) {
// PanResponder to handle dragging
const panResponder = useRef(
PanResponder.create({
onStartShouldSetPanResponder: () => true,
onMoveShouldSetPanResponder: () => true,
onPanResponderMove: (_, gestureState) => {
// Optional drag logic
},
onPanResponderRelease: () => {
// Optionally do something when dragging stops
},
})
).current;
return (
<View style={styles.pullDownTab} {...panResponder.panHandlers}>
{/* Buttons Container */}
<View style={styles.buttonsContainer}>
<Route name={'Best'} color={'blue'} onPress={() => onSubmit(1)} />
<Route name={'Fastest'} color={'red'} onPress={() => onSubmit(2)} />
<Route name={'Alternate'} color={'grey'} onPress={() => onSubmit(0)} />
</View>
{/* Emergency Button */}
<View style={styles.emergencyContainer}>
<EmergencyBut />
</View>
</View>
);
}
const styles = StyleSheet.create({
pullDownTab: {
position: 'absolute',
width: '100%',
height: '30%',
backgroundColor: '#f1f0e4',
bottom: 0,
paddingHorizontal: 10, // Optional padding
paddingVertical: 10,
},
buttonsContainer: {
flexDirection: 'row',
justifyContent: 'space-between', // Distribute buttons horizontally
alignItems: 'center', // Center buttons vertically
flex: 1, // Make the row take available space
},
emergencyContainer: {
alignItems: 'center', // Center the emergency button horizontally
justifyContent: 'flex-end', // Position it at the bottom
paddingVertical: 10, // Optional padding for spacing
},
});