Skip to content

Commit 1a9308e

Browse files
authored
Tsk4.04.01 highlight indoor poi (#205)
* make some POI metadata consistent * added missing ',' in H map data that cause it to malfunction * adding indoor markers in png and svg format in asset folder * adjusting nodes for POI markers in indoor map * togglable highlights for indoor POIs * bruh forgot to change a test * linter bruh * adjusted some map data to stop it from hiding some room numbers in H * [REFACTOR] Extracted the highlight logic and separated into helper methods to reduce complexity and improve readibility * Changing colors, hopefully better for my colorblind brothers and sisters out there * forgot to change color for dark mode as well * fixed mislabeled bathroom in LB + increased opacity of highlights to make them more visible * renamed folder to a better and more accurate name * adjusting colors * changed some icons + changed some colors * changed some highlight colors * changed icons * changing VL map data due to icon hiding room number * changed icons in settings to use icons that are displayed on map * Made highlights larger to make them more visible
1 parent 2ed779e commit 1a9308e

18 files changed

Lines changed: 802 additions & 283 deletions

__tests__/building-floor.test.tsx

Lines changed: 184 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ import BuildingFloor from "@/components/map/building-floor";
22
import { render } from "@testing-library/react-native";
33

44
describe("building floor", () => {
5+
const basePoiFilters = {
6+
bathrooms: false,
7+
elevators: false,
8+
waterFountains: false,
9+
stairs: false,
10+
escalators: false,
11+
};
12+
513
const baseInfo = {
614
buildingCode: "H" as const,
715
graphData: {
@@ -34,6 +42,57 @@ describe("building floor", () => {
3442
y: 100,
3543
accessible: true,
3644
},
45+
H_BATHROOM: {
46+
id: "H_BATHROOM",
47+
type: "point_of_interest",
48+
buildingId: "H",
49+
floor: 1,
50+
x: 350,
51+
y: 100,
52+
accessible: true,
53+
metadata: {
54+
POI: "Bathroom",
55+
},
56+
},
57+
H_WATER_FOUNTAIN: {
58+
id: "H_WATER_FOUNTAIN",
59+
type: "point_of_interest",
60+
buildingId: "H",
61+
floor: 1,
62+
x: 380,
63+
y: 100,
64+
accessible: true,
65+
metadata: {
66+
POI: "Water fountain",
67+
},
68+
},
69+
H_ELEVATOR_DOOR: {
70+
id: "H_ELEVATOR_DOOR",
71+
type: "elevator_door",
72+
buildingId: "H",
73+
floor: 1,
74+
x: 410,
75+
y: 100,
76+
accessible: true,
77+
},
78+
H_STAIR_LANDING: {
79+
id: "H_STAIR_LANDING",
80+
type: "stair_landing",
81+
buildingId: "H",
82+
floor: 1,
83+
x: 440,
84+
y: 100,
85+
accessible: false,
86+
},
87+
H_ESCALATOR: {
88+
id: "H_ESCALATOR",
89+
type: "escalator",
90+
buildingId: "H",
91+
floor: 1,
92+
x: 470,
93+
y: 100,
94+
accessible: true,
95+
},
3796
},
3897
},
3998
images: {
@@ -42,14 +101,15 @@ describe("building floor", () => {
42101
};
43102

44103
it("Should render", () => {
45-
render(<BuildingFloor floor={1} info={baseInfo} />);
104+
render(<BuildingFloor floor={1} info={baseInfo} poiFilters={basePoiFilters} />);
46105
});
47106

48107
it("highlights the active edge while dimming other edges in step mode", () => {
49108
const { getByTestId } = render(
50109
<BuildingFloor
51110
floor={1}
52111
info={baseInfo}
112+
poiFilters={basePoiFilters}
53113
navigationPath={["H110", "H111", "H112"]}
54114
isStepMode
55115
activeStepIndex={1}
@@ -64,4 +124,127 @@ describe("building floor", () => {
64124
expect(edge1.props.strokeOpacity).toBe(1);
65125
expect(edge1.props.strokeWidth).toBe(22);
66126
});
127+
128+
it("renders bathroom icons for bathroom POI nodes", () => {
129+
const { queryByTestId } = render(
130+
<BuildingFloor floor={1} info={baseInfo} poiFilters={basePoiFilters} />,
131+
);
132+
133+
expect(queryByTestId("bathroom-icon-H_BATHROOM")).toBeTruthy();
134+
});
135+
136+
it("renders water fountain icons for water fountain POI nodes", () => {
137+
const { queryByTestId } = render(
138+
<BuildingFloor floor={1} info={baseInfo} poiFilters={basePoiFilters} />,
139+
);
140+
141+
expect(queryByTestId("water-fountain-icon-H_WATER_FOUNTAIN")).toBeTruthy();
142+
});
143+
144+
it("renders elevator icons for elevator door nodes", () => {
145+
const { queryByTestId } = render(
146+
<BuildingFloor floor={1} info={baseInfo} poiFilters={basePoiFilters} />,
147+
);
148+
149+
expect(queryByTestId("elevator-icon-H_ELEVATOR_DOOR")).toBeTruthy();
150+
});
151+
152+
it("renders stair icons for stair landing nodes", () => {
153+
const { queryByTestId } = render(
154+
<BuildingFloor floor={1} info={baseInfo} poiFilters={basePoiFilters} />,
155+
);
156+
157+
expect(queryByTestId("stair-icon-H_STAIR_LANDING")).toBeTruthy();
158+
});
159+
160+
it("renders escalator icons for escalator nodes", () => {
161+
const { queryByTestId } = render(
162+
<BuildingFloor floor={1} info={baseInfo} poiFilters={basePoiFilters} />,
163+
);
164+
165+
expect(queryByTestId("escalator-icon-H_ESCALATOR")).toBeTruthy();
166+
});
167+
168+
it("highlights water fountain nodes when the water fountains toggle is enabled", () => {
169+
const { queryByTestId } = render(
170+
<BuildingFloor
171+
floor={1}
172+
info={baseInfo}
173+
poiFilters={{
174+
...basePoiFilters,
175+
waterFountains: true,
176+
}}
177+
/>,
178+
);
179+
180+
expect(queryByTestId("water-fountain-highlight-H_WATER_FOUNTAIN")).toBeTruthy();
181+
});
182+
183+
it("does not highlight water fountain nodes when the water fountains toggle is disabled", () => {
184+
const { queryByTestId } = render(
185+
<BuildingFloor floor={1} info={baseInfo} poiFilters={basePoiFilters} />,
186+
);
187+
188+
expect(queryByTestId("water-fountain-highlight-H_WATER_FOUNTAIN")).toBeNull();
189+
});
190+
191+
it("highlights bathroom nodes when the bathrooms toggle is enabled", () => {
192+
const { queryByTestId } = render(
193+
<BuildingFloor
194+
floor={1}
195+
info={baseInfo}
196+
poiFilters={{
197+
...basePoiFilters,
198+
bathrooms: true,
199+
}}
200+
/>,
201+
);
202+
203+
expect(queryByTestId("bathroom-highlight-H_BATHROOM")).toBeTruthy();
204+
});
205+
206+
it("highlights elevator nodes when the elevators toggle is enabled", () => {
207+
const { queryByTestId } = render(
208+
<BuildingFloor
209+
floor={1}
210+
info={baseInfo}
211+
poiFilters={{
212+
...basePoiFilters,
213+
elevators: true,
214+
}}
215+
/>,
216+
);
217+
218+
expect(queryByTestId("elevator-highlight-H_ELEVATOR_DOOR")).toBeTruthy();
219+
});
220+
221+
it("highlights stair nodes when the stairs toggle is enabled", () => {
222+
const { queryByTestId } = render(
223+
<BuildingFloor
224+
floor={1}
225+
info={baseInfo}
226+
poiFilters={{
227+
...basePoiFilters,
228+
stairs: true,
229+
}}
230+
/>,
231+
);
232+
233+
expect(queryByTestId("stair-highlight-H_STAIR_LANDING")).toBeTruthy();
234+
});
235+
236+
it("highlights escalator nodes when the escalators toggle is enabled", () => {
237+
const { queryByTestId } = render(
238+
<BuildingFloor
239+
floor={1}
240+
info={baseInfo}
241+
poiFilters={{
242+
...basePoiFilters,
243+
escalators: true,
244+
}}
245+
/>,
246+
);
247+
248+
expect(queryByTestId("escalator-highlight-H_ESCALATOR")).toBeTruthy();
249+
});
67250
});

__tests__/components/map/map-settings.test.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ describe("MapSettings Component", () => {
3939
poiFilters: {
4040
bathrooms: true,
4141
elevators: false,
42-
washrooms: true,
42+
waterFountains: true,
43+
stairs: false,
44+
escalators: false,
4345
},
4446
setPoiFilters: jest.fn(),
4547
};
@@ -62,7 +64,7 @@ describe("MapSettings Component", () => {
6264
fireEvent.press(icon.parent);
6365

6466
expect(getByText("Settings")).toBeTruthy();
65-
expect(getByText("Points of Interest")).toBeTruthy();
67+
expect(getByText("Highlight Points of Interest")).toBeTruthy();
6668
});
6769

6870
it("should toggle the wheelchair accessibility switch", () => {
@@ -118,8 +120,12 @@ describe("MapSettings Component", () => {
118120
fireEvent.press(icon.parent);
119121

120122
const checkboxes = getAllByText("checkbox");
123+
const uncheckedBoxes = getAllByText("square-outline");
121124

122125
expect(checkboxes.length).toBe(2);
123-
expect(getByText("square-outline")).toBeTruthy();
126+
expect(uncheckedBoxes.length).toBe(3);
127+
expect(getByText("Water Fountains")).toBeTruthy();
128+
expect(getByText("Stairs")).toBeTruthy();
129+
expect(getByText("Escalators")).toBeTruthy();
124130
});
125131
});

app/(tabs)/(map)/[buildingCode].tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ export default function IndoorMap() {
7878
const [poiFilters, setPoiFilters] = useState({
7979
bathrooms: false,
8080
elevators: false,
81-
washrooms: false,
81+
waterFountains: false,
82+
stairs: false,
83+
escalators: false,
8284
});
8385
const previousWheelchairOnly = useRef(wheelchairOnly);
8486

@@ -641,10 +643,10 @@ export default function IndoorMap() {
641643
routeError={inputValidationError ?? routeError}
642644
/>
643645
<MapSettings
644-
wheelchairOnly={wheelchairOnly} //TODO temp
645-
setWheelchairOnly={handleSetWheelchairOnly} //TODO temp
646-
poiFilters={poiFilters} //TODO temp
647-
setPoiFilters={setPoiFilters} //TODO temp
646+
wheelchairOnly={wheelchairOnly}
647+
setWheelchairOnly={handleSetWheelchairOnly}
648+
poiFilters={poiFilters}
649+
setPoiFilters={setPoiFilters}
648650
/>
649651
<IndoorNavigationControls
650652
onNext={() => {
@@ -671,6 +673,7 @@ export default function IndoorMap() {
671673
/>
672674
<BuildingFloor
673675
info={floorInfo}
676+
poiFilters={poiFilters}
674677
navigationPath={navigationPath}
675678
floor={defaultFloor}
676679
isStepMode={hasStepNavigation}

assets/icons/bathroom.png

20 KB
Loading

assets/icons/elevator.png

19.9 KB
Loading

assets/icons/escalator.png

22.1 KB
Loading

assets/icons/stairway.png

1.1 MB
Loading

assets/icons/water_fountain.png

6.1 KB
Loading

0 commit comments

Comments
 (0)