-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #225 from carls-app/map-report
Add map reporting screen
- Loading branch information
Showing
7 changed files
with
176 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// @flow | ||
|
||
export {MapView} from './mapbox' | ||
export {MapReporterView} from './report' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
// @flow | ||
import * as React from 'react' | ||
import {ScrollView, View, Text, StyleSheet} from 'react-native' | ||
import {CellTextField} from '../../components/cells/textfield' | ||
import {ButtonCell} from '../../components/cells/button' | ||
import {TableView, Section} from 'react-native-tableview-simple' | ||
import {submitReport} from './submit' | ||
import type {Building} from '../types' | ||
import * as c from '../../components/colors' | ||
import type {TopLevelViewPropsType} from '../../types' | ||
|
||
type Props = TopLevelViewPropsType & { | ||
navigation: {state: {params: {item: Building}}}, | ||
} | ||
|
||
type State = { | ||
name: string, | ||
description: string, | ||
} | ||
|
||
export class MapReporterView extends React.PureComponent<Props, State> { | ||
static navigationOptions = () => { | ||
return { | ||
title: 'Suggest an Edit', | ||
} | ||
} | ||
|
||
static getDerivedStateFromProps(nextProps: Props) { | ||
let building = nextProps.navigation.state.params.building | ||
return {name: building.name} | ||
} | ||
|
||
state = { | ||
name: this.props.navigation.state.params.building.name, | ||
description: '', | ||
} | ||
|
||
submit = () => { | ||
submitReport(this.state) | ||
} | ||
|
||
onChangeDescription = (desc: string) => { | ||
this.setState(() => ({description: desc})) | ||
} | ||
|
||
render() { | ||
let name = this.props.navigation.state.params.building.name | ||
let description = this.state.description | ||
|
||
return ( | ||
<ScrollView | ||
keyboardDismissMode="on-drag" | ||
keyboardShouldPersistTaps="always" | ||
> | ||
<View style={styles.helpWrapper}> | ||
<Text style={styles.helpTitle}>Thanks for spotting a problem!</Text> | ||
<Text style={styles.helpDescription}> | ||
There’s a problem with “{name}”, you say? | ||
</Text> | ||
<Text style={styles.helpDescription}> | ||
If you could tell us what the problems are, we’d greatly appreciate | ||
it. | ||
</Text> | ||
</View> | ||
|
||
<TableView> | ||
<Section header="DESCRIPTION"> | ||
<DefinitionCell | ||
onChange={this.onChangeDescription} | ||
text={description} | ||
/> | ||
</Section> | ||
|
||
<Section footer="Thanks for reporting!"> | ||
<ButtonCell onPress={this.submit} title="Submit Report" /> | ||
</Section> | ||
</TableView> | ||
</ScrollView> | ||
) | ||
} | ||
} | ||
|
||
type TextFieldProps = {text: string, onChange: string => any} | ||
const DefinitionCell = ({text, onChange = () => {}}: TextFieldProps) => ( | ||
<CellTextField | ||
autoCapitalize="sentences" | ||
hideLabel={true} | ||
multiline={true} | ||
onChangeText={onChange} | ||
onSubmitEditing={onChange} | ||
placeholder="What’s the problem?" | ||
returnKeyType="default" | ||
value={text} | ||
/> | ||
) | ||
|
||
const styles = StyleSheet.create({ | ||
helpWrapper: { | ||
backgroundColor: c.white, | ||
borderTopWidth: StyleSheet.hairlineWidth, | ||
borderBottomWidth: StyleSheet.hairlineWidth, | ||
borderTopColor: c.iosHeaderTopBorder, | ||
borderBottomColor: c.iosHeaderBottomBorder, | ||
marginBottom: 10, | ||
paddingBottom: 15, | ||
paddingTop: 15, | ||
}, | ||
helpTitle: { | ||
fontSize: 16, | ||
fontWeight: 'bold', | ||
paddingHorizontal: 15, | ||
}, | ||
helpDescription: { | ||
fontSize: 14, | ||
paddingTop: 5, | ||
paddingHorizontal: 15, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// @flow | ||
|
||
export {MapReporterView} from './editor' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// @flow | ||
|
||
import {sendEmail} from '../../components/send-email' | ||
import {GH_NEW_ISSUE_URL} from '../../../globals' | ||
|
||
export function submitReport({name, description}: {[key: string]: string}) { | ||
const body = makeEmailBody({name, description}) | ||
|
||
return sendEmail({ | ||
to: ['[email protected]'], | ||
subject: `[carls-map] Suggestion for building ${name}`, | ||
body, | ||
}) | ||
} | ||
|
||
function makeEmailBody({name, description}) { | ||
return ` | ||
Hi! Thanks for letting us know about a map change. | ||
With regards to the building named "${name}", you said: | ||
> ${description} | ||
Please do not change anything below this line. | ||
------------ | ||
Project maintainers: ${GH_NEW_ISSUE_URL} | ||
` | ||
} |