-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindoor-navigation-controls.tsx
More file actions
128 lines (122 loc) · 3.46 KB
/
Copy pathindoor-navigation-controls.tsx
File metadata and controls
128 lines (122 loc) · 3.46 KB
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
import { Colors } from "@/constants/theme";
import { useColorScheme } from "@/hooks/use-color-scheme";
import { Ionicons } from "@expo/vector-icons";
import React from "react";
import { View, Text, TouchableOpacity, StyleSheet } from "react-native";
interface IndoorNavigationControlsProps {
onNext: () => void;
onPrevious: () => void;
currentFloor: number;
canGoNext?: boolean;
canGoPrevious?: boolean;
mode?: "floor" | "step";
currentStep?: number;
totalSteps?: number;
stepInstruction?: string;
}
export default function IndoorNavigationControls({
onNext,
onPrevious,
currentFloor,
canGoNext = true,
canGoPrevious = true,
mode = "floor",
currentStep = 1,
totalSteps = 1,
stepInstruction,
}: Readonly<IndoorNavigationControlsProps>) {
const colorScheme = useColorScheme();
const theme = Colors[colorScheme];
const styles = makeStyles(theme);
const formatFloor = (floor: number) => {
if (floor < 0) return `B${Math.abs(floor)}`;
return `${floor}`;
};
const isStepMode = mode === "step";
const centerText = isStepMode
? `Step ${currentStep} of ${totalSteps}`
: `Floor ${formatFloor(currentFloor)}`;
return (
<View style={styles.container}>
<TouchableOpacity
style={[styles.sideButton, !canGoPrevious && styles.disabled]}
onPress={onPrevious}
disabled={!canGoPrevious}
>
<Ionicons name="arrow-back" size={18} color={theme.mapSettings.fabIcon} />
<Text style={styles.sideText}>{isStepMode ? "Prev Step" : "Prev Floor"}</Text>
</TouchableOpacity>
<View style={styles.centerCard}>
<Text style={styles.instructionText}>{centerText}</Text>
{isStepMode && stepInstruction ? (
<Text style={styles.stepInstructionText} numberOfLines={4}>
{stepInstruction}
</Text>
) : null}
</View>
<TouchableOpacity
style={[styles.sideButton, !canGoNext && styles.disabled]}
testID="next-button"
onPress={onNext}
disabled={!canGoNext}
>
<Text style={styles.sideText}>{isStepMode ? "Next Step" : "Next Floor"}</Text>
<Ionicons name="arrow-forward" size={18} color={theme.mapSettings.fabIcon} />
</TouchableOpacity>
</View>
);
}
const makeStyles = (theme: typeof Colors.light | typeof Colors.dark) =>
StyleSheet.create({
container: {
position: "absolute",
bottom: 30,
left: 16,
right: 16,
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
zIndex: 20,
},
sideButton: {
flexDirection: "row",
alignItems: "center",
backgroundColor: theme.mapSettings.fabBackground,
paddingHorizontal: 10,
paddingVertical: 8,
borderRadius: 20,
gap: 4,
elevation: 5,
},
sideText: {
color: theme.mapSettings.fabIcon,
fontWeight: "600",
fontSize: 12,
},
disabled: {
opacity: 0.4,
},
centerCard: {
flex: 1,
marginHorizontal: 6,
backgroundColor: theme.mapSettings.panelBackground,
paddingVertical: 10,
paddingHorizontal: 12,
borderRadius: 16,
alignItems: "center",
elevation: 6,
},
instructionText: {
color: theme.mapSettings.text,
textAlign: "center",
fontWeight: "500",
fontSize: 14,
},
stepInstructionText: {
marginTop: 4,
color: theme.mapSettings.text,
textAlign: "center",
fontSize: 13,
lineHeight: 18,
},
});