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>
66 lines
1.6 KiB
TypeScript
66 lines
1.6 KiB
TypeScript
import { DEFAULT_SERVICE, type ServiceId } from "@/constants/services";
|
|
import type { DriverStore, LocationStore, MarkerData } from "@/types/type";
|
|
import { create } from "zustand";
|
|
|
|
export const useLocationStore = create<LocationStore>((set) => ({
|
|
userAddress: null,
|
|
userLongitude: null,
|
|
userLatitude: null,
|
|
destinationLongitude: null,
|
|
destinationLatitude: null,
|
|
destinationAddress: null,
|
|
|
|
setUserLocation: ({
|
|
latitude,
|
|
longitude,
|
|
address,
|
|
}: {
|
|
latitude: number;
|
|
longitude: number;
|
|
address: string;
|
|
}) => {
|
|
set(() => ({
|
|
userLatitude: latitude,
|
|
userLongitude: longitude,
|
|
userAddress: address,
|
|
}));
|
|
},
|
|
|
|
setDestinationLocation: ({
|
|
latitude,
|
|
longitude,
|
|
address,
|
|
}: {
|
|
latitude: number;
|
|
longitude: number;
|
|
address: string;
|
|
}) => {
|
|
set(() => ({
|
|
destinationLatitude: latitude,
|
|
destinationLongitude: longitude,
|
|
destinationAddress: address,
|
|
}));
|
|
},
|
|
}));
|
|
|
|
type ServiceStore = {
|
|
service: ServiceId;
|
|
setService: (service: ServiceId) => void;
|
|
};
|
|
|
|
/** Which service the rider picked on the home screen. */
|
|
export const useServiceStore = create<ServiceStore>((set) => ({
|
|
service: DEFAULT_SERVICE,
|
|
setService: (service: ServiceId) => set(() => ({ service })),
|
|
}));
|
|
|
|
export const useDriverStore = create<DriverStore>((set) => ({
|
|
drivers: [] as MarkerData[],
|
|
selectedDriver: null,
|
|
|
|
setSelectedDriver: (driverId: number) =>
|
|
set(() => ({ selectedDriver: driverId })),
|
|
setDrivers: (drivers: MarkerData[]) => set(() => ({ drivers })),
|
|
clearSelectedDriver: () => set(() => ({ selectedDriver: null })),
|
|
}));
|