blazerapp/app/SSLOps.js

138 lines
4.5 KiB
JavaScript
Raw Permalink Normal View History

2020-08-22 20:01:15 -04:00
import React, { useState } from 'react';
2020-08-09 20:56:12 -04:00
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
2020-08-22 20:01:15 -04:00
FlatList,
TouchableOpacity,
Image,
Dimensions
2020-08-09 20:56:12 -04:00
} from 'react-native';
import {
Header,
LearnMoreLinks,
Colors,
DebugInstructions,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
import { NavigationContainer } from '@react-navigation/native'
import { createStackNavigator } from '@react-navigation/stack'
2020-08-22 20:01:15 -04:00
import styles from './styles/liststyles';
import { url } from './resources/fetchInfo.json';
import LinearGradient from 'react-native-linear-gradient';
2021-08-01 02:10:38 -04:00
import Ionicons from 'react-native-vector-icons/Ionicons';
2021-08-17 21:18:32 -04:00
import I18n from './i18n';
2020-08-22 20:01:15 -04:00
const Stack = createStackNavigator();
2021-08-17 21:18:32 -04:00
{/*export const SSLInfo = ({route}) => {
const item = route.params;
console
return (
2020-11-20 02:44:02 -05:00
<View style = {{padding: 10, backgroundColor: 'white', height: '100%'}}>
2020-12-24 02:34:47 -05:00
<View style={[styles.infoContainer, {flexDirection: 'row', alignItems: 'center'}]}>
<View style={{width: '15%', display: 'flex', justifyContent: 'center'}}>
<Image source={require('./assets/desc.png')} style={{height: 50, width: 50}}/>
</View>
<View style={{width: '85%'}}>
<Text style = {styles.title}>{item.text}</Text>
</View>
</View>
2020-12-24 02:34:47 -05:00
<View style={[styles.infoContainer, {flexDirection: 'row', alignItems: 'center'}]}>
<View style={{width: '15%', display: 'flex', justifyContent: 'center'}}>
<Image source={require('./assets/unknown.png')} style={{height: 50, width: 50}}/>
</View>
<View style={{width: '85%'}}>
<Text style = {styles.title}>{item.teacher}</Text>
</View>
</View>
2020-12-24 02:34:47 -05:00
<View style={[styles.infoContainer, {flexDirection: 'row', alignItems: 'center'}]}>
<View style={{width: '15%', display: 'flex', justifyContent: 'center'}}>
<Image source={require('./assets/location.png')} style={{height: 50, width: 50}}/>
</View>
<View style={{width: '85%'}}>
<Text style={{fontSize:20}}>{item.loc}</Text>
</View>
</View>
</View>
)
2021-08-17 21:18:32 -04:00
}*/}
function SSLElement (props) {
const item = props.item;
2021-09-12 18:19:34 -04:00
const date = item.item.date.split('-')
const [expand, setExpand] = useState(false);
return(
<View>
<TouchableOpacity style={styles.listItem} onPress={()=>setExpand(!expand)}>
<View style = {styles.container2}>
2021-08-01 02:10:38 -04:00
<Ionicons name="school-outline" size={36} color={'#323232'} style={{marginRight: 15}} />
<View style = {styles.accordian}>
2021-09-12 18:19:34 -04:00
<View style = {{display: 'flex', alignContent: 'center', width: '80%'}}>
<Text style={styles.title}>{item.item.title}</Text>
<View style={{paddingBottom: '2%'}}><Text style = {{fontSize: 12, fontWeight: '200'}}>{`${date[1]}/${date[2]}/${date[0]}`}</Text></View>
</View>
{expand?<LinearGradient start={{x: 0, y: 0.25}} end={{x: .5, y: 1}} colors={['red', '#FF7373']} style={{borderRadius: 24, alignSelf: 'center'}}><Image source = {require('./assets/collapse.png')} style={{tintColor: 'white'}}/></LinearGradient>:<Image source = {require('./assets/expand.png')} style={{tintColor: '#b2b2b2', alignSelf: 'center'}}/>}
</View>
</View>
2021-09-12 18:19:34 -04:00
{expand?
<View style={{marginLeft: 50}}>
<Text style={styles.accordianHeader}>{I18n.t('ssl.information')}</Text>
<Text style={styles.accordianText}>{item.item.text}</Text>
<Text style={styles.accordianHeader}>{'\n'}{I18n.t('ssl.sponsor')}</Text>
<Text style={styles.accordianText}>{item.item.teacher}</Text>
<Text style={styles.accordianHeader}>{'\n'}{I18n.t('ssl.location')}</Text>
<Text style={[styles.accordianText, {paddingBottom: '4%'}]}>{item.item.location}</Text>
</View>:<></>}
</TouchableOpacity>
</View>
2020-08-22 20:01:15 -04:00
)
}
2020-08-09 20:56:12 -04:00
class SSLOps extends React.Component {
2020-08-22 20:01:15 -04:00
constructor(props) {
super(props)
this.state = {
data: []
}
}
componentDidMount() {
2021-09-12 18:19:34 -04:00
fetch(`${url}/api/`+String(I18n.locale).split('-')[0]+`/ssl_ops`,{
2021-09-08 23:50:20 -04:00
//fetch(`${url}/api/en/sslOps`,{
2020-08-22 20:01:15 -04:00
headers: {
'Cache-Control': 'no-cache'
}
}
)
.then((response) => {
return response.text();
})
.then((json) => {
2021-09-12 15:08:49 -04:00
const data = JSON.parse(json)
data.sort((a,b)=>a.id-b.id)
2021-09-08 23:50:20 -04:00
this.setState({data: JSON.parse(json)});
2020-08-22 20:01:15 -04:00
})
.catch((error) => console.error(error))
}
2020-08-09 20:56:12 -04:00
render() {
return (
<ScrollView style={styles.moreDefault}>
2020-08-22 20:01:15 -04:00
<FlatList
data={this.state.data}
renderItem={item=><SSLElement item={item} name={item.title} navigation={this.props.navigation}/>}
2020-08-22 20:01:15 -04:00
keyExtractor={item=>JSON.stringify(item)}
/>
</ScrollView>
2020-08-09 20:56:12 -04:00
)
}
}
export default SSLOps;