Skip to content

Commit 43a9524

Browse files
committed
poke at the reporting view a bit
1 parent d98d48d commit 43a9524

File tree

3 files changed

+106
-0
lines changed

3 files changed

+106
-0
lines changed

source/views/building-hours/detail/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ export class BuildingHoursDetailView extends React.PureComponent {
4141
this.setState({now: moment.tz(CENTRAL_TZ)})
4242
}
4343

44+
reportProblem = () => {
45+
this.props.navigation.navigate('BuildingHoursProblemReportView', {
46+
initialBuilding: this.props.navigation.state.params.building,
47+
})
48+
}
49+
4450
render() {
4551
const info = this.props.navigation.state.params.building
4652
const {now} = this.state

source/views/building-hours/detail/schedule-table.ios.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ export class ScheduleTable extends React.PureComponent {
2323

2424
return (
2525
<TableView>
26+
<Section>
27+
<Cell
28+
accessory="DisclosureIndicator"
29+
title="Suggest an Edit"
30+
onPress={onProblemReport}
31+
/>
32+
</Section>
33+
2634
{schedules.map(set =>
2735
<Section
2836
key={set.title}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/**
2+
* @flow
3+
*
4+
* Building Hours "report a problem" screen.
5+
*/
6+
7+
import React from 'react'
8+
import {ScrollView, Text, StyleSheet} from 'react-native'
9+
import {TableView, Section, Cell} from 'react-native-tableview-simple'
10+
import type {BuildingType, NamedBuildingScheduleType} from '../types'
11+
import type {TopLevelViewPropsType} from '../../types'
12+
13+
export class BuildingHoursProblemReportView extends React.PureComponent {
14+
static navigationOptions = {
15+
title: 'Report a Problem',
16+
}
17+
18+
state: {
19+
building: BuildingType,
20+
} = {
21+
building: this.props.navigation.state.params.initialBuilding,
22+
}
23+
24+
props: TopLevelViewPropsType & {
25+
navigation: {state: {params: {initialBuilding: BuildingType}}},
26+
}
27+
28+
onChangeSchedule = (index: number, newSchedule: NamedBuildingScheduleType) => {
29+
this.setState(state => {
30+
const schedule = [...state.building.schedule]
31+
schedule.splice(index, 1, newSchedule)
32+
return {building: {...state.building, schedule}}
33+
})
34+
}
35+
36+
render() {
37+
console.log(this.state.building)
38+
39+
return (
40+
<ScrollView>
41+
<Text>
42+
Thanks for spotting a problem! If you could tell us what the new times
43+
are, we'd greatly appreciate it.
44+
</Text>
45+
46+
<TableView>
47+
{this.state.building.schedule}
48+
<EditableSchedule schedule={{}} />
49+
</TableView>
50+
</ScrollView>
51+
)
52+
}
53+
}
54+
55+
class EditableSchedule extends React.PureComponent {
56+
render() {
57+
return (
58+
<Section header="KITCHEN">
59+
60+
<TitleCell text="Kitchen" />
61+
62+
<TimesCell days="Mon-Thu" times="7:30AM — 8PM" />
63+
<TimesCell days="Friday" times="7:30AM — 8PM" />
64+
<TimesCell days="Saturday" times="9AM — 8PM" />
65+
<TimesCell days="Sunday" times="9AM — 8PM" />
66+
67+
<AddScheduleCell />
68+
69+
<NotesCell text="The kitchen stops cooking at 8 p.m." />
70+
</Section>
71+
)
72+
}
73+
}
74+
75+
// "Title" will become a textfield like the login form
76+
const TitleCell = ({text, onChange}) =>
77+
<Cell title="Title" cellStyle="RightDetail" detail={text} />
78+
79+
// "Notes" will become a big textarea
80+
const NotesCell = ({text, onChange}) =>
81+
<Cell title="Notes" cellStyle="Subtitle" detail={text} />
82+
83+
const AddScheduleCell = () =>
84+
<Cell title="Add Schedule" accessory="DisclosureIndicator" />
85+
86+
const TimesCell = ({days, times, onPress}) =>
87+
<Cell
88+
title={days}
89+
accessory="Detail"
90+
cellStyle="RightDetail"
91+
detail={times}
92+
/>

0 commit comments

Comments
 (0)