Guest User

Untitled

a guest
Jan 24th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. import React from 'react';
  2. import { View, ScrollView, Platform, Dimensions, StyleSheet } from 'react-native';
  3. import { Icon } from 'react-native-elements';
  4. import { Toolbar, ThemeContext, getTheme } from 'react-native-material-ui';
  5. import Pdf from 'react-native-pdf';
  6.  
  7.  
  8. export class StreckenScreen extends React.Component {
  9.  
  10. constructor (props) {
  11. super(props);
  12. this.state = { troll : 'Marathon'};
  13. }
  14. static navigationOptions = {
  15. drawerLabel: 'Strecke',
  16. drawerIcon: ({ tintColor }) => (
  17. <Icon name={'place'} color={tintColor} />
  18. ),
  19. };
  20.  
  21.  
  22.  
  23. // states
  24.  
  25. render() {
  26. const sourcemar = require('./Infos/Strecke_mar_fix.pdf');
  27. const sourceteam = require('./Infos/Strecke_team_fix.pdf');
  28. const sourcecity = require('./Infos/Strecke_10k_fix.pdf');
  29.  
  30. let sourceSite = sourcemar;
  31. if (this.state.troll == 'Teamrun') {
  32. sourceSite = sourceteam;
  33. } else if (this.state.troll == 'Cityrun') {
  34. sourceSite = sourcecity;
  35. } else {
  36. sourceSite = sourcemar;
  37. }
  38.  
  39. return (
  40. <ThemeContext.Provider value={getTheme(brotheme)}>
  41. <View style={{ flexDirection: 'column', flex: 1 }}>
  42.  
  43. <Toolbar
  44. leftElement="menu"
  45. onLeftElementPress={() => this.props.navigation.openDrawer()}
  46. centerElement="Streckenplan"
  47. rightElement={{
  48. menu: {
  49. labels: ['Marathon', 'Teamrun', 'Cityrun']
  50. }
  51. }}
  52. onRightElementPress={(label) => {
  53. if (label.index == 0) {
  54. let that = this;
  55. (that) => that.setState({ troll : 'Marathon'})
  56. } else if (label.index == 1) {
  57. let that = this;
  58. (that) => that.setState({ troll : 'Teamrun'})
  59. } else if (label.index == 2) {
  60. let that = this;
  61. (that) => that.setState({ troll : 'Cityrun'})
  62. }
  63. }}
  64. />
  65. <Pdf
  66. source={sourceSite}
  67. onLoadComplete={(numberOfPages, filePath) => {
  68. console.log(`number of pages: ${numberOfPages}`);
  69. }}
  70. onPageChanged={(page, numberOfPages) => {
  71. console.log(`current page: ${page}`);
  72. }}
  73. onError={(error) => {
  74. console.log(error);
  75. }}
  76. style={styles.pdf}
  77. />
  78. </View>
  79.  
  80. </ThemeContext.Provider >
  81. );
  82. }
  83. }
  84.  
  85.  
  86. const styles = StyleSheet.create({
  87. container: {
  88. flex: 1,
  89. justifyContent: 'flex-start',
  90. alignItems: 'center',
  91. marginTop: 25,
  92. },
  93. pdf: {
  94. flex: 1,
  95. width: Dimensions.get('window').width,
  96. zIndex: 1,
  97. paddingTop: 30
  98. },
  99. head: {
  100. flex: 1,
  101. }
  102. });
  103.  
  104. const brotheme = {
  105. palette: {
  106. primaryColor: '#1B88EA',
  107. },
  108. }
Add Comment
Please, Sign In to add comment