From 4b14f130ccf8b80e21976aa55ca921f8827d1534 Mon Sep 17 00:00:00 2001 From: M10T Date: Tue, 11 Aug 2020 12:35:10 -0400 Subject: [PATCH] Added announcements page --- app/Announcements.js | 43 +++++++++++++++++++++++++++++++++++++++++-- app/LunchEvents.js | 3 --- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/app/Announcements.js b/app/Announcements.js index a0e8223..6d63080 100644 --- a/app/Announcements.js +++ b/app/Announcements.js @@ -6,6 +6,7 @@ import { View, Text, StatusBar, + FlatList, } from 'react-native'; import { @@ -16,11 +17,49 @@ import { ReloadInstructions, } from 'react-native/Libraries/NewAppScreen'; +import styles from './styles/liststyles' + +const Announcement = ({item}) => { + return ( + + {item.item.message} + + ) +} + class Announcements extends React.Component { + + constructor(props) { + super(props) + this.state = { + data: [] + } + } + + componentDidMount() { + fetch('https://6dc2642ae9b3.ngrok.io/api/en/announcements',{ + headers: { + 'Cache-Control': 'no-cache' + } + } + ) + .then((response) => { + return response.text(); + }) + .then((json) => { + this.setState({data: JSON.parse(json).data}); + }) + .catch((error) => console.error(error)) + } + render() { return ( - - + + } + keyExtractor={item=>JSON.stringify(item)} + /> ) } diff --git a/app/LunchEvents.js b/app/LunchEvents.js index 2d7234e..2134fc8 100644 --- a/app/LunchEvents.js +++ b/app/LunchEvents.js @@ -56,9 +56,6 @@ class LunchEvents extends React.Component { this.setState({data: JSON.parse(json)}); }) .catch((error) => console.error(error)) - .finally(() => { - this.setState({ isLoading: false }); - }); } render() {