From a943e2eb4b9b357f7f74f56845dfa4765d741f92 Mon Sep 17 00:00:00 2001 From: M10T Date: Mon, 10 Aug 2020 17:41:10 -0400 Subject: [PATCH] Added Lunch Events interface --- app/Clubs.js | 17 ++----------- app/LunchEvents.js | 54 +++++++++++++++++++++++++++++++++++++--- app/styles/liststyles.js | 19 ++++++++++++++ 3 files changed, 72 insertions(+), 18 deletions(-) create mode 100644 app/styles/liststyles.js diff --git a/app/Clubs.js b/app/Clubs.js index be69279..7cdce18 100644 --- a/app/Clubs.js +++ b/app/Clubs.js @@ -19,6 +19,7 @@ import { ReloadInstructions, } from 'react-native/Libraries/NewAppScreen'; import { SearchBar } from 'react-native-elements'; +import styles from './styles/liststyles' const ClubElement = ({item}) => { const [visible, setVisible] = useState(0) @@ -101,19 +102,5 @@ class Clubs extends React.Component { ); } } -const styles = StyleSheet.create({ - container: { - flex: 1, - marginTop: StatusBar.currentHeight || 0, - }, - item: { - backgroundColor: '#bababa', - padding: 20, - marginVertical: 8, - marginHorizontal: 16, - }, - title: { - fontSize: 32, - }, -}); + export default Clubs; \ No newline at end of file diff --git a/app/LunchEvents.js b/app/LunchEvents.js index 378ff5f..f46d3c0 100644 --- a/app/LunchEvents.js +++ b/app/LunchEvents.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useState } from 'react'; import { SafeAreaView, StyleSheet, @@ -6,6 +6,8 @@ import { View, Text, StatusBar, + FlatList, + TouchableOpacity, } from 'react-native'; import { @@ -16,11 +18,57 @@ import { ReloadInstructions, } from 'react-native/Libraries/NewAppScreen'; +import styles from './styles/liststyles' + +const LunchEvent = ({item}) => { + const [visible, setVisible] = useState(0) + const extra = visible?({'\n'}{item.item.text}{'\n\n'}Location: {item.item.loc}):(<>); + return( + + setVisible(!visible)}> + {item.item.title} + {extra} + + + ) +} + class LunchEvents extends React.Component { + + constructor(props) { + super(props) + this.state = { + data: [] + } + } + + componentDidMount() { + fetch('https://6dc2642ae9b3.ngrok.io/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)) + .finally(() => { + this.setState({ isLoading: false }); + }); + } + render() { return ( - - + + } + keyExtractor={item=>JSON.stringify(item)} + /> ) } diff --git a/app/styles/liststyles.js b/app/styles/liststyles.js new file mode 100644 index 0000000..a785e82 --- /dev/null +++ b/app/styles/liststyles.js @@ -0,0 +1,19 @@ +import {StyleSheet, StatusBar} from 'react-native'; + +const styles = StyleSheet.create({ + container: { + flex: 1, + marginTop: StatusBar.currentHeight || 0, + }, + item: { + backgroundColor: '#bababa', + padding: 20, + marginVertical: 8, + marginHorizontal: 16, + }, + title: { + fontSize: 32, + }, +}); + +export default styles; \ No newline at end of file