mirror of
https://github.com/Blair-SGA-Dev-Team/blazerapp.git
synced 2024-11-21 20:41:16 -05:00
Added announcements page
This commit is contained in:
parent
93f0bc8ad9
commit
4b14f130cc
|
@ -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>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user