diff --git a/app/App.js b/app/App.js index bd5316e..8b858a9 100644 --- a/app/App.js +++ b/app/App.js @@ -24,6 +24,7 @@ import Calendar from './Calendar' import Poll from './Poll' import Clubs from './Clubs' import More from './More' +import Staff from './Staff' const Tab = createBottomTabNavigator(); @@ -34,12 +35,13 @@ class App extends React.Component { - + + @@ -47,8 +49,4 @@ class App extends React.Component { } } -const styles = StyleSheet.create({ - -} -); export default App; diff --git a/app/Staff.js b/app/Staff.js new file mode 100644 index 0000000..79dbf8f --- /dev/null +++ b/app/Staff.js @@ -0,0 +1,78 @@ +import React, { useState } from 'react'; +import { + SafeAreaView, + StyleSheet, + ScrollView, + View, + Text, + StatusBar, + FlatList, + TouchableOpacity +} from 'react-native'; + +import { + Header, + LearnMoreLinks, + Colors, + DebugInstructions, + ReloadInstructions, +} from 'react-native/Libraries/NewAppScreen'; + +import { url } from './resources/fetchInfo.json' +import styles from './styles/liststyles' + +const TeacherElement = ({item}) => { + const [visible, setVisible] = useState(0) + const extra = [...item.item.emails.map(email=>(Email: {email}))] + return( + + setVisible(!visible)} activeOpacity={0.8}> + {item.item.name} + {visible?extra:<>} + + + ) +} + +class Staff extends React.Component { + + constructor(props) { + super(props) + this.state = { + isLoading: true + } + } + + componentDidMount() { + fetch(`${url}/api/en/teachers`,{ + headers: { + 'Cache-Control': 'no-cache' + } + } + ) + .then((response) => { + return response.text(); + }) + .then((json) => { + this.setState({data: JSON.parse(json).data}); + }) + .catch((error) => console.error(error)) + .finally(()=>this.setState({isLoading:false})) + } + + render() { + if(this.state.isLoading) return () + + return ( + + } + keyExtractor={(item,index)=>JSON.stringify(item)+index} + /> + + ) + } +} + +export default Staff; \ No newline at end of file