diff --git a/src/pages/CafeDetail.tsx b/src/pages/CafeDetail.tsx index f9e228a..ecc2466 100644 --- a/src/pages/CafeDetail.tsx +++ b/src/pages/CafeDetail.tsx @@ -168,18 +168,51 @@ function ImageCarousel({ images }: { images: string[] }) { ); } -async function openNavigationPicker(name: string, lat: number, lng: number) { - const mapsUrl = `https://www.google.com/maps/dir/?api=1&destination=${lat},${lng}`; +function NavigationSheet({ + isOpen, + onClose, + lat, + lng, +}: { + isOpen: boolean; + onClose: () => void; + lat: number; + lng: number; +}) { + if (!isOpen) return null; - if (navigator.share) { - try { - await navigator.share({ title: name, url: mapsUrl }); - } catch { - // user dismissed the native share sheet - } - } else { - window.open(mapsUrl, "_blank"); - } + const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent); + + const apps: { label: string; url: string }[] = [ + { label: "نشان", url: `https://neshan.org/maps/@${lat},${lng},15z` }, + { label: "بلد", url: `https://balad.ir/p?lat=${lat}&lng=${lng}` }, + { label: "Waze", url: `https://waze.com/ul?ll=${lat},${lng}&navigate=yes` }, + { label: "Google Maps", url: `https://www.google.com/maps/dir/?api=1&destination=${lat},${lng}` }, + ...(isIOS ? [{ label: "Apple Maps", url: `maps://?daddr=${lat},${lng}` }] : []), + ]; + + return createPortal( + <> +
+
+
+

مسیریابی با

+
+ {apps.map((app) => ( + + ))} +
+
+ , + document.body, + ); } export default function CafeDetail() { @@ -187,6 +220,7 @@ export default function CafeDetail() { const navigate = useNavigate(); const now = useNow(); const [isReservationOpen, setIsReservationOpen] = useState(false); + const [isNavigationOpen, setIsNavigationOpen] = useState(false); const [schedules, setSchedules] = useState([]); const [selectedEventUuid] = useState(""); const [schedule, setSchedule] = useState( @@ -332,9 +366,7 @@ export default function CafeDetail() {
); } diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index 256ca82..ddbd183 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -244,6 +244,7 @@ function MyReservationsRow() { function CafeCard({ cafe }: { cafe: Cafe }) { const navigate = useNavigate() const remainingTickets = cafe.schedules?.[0]?.remaining_tickets + const firstImage = cafe.media.find((m) => m.type === 'image') return (