blazerapp/app/ChallengeWeek.js

115 lines
3.1 KiB
JavaScript
Raw Permalink Normal View History

2020-08-14 11:57:45 -04:00
import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
2020-10-25 02:57:39 -04:00
Linking,
2021-07-30 00:36:45 -04:00
Animated,
TouchableOpacity,
Image
2020-08-14 11:57:45 -04:00
} from 'react-native';
import {
Header,
LearnMoreLinks,
Colors,
DebugInstructions,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
2020-10-25 02:57:39 -04:00
import styles from './styles/liststyles';
2020-08-14 11:57:45 -04:00
import { url } from './resources/fetchInfo.json'
2021-08-17 21:18:32 -04:00
import I18n from 'i18n-js';
2020-08-14 11:57:45 -04:00
class ChallengeWeek extends React.Component {
constructor(props) {
super(props)
this.state = {
2021-07-30 00:36:45 -04:00
isLoading: true,
flip: true
2020-08-14 11:57:45 -04:00
}
}
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))
2021-07-30 00:36:45 -04:00
2021-08-17 21:18:32 -04:00
/*this.animatedValue=new Animated.Value(0);
2021-07-30 00:36:45 -04:00
this.value=0;
this.animatedValue.addListener(({value}) => {
this.value=value;
})
this.frontInterpolate = this.animatedValue.interpolate({
inputRange:[0,180],
outputRange:['0deg', '180deg'],
})
this.backInterpolate = this.animatedValue.interpolate({
inputRange:[0,180],
outputRange: ['180deg','360deg']
2021-08-17 21:18:32 -04:00
})*/
2021-07-30 00:36:45 -04:00
}
2021-08-17 21:18:32 -04:00
/*flipCard() {
2021-07-30 00:36:45 -04:00
if (this.value >= 90) {
Animated.spring(this.animatedValue, {
toValue:0,
friction:8,
tension: 10
}).start();
}
else {
Animated.spring(this.animatedValue, {
toValue:180,
friction: 8,
tension: 10
}).start();
}
this.setState({flip:!this.state.flip})
2021-08-17 21:18:32 -04:00
}*/
2020-08-14 11:57:45 -04:00
render() {
2021-08-17 21:18:32 -04:00
{/*const frontAnimatedStyle = {
2021-07-30 00:36:45 -04:00
transform: [
{rotateY:this.frontInterpolate}
]
}
const backAnimatedStyle = {
transform: [
{rotateY:this.backInterpolate}
]
}
var styling={}
var styling2={}
if (this.state.flip) {
styling=({height: '100%', width: '100%', backgroundColor: 'white', borderRadius: 20, textAlign: 'center', display: 'flex', alignContent: 'center', padding: '5%', paddingTop: '15%', borderColor: 'red', borderWidth: 1})
styling2=({display:'none'})
}
else {
styling=({display:'none'})
styling2=({height: '100%', width: '100%', backgroundColor: 'white', borderRadius: 20, textAlign: 'center', display: 'flex', alignContent: 'center', padding: '5%', paddingTop: '15%', borderColor: 'red', borderWidth: 1})
2021-08-17 21:18:32 -04:00
}*/}
2021-07-30 00:36:45 -04:00
2020-08-14 11:57:45 -04:00
if (this.state.isLoading) {
return <View/>
} else {
return (
2021-08-01 02:10:38 -04:00
<View style={{alignItems:'center',paddingiorizontal:'10%', height: '100%', backgroundColor: 'white', justifyContent: 'center', padding: '2%'}}>
<Text style={{fontSize: 32, fontWeight: 'bold', marginBottom: '10%', color: 'red', textAlign: 'center'}}>{this.state.data.title}</Text>
<Text style={{textAlign:'center', fontSize: 24, marginBottom: '5%', textAlign: 'center', fontWeight: '200'}}>{this.state.data.text}</Text>
2021-08-17 21:18:32 -04:00
<Text style={{textAlign:'center', fontSize: 20, textDecorationLine: 'underline', textDecorationStyle: "solid", textDecorationColor: "#000"}} onPress={() => Linking.openURL(this.state.data.link)}>{I18n.t("challenge.link")}</Text>
2020-08-14 11:57:45 -04:00
</View>
)
}
}
}
export default ChallengeWeek;