Bug fixing

This commit is contained in:
John Lyon-Smith
2018-04-23 14:01:52 -07:00
parent 5cb13f7498
commit 9730c83c9c
26 changed files with 121 additions and 147 deletions

View File

@@ -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 {
<View style={styles.panel}>
<View style={{ flexDirection: "column", justifyContent: "center" }}>
<MapView
ref={(ref) => (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}

View File

@@ -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]}
</Text>
<Text style={{ fontSize: 14, color: "gray" }}>
{`${item.address || "..."} | ${
{`${dotify(item.address) || "..."} | ${
this.position
? geoDistance(
this.position.latitude,