Created
January 23, 2019 13:35
-
-
Save thomascuriger/aa7f8fd8658b27a1b0a08ed5bf591f20 to your computer and use it in GitHub Desktop.
capital
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { View, ScrollView, Platform, Dimensions, StyleSheet } from 'react-native'; | |
import { Icon } from 'react-native-elements'; | |
import { Toolbar, ThemeContext, getTheme } from 'react-native-material-ui'; | |
import Pdf from 'react-native-pdf'; | |
export class StreckenScreen extends React.Component { | |
static navigationOptions = { | |
drawerLabel: 'Strecke', | |
drawerIcon: ({ tintColor }) => ( | |
<Icon name={'place'} color={tintColor} /> | |
), | |
}; | |
constructor (props) { | |
super(props); | |
this.setState = { troll : 'Marathon'}; | |
} | |
// states | |
render() { | |
const sourcemar = require('./Infos/Strecke_mar_fix.pdf'); | |
const sourceteam = require('./Infos/Strecke_team_fix.pdf'); | |
const sourcecity = require('./Infos/Strecke_10k_fix.pdf'); | |
let sourceSite = sourcemar; | |
if (this.state == 'Teamrun') { | |
sourceSite = sourceteam; | |
} else if (this.state == 'Cityrun') { | |
sourceSite = sourcecity; | |
} else { | |
sourceSite = sourcemar; | |
} | |
return ( | |
<ThemeContext.Provider value={getTheme(brotheme)}> | |
<View style={{ flexDirection: 'column', flex: 1 }}> | |
<Toolbar | |
leftElement="menu" | |
onLeftElementPress={() => this.props.navigation.openDrawer()} | |
centerElement="Streckenplan" | |
rightElement={{ | |
menu: { | |
labels: ['Marathon', 'Teamrun', 'Cityrun'] | |
} | |
}} | |
onRightElementPress={(label) => { | |
if (label.index == 0) { | |
() => this.setState({ troll : 'Marathon'}) | |
} else if (label.index == 1) { | |
() => this.setState({ troll : 'Teamrun'}) | |
} else if (label.index == 2) { | |
() => this.setState({ troll : 'Cityrun'}) | |
} | |
}} | |
/> | |
source={sourceSite} | |
onLoadComplete={(numberOfPages, filePath) => { | |
console.log(`number of pages: ${numberOfPages}`); | |
}} | |
onPageChanged={(page, numberOfPages) => { | |
console.log(`current page: ${page}`); | |
}} | |
onError={(error) => { | |
console.log(error); | |
}} | |
style={styles.pdf} | |
/> | |
</View> | |
</ThemeContext.Provider > | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
justifyContent: 'flex-start', | |
alignItems: 'center', | |
marginTop: 25, | |
}, | |
pdf: { | |
flex: 1, | |
width: Dimensions.get('window').width, | |
zIndex: 1, | |
paddingTop: 30 | |
}, | |
head: { | |
flex: 1, | |
} | |
}); | |
const brotheme = { | |
palette: { | |
primaryColor: '#1B88EA', | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment