-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnavigation.jsx
145 lines (132 loc) · 5.36 KB
/
navigation.jsx
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
144
145
import React, { useState, useEffect } from "react";
import { FaPause, FaPlay, FaStop, FaMapMarkerAlt } from "react-icons/fa";
import { BiTime } from "react-icons/bi";
import { GiPathDistance } from "react-icons/gi";
import { MdAttachMoney } from "react-icons/md";
const RideTracker = () => {
const [isPaused, setIsPaused] = useState(false);
const [distance, setDistance] = useState(0);
const [time, setTime] = useState(0);
const [fare, setFare] = useState(0);
const mockDropOffStations = [
{ id: 1, name: "Central Station", distance: "0.5 km" },
{ id: 2, name: "Downtown Hub", distance: "1.2 km" },
{ id: 3, name: "Park Station", distance: "2.0 km" },
];
useEffect(() => {
let interval;
if (!isPaused) {
interval = setInterval(() => {
setDistance((prev) => prev + 0.1);
setTime((prev) => prev + 1);
setFare((prev) => prev + 0.25);
}, 1000);
}
return () => clearInterval(interval);
}, [isPaused]);
const formatTime = (seconds) => {
const mins = Math.floor(seconds / 60);
const secs = seconds % 60;
return `${mins}:${secs.toString().padStart(2, "0")}`;
};
const handlePauseResume = () => {
setIsPaused(!isPaused);
};
const handleEndRide = () => {
setIsPaused(true);
// Additional end ride logic here
};
return (
<div className="min-h-screen bg-gray-50 p-4">
<div className="max-w-4xl mx-auto bg-white rounded-xl shadow-lg overflow-hidden">
{/* Map Placeholder */}
<div className="h-64 bg-gray-200 relative" role="region" aria-label="Ride map">
<div className="absolute inset-0 flex items-center justify-center">
<FaMapMarkerAlt className="text-green-500 text-4xl animate-bounce" />
</div>
</div>
{/* Ride Information */}
<div className="p-6">
<div className="grid grid-cols-3 gap-4 mb-6">
{/* ETA */}
<div className="bg-gray-50 p-4 rounded-lg">
<div className="flex items-center space-x-2">
<BiTime className="text-green-500 text-xl" />
<span className="text-gray-700 font-semibold">ETA</span>
</div>
<p className="text-2xl font-bold text-gray-800 mt-2">12 mins</p>
</div>
{/* Distance */}
<div className="bg-gray-50 p-4 rounded-lg">
<div className="flex items-center space-x-2">
<GiPathDistance className="text-green-500 text-xl" />
<span className="text-gray-700 font-semibold">Distance</span>
</div>
<p className="text-2xl font-bold text-gray-800 mt-2">
{distance.toFixed(1)} km
</p>
</div>
{/* Fare */}
<div className="bg-gray-50 p-4 rounded-lg">
<div className="flex items-center space-x-2">
<MdAttachMoney className="text-green-500 text-xl" />
<span className="text-gray-700 font-semibold">Fare</span>
</div>
<p className="text-2xl font-bold text-gray-800 mt-2">
${fare.toFixed(2)}
</p>
</div>
</div>
{/* Nearby Stations */}
<div className="mb-6">
<h3 className="text-lg font-semibold text-gray-700 mb-3">
Nearby Drop-off Stations
</h3>
<div className="space-y-2">
{mockDropOffStations.map((station) => (
<div
key={station.id}
className="flex items-center justify-between bg-gray-50 p-3 rounded-lg hover:bg-gray-100 transition-colors duration-200"
>
<span className="text-gray-700">{station.name}</span>
<span className="text-green-500 font-medium">
{station.distance}
</span>
</div>
))}
</div>
</div>
{/* Action Buttons */}
<div className="flex space-x-4">
<button
onClick={handlePauseResume}
className="flex-1 flex items-center justify-center space-x-2 bg-green-500 text-white py-3 rounded-lg hover:bg-green-600 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-green-500 focus:ring-offset-2"
aria-label={isPaused ? "Resume ride" : "Pause ride"}
>
{isPaused ? (
<>
<FaPlay className="text-lg" />
<span>Resume</span>
</>
) : (
<>
<FaPause className="text-lg" />
<span>Pause</span>
</>
)}
</button>
<button
onClick={handleEndRide}
className="flex-1 flex items-center justify-center space-x-2 bg-red-500 text-white py-3 rounded-lg hover:bg-red-600 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2"
aria-label="End ride"
>
<FaStop className="text-lg" />
<span>End Ride</span>
</button>
</div>
</div>
</div>
</div>
);
};
export default RideTracker;