Few more bug fixes

This commit is contained in:
John Lyon-Smith
2018-04-23 15:16:56 -07:00
parent 24420935a1
commit 30a66e4e34
4 changed files with 34 additions and 28 deletions

View File

@@ -97,16 +97,14 @@ export class Activity extends React.Component {
.getActivity(id)
.then((activity) => {
if (activity) {
const [lng, lat] = activity.location.coordinates
activity.location = formatLatLng(lat, lng)
this.setState({
binder: new FormBinder(activity, Activity.bindings),
region: {
latitude: lat,
longitude: lng,
latitudeDelta: 0.01,
longitudeDelta: 0.01,
},
// region: {
// latitude: lat,
// longitude: lng,
// latitudeDelta: 0.01,
// longitudeDelta: 0.01,
// },
})
}
})

View File

@@ -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 <Route render={() => <Redirect to={"/workItem"} />} />
return <Route render={() => <Redirect to={"/home"} />} />
}

View File

@@ -96,7 +96,7 @@ export class Login extends React.Component {
let { history } = this.props
if (obj) {
this.setState({ waitModal: { message: "Loggin In..." } })
this.setState({ waitModal: { message: "Logging In..." } })
api
.login(obj.email.trim(), obj.password, obj.rememberMe)
.then((user) => {

View File

@@ -22,6 +22,7 @@ import {
workItemTypeText,
pad,
regionContainingPoints,
dotify,
} from "../util"
import { ensurePermissions } from "../App"
import { versionInfo } from "../version"
@@ -79,7 +80,7 @@ export class Home extends React.Component {
results[PermissionsAndroid.PERMISSIONS.CAMERA] ===
PermissionsAndroid.RESULTS.GRANTED
) {
this.setState({ haveCameraPerm: true })
this.setState({ haveCameraPermission: true })
}
},
() => {
@@ -141,15 +142,15 @@ export class Home extends React.Component {
if (this.state.positionInfo) {
const coords = this.state.positionInfo.coords
const workItem = this.sections[sectionIndex]
const [lng, lat] = workItem.location.coordinates
const workItem = this.state.sections[sectionIndex]
const { latitude, longitude } = workItem.coordinate
this.setState({
workItemDistance: geoDistance(
coords.latitude,
coords.longitude,
lat,
lng,
latitude,
longitude,
"K"
).toFixed(2),
})
@@ -183,13 +184,17 @@ export class Home extends React.Component {
@autobind
handleGlassesPress() {
const { lat: lat1, lng: lng1 } = this.state.positionInfo.coords
const {
latitude: latitude1,
longitude: longitude1,
} = this.state.positionInfo.coords
let closestWorkItem = null
let shortestDistance = config.minDistanceToItem
this.state.sections.forEach((workItem) => {
const [lng2, lat2] = workItem.location.coordinates
const distance = geoDistance(lat1, lng1, lat2, lng2, "K") * 1000
const { latitude: latitude2, longitude: longitude2 } = workItem.coordinate
const distance =
geoDistance(latitude1, longitude1, latitude2, longitude2, "K") * 1000
if (distance <= shortestDistance) {
closestWorkItem = workItem
@@ -290,14 +295,14 @@ export class Home extends React.Component {
<Text>
{pad(workItem.ticketNumber, 4) +
": " +
workItemTypeText[workItem.workItemType]}
</Text>
<Text>
{workItem.address} ({this.workItemDistance > 0
? this.workItemDistance.toString()
: "?"}{" "}
km)
workItemTypeText[workItem.workItemType] +
" (" +
(workItemDistance > 0
? workItemDistance.toString()
: "?") +
" km)"}
</Text>
<Text>{dotify(workItem.address)}</Text>
</View>
</Callout>
</Marker>
@@ -311,6 +316,8 @@ export class Home extends React.Component {
flexBasis: 0,
width: "100%",
}}>
{/*
// TODO: Search feature
<View
style={{
flexDirection: "row",
@@ -334,7 +341,7 @@ export class Home extends React.Component {
name="cancel"
size={16}
/>
</View>
</View> */}
<SectionList
ref={(ref) => (this.sectionList = ref)}
style={{ width: "100%", flexGrow: 1 }}
@@ -374,7 +381,7 @@ export class Home extends React.Component {
<TouchableHighlight
style={{
height: 50,
paddingLeft: 20,
paddingLeft: 10,
paddingRight: 20,
backgroundColor: "white",
}}
@@ -388,7 +395,7 @@ export class Home extends React.Component {
}}>
<Text
style={{
fontSize: 8,
fontSize: 9,
width: 45,
alignSelf: "center",
}}>
@@ -399,6 +406,7 @@ export class Home extends React.Component {
flexGrow: 1,
flexBasis: 0,
flexDirection: "column",
marginLeft: 10,
}}>
<Text style={{ fontSize: 20, fontWeight: "bold" }}>
{activity.resolution}