Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. // screens/ViewNews.js
  2. import React, { Component } from 'react';
  3. import {
  4. StyleSheet,
  5. SafeAreaView,
  6. ScrollView,
  7. Dimensions,
  8. } from 'react-native';
  9.  
  10. import {
  11. Tile,
  12. Title,
  13. Screen,
  14. Divider,
  15. View,
  16. Overlay
  17. } from '@shoutem/ui';
  18.  
  19. import {Actions} from 'react-native-router-flux';
  20. import HTML from 'react-native-render-html';
  21.  
  22. export default class ViewNews extends Component<{}> {
  23.  
  24. home(){
  25. Actions.reset('home');
  26. Actions.home();
  27. }
  28.  
  29. constructor(props) {
  30. super(props);
  31. this.state = {
  32. newspost: [],
  33. }
  34. }
  35. render() {
  36. const news = this.state.newspost;
  37. const regex = /[!@#$%^&*<>0-9;]/g;
  38. console.log("newspost: "+this.props.newspost);
  39. return (
  40. <SafeAreaView style={styles.safeArea}>
  41. <Screen style={{ flex: 1 }}>
  42. <ScrollView>
  43. {
  44. <View>
  45. <Tile>
  46. <Overlay styleName="image-overlay">
  47. <Title style={{color: '#fff', fontWeight: '800'}} styleName="md-gutter-bottom">{this.props.newspost.postTitle.replace(regex, "").toUpperCase()}</Title>
  48. </Overlay>
  49. </Tile>
  50. <Screen style={{paddingLeft: 15, paddingRight: 15, paddingTop: 15, paddingBottom: 15, width:375}} styleName="paper">
  51. <HTML
  52. tagsStyles={{
  53. body: {fontSize: 20},
  54. p: {fontSize: 20, fontWeight: "normal"},
  55. strong: {fontSize: 20,},
  56. blockquote: {fontSize: 20},
  57. a: {fontSize: 20, color: "#000"},
  58. em: {fontSize: 20,},
  59. img: {height: 250, width: 350},
  60. }}
  61. styleName="paper md-gutter multiline"
  62. html={this.props.newspost.postContent}
  63. imagesMaxWidth={Dimensions.get('window').width}
  64. ignoredStyles={['width', 'height', 'video']}
  65. onLinkPress={(evt, href) => this.onLinkPress(href)}
  66. />
  67. <Divider styleName="line" />
  68. </Screen>
  69. </View>
  70. }
  71. </ScrollView>
  72. </Screen>
  73.  
  74. </SafeAreaView>
  75. );
  76. }
  77. };
  78.  
  79. const styles = StyleSheet.create({
  80. container: {
  81. flex: 1, // 1:1
  82. flexDirection: 'column',
  83. backgroundColor: '#fff'
  84. },
  85. safeArea: {
  86. flex: 1,
  87. backgroundColor: '#fff'
  88. },
  89. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement