import React, { useState } from 'react'; import { SafeAreaView, StyleSheet, ScrollView, View, Text, StatusBar, FlatList, TouchableOpacity, Image, Dimensions } from 'react-native'; import { Header, LearnMoreLinks, Colors, DebugInstructions, ReloadInstructions, } from 'react-native/Libraries/NewAppScreen'; import { NavigationContainer } from '@react-navigation/native' import { createStackNavigator } from '@react-navigation/stack' import styles from './styles/liststyles' import { url } from './resources/fetchInfo.json' import LinearGradient from 'react-native-linear-gradient'; import Ionicons from 'react-native-vector-icons/Ionicons'; import I18n from 'i18n-js'; const Stack = createStackNavigator(); {/*export const LunchInfo = ({route}) => { const item = route.params; return ( {item.text} {item.loc} ) }*/} function LunchEvent (props) { const item = props.item const [expand, setExpand] = useState(false); var time_array = item.time.split(':') if (time_array[0]>12) { var time = String(parseInt(time_array[0])-12) + ':' + String(time_array[1]) + ' PM' } else { var time = String(time_array[0])+':'+String(time_array[1]) + ' AM' } return( setExpand(!expand)}> {item.title} {expand?:} {expand? {I18n.t('lunch.information')} {item.text} {'\n'}{I18n.t('lunch.location')} {item.location} {'\n'}{I18n.t('lunch.time')} {time} :<>} ) } class LunchEvents extends React.Component { constructor(props) { super(props) this.state = { data: [] } } componentDidMount() { fetch(`${url}/api/`+String(I18n.locale).split('-')[0]+`/lunch_events`,{ headers: { 'Cache-Control': 'no-cache' } } ) .then((response) => { return response.text(); }) .then((json) => { const data = JSON.parse(json) data.sort((a,b)=>a.id-b.id) this.setState({data: data}); }) .catch((error) => console.error(error)) } render() { return ( } keyExtractor={item=>JSON.stringify(item)} /> ) } } export default LunchEvents;