Make PhotoPanel bound

This commit is contained in:
John Lyon-Smith
2018-04-26 14:11:12 -07:00
parent 109e9f4d3d
commit 71cec6088a
10 changed files with 327 additions and 190 deletions

View File

@@ -52,6 +52,8 @@ export class Home extends React.Component {
workItemDistance: -1,
}
this.watchId = null
ensurePermissions(
[
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
@@ -173,8 +175,20 @@ export class Home extends React.Component {
}
@autobind
handleItemSelect(item) {
this.props.history.push(`/activity?id=${item._id}`)
handleItemSelect(activity) {
this.props.history.push(`/activity?id=${activity._id}`)
}
@autobind
handleSectionSelect(workItem) {
const { latitude, longitude } = workItem.coordinate
const region = {
latitude,
longitude,
latitudeDelta: 0.01,
longitudeDelta: 0.01,
}
this.setState({ region })
}
@autobind
@@ -276,6 +290,7 @@ export class Home extends React.Component {
showsTraffic={false}
showsIndoors={false}
zoomControlEnabled={false}
showsMyLocationButton={false}
region={region}>
{sections.map((workItem, index) => (
<Marker
@@ -348,32 +363,40 @@ export class Home extends React.Component {
sections={sections}
stickySectionHeadersEnabled={true}
renderSectionHeader={({ section: workItem }) => (
<View
key={workItem._id}
<TouchableHighlight
style={{
flexDirection: "row",
justifyContent: "flex-start",
alignItems: "center",
backgroundColor: "#F4F4F4",
paddingLeft: 8,
height: 45,
}}>
<Icon
name={
workItem.workItemType === "order"
? "hardhat"
: workItem.workItemType === "complaint"
? "question"
: "clipboard"
}
size={16}
style={{ marginRight: 10 }}
/>
<Text style={{ fontSize: 16 }}>
{workItemTypeText[workItem.workItemType].toUpperCase()}{" "}
{pad(workItem.ticketNumber, 4)}
</Text>
</View>
backgroundColor: "#F4F4F4",
}}
underlayColor="#EEEEEE"
onPress={() => this.handleSectionSelect(workItem)}>
<View
key={workItem._id}
style={{
height: "100%",
width: "100%",
flexDirection: "row",
justifyContent: "flex-start",
alignItems: "center",
}}>
<Icon
name={
workItem.workItemType === "order"
? "hardhat"
: workItem.workItemType === "complaint"
? "question"
: "clipboard"
}
size={16}
style={{ marginRight: 10 }}
/>
<Text style={{ fontSize: 16 }}>
{workItemTypeText[workItem.workItemType].toUpperCase()}{" "}
{pad(workItem.ticketNumber, 4)}
</Text>
</View>
</TouchableHighlight>
)}
keyExtractor={(item) => item._id}
renderItem={({ item: activity, section }) => {