Added Challenge of the Week

This commit is contained in:
M10T 2020-08-14 11:57:45 -04:00
parent e663cc9a95
commit 6d31bf277f
3 changed files with 67 additions and 4 deletions

55
app/ChallengeWeek.js Normal file
View File

@ -0,0 +1,55 @@
import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
} from 'react-native';
import {
Header,
LearnMoreLinks,
Colors,
DebugInstructions,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
import { url } from './resources/fetchInfo.json'
class ChallengeWeek extends React.Component {
constructor(props) {
super(props)
this.state = {
isLoading: true
}
}
componentDidMount() {
fetch(`${url}/api/en/challenge`,{
headers: {
'Cache-Control': 'no-cache'
}}
).then((response) => {
return response.text();
}).then((json) => {
this.setState({data: JSON.parse(json),isLoading:false});
}).catch((error) => console.error(error))
}
render() {
if (this.state.isLoading) {
return <View/>
} else {
return (
<View style={{alignItems:'center',paddingTop:'5%',paddingLeft:'10%',paddingRight:'10%'}}>
<Text style={{fontSize:32,marginBottom:'10%',textAlign:'center'}}>{this.state.data.title}</Text>
<Text style={{textAlign:'center'}}>{this.state.data.text}</Text>
</View>
)
}
}
}
export default ChallengeWeek;

View File

@ -55,12 +55,9 @@ class Clubs extends React.Component {
'Cache-Control': 'no-cache' 'Cache-Control': 'no-cache'
} }) } })
.then((response) => { .then((response) => {
//console.log(response.text());
return response.text(); return response.text();
}) })
.then((json) => { .then((json) => {
//onsole.log("done bitch?")
//console.log(json);
this.setState({data: JSON.parse(json).clubs}); this.setState({data: JSON.parse(json).clubs});
this.setState({dataSearch:JSON.parse(json).clubs }); this.setState({dataSearch:JSON.parse(json).clubs });
}) })

View File

@ -27,6 +27,7 @@ import Resources from './Resources'
import StudentWeek from './StudentWeek' import StudentWeek from './StudentWeek'
import SSLOps from './SSLOps' import SSLOps from './SSLOps'
import LunchEvents from './LunchEvents' import LunchEvents from './LunchEvents'
import ChallengeWeek from './ChallengeWeek'
import { LinearGradient } from 'react-native-linear-gradient' import { LinearGradient } from 'react-native-linear-gradient'
const Stack = createStackNavigator() const Stack = createStackNavigator()
@ -46,7 +47,8 @@ class MoreSwitch extends React.Component {
{name:"Resources",key:"resources"}, {name:"Resources",key:"resources"},
{name:"Student of the Week",key:"studentweek"}, {name:"Student of the Week",key:"studentweek"},
{name:"Lunch Events",key:"lunchevent"}, {name:"Lunch Events",key:"lunchevent"},
{name:"SSL Opportunities",key:"sslops"} {name:"SSL Opportunities",key:"sslops"},
{name:"Challenge of the Week",key:"challengeweek"},
]} ]}
renderItem={({item})=> renderItem={({item})=>
<TouchableOpacity style={styles.moreitem} onPress={()=>this.props.navigation.navigate(item.key)}> <TouchableOpacity style={styles.moreitem} onPress={()=>this.props.navigation.navigate(item.key)}>
@ -118,6 +120,15 @@ class More extends React.Component {
headerLeft:null headerLeft:null
}} }}
/> />
<Stack.Screen
name="challengeweek"
component={ChallengeWeek}
options={{
title:'Challenge of the Week',
headerTitleStyle:[styles.headerTitle,{alignSelf:'center'}],
headerLeft:null
}}
/>
</Stack.Navigator> </Stack.Navigator>
</NavigationContainer> </NavigationContainer>
) )