Guest User

Untitled

a guest
Jan 24th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.22 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. // states
  22.  
  23. render() {
  24. const sourcemar = require('./Infos/Strecke_mar_fix.pdf');
  25. const sourceteam = require('./Infos/Strecke_team_fix.pdf');
  26. const sourcecity = require('./Infos/Strecke_10k_fix.pdf');
  27.  
  28. let sourceSite = sourcemar;
  29. if (this.state.troll == 'Teamrun') {
  30. sourceSite = sourceteam;
  31. } else if (this.state.troll == 'Cityrun') {
  32. sourceSite = sourcecity;
  33. } else {
  34. sourceSite = sourcemar;
  35. }
  36.  
  37. return (
  38. <ThemeContext.Provider value={getTheme(brotheme)}>
  39. <View style={{ flexDirection: 'column', flex: 1 }}>
  40.  
  41. <Toolbar
  42. leftElement="menu"
  43. onLeftElementPress={() => this.props.navigation.openDrawer()}
  44. centerElement="Streckenplan"
  45. rightElement={{
  46. menu: {
  47. labels: ['Marathon', 'Teamrun', 'Cityrun']
  48. }
  49. }}
  50. onRightElementPress={(label) => {
  51. if (label.index == 0) {
  52. this.setState({ troll : 'Marathon'});
  53. } else if (label.index == 1) {
  54. this.setState({ troll : 'Teamrun'});
  55. } else if (label.index == 2) {
  56. this.setState({ troll : 'Cityrun'})
  57. }
  58. }}
  59. />
  60. <Pdf
  61. source={sourceSite}
  62. onLoadComplete={(numberOfPages, filePath) => {
  63. console.log(`number of pages: ${numberOfPages}`);
  64. }}
  65. onPageChanged={(page, numberOfPages) => {
  66. console.log(`current page: ${page}`);
  67. }}
  68. onError={(error) => {
  69. console.log(error);
  70. }}
  71. style={styles.pdf}
  72. />
  73. </View>
  74.  
  75. </ThemeContext.Provider >
  76. );
  77. }
  78. }
  79.  
  80.  
  81. const styles = StyleSheet.create({
  82. container: {
  83. flex: 1,
  84. justifyContent: 'flex-start',
  85. alignItems: 'center',
  86. marginTop: 25,
  87. },
  88. pdf: {
  89. flex: 1,
  90. width: Dimensions.get('window').width,
  91. zIndex: 1,
  92. paddingTop: 30
  93. },
  94. head: {
  95. flex: 1,
  96. }
  97. });
  98.  
  99. const brotheme = {
  100. palette: {
  101. primaryColor: '#1B88EA',
  102. },
  103. }
Add Comment
Please, Sign In to add comment