Added announcements page

This commit is contained in:
M10T 2020-08-11 12:35:10 -04:00
parent 93f0bc8ad9
commit 4b14f130cc
2 changed files with 41 additions and 5 deletions

View File

@ -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 (
<View style={styles.item}>
<Text style={styles.title}>{item.item.message}</Text>
</View>
)
}
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 (
<View>
<View style={styles.container}>
<FlatList
data={this.state.data}
renderItem={item=><Announcement item={item}/>}
keyExtractor={item=>JSON.stringify(item)}
/>
</View>
)
}

View File

@ -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() {