This app now features a comprehensive ride management system similar to Uber, handling both collector (customer) and customer (Rider) roles with distinct color themes and full ride flow tracking.
- Primary Color:
amber-600(#d97706) - Secondary Color:
amber-50toamber-200for backgrounds - Use Case: customers requesting raddi pickup services
- Primary Color:
emerald-600(#059669) - Secondary Color:
emerald-50toemerald-200for backgrounds - Use Case: customers collecting raddi from customers
- Stores user authentication token
- NEW: Stores user role ('collector' | 'customer')
- Actions:
login(token): Store auth tokensetRole(role): Set user rolesetuser(userData): Store user datalogout(): Clear all auth data
Manages the complete ride lifecycle with the following states:
Ride Statuses:
idle- No active ridesearching- collector searching for customerpending- Order placed, waiting for acceptanceaccepted- customer accepted the orderon_way- customer heading to pickup locationarrived- customer arrived at pickuppicked_up- Items picked upcompleted- Ride completedcancelled- Ride cancelled
Actions:
createOrder()- collector creates a new orderacceptOrder()- customer accepts an orderupdatecustomerLocation()- Update customer's real-time locationupdatecollectorLocation()- Update collector's locationsetRideStatus()- Update ride statuscompleteRide()- Mark ride as completedcancelRide()- Cancel the rideresetRide()- Reset to initial state
-
Initial State (idle)
- User sees map with their current location
- "Request Pickup" button visible at bottom
-
Request Pickup
- Bottom sheet appears with form:
- Pickup address
- Approximate weight (kg)
- Submit triggers
createOrderaction - Status changes to
pending
- Bottom sheet appears with form:
-
Waiting for customer (pending)
- "Finding a customer..." message displayed
- Can cancel the order
- Socket listening for customer acceptance
-
customer Accepted (accepted)
- Toast notification: "Order Accepted!"
- customer name and ETA displayed
- Map shows customer's location
- Route drawn between collector and customer
-
customer On Way (on_way)
- Real-time updates of customer location
- Route updates dynamically
- Status: "customer on the way"
-
customer Arrived (arrived)
- Notification: "customer has arrived"
- Can contact customer
-
Items Picked Up (picked_up)
- Notification: "Items picked up"
- Tracking continues if customer moves
-
Ride Completed (completed)
- Success notification
- Ride details displayed
- Auto-reset after 3 seconds
-
Available for Orders (idle)
- Map shows customer's current location
- "Waiting for orders..." status
- Location tracked in background
-
New Order Received
- Modal appears with order details:
- customer name
- Pickup address
- Approximate weight
- Distance
- Options: Accept or Reject
- Modal appears with order details:
-
Order Accepted (accepted)
- Order info card displayed on map
- customer location visible
- "Start Navigation" button
- Route drawn to customer
-
Navigate to customer (on_way)
- Real-time location sent to customer every 10 seconds
- "Mark as Arrived" button visible
- Route updates
-
Arrived at Pickup (arrived)
- Status updated
- customer notified
- "Pick Up Items" button
-
Items Picked Up (picked_up)
- Status updated
- "Complete Ride" button visible
-
Ride Completed (completed)
- Success notification
- Auto-reset after 2 seconds
- Ready for next order
makeRaddiOrder- Create new pickup request{ customerId: number, pickupLatitude: number, pickupLongitude: number, pickupAddress: string, approximateRaddiInKg: string }
cancelOrder- Cancel pending order
acceptOrder- Accept incoming order{ orderId: string, customerId: string, customerName: string }
rejectOrder- Reject incoming orderupdatecustomerLocation- Send location update{ orderId: string, latitude: number, longitude: number }
updateRideStatus- Update ride status{ orderId: string, status: string }
orderCreated- Confirmation of order creationorderAccepted- customer accepted ordercustomerLocationUpdate- Real-time customer locationrideStatusUpdate- Status changesorderCancelled- Order was cancelled
newOrderAvailable- New order notificationorderCancelledBycustomer- customer cancelled
- Main screen for collectors
- Handles order creation and tracking
- Shows real-time customer location
- Displays ride status
- Color theme: Amber
- Main screen for customers
- Receives and displays incoming orders
- Order accept/reject modal
- Status update buttons
- Real-time location broadcasting
- Color theme: Emerald
- Displays interactive map
- Shows markers for collector/customer locations
- Draws route between locations
- Auto-fits map to show all markers
- Uses OSRM for routing
- Fallback to straight line if routing fails
- Role-based routing
- collectors see: Home | Activity | Request | Account
- customers see: Home | Activity | Orders | Account
- Tab bar color adapts to role
- Initial route: "Ride" (role-specific screen)
- Continuous GPS updates
- Permission handling
- 10-second intervals during active rides
- Background location updates
- Real-time marker movement
- Dynamic route recalculation
- Smooth animations
- Auto-zoom to fit all markers
All screens adapt based on user role:
- Home Screen: Role-specific labels and colors
- Profile Screen: Role-specific banner color
- Navigation: Role-specific active color
- Ride Screens: Complete theme integration
- Location updates throttled to 10 seconds
- Socket listeners cleaned up on unmount
- Map animations optimized
- Efficient state updates
- Permission denied fallback
- Socket disconnection handling
- Location unavailable fallback
- Network error notifications
- Clear status indicators
- Toast notifications for all events
- Loading states
- Smooth transitions
- Intuitive button placement
- In-App Chat: Communication between collector and customer
- Rating System: Rate completed rides
- Payment Integration: In-app payment processing
- Ride History: View past rides
- Push Notifications: Background notifications
- ETA Calculation: Real-time arrival estimates
- Multiple Orders: customers handle multiple orders
- Order Queue: collectors see available customers
- Price Estimation: Automatic pricing
- Analytics: Dashboard with ride statistics
- collector can create order
- customer receives order notification
- customer can accept/reject orders
- Real-time location updates work
- Map shows correct markers
- Route drawing works
- Status updates propagate correctly
- Toast notifications appear
- Cancel functionality works
- Ride completion works
- Color themes correct for both roles
- Navigation works correctly
- Socket reconnection handling
- Permission handling
- Error scenarios handled
{
"@react-navigation/bottom-tabs": "Tab navigation",
"react-native-maps": "Map display and markers",
"lucide-react-native": "Icons",
"react-native-alert-notification": "Toast notifications",
"@reduxjs/toolkit": "State management",
"socket.io-client": "Real-time communication"
}src/
├── store/
│ ├── store.tsx (Redux store configuration)
│ └── slices/
│ ├── authSlice.tsx (Auth + Role)
│ ├── rideSlice.tsx (Ride state management)
│ └── socketSlice.tsx (Socket connection)
├── screens/
│ └── authenticated/
│ ├── collectorRideScreen.tsx (collector ride flow)
│ ├── customerRideScreen.tsx (customer ride flow)
│ ├── Home.tsx (Role-aware home)
│ └── Profile.tsx (Role-aware profile)
├── components/
│ ├── LiveMap.tsx (Enhanced map)
│ ├── Header.tsx
│ └── BottomSheet.tsx
├── navigation/
│ └── authenticated.tsx (Role-based navigation)
└── services/
└── socketService.tsx (Socket.io client)
This comprehensive ride management system provides:
- ✅ Full ride lifecycle tracking (8 states)
- ✅ Real-time location updates
- ✅ Role-based UI/UX (collector/customer)
- ✅ Dynamic color theming
- ✅ Socket-based communication
- ✅ Interactive map with routing
- ✅ Notifications and status updates
- ✅ Complete state management
- ✅ Professional user experience
The system is production-ready and follows industry best practices for ride-hailing applications.