|
|
@@ -33,6 +33,38 @@ interface TabItem {
|
|
|
lng: number;
|
|
|
}
|
|
|
|
|
|
+const dummyTabItems: TabItem[] = [
|
|
|
+ {
|
|
|
+ imgURL: require('../../assets/dummyStationPicture.png'),
|
|
|
+ date: '今天',
|
|
|
+ time: '16:30',
|
|
|
+ chargeStationName: '觀塘偉業街充電站',
|
|
|
+ chargeStationAddress: '九龍觀塘偉業街143號地下',
|
|
|
+ distance: '400米',
|
|
|
+ latitude: 22.31337,
|
|
|
+ longitude: 114.21823
|
|
|
+ },
|
|
|
+ {
|
|
|
+ imgURL: require('../../assets/dummyStationPicture5.jpeg'),
|
|
|
+ date: '3月15',
|
|
|
+ time: '17:45',
|
|
|
+ chargeStationName: '香港沙頭角農莊',
|
|
|
+ chargeStationAddress: '香港沙頭角農莊停車場',
|
|
|
+ distance: '680米',
|
|
|
+ latitude: 22.53898,
|
|
|
+ longitude: 114.21319
|
|
|
+ },
|
|
|
+ {
|
|
|
+ imgURL: require('../../assets/dummyStationPicture4.jpeg'),
|
|
|
+ date: '3月15',
|
|
|
+ time: '17:45',
|
|
|
+ chargeStationName: '黃竹坑香葉道充電站',
|
|
|
+ chargeStationAddress: '黃竹坑香葉道44號地下',
|
|
|
+ distance: '680米',
|
|
|
+ latitude: 22.24839,
|
|
|
+ longitude: 114.16303
|
|
|
+ }
|
|
|
+];
|
|
|
const SearchResultComponent = () => {
|
|
|
const [region, setRegion] = useState<Region>({
|
|
|
latitude: 22.302711, // Default to Hong Kong coordinates
|
|
|
@@ -47,9 +79,10 @@ const SearchResultComponent = () => {
|
|
|
const snapPoints = useMemo(() => ['25%', '65%'], []);
|
|
|
const mapRef = useRef<MapView>(null);
|
|
|
const params = useLocalSearchParams();
|
|
|
- const [filteredItems, setFilteredItems] = useState<TabItem[]>([]);
|
|
|
+
|
|
|
const [isLoading, setIsLoading] = useState(true);
|
|
|
|
|
|
+ const [filteredItems, setFilteredItems] = useState<TabItem[]>([]);
|
|
|
useEffect(() => {
|
|
|
if (params.latitude && params.longitude) {
|
|
|
setRegion({
|
|
|
@@ -83,7 +116,16 @@ const SearchResultComponent = () => {
|
|
|
mapRef.current.animateToRegion(region, 1000);
|
|
|
}
|
|
|
}, [region]);
|
|
|
-
|
|
|
+ useEffect(() => {
|
|
|
+ if (searchInput === '') {
|
|
|
+ setFilteredItems([]);
|
|
|
+ } else {
|
|
|
+ const filteredData = dummyTabItems.filter((item) =>
|
|
|
+ item.chargeStationName.includes(searchInput.toLocaleUpperCase())
|
|
|
+ );
|
|
|
+ setFilteredItems(filteredData);
|
|
|
+ }
|
|
|
+ }, [searchInput]);
|
|
|
if (errorMsg) {
|
|
|
return (
|
|
|
<View className="flex-1 justify-center items-center ">
|
|
|
@@ -140,8 +182,9 @@ const SearchResultComponent = () => {
|
|
|
lat: station.StationLat,
|
|
|
date: '今天',
|
|
|
stationID: station.StationID,
|
|
|
+
|
|
|
// imgURL: stationImages[station.StationID] || require('../../assets/dummyStationPicture.png'),
|
|
|
- imgURL: station.image,
|
|
|
+ imgURL: station.image
|
|
|
// distance: distance !== null ? formatDistance(distance) : 'N/A'
|
|
|
};
|
|
|
})
|
|
|
@@ -157,6 +200,7 @@ const SearchResultComponent = () => {
|
|
|
}
|
|
|
}, [currentLocation]);
|
|
|
|
|
|
+ console.log('tabItems', tabItems);
|
|
|
const formatDistance = (distanceInMeters: number): string => {
|
|
|
if (distanceInMeters < 1000) {
|
|
|
return `${Math.round(distanceInMeters)}米`;
|
|
|
@@ -296,8 +340,8 @@ const SearchResultComponent = () => {
|
|
|
chargeStationAddress: item.chargeStationAddress,
|
|
|
chargeStationID: item.stationID,
|
|
|
chargeStationName: item.chargeStationName,
|
|
|
- // chargeStationLat: item.lat,
|
|
|
- // chargeStationLng: item.lng
|
|
|
+ stationLat: item.lat,
|
|
|
+ stationLng: item.lng
|
|
|
}
|
|
|
});
|
|
|
}}
|