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 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 | 12x 12x 12x 12x 12x 12x 3x | import React from "react";
import { View, Text, StyleSheet } from "react-native";
import { Ionicons, MaterialIcons } from "@expo/vector-icons";
import useNavigationInfo from "../../hooks/useNavigationInfo";
import { calculateETA } from "../../utils/navigationUtils";
import { Step } from "../../api/outdoorDirectionsApi";
import {
getManeuverIcon,
getStreetOnlyInstruction,
} from "../navigation-direction/navigationDirectionUtils";
import { useTheme } from "../../hooks/useTheme";
interface NavigationInfoTopCombinedProps {
readonly destination: string;
readonly showInfoExtended: boolean;
readonly showHudExtended: boolean;
readonly hudStep?: Step;
}
export default function NavigationInfoTopCombined({
destination,
showInfoExtended,
showHudExtended,
hudStep,
}: NavigationInfoTopCombinedProps) {
const { colors } = useTheme();
const distance = useNavigationInfo((state) => state.pathDistance);
const duration = useNavigationInfo((state) => state.pathDuration);
const street = getStreetOnlyInstruction(hudStep?.instruction);
const showHud = showHudExtended && Boolean(hudStep && street);
return (
<View
style={[
styles.container,
{ backgroundColor: colors.card, borderColor: colors.primary },
]}
>
<View style={[styles.topSection, { backgroundColor: colors.card }]}>
<View style={styles.headerRow}>
<MaterialIcons name="place" size={18} color={colors.text} />
<Text
style={[styles.title, { color: colors.text }]}
numberOfLines={1}
>
{destination}
</Text>
</View>
{showInfoExtended && (
<>
<View
style={[styles.divider, { backgroundColor: colors.border }]}
/>
<View style={styles.infoRow}>
<Text style={[styles.label, { color: colors.textMuted }]}>
Arriving at
</Text>
<Text style={[styles.value, { color: colors.text }]}>
{calculateETA(duration)}
</Text>
</View>
<View style={styles.infoRow}>
<Text style={[styles.label, { color: colors.textMuted }]}>
Distance
</Text>
<Text style={[styles.value, { color: colors.text }]}>
{distance}
</Text>
</View>
</>
)}
</View>
{showHud && (
<View style={[styles.hudSection, { backgroundColor: colors.primary }]}>
<Ionicons
name={getManeuverIcon(hudStep!.maneuverType)}
size={16}
color="#ffffff"
/>
<Text style={styles.hudText} numberOfLines={1}>
{street}
</Text>
</View>
)}
</View>
);
}
const styles = StyleSheet.create({
container: {
borderRadius: 18,
borderWidth: 1,
elevation: 4,
overflow: "hidden",
},
topSection: {
padding: 14,
},
headerRow: {
flexDirection: "row",
alignItems: "center",
},
title: {
marginLeft: 6,
fontWeight: "bold",
fontSize: 16,
flex: 1,
},
divider: {
height: 1,
marginVertical: 8,
},
infoRow: {
flexDirection: "row",
justifyContent: "space-between",
marginVertical: 2,
},
label: {
fontSize: 14,
},
value: {
fontWeight: "bold",
fontSize: 14,
},
hudSection: {
flexDirection: "row",
alignItems: "center",
gap: 8,
paddingHorizontal: 14,
paddingVertical: 10,
},
hudText: {
color: "#ffffff",
fontWeight: "700",
fontSize: 15,
flex: 1,
},
});
|