Skip to content

Commit 2a81bdb

Browse files
committed
hook up a button at the bottom of the BusView to open the map
1 parent d0d4af6 commit 2a81bdb

File tree

4 files changed

+53
-12
lines changed

4 files changed

+53
-12
lines changed

source/navigation.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
BuildingHoursView,
1919
BuildingHoursDetailView,
2020
} from './views/building-hours'
21-
import TransportationView from './views/transportation'
21+
import TransportationView, {BusMapView} from './views/transportation'
2222
import SettingsView from './views/settings'
2323
import SISLoginView from './views/settings/login'
2424
import CreditsView from './views/settings/credits'
@@ -58,6 +58,7 @@ export const AppNavigator = StackNavigator(
5858
StudentOrgsDetailView: {screen: StudentOrgsDetailView},
5959
StudentOrgsView: {screen: StudentOrgsView},
6060
TransportationView: {screen: TransportationView},
61+
BusMapView: {screen: BusMapView},
6162
},
6263
{
6364
navigationOptions: {

source/views/transportation/bus/bus-line.js

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
// @flow
22
import React from 'react'
3-
import {View, StyleSheet, Platform} from 'react-native'
3+
import {View, Text, StyleSheet, Platform} from 'react-native'
44
import type {BusLineType, FancyBusTimeListType} from './types'
55
import {getScheduleForNow, getSetOfStopsForNow} from './lib'
66
import get from 'lodash/get'
77
import zip from 'lodash/zip'
88
import head from 'lodash/head'
99
import last from 'lodash/last'
10+
import Icon from 'react-native-vector-icons/Ionicons'
1011
import moment from 'moment-timezone'
1112
import * as c from '../../components/colors'
1213
import {Separator} from '../../components/separator'
1314
import {BusStopRow} from './bus-stop-row'
14-
import {ListRow, ListSectionHeader} from '../../components/list'
15+
import {ListRow, ListSectionHeader, Title, Detail} from '../../components/list'
16+
import {Row, Column} from '../../components/layout'
1517

1618
const TIME_FORMAT = 'h:mma'
1719
const TIMEZONE = 'America/Winnipeg'
@@ -65,7 +67,7 @@ const parseTime = (now: moment) => time => {
6567
}
6668

6769
export class BusLine extends React.PureComponent {
68-
props: {line: BusLineType, now: moment}
70+
props: {line: BusLineType, now: moment, openMap: () => any}
6971

7072
render() {
7173
const {line, now} = this.props
@@ -121,11 +123,39 @@ export class BusLine extends React.PureComponent {
121123
isFirstRow={i === 0}
122124
isLastRow={i === list.length - 1}
123125
/>
124-
{i < list.length - 1
125-
? <Separator style={styles.separator} />
126-
: null}
126+
<Separator style={styles.separator} />
127127
</View>,
128128
)}
129+
130+
<ListRow
131+
onPress={this.props.openMap}
132+
fullWidth={true}
133+
spacing={{left: 45}}
134+
>
135+
<Row alignItems="center">
136+
<Column alignItems="center" width={45} paddingRight={5}>
137+
<Icon
138+
name={
139+
Platform.OS === 'ios'
140+
? 'ios-navigate-outline'
141+
: 'md-navigate'
142+
}
143+
size={24}
144+
style={{color: c.iosDisabledText}}
145+
/>
146+
</Column>
147+
148+
<Column>
149+
<Title>
150+
<Text>Open Map</Text>
151+
</Title>
152+
153+
<Detail>
154+
<Text>See the planned bus route on a map!</Text>
155+
</Detail>
156+
</Column>
157+
</Row>
158+
</ListRow>
129159
</View>
130160
)
131161
}

source/views/transportation/bus/bus-view.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type {BusLineType} from './types'
66
import {BusLine} from './bus-line'
77
import moment from 'moment-timezone'
88
import {NoticeView} from '../../components/notice'
9+
import type {TopLevelViewPropsType} from '../../types'
910

1011
import {data as defaultBusLines} from '../../../../docs/bus-times.json'
1112

@@ -31,7 +32,7 @@ export class BusView extends React.PureComponent {
3132
clearTimeout(this.state.intervalId)
3233
}
3334

34-
props: {
35+
props: TopLevelViewPropsType & {
3536
busLines: BusLineType[],
3637
line: string,
3738
}
@@ -40,6 +41,10 @@ export class BusView extends React.PureComponent {
4041
this.setState(() => ({now: moment.tz(TIMEZONE)}))
4142
}
4243

44+
openMap = () => {
45+
this.props.navigation.navigate('BusMapView', {line: this.props.line})
46+
}
47+
4348
render() {
4449
let {now} = this.state
4550
// now = moment.tz('Fri 8:13pm', 'ddd h:mma', true, TIMEZONE)
@@ -56,7 +61,7 @@ export class BusView extends React.PureComponent {
5661

5762
return (
5863
<ScrollView>
59-
<BusLine line={activeBusLine} now={now} />
64+
<BusLine line={activeBusLine} now={now} openMap={this.openMap} />
6065
</ScrollView>
6166
)
6267
}

source/views/transportation/index.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,31 @@ import {TabBarIcon} from '../components/tabbar-icon'
1212
import OtherModesView from './otherModes'
1313
import BusView from './bus'
1414

15+
export {BusMapView} from './bus/map'
16+
1517
export default TabNavigator(
1618
{
1719
ExpressLineBusView: {
18-
screen: () => <BusView line="Express Bus" />,
20+
screen: ({navigation}) =>
21+
<BusView line="Express Bus" navigation={navigation} />,
1922
navigationOptions: {
2023
tabBarLabel: 'Express Bus',
2124
tabBarIcon: TabBarIcon('bus'),
2225
},
2326
},
2427

2528
RedLineBusView: {
26-
screen: () => <BusView line="Red Line" />,
29+
screen: ({navigation}) =>
30+
<BusView line="Red Line" navigation={navigation} />,
2731
navigationOptions: {
2832
tabBarLabel: 'Red Line',
2933
tabBarIcon: TabBarIcon('bus'),
3034
},
3135
},
3236

3337
BlueLineBusView: {
34-
screen: () => <BusView line="Blue Line" />,
38+
screen: ({navigation}) =>
39+
<BusView line="Blue Line" navigation={navigation} />,
3540
navigationOptions: {
3641
tabBarLabel: 'Blue Line',
3742
tabBarIcon: TabBarIcon('bus'),

0 commit comments

Comments
 (0)