components/drawer/NavBar.tsx   A
last analyzed

Complexity

Total Complexity 6
Complexity/F 1.5

Size

Lines of Code 98
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 80
mnd 2
bc 2
fnc 4
dl 0
loc 98
rs 10
bpm 0.5
cpm 1.5
noi 0
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
B NavBar.tsx ➔ NavBar 0 57 6
1
import React from "react";
2
import { useState, useEffect } from 'react';
3
import { ScrollView, Image, Text, View, StyleSheet, StatusBar, Button, Pressable } from 'react-native';
4
import Icon from 'react-native-vector-icons/Octicons';
5
import HowModal from "../modals/HowModal";
6
7
8
9
export default function NavBar({navigation, mapRef, position}) {
10
    const [howModal, setHowModal] = useState(false);
11
12
    function DrawerButton({navigation}) {
13
        return (
14
          <Pressable style={[styles.drawer, styles.shadowProp]} onPress={() => navigation.openDrawer()}> 
15
            <Icon 
16
            name='three-bars' 
17
            size={20} 
18
            color='black'
19
            />
20
          </Pressable>
21
        );
22
      };
23
24
      function HowToDrive({navigation}) {
25
        return (
26
            <Pressable style={[styles.info, styles.shadowProp]} onPress={() => setHowModal(!howModal)}>
27
                <Icon 
28
                    name='question' 
29
                    size={16} 
30
                    color='black'
31
                />
32
                <Text style={{marginLeft: 8}}>How to drive?</Text>
33
            </Pressable>
34
        )
35
      }
36
37
      function Location({navigation}) {
38
        return (
39
            <Pressable style={[styles.drawer, styles.shadowProp]} onPress={() => {
40
              mapRef.current.animateToRegion({
41
                latitude: position.latitude? position.latitude : 56.161013580817986,
42
                longitude: position.longitude? position.longitude : 15.587742977884904,
43
                latitudeDelta: 0.03,
44
                longitudeDelta: 0.03,
45
              })
46
            }}> 
47
              <Icon 
48
              name='location' 
49
              size={20} 
50
              color='black'
51
              />
52
            </Pressable>
53
          );
54
      }
55
56
    return (
57
        <View style={styles.container}>
58
            <DrawerButton navigation={navigation}/>
59
            <HowToDrive navigation={navigation}/>
60
            <Location navigation={navigation}/>
61
            <HowModal navigation={navigation} modalVisible={howModal} setModalVisible={setHowModal}></HowModal>
62
        </View>
63
    )
64
}
65
66
const styles = StyleSheet.create({
67
    container: {
68
        position: 'absolute',
69
        justifyContent: 'space-evenly',
70
        width: '100%',
71
        flexDirection: 'row',
72
    },
73
    info: {
74
        width: 250,
75
        height: 40, 
76
        backgroundColor: 'white',
77
        marginTop: 50,
78
        borderRadius: 25,
79
        justifyContent: 'center',
80
        alignItems: 'center',
81
        flexDirection: 'row'
82
    },
83
84
    drawer: {
85
        width: 40,
86
        height: 40, 
87
        backgroundColor: 'white',
88
        marginTop: 50,
89
        borderRadius: 25,
90
        justifyContent: 'center',
91
        alignItems: 'center',
92
    },
93
    
94
    shadowProp: {
95
        elevation: 5,
96
        shadowColor: 'black'
97
      },
98
});