All files / src/components/navigation-info NavigationInfoBottom.tsx

100% Statements 7/7
100% Branches 0/0
100% Functions 3/3
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                          1x           7x 7x 7x                                               1x                        
import { View, Text, StyleSheet } from "react-native";
import React from "react";
import BottomDrawer from "../BottomDrawer";
import useNavigationInfo from "../../hooks/useNavigationInfo";
import { calculateETA } from "../../utils/navigationUtils";
 
interface NavigationInfoBottomProps {
  readonly visible: boolean;
  readonly onClose: () => void;
  readonly onPressAction?: () => void;
  readonly onSnapIndexChange: (index: number) => void;
}
 
const NavigationInfoBottom = ({
  visible,
  onClose,
  onPressAction,
  onSnapIndexChange,
}: NavigationInfoBottomProps) => {
  const distance = useNavigationInfo((state) => state.pathDistance);
  const duration = useNavigationInfo((state) => state.pathDuration);
  return (
    <BottomDrawer
      visible={visible}
      onClose={onClose}
      snapPoints={["5%", "25%"]}
      enablePanDownToClose={false}
      handleMode={"toggle"}
      enableDynamicSizing={false}
      initialSnapIndex={1}
      onPressAction={onPressAction}
      onSnapIndexChange={onSnapIndexChange}
    >
      <View>
        <Text style={styles.smallText}>Estimated Time Arrival</Text>
        <Text style={styles.bigText}>{calculateETA(duration)}</Text>
        <Text style={styles.smallText}>Distance</Text>
        <Text style={styles.bigText}>{distance}</Text>
      </View>
    </BottomDrawer>
  );
};
 
export default NavigationInfoBottom;
 
const styles = StyleSheet.create({
  smallText: {
    color: "#800020",
    textAlign: "center",
  },
  bigText: {
    color: "#800020",
    fontWeight: "bold",
    fontSize: 50,
    textAlign: "center",
  },
});