From 71e18161734d9aa90e53441be6079eea4ae8086d Mon Sep 17 00:00:00 2001 From: John Lyon-Smith Date: Thu, 31 May 2018 11:15:53 -0700 Subject: [PATCH] Added wait modals everywhere. Reduce required distance to item --- mobile/android/DeightonAR.iml | 2 +- mobile/android/app/app.iml | 154 ++++++++++++++++++++++++++++++++ mobile/src/Activity/Activity.js | 10 ++- mobile/src/Home/Home.js | 27 +++++- mobile/src/WorkItem/WorkItem.js | 12 +++ mobile/src/config.js | 8 +- 6 files changed, 205 insertions(+), 8 deletions(-) create mode 100644 mobile/android/app/app.iml diff --git a/mobile/android/DeightonAR.iml b/mobile/android/DeightonAR.iml index 80879bc..a0af59d 100644 --- a/mobile/android/DeightonAR.iml +++ b/mobile/android/DeightonAR.iml @@ -8,7 +8,7 @@ - + diff --git a/mobile/android/app/app.iml b/mobile/android/app/app.iml new file mode 100644 index 0000000..0849881 --- /dev/null +++ b/mobile/android/app/app.iml @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mobile/src/Activity/Activity.js b/mobile/src/Activity/Activity.js index d03fee7..5d9a706 100644 --- a/mobile/src/Activity/Activity.js +++ b/mobile/src/Activity/Activity.js @@ -97,16 +97,19 @@ export class Activity extends React.Component { this.region = null this.isMapReady = false this.goToRegionWhenReady = false + } + componentDidMount() { const { search } = this.props.location const params = search ? new URLSearchParams(search) : { get: () => null } const id = params.get("id") const workItemId = params.get("workItemId") - const getWorkItem = (id) => { + this.setState({ waitModal: { message: "Loading Work Item Details..." } }) api .getWorkItem(id) .then((workItem) => { + this.setState({ waitModal: null }) if (workItem) { const [lng, lat] = workItem.location.coordinates @@ -139,6 +142,7 @@ export class Activity extends React.Component { }) .catch((err) => { this.setState({ + waitModal: null, messageModal: { icon: "hand", message: "Unable to get work item details", @@ -150,9 +154,12 @@ export class Activity extends React.Component { } if (id) { + this.setState({ waitModal: { message: "Loading Activity..." } }) api .getActivity(id) .then((activity) => { + this.setState({ waitModal: null }) + if (activity) { this.setState({ binder: new FormBinder(activity, Activity.bindings), @@ -163,6 +170,7 @@ export class Activity extends React.Component { }) .catch((err) => { this.setState({ + waitModal: null, messageModal: { icon: "hand", message: "Unable to get activity details", diff --git a/mobile/src/Home/Home.js b/mobile/src/Home/Home.js index 712ee11..2970201 100644 --- a/mobile/src/Home/Home.js +++ b/mobile/src/Home/Home.js @@ -13,7 +13,7 @@ import { } from "react-native" import MapView, { Marker, Callout } from "react-native-maps" import { Icon, Header, Geolocation } from "../ui" -import { MessageModal } from "../Modal" +import { MessageModal, WaitModal } from "../Modal" import { api } from "../API" import { reactAutoBind } from "auto-bind2" import { ifIphoneX } from "react-native-iphone-x-helper" @@ -41,6 +41,8 @@ export class Home extends React.Component { super(props) reactAutoBind(this) this.state = { + waitModal: null, + messageModal: null, sections: [], showWorkItems: true, haveCameraPermission: false, @@ -97,7 +99,14 @@ export class Home extends React.Component { this.state.haveLocationPermission = true this.state.haveCameraPermission = true } + } + componentDidMount() { + this.loadWorkItems() + } + + loadWorkItems() { + this.setState({ waitModal: { message: "Loading Work Items..." } }) api .listTeams() .then((list) => { @@ -105,6 +114,8 @@ export class Home extends React.Component { return api.listWorkItemActivities() }) .then((list) => { + this.setState({ waitModal: null }) + list.items.forEach((item) => { item.data.forEach((datum) => { const team = this.teams.find((team) => team._id === datum.team) @@ -130,6 +141,7 @@ export class Home extends React.Component { }) .catch((err) => { this.setState({ + waitModal: null, messageModal: { icon: "hand", message: "Unable to get a list of work items, activities and teams", @@ -246,7 +258,13 @@ export class Home extends React.Component { } handleToggleWorkItemsList() { - this.setState({ showWorkItems: !this.state.showWorkItems }) + const newShowWorkItems = !this.state.showWorkItems + + this.setState({ showWorkItems: newShowWorkItems }) + + if (newShowWorkItems) { + this.loadWorkItems() + } } handleCalloutPress(workItem) { @@ -287,6 +305,7 @@ export class Home extends React.Component { sections, showWorkItems, messageModal, + waitModal, haveCameraPermission, haveLocationPermission, } = this.state @@ -491,6 +510,10 @@ export class Home extends React.Component { {haveLocationPermission && ( )} + null } const id = params.get("id") if (id) { + this.setState({ waitModal: { message: "Loading Work Item..." } }) + api .getWorkItem(id) .then((workItem) => { + this.setState({ waitModal: null }) + if (workItem) { const [longitude, latitude] = workItem.location.coordinates @@ -136,6 +142,7 @@ export class WorkItem extends React.Component { }) .catch((err) => { this.setState({ + waitModal: null, messageModal: { icon: "hand", message: "Unable to get work item details", @@ -167,14 +174,18 @@ export class WorkItem extends React.Component { const { binder } = this.state let obj = binder.getModifiedBindingValues() + this.setState({ waitModal: { message: "Creating Work Item..." } }) + if (!obj._id) { api .createWorkItem(obj) .then((workItem) => { + this.setState({ waitModal: null }) this.handleBackPress() }) .catch((error) => { this.setState({ + waitModal: null, messageModal: { icon: "hand", message: "Unable to create work item", @@ -190,6 +201,7 @@ export class WorkItem extends React.Component { }) .catch((error) => { this.setState({ + waitModal: null, messageModal: { icon: "hand", message: "Unable to update work item", diff --git a/mobile/src/config.js b/mobile/src/config.js index e9eef1f..7726390 100644 --- a/mobile/src/config.js +++ b/mobile/src/config.js @@ -2,20 +2,20 @@ import React from "react" import { Platform } from "react-native" export const config = { - localIPAddr: "192.168.1.175", - //localIPAddr: "192.168.1.14", + //localIPAddr: "192.168.1.175", + localIPAddr: "192.168.1.14", viroAPIKey: "06F37B6A-74DA-4A83-965A-7DE2209A5C46", googleGeocodeAPIKey: "AIzaSyCs4JVT6gysnY5dAJ7KjVJYeykLv_xz1GI", googleGeocodeURL: "https://maps.googleapis.com/maps/api/geocode/json", refererURL: "https://dar.kss.us.com", - minDistanceToItem: 20, + minDistanceToItem: 10, workItemRegionDelta: 0.005, activityRegionDelta: 0.005, homeRegionInset: 0.02, homeRegionDelta: 0.005, geocodeDelayMilliseconds: 500, - // defaultUser: "john@lyon-smith.org", + //defaultUser: "john@lyon-smith.org", defaultUser: "", // This region is downtown Toronto