|
| 1 | +// @flow |
| 2 | +import React from 'react' |
| 3 | +import {View, Platform, ScrollView, StyleSheet} from 'react-native' |
| 4 | +import type {TopLevelViewPropsType} from '../types' |
| 5 | +import type {CarletonDetailMenuType} from './types' |
| 6 | +import {Row} from '../components/layout' |
| 7 | +import {ListRow, ListSeparator, Title} from '../components/list' |
| 8 | +import {NoticeView} from '../components/notice' |
| 9 | + |
| 10 | +import {carleton} from './tabs' |
| 11 | + |
| 12 | +const styles = StyleSheet.create({ |
| 13 | + rowText: { |
| 14 | + paddingVertical: 6, |
| 15 | + }, |
| 16 | +}) |
| 17 | + |
| 18 | +export class CarletonMenuPicker extends React.Component { |
| 19 | + props: TopLevelViewPropsType; |
| 20 | + |
| 21 | + onPressRow = (data: CarletonDetailMenuType) => { |
| 22 | + let name = data.title |
| 23 | + let id = data.props.cafeId |
| 24 | + let message = data.props.loadingMessage |
| 25 | + |
| 26 | + this.props.navigator.push({ |
| 27 | + id: 'BonAppHostedMenu', |
| 28 | + title: name, |
| 29 | + backButtonTitle: 'Carleton', |
| 30 | + index: this.props.route.index + 1, |
| 31 | + props: { |
| 32 | + name: name, |
| 33 | + loadingMessage: message, |
| 34 | + cafeId: id, |
| 35 | + }, |
| 36 | + }) |
| 37 | + } |
| 38 | + |
| 39 | + render() { |
| 40 | + if (!carleton) { |
| 41 | + return <NoticeView text={'No Carleton Cafes to choose.'} /> |
| 42 | + } |
| 43 | + |
| 44 | + return ( |
| 45 | + <ScrollView style={{paddingTop: Platform.OS === 'ios' ? 20 : 0}}> |
| 46 | + {carleton.map((loc: CarletonDetailMenuType, i, collection) => |
| 47 | + <View key={`${i}`}> |
| 48 | + <ListRow |
| 49 | + onPress={() => this.onPressRow(loc)} |
| 50 | + arrowPosition='center'> |
| 51 | + <Row alignItems='center'> |
| 52 | + <Title style={styles.rowText}>{loc.title}</Title> |
| 53 | + </Row> |
| 54 | + </ListRow> |
| 55 | + {i < collection.length - 1 ? <ListSeparator spacing={{left: 15}} /> : null} |
| 56 | + </View> |
| 57 | + )} |
| 58 | + </ScrollView> |
| 59 | + ) |
| 60 | + } |
| 61 | +} |
0 commit comments