Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/ * * * TM 3 5 2 2 3 J TMA 0 2 Q 1 , code * * 2 6 / 1 0
TMJ TMA Q code
Intial version Chris Thomson
Line modified to getDate rather than getDay Chris Thomson
This is the main application code for the React Native application.
It is a simple application that allows a user to register a userid
and then make a taxi request or offer.
The application uses the Expo framework to provide access to the
device GPS and to provide a simple UI
The application uses the TaxiService library to access the taxi
service API.
The application uses the NominatimService library to access the
Nominatim service to lookup the address of the current GPS location.
The application uses the TimePicker, AddressPicker and WaitTime
components to provide a simple UI
import Text, TextInput, Button, SafeAreaView, View, StyleSheet from 'reactnative';
import useState from 'react';
import TimePicker from componentsTimePicker;
import AddressPicker from componentsAddressPicker;
import WaitTime from componentsWaitTime;
import getLocationAddress from librariesNominatimService;
import as Taxi from librariesTaxiService;
import as Location from 'expolocation';
import StackNav from componentsStackNav;
Requests user permission to get the GPS location of the device.
This needs to be called before the GPS is read.
@returns true if permission is granted, otherwise throws an error.
async function getUserPermission: Promise
let status await Location.requestForegroundPermissionsAsync;
if status 'granted'
throwPermission to access location was denied, please check your device settings.;
else
return true;
export default function App
State variables to hold the data entered by the user.
const ownerAddress setOwnerAddress useState;
const customerAddress setCustomerAddress useState;
const ownerHours setOwnerHours useState;
const ownerMinutes setOwnerMinutes useState;
const ownerMatches setOwnerMatches useState;
const customerHours setCustomerHours useState;
const customerMinutes setCustomerMinutes useState;
const ownerWait setOwnerWait useState;
const useridsetUserid useState;
const ownerOrderidsetOwnerOrderid useState;
const customerMatches setCustomerMatches useState;
Make sure we can get the GPS location when required.
getUserPermission;
const getOwnerData async
fetch the current location.
const location await Location.getCurrentPositionAsync;
setOwnerAddresslocation found";
const transportOwnerMake async
const now new Date;
Create a start and end time for the order.
const start new DatenowgetFullYear now.getMonth now.getDate parseIntownerHours parseIntownerMinutes;
const end new DatestartgetTime parseIntownerWait;
const order await Taxi.postOrdersuserid start.toISOString end.toISOString ownerAddress;
setOwnerOrderidorderid;
const transportOwnerCancel
if ownerOrderid
Taxi.deleteOrdersuserid ownerOrderid;
setOwnerOrderid;
const transportOwnerMatches async
const matches await Taxi.getMatchesuserid;
setOwnerMatchesJSONstringifymatches;
The UI for the application.
return
Owner Offer
Matches: ownerMatches
Customer Request
Matches: customerMatche
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started