blazerapp/app/LunchEvents.js

114 lines
4.0 KiB
JavaScript
Raw Permalink Normal View History

2020-08-10 17:41:10 -04:00
import React, { useState } from 'react';
2020-08-09 20:16:52 -04:00
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
2020-08-10 17:41:10 -04:00
FlatList,
TouchableOpacity,
Image,
Dimensions
2020-08-09 20:16:52 -04:00
} 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'
2020-08-10 17:41:10 -04:00
import styles from './styles/liststyles'
import { url } from './resources/fetchInfo.json'
import LinearGradient from 'react-native-linear-gradient';
2021-08-01 02:10:38 -04:00
import Ionicons from 'react-native-vector-icons/Ionicons';
2021-08-17 21:18:32 -04:00
import I18n from 'i18n-js';
const Stack = createStackNavigator();
2020-08-10 17:41:10 -04:00
2021-08-17 21:18:32 -04:00
{/*export const LunchInfo = ({route}) => {
2020-10-25 02:57:39 -04:00
const item = route.params;
return (
2020-11-20 02:44:02 -05:00
<View style = {{padding: 10, backgroundColor: 'white', height: '100%'}}>
2020-12-24 02:34:47 -05:00
<View style={[styles.infoContainer, {flexDirection: 'row', alignItems: 'center'}]}>
<View style={{width: '15%', display: 'flex', justifyContent: 'center'}}>
<Image source={require('./assets/desc.png')} style={{height: 50, width: 50}}/>
</View>
<View style={{width: '85%'}}>
<Text style = {styles.title}>{item.text}</Text>
</View>
2020-10-25 02:57:39 -04:00
</View>
2020-12-24 02:34:47 -05:00
<View style={[styles.infoContainer, {flexDirection: 'row', alignItems: 'center'}]}>
<View style={{width: '15%', display: 'flex', justifyContent: 'center'}}>
<Image source={require('./assets/location.png')} style={{height: 50, width: 50}}/>
</View>
<View style={{width: '85%'}}>
<Text style={{fontSize:20}}>{item.loc}</Text>
</View>
2020-10-25 02:57:39 -04:00
</View>
</View>
)
2021-08-17 21:18:32 -04:00
}*/}
2020-10-25 02:57:39 -04:00
function LunchEvent (props) {
const item = props.item
const [expand, setExpand] = useState(false);
2020-10-25 02:57:39 -04:00
return(
<View>
<TouchableOpacity style={styles.listItem} onPress={()=>setExpand(!expand)}>
<View style={styles.container2}>
2021-08-01 02:10:38 -04:00
<Ionicons name="fast-food-outline" size={36} color={'#323232'} style={{marginRight: 15}} />
<View style = {styles.accordian}>
<Text style={styles.title}>{item.title}</Text>
{expand?<LinearGradient start={{x: 0, y: 0.25}} end={{x: .5, y: 1}} colors={['red', '#FF7373']} style={{borderRadius: 24, alignSelf: 'center'}}><Image source = {require('./assets/collapse.png')} style={{tintColor: 'white'}}/></LinearGradient>:<Image source = {require('./assets/expand.png')} style={{tintColor: '#b2b2b2', alignSelf: 'center'}}/>}
</View>
</View>
2021-08-17 21:18:32 -04:00
{expand?<View style={{marginLeft: 50}}><Text style={styles.accordianHeader}>{I18n.t('lunch.information')}</Text><Text style={styles.accordianText}>{item.text}</Text><Text style={styles.accordianHeader}>{'\n'}{I18n.t('lunch.location')}</Text><Text style={[styles.accordianText, {paddingBottom: '4%'}]}>{item.loc}</Text></View>:<></>}
2020-10-25 02:57:39 -04:00
</TouchableOpacity>
</View>
)
}
2020-08-09 20:16:52 -04:00
class LunchEvents extends React.Component {
2020-10-25 02:57:39 -04:00
constructor(props) {
super(props)
this.state = {
data: []
}
}
componentDidMount() {
fetch(`${url}/api/en/lunchEvents`,{
headers: {
'Cache-Control': 'no-cache'
}
}
)
.then((response) => {
return response.text();
})
.then((json) => {
this.setState({data: JSON.parse(json)});
})
.catch((error) => console.error(error))
}
render() {
return (
<ScrollView style={styles.moreDefault}>
2020-10-25 02:57:39 -04:00
<FlatList
data={this.state.data}
renderItem={({item}) => <LunchEvent item={item} name={this.props.title} navigation={this.props.navigation}/>}
keyExtractor={item=>JSON.stringify(item)}
/>
</ScrollView>
2020-10-25 02:57:39 -04:00
)
}
2020-08-09 20:16:52 -04:00
}
export default LunchEvents;
2020-10-25 02:57:39 -04:00