Center new work item on user

This commit is contained in:
John Lyon-Smith
2018-05-16 13:15:56 -07:00
parent 23d4a95bd6
commit 15bc64a42b
3 changed files with 32 additions and 4 deletions

View File

@@ -20,6 +20,7 @@ import {
Header,
BoundOptionStrip,
BoundPhotoPanel,
Geolocation,
} from "../ui"
import { MessageModal, ProgressModal, WaitModal } from "../Modal"
import autobind from "autobind-decorator"
@@ -98,6 +99,7 @@ export class WorkItem extends React.Component {
messageModal: null,
waitModal: null,
progressModal: null,
region: config.initialRegion,
}
const { search } = this.props.location
@@ -287,6 +289,20 @@ export class WorkItem extends React.Component {
}
}
@autobind
handlePositionUpdate(position) {
const { coords } = position
this.setState({
region: {
latitude: coords.latitude,
longitude: coords.longitude,
latitudeDelta: 0.02,
longitudeDelta: 0.02,
},
})
}
render() {
const {
binder,
@@ -294,6 +310,7 @@ export class WorkItem extends React.Component {
waitModal,
progressModal,
uploadPercent,
region,
} = this.state
return (
@@ -344,7 +361,7 @@ export class WorkItem extends React.Component {
showsBuildings={false}
showsTraffic={false}
showsIndoors={false}
initialRegion={config.initialRegion}
region={region}
onRegionChange={this.handleRegionChange}
onMapReady={this.handleOnMapReady}
/>
@@ -393,6 +410,7 @@ export class WorkItem extends React.Component {
)}
{isIphoneX ? <View style={{ height: 30, width: "100%" }} /> : null}
</ScrollView>
<Geolocation onUpdate={this.handlePositionUpdate} watch={false} />
<ProgressModal
open={!!progressModal}
message={progressModal ? progressModal.message : ""}