diff --git a/design/Deighton AR Design.sketch b/design/Deighton AR Design.sketch index 29e6330..9c6a426 100644 Binary files a/design/Deighton AR Design.sketch and b/design/Deighton AR Design.sketch differ diff --git a/mobile/src/API.js b/mobile/src/API.js index 35408e6..555f108 100644 --- a/mobile/src/API.js +++ b/mobile/src/API.js @@ -390,14 +390,18 @@ class API extends EventEmitter { method: "GET", mode: "no-cors", } + let headers = new Headers() - fetch( + headers.set("Referer", config.refererURL) + fetchOptions.headers = headers + + const path = config.googleGeocodeURL + - `?latlng=${coord.latitude},${coord.longitude}&key=${ - config.googleAPIKey - }`, - fetchOptions - ) + `?latlng=${coord.latitude},${coord.longitude}&key=${ + config.googleGeocodeAPIKey + }` + + fetch(path, fetchOptions) .then((res) => { return Promise.all([Promise.resolve(res), res.json()]) }) @@ -407,7 +411,7 @@ class API extends EventEmitter { if (res.ok) { let address = "" - if (responseBody.results && responseBody.result.length > 0) { + if (responseBody.results && responseBody.results.length > 0) { address = responseBody.results[0].formatted_address } diff --git a/mobile/src/ARViewer/ARViewer.js b/mobile/src/ARViewer/ARViewer.js index cfc22fe..f5787f0 100644 --- a/mobile/src/ARViewer/ARViewer.js +++ b/mobile/src/ARViewer/ARViewer.js @@ -15,6 +15,7 @@ import { import autobind from "autobind-decorator" import backImage from "./images/back.png" import { config } from "../config" +import "url-search-params-polyfill" const shapes = { order: { diff --git a/mobile/src/Activity/Activity.js b/mobile/src/Activity/Activity.js index c98d84f..ae641b8 100644 --- a/mobile/src/Activity/Activity.js +++ b/mobile/src/Activity/Activity.js @@ -27,6 +27,7 @@ import KeyboardSpacer from "react-native-keyboard-spacer" import { isIphoneX } from "react-native-iphone-x-helper" import { api } from "../API" import { formatLatLng, parseLatLng } from "../util" +import "url-search-params-polyfill" const styles = StyleSheet.create({ container: { @@ -189,7 +190,7 @@ export class Activity extends React.Component { @@ -220,31 +221,33 @@ export class Activity extends React.Component { label="Date & Time:" /> - + + - + diff --git a/mobile/src/Auth/DefaultRoute.js b/mobile/src/Auth/DefaultRoute.js index 1323068..6735acf 100644 --- a/mobile/src/Auth/DefaultRoute.js +++ b/mobile/src/Auth/DefaultRoute.js @@ -3,5 +3,5 @@ import { Route, Redirect } from "react-router-native" export const DefaultRoute = () => { // NOTE: When working on the app, change this to the page you are working on - return } /> + return } /> } diff --git a/mobile/src/Auth/Login.js b/mobile/src/Auth/Login.js index 23c76fc..96b839c 100644 --- a/mobile/src/Auth/Login.js +++ b/mobile/src/Auth/Login.js @@ -125,7 +125,7 @@ export class Login extends React.Component { } render() { - const { messageModal, apiModal } = this.state + const { messageModal, apiModal, waitModal } = this.state return ( diff --git a/mobile/src/Home/Home.js b/mobile/src/Home/Home.js index 9a43e80..b8b62c7 100644 --- a/mobile/src/Home/Home.js +++ b/mobile/src/Home/Home.js @@ -27,9 +27,9 @@ import { ensurePermissions } from "../App" import { versionInfo } from "../version" import { config } from "../config" import KeyboardSpacer from "react-native-keyboard-spacer" -import hardhatPinImage from "./images/hardhat.png" -import clipboardPinImage from "./images/clipboard.png" -import questionPinImage from "./images/question.png" +import hardhatPinImage from "./images/hardhat-pin.png" +import clipboardPinImage from "./images/clipboard-pin.png" +import questionPinImage from "./images/question-pin.png" const neverAskForLocationPermissionKeyName = "NeverAskForLocationPermission" const neverAskForCameraKeyName = "NeverAskForCameraPermission" @@ -141,7 +141,7 @@ export class Home extends React.Component { if (this.state.positionInfo) { const coords = this.state.positionInfo.coords - const workItem = sections[sectionIndex] + const workItem = this.sections[sectionIndex] const [lng, lat] = workItem.location.coordinates this.setState({ @@ -159,16 +159,16 @@ export class Home extends React.Component { @autobind handleWorkItemsListPress() { const { positionInfo } = this.state - this.props.history.push( - `/workItemList${ - positionInfo - ? "?latLng=" + - coords.latitude.toString() + - "," + - coords.longitude.toString() - : "" - }` - ) + + if (positionInfo) { + const { coords } = positionInfo + + this.props.history.push( + `/workItemList?latLng=${coords.latitude},${coords.longitude}` + ) + } else { + this.props.history.push("/workItemList") + } } @autobind @@ -184,8 +184,8 @@ export class Home extends React.Component { @autobind handleGlassesPress() { const { lat: lat1, lng: lng1 } = this.state.positionInfo.coords - const closestWorkItem = null - const shortestDistance = config.minDistanceToItem + let closestWorkItem = null + let shortestDistance = config.minDistanceToItem this.state.sections.forEach((workItem) => { const [lng2, lat2] = workItem.location.coordinates @@ -270,7 +270,7 @@ export class Home extends React.Component { showsBuildings={false} showsTraffic={false} showsIndoors={false} - zoomControlEnabled + zoomControlEnabled={false} region={region}> {sections.map((workItem, index) => ( - {message} + + {message} + ) diff --git a/mobile/src/WorkItem/WorkItem.js b/mobile/src/WorkItem/WorkItem.js index b196ef1..c84f497 100644 --- a/mobile/src/WorkItem/WorkItem.js +++ b/mobile/src/WorkItem/WorkItem.js @@ -28,6 +28,7 @@ import { ifIphoneX, isIphoneX } from "react-native-iphone-x-helper" import KeyboardSpacer from "react-native-keyboard-spacer" import { api } from "../API" import "url-search-params-polyfill" +import { config } from "../config" import { workItemTypeEnum, formatLatLng, parseLatLng } from "../util" const styles = StyleSheet.create({ @@ -58,6 +59,7 @@ export class WorkItem extends React.Component { location: { isValid: (r, v) => v !== "", isReadOnly: true, + alwaysGet: true, }, address: { isValid: true, @@ -74,15 +76,18 @@ export class WorkItem extends React.Component { constructor(props) { super(props) + + region = { + latitude: 43.653908, + longitude: -79.384293, + latitudeDelta: 0.0922, + longitudeDelta: 0.0421, + } + this.state = { binder: new FormBinder({}, WorkItem.bindings), messageModal: null, - region: { - latitude: 43.653908, - longitude: -79.384293, - latitudeDelta: 0.0922, - longitudeDelta: 0.0421, - }, + region, } const { search } = this.props.location @@ -96,15 +101,17 @@ export class WorkItem extends React.Component { .then((workItem) => { if (workItem) { const [lng, lat] = workItem.location.coordinates + const region = { + latitude: lat, + longitude: lng, + latitudeDelta: 0.01, + longitudeDelta: 0.01, + } + workItem.location = formatLatLng(lat, lng) this.setState({ binder: new FormBinder(workItem, WorkItem.bindings), - region: { - latitude: lat, - longitude: lng, - latitudeDelta: 0.01, - longitudeDelta: 0.01, - }, + region, }) } }) @@ -198,6 +205,7 @@ export class WorkItem extends React.Component { if (this.geoCodeTimer) { clearTimeout(this.geoCodeTimer) + this.geoCodeTimer = null } this.geoCodeTimer = setTimeout( @@ -209,12 +217,16 @@ export class WorkItem extends React.Component { @autobind handleStartAddressLookup(latLng) { api - .addressLookup(latLng) + .getAddress(latLng) .then((address) => { - this.setState({ address }) + if (this.addressInput) { + this.addressInput.handleChangeText(address) + } }) .catch(() => { - this.setState({ address: "" }) + if (this.addressInput) { + this.addressInput.handleChangeText("") + } }) } @@ -252,6 +264,7 @@ export class WorkItem extends React.Component { (this.mapView = ref)} style={{ flexDirection: "column", justifyContent: "center", @@ -262,7 +275,7 @@ export class WorkItem extends React.Component { showsBuildings={false} showsTraffic={false} showsIndoors={false} - zoomControlEnabled + zoomControlEnabled={false} rotateEnabled={false} region={region} onRegionChange={this.handleRegionChange} diff --git a/mobile/src/WorkItem/WorkItemList.js b/mobile/src/WorkItem/WorkItemList.js index 750cdaa..439b0ef 100644 --- a/mobile/src/WorkItem/WorkItemList.js +++ b/mobile/src/WorkItem/WorkItemList.js @@ -20,7 +20,9 @@ import { parseLatLng, pad, geoDistance, + dotify, } from "../util" +import "url-search-params-polyfill" const styles = StyleSheet.create({ container: { @@ -179,7 +181,7 @@ export class WorkItemList extends React.Component { {workItemTypeText[item.workItemType]} - {`${item.address || "..."} | ${ + {`${dotify(item.address) || "..."} | ${ this.position ? geoDistance( this.position.latitude, diff --git a/mobile/src/config.js b/mobile/src/config.js index 4720bc3..41605ca 100644 --- a/mobile/src/config.js +++ b/mobile/src/config.js @@ -4,11 +4,9 @@ import { Platform } from "react-native" export const config = { localIPAddr: "192.168.1.175", viroAPIKey: "06F37B6A-74DA-4A83-965A-7DE2209A5C46", - googleAPIKey: - Platform.os === "ios" - ? "AIzaSyDN4E_vzO4cKjKHkMg_49hX1GBnU34kx4U" - : "AIzaSyAC7r1GjMFL1atZdbEcFSdCaXDrPnISqTc", + googleGeocodeAPIKey: "AIzaSyCs4JVT6gysnY5dAJ7KjVJYeykLv_xz1GI", googleGeocodeURL: "https://maps.googleapis.com/maps/api/geocode/json", + refererURL: "https://dar.kss.us.com", defaultUser: "john@lyon-smith.org", //defaultUser: "", //minGPSAccuracy: 20, diff --git a/mobile/src/ui/BoundInput.js b/mobile/src/ui/BoundInput.js index 11a4ebc..7ce0436 100644 --- a/mobile/src/ui/BoundInput.js +++ b/mobile/src/ui/BoundInput.js @@ -54,7 +54,12 @@ export class BoundInput extends React.Component { return ( - + {label} 1} numberOfLines={lines} diff --git a/mobile/src/util.js b/mobile/src/util.js index 403f011..ac284a0 100644 --- a/mobile/src/util.js +++ b/mobile/src/util.js @@ -56,6 +56,14 @@ export const pad = (num, size) => { return s } +export const dotify = (s) => { + if (s.length < 30) { + return s + } else { + return s.substring(0, 26) + "..." + } +} + export const regionContainingPoints = (points, inset) => { let minX, maxX, diff --git a/website/src/Teams/Teams.js b/website/src/Teams/Teams.js index 13be65b..1f89aee 100644 --- a/website/src/Teams/Teams.js +++ b/website/src/Teams/Teams.js @@ -143,75 +143,6 @@ export class Teams extends Component { }) } - @autobind - handleResendEmail() { - this.setState({ - waitModal: { message: "Resending Email..." }, - }) - api - .sendConfirmEmail({ existingEmail: this.state.selectedTeam.email }) - .then(() => { - this.setState({ - waitModal: null, - messageModal: { - icon: "thumb", - message: `An email has been sent to '${ - this.state.selectedTeam.email - }' with further instructions.`, - }, - }) - }) - .catch((error) => { - this.setState({ - error: true, - waitModal: null, - messageModal: { - icon: "hand", - message: "Unable to request email change.", - detail: error.message, - }, - }) - }) - } - - @autobind - handleChangeEmailDismiss(newEmail) { - this.setState({ changeEmailModal: null }) - if (!newEmail) { - return - } - this.setState({ - waitModal: { message: "Requesting Email Change..." }, - }) - if (this.state.selectedTeam) { - api - .sendConfirmEmail({ - existingEmail: this.state.selectedTeam.email, - newEmail, - }) - .then(() => { - this.setState({ - waitModal: null, - messageModal: { - icon: "hand", - message: `An email has been sent to '${newEmail}' to confirm this email.`, - }, - }) - }) - .catch((error) => { - this.setState({ - error: true, - waitModal: null, - messageModal: { - icon: "hand", - message: "Unable to request email change.", - detail: error.message, - }, - }) - }) - } - } - @autobind handleRemove() { this.setState({