Fix home map and location, add service selector
The Android map never drew because mapType was "mutedStandard", an Apple Maps value. Android's MapManager looks the name up in a fixed table and unboxes the result into an int, so an unrecognised value threw a NullPointerException in the native view manager before any tile rendered. Android now gets "standard" plus a customMapStyle that mutes POI and transit labels, since showsPointsOfInterest is iOS-only too. Location hung indefinitely: getCurrentPositionAsync was called with no accuracy and no timeout, so it waited for a GPS fix that never arrives indoors or on an emulator with no mock location. useUserLocation now takes a cached fix first for an immediate render, caps the precise reading at 15 seconds, and checks device location services separately from app permission. Reverse geocoding moved off the critical path so a failed lookup costs the address label rather than the coordinates. The single boolean became five states, each with its own notice and either a retry or a settings shortcut, since retrying a hard denial does nothing. Map also no longer deletes itself when the driver fetch fails or the location is still pending: drivers are an overlay, and calculateRegion already falls back to Beirut. Adds a four-tile service selector above Recent Rides - Car, Moto, Courier, My Car - with the choice held in useServiceStore for the booking flow to read. English only for now; the intended Arabic names are recorded in constants/services.ts for the language pass. Selection styling matches the role picker on sign-up so the two read as one control. app.config.js layers the Google Maps key and expo-location permission strings onto app.json. No effect under Expo Go, which ignores native config, but required for the first EAS build. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
bc23c94ea2
commit
59e336c23d
@@ -0,0 +1,58 @@
|
||||
import { Linking, Text, TouchableOpacity, View } from "react-native";
|
||||
|
||||
import type { LocationStatus } from "@/lib/use-user-location";
|
||||
|
||||
const COPY: Record<string, { title: string; body: string; action: string }> = {
|
||||
denied: {
|
||||
title: "Location access is off",
|
||||
body: "Waseel needs your location to show nearby drivers and set your pickup point.",
|
||||
action: "Open Settings",
|
||||
},
|
||||
"services-off": {
|
||||
title: "Location services are off",
|
||||
body: "Turn on location on your device, then try again.",
|
||||
action: "Try Again",
|
||||
},
|
||||
unavailable: {
|
||||
title: "Couldn't find your location",
|
||||
body: "Move somewhere with a clearer signal, or set your pickup point manually.",
|
||||
action: "Try Again",
|
||||
},
|
||||
};
|
||||
|
||||
/** Fills the map slot when there's no position to draw. */
|
||||
export const LocationNotice = ({
|
||||
status,
|
||||
onRetry,
|
||||
}: {
|
||||
status: LocationStatus;
|
||||
onRetry: () => void;
|
||||
}) => {
|
||||
const copy = COPY[status];
|
||||
|
||||
if (!copy) return null;
|
||||
|
||||
return (
|
||||
<View className="flex-1 items-center justify-center px-6">
|
||||
<Text className="text-base font-JakartaBold text-black text-center">
|
||||
{copy.title}
|
||||
</Text>
|
||||
|
||||
<Text className="text-sm font-Jakarta text-general-200 text-center mt-2">
|
||||
{copy.body}
|
||||
</Text>
|
||||
|
||||
<TouchableOpacity
|
||||
onPress={() =>
|
||||
status === "denied" ? void Linking.openSettings() : onRetry()
|
||||
}
|
||||
activeOpacity={0.8}
|
||||
className="mt-5 rounded-full bg-primary-500 px-6 py-3"
|
||||
>
|
||||
<Text className="text-white font-JakartaBold text-sm">
|
||||
{copy.action}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user