Skip to content

Commit

Permalink
fixed the back to stop feature
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunsinghofficial committed Aug 21, 2024
1 parent 59a82e3 commit 9ba1d20
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/components/map/GoogleMap.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
export let selectedRoute = null;
export let showRoute = false;
export let showRouteMap = false;
export let showAllStops = true;
const dispatch = createEventDispatcher();
Expand Down Expand Up @@ -84,6 +85,11 @@
markers = [];
}
$: if (showAllStops) {
clearAllMarkers();
allStops.forEach((s) => addMarker(s));
}
$: if (selectedRoute && showRoute) {
clearAllMarkers();
const stopsToShow = allStops.filter((s) => s.routeIds.includes(selectedRoute.id));
Expand Down
13 changes: 10 additions & 3 deletions src/components/oba/StopPane.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
export let stop;
export let arrivalsAndDeparturesResponse = null;
export let showAllStops = true;
let arrivalsAndDepartures;
let loading = false;
let error;
Expand All @@ -29,6 +31,11 @@
loading = false;
}
$: if (showAllStops) {
showTripDetails = false;
selectedTripDetails = null;
}
$: (async (s, arrDep) => {
// if the arrivalsAndDeparturesResponse is passed in, use that
// instead of loading fresh data.
Expand Down Expand Up @@ -67,13 +74,13 @@
showTripDetails = true;
dispatch('tripSelected', selectedTripDetails);
dispatch('updateRouteMap', { show: true });
console.log('StopPane: Trip selected, showing route map');
}
function handleCloseTripDetailModal() {
showTripDetails = false;
dispatch('tripSelected', null);
dispatch('updateRouteMap', { show: false });
dispatch('showAllStops');
}
</script>

Expand All @@ -84,7 +91,7 @@
>
<div class="flex items-center text-white">
<svg
class="-ml-1 mr-3 h-5 w-5 animate-spin text-white"
class="w-5 h-5 mr-3 -ml-1 text-white animate-spin"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
Expand Down Expand Up @@ -122,7 +129,7 @@
Arrivals and Departures
</h3>
</div>
<div class="scrollbar-hidden h-96 space-y-2 overflow-y-scroll rounded-lg">
<div class="space-y-2 overflow-y-scroll rounded-lg scrollbar-hidden h-96">
<div>
{#each arrivalsAndDepartures.arrivalsAndDepartures as arrival}
<ArrivalDeparture
Expand Down
33 changes: 26 additions & 7 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
let showRoute = false;
let selectedRoute = null;
let showRouteMap = false;
let showAllStops = false;
function stopSelected(event) {
stop = event.detail.stop;
Expand All @@ -21,22 +22,40 @@
}
function tripSelected(event) {
selectedTrip = event.detail;
showRoute = true;
selectedRoute = {
id: event.detail.routeId,
shortName: event.detail.routeShortName
};
if (event.detail) {
selectedTrip = event.detail;
showRoute = true;
selectedRoute = {
id: event.detail.routeId,
shortName: event.detail.routeShortName
};
} else {
selectedTrip = null;
showRoute = false;
selectedRoute = null;
}
}
function handleUpdateRouteMap(event) {
showRouteMap = event.detail.show;
showAllStops = !event.detail.show;
}
function handleShowAllStops() {
showAllStops = true;
showRouteMap = false;
}
</script>

{#if stop}
<ModalPane on:close={closePane}>
<StopPane {stop} on:tripSelected={tripSelected} on:updateRouteMap={handleUpdateRouteMap} />
<StopPane
{showAllStops}
{stop}
on:tripSelected={tripSelected}
on:updateRouteMap={handleUpdateRouteMap}
on:showAllStops={handleShowAllStops}
/>
</ModalPane>
{/if}

Expand Down

0 comments on commit 9ba1d20

Please sign in to comment.