Start adding API selection modal and supporting code

This commit is contained in:
John Lyon-Smith
2018-04-08 20:53:01 -07:00
parent 7891bb71c9
commit d674f5e7eb
6 changed files with 171 additions and 41 deletions

View File

@@ -55,6 +55,17 @@ export class Home extends React.Component {
}
}
@autobind
handleMarkerPress(e, sectionIndex) {
if (this.sectionList) {
this.sectionList.scrollToLocation({
sectionIndex,
itemIndex: 0,
viewOffset: 45,
})
}
}
@autobind
handleWorkItemsListPress() {
this.props.history.push("/workitemlist")
@@ -116,14 +127,19 @@ export class Home extends React.Component {
latitudeDelta: 0.0922,
longitudeDelta: 0.0922,
}}>
{sections.map((section, index) => (
{sections.map((workItem, index) => (
<Marker
key={index}
coordinate={section.coordinate}
title={workItemTypeText[section.workItemType]}
description={section.address}
coordinate={workItem.coordinate}
title={
pad(workItem.ticketNumber, 4) +
": " +
workItemTypeText[workItem.workItemType]
}
description={workItem.address}
image={pinImage}
anchor={{ x: 0.5, y: 1.0 }}
onPress={(e) => this.handleMarkerPress(e, index)}
/>
))}
</MapView>
@@ -152,8 +168,10 @@ export class Home extends React.Component {
/>
</View>
<SectionList
ref={(ref) => (this.sectionList = ref)}
style={{ width: "100%", flexGrow: 1 }}
sections={sections}
stickySectionHeadersEnabled={true}
renderSectionHeader={({ section: workItem }) => (
<View
key={workItem._id}
@@ -169,10 +187,10 @@ export class Home extends React.Component {
</Text>
</View>
)}
keyExtractor={(item) => item._id}
renderItem={({ item: activity, section }) => {
return (
<View
key={activity._id}
style={{
flexDirection: "row",
height: 50,