<commit_before>import React from 'react';
import {
	View,
	Text,
	TouchableHighlight,
	ScrollView,
	Image,
	ListView,
} from 'react-native';

import Icon from 'react-native-vector-icons/Ionicons';
import { Actions } from 'react-native-router-flux';

const css = require('../../styles/css');
const logger = require('../../util/logger');
const general = require('../../util/general');

const menuDataSource = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 });

class DiningDetail extends React.Component {
	constructor(props) {
		super(props);
		this.state = {
			filters: [],
			activeMeal: 'Breakfast',
		};
	}

	componentDidMount() {
		logger.ga('View Mounted: Dining Detail');
	}

	addFilter = (filter) => {
		if (filter === 'Breakfast' || filter === 'Lunch' || filter === 'Dinner') {
			this.setState({
				activeMeal: filter
			});
		} else {
			if (this.state.filters.indexOf(filter) < 0) {
				// Add filter
				this.setState({
					filters: [...this.state.filters, filter]
				});
			} else {
				// Remove filter
				const temp = [...this.state.filters];
				temp.splice(temp.indexOf(filter), 1);
				this.setState({
					filters: temp
				});
			}
		}
	}

	render() {
		const { data } = this.props;

		return (
			<View style={[css.main_container, css.whitebg]}>
				<ScrollView contentContainerStyle={[css.scroll_main, css.whitebg]}>
					<DiningDescription
						name={data.name}
						description={data.description}
						regularHours={data.regularHours}
						specialHours={data.specialHours}
					/>
					<DiningImages
						images={data.images}
					/>
					<DiningDirections
						latitude={data.coords.lat}
						longitude={data.coords.lon}
						distance={data.distanceMilesStr}
					/>
					<DiningMenu
						data={data}
						filters={this.state.filters}
						activeMeal={this.state.activeMeal}
						addFilter={(filter) => this.addFilter(filter)}
					/>
				</ScrollView>
			</View>
		);
	}
}

export default DiningDetail;

/*
	Presentational Components, should probably be moved out of this file
*/
const DiningDescription = ({ name, description, regularHours, specialHours }) => (
	<View style={css.dl_market_name}>
		<Text style={css.dl_market_name_text}>{name}</Text>
		{description ? (
			<Text style={css.dl_market_desc_text}>{description}</Text>
		) : null }
		{regularHours ? (
			<Text style={css.dl_market_desc_text}>{regularHours}</Text>
		) : null }
		{specialHours ? (
			<Text style={css.dl_market_desc_text}>Special Hours:{'\n'}{specialHours}</Text>
		) : null }
	</View>
);

const DiningImages = ({ images }) => (
	<View>
		{(images) ? (
			<ScrollView
				style={css.dl_market_scroller}
				directionalLockEnabled={false}
				horizontal={true}
			>
				{images.map((object, i) => (
					<Image
						key={i}
						style={css.dl_market_scroller_image}
						resizeMode={'cover'}
						source={{ uri: object }}
					/>
				))}
			</ScrollView>
		) : null }
	</View>
);

const DiningDirections = ({ latitude, longitude, distance }) => (
	<View>
		{latitude !== 0 && longitude !== 0 ? (
			<View style={css.dl_market_directions}>
				<Text style={css.dl_dir_label}>Directions</Text>
				<TouchableHighlight
					style={css.dl_dir_traveltype_container}
					underlayColor={'rgba(200,200,200,.1)'}
					onPress={() => general.gotoNavigationApp('walk', latitude, longitude)}
				>
					<View style={css.dl_dir_traveltype_container}>
						<Icon name="md-walk" size={32} color="#182B49" />
						{distance ? (
							<Text style={css.dl_dir_eta}>{distance}</Text>
						) : null }
					</View>
				</TouchableHighlight>
			</View>
		) : null }
	</View>
);

const DiningMenu = ({ data, filters, addFilter, activeMeal }) => (
	<View>
		{(!data.menuItems && data.menuWebsite) ? (
			<TouchableHighlight underlayColor={'rgba(200,200,200,.1)'} onPress={() => general.openURL(data.menuWebsite)}>
				<View style={css.dd_menu_container}>
					{data.name.indexOf('Market') >= 0 ? (
						<Text style={css.dd_menu_text}>View To Go Menu</Text>
					) : (
						<Text style={css.dd_menu_text}>View Menu</Text>
					)}
				</View>
			</TouchableHighlight>
		) : (
			<View>
				<MenuFilters
					filters={filters}
					addFilter={addFilter}
					activeMeal={activeMeal}
				/>
				<MenuList
					filters={filters}
					data={data}
					activeMeal={activeMeal}
				/>
			</View>
		)}
	</View>
);

const DiningMenuHeader = () => (
	<View style={css.dl_market_date}>
		<Text style={css.dl_market_date_label}>
			Menu for {general.getTimestamp('mmmm d, yyyy')}<commit_msg>Pass menuItems to MenuList<commit_after>import React from 'react';
import {
	View,
	Text,
	TouchableHighlight,
	ScrollView,
	Image,
	ListView,
} from 'react-native';

import Icon from 'react-native-vector-icons/Ionicons';
import { Actions } from 'react-native-router-flux';

const css = require('../../styles/css');
const logger = require('../../util/logger');
const general = require('../../util/general');

const menuDataSource = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 });

class DiningDetail extends React.Component {
	constructor(props) {
		super(props);
		this.state = {
			filters: [],
			activeMeal: 'Breakfast',
		};
	}

	componentDidMount() {
		logger.ga('View Mounted: Dining Detail');
	}

	addFilter = (filter) => {
		if (filter === 'Breakfast' || filter === 'Lunch' || filter === 'Dinner') {
			this.setState({
				activeMeal: filter
			});
		} else {
			if (this.state.filters.indexOf(filter) < 0) {
				// Add filter
				this.setState({
					filters: [...this.state.filters, filter]
				});
			} else {
				// Remove filter
				const temp = [...this.state.filters];
				temp.splice(temp.indexOf(filter), 1);
				this.setState({
					filters: temp
				});
			}
		}
	}

	render() {
		const { data } = this.props;

		return (
			<View style={[css.main_container, css.whitebg]}>
				<ScrollView contentContainerStyle={[css.scroll_main, css.whitebg]}>
					<DiningDescription
						name={data.name}
						description={data.description}
						regularHours={data.regularHours}
						specialHours={data.specialHours}
					/>
					<DiningImages
						images={data.images}
					/>
					<DiningDirections
						latitude={data.coords.lat}
						longitude={data.coords.lon}
						distance={data.distanceMilesStr}
					/>
					<DiningMenu
						data={data}
						filters={this.state.filters}
						activeMeal={this.state.activeMeal}
						addFilter={(filter) => this.addFilter(filter)}
					/>
				</ScrollView>
			</View>
		);
	}
}

export default DiningDetail;

/*
	Presentational Components, should probably be moved out of this file
*/
const DiningDescription = ({ name, description, regularHours, specialHours }) => (
	<View style={css.dl_market_name}>
		<Text style={css.dl_market_name_text}>{name}</Text>
		{description ? (
			<Text style={css.dl_market_desc_text}>{description}</Text>
		) : null }
		{regularHours ? (
			<Text style={css.dl_market_desc_text}>{regularHours}</Text>
		) : null }
		{specialHours ? (
			<Text style={css.dl_market_desc_text}>Special Hours:{'\n'}{specialHours}</Text>
		) : null }
	</View>
);

const DiningImages = ({ images }) => (
	<View>
		{(images) ? (
			<ScrollView
				style={css.dl_market_scroller}
				directionalLockEnabled={false}
				horizontal={true}
			>
				{images.map((object, i) => (
					<Image
						key={i}
						style={css.dl_market_scroller_image}
						resizeMode={'cover'}
						source={{ uri: object }}
					/>
				))}
			</ScrollView>
		) : null }
	</View>
);

const DiningDirections = ({ latitude, longitude, distance }) => (
	<View>
		{latitude !== 0 && longitude !== 0 ? (
			<View style={css.dl_market_directions}>
				<Text style={css.dl_dir_label}>Directions</Text>
				<TouchableHighlight
					style={css.dl_dir_traveltype_container}
					underlayColor={'rgba(200,200,200,.1)'}
					onPress={() => general.gotoNavigationApp('walk', latitude, longitude)}
				>
					<View style={css.dl_dir_traveltype_container}>
						<Icon name="md-walk" size={32} color="#182B49" />
						{distance ? (
							<Text style={css.dl_dir_eta}>{distance}</Text>
						) : null }
					</View>
				</TouchableHighlight>
			</View>
		) : null }
	</View>
);

const DiningMenu = ({ data, filters, addFilter, activeMeal }) => (
	<View>
		{(!data.menuItems && data.menuWebsite) ? (
			<TouchableHighlight underlayColor={'rgba(200,200,200,.1)'} onPress={() => general.openURL(data.menuWebsite)}>
				<View style={css.dd_menu_container}>
					{data.name.indexOf('Market') >= 0 ? (
						<Text style={css.dd_menu_text}>View To Go Menu</Text>
					) : (
						<Text style={css.dd_menu_text}>View Menu</Text>
					)}
				</View>
			</TouchableHighlight>
		) : (
			<View>
				<MenuFilters
					filters={filters}
					addFilter={addFilter}
					activeMeal={activeMeal}
				/>
				<MenuList
					filters={filters}
					data={data.menuItems}
					activeMeal={activeMeal}
				/>
			</View>
		)}
	</View>
);

const DiningMenuHeader = () => (
	<View style={css.dl_market_date}>
		<Text style={css.dl_market_date_label}>
			Menu for {general.getTimestamp('mmmm d, yyyy')}
{'fraction_non_alphanumeric': 0.1708559406488761, 'fraction_numerical': 0.007972539032222345, 'mean_word_length': 3.242367308595585, 'pattern_counts': {'":': 0, '<': 109, '<?xml version=': 0, '>': 131, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4490014', 'n_tokens_mistral': 3865, 'n_tokens_neox': 3070, 'n_words': 522}