Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- import { Container, Footer, FooterTab, Button, Content, Text, CardItem, Right, Left, View} from 'native-base';
- import { Image, Dimensions, ScrollView, StyleSheet, Clipboard, Linking, Share } from 'react-native';
- import RBSheet from "react-native-raw-bottom-sheet";
- import LinkToOriginal from './LinkSumberDesc';
- import HTML from 'react-native-render-html';
- import GestureRecognizer from 'react-native-swipe-gestures';
- import { FloatingAction } from "react-native-floating-action";
- import Icon from 'react-native-vector-icons/SimpleLineIcons';
- import analytics from '@react-native-firebase/analytics';
- import moment from 'moment/min/moment-with-locales'
- moment.locale('id')
- const actions = [
- // {
- // text: "Baca Berita",
- // icon: <Icon type='SimpleLineIcons' name='volume-2' style={{color:'white'}}/>,
- // name: "bt_baca",
- // position: 1,
- // color:'rgba(58,61,65,1)'
- // },
- {
- text: "Buka Browser",
- icon: <Icon type='SimpleLineIcons' name='globe' style={{color:'white'}}/>,
- name: "bt_browse",
- position: 2,
- color:'#5BC97F',
- },
- {
- text: "Salin Link Sumber",
- icon: <Icon type='SimpleLineIcons' name='link' style={{color:'white'}}/>,
- name: "bt_salin",
- position: 3,
- color:'#5BC97F'
- },
- {
- text: "Kirim Link Sumber",
- icon: <Icon type='SimpleLineIcons' name='share-alt' style={{color:'white'}}/>,
- name: "bt_kirim",
- position: 4,
- color: '#5BC97F'
- }
- ];
- function Desc({ judul, ilustrasi, sumber, tgl, isi }){
- scrollToEnd = () => {
- this.scrollView.scrollToEnd();
- }
- let paragraf = (isi.split( ' ').length)
- return (
- <View style={darkStyles.container}>
- <Image source={{uri: ilustrasi }} style={darkStyles.img}/>
- <View style={darkStyles.viewJudul}>
- <Text style={darkStyles.judul}>{judul}</Text>
- </View>
- <View style={darkStyles.viewSumberTgl}>
- <Text style={darkStyles.sumberTgl}>{sumber}</Text>
- <Text style={darkStyles.sumberTgl}>{moment(tgl).utc().format('DD MMMM YYYY')}</Text>
- </View>
- <View style={darkStyles.viewHTML} accessible={true} accessibilityRole={'text'}>
- <ScrollView style={darkStyles.html} ref={(scrollView) => { this.scrollView = scrollView }}>
- <HTML
- html={`<body>${isi}<br><br>${'('+paragraf+' Kata)'}</body>`}
- imagesMaxWidth={Dimensions.get('window').width}
- ignoredTags={['script','div']}
- tagsStyles= {{ body: { color: 'white'},
- a: { color: 'white', textDecorationLine: 'none'}}}
- />
- </ScrollView>
- </View>
- </View>
- )
- }
- export default class DescScreen extends Component {
- componentDidMount(){
- const screen = "content"
- analytics().setCurrentScreen(screen, screen)
- }
- render() {
- const item = this.props.navigation.getParam('item');
- let jam = moment(item.tgl).fromNow();
- // jam = jam.replace('hours ago', 'j')
- return (
- <Container>
- <Content>
- <Desc judul={item.judul} ilustrasi={item.ilustrasi} link={item.link} tgl={item.tgl} isi={item.isi} sumber={item.sumber}/>
- </Content>
- <FloatingAction
- color={'#5BC97F'}
- actions={actions}
- onPressItem={name => {
- console.log(`selected button: ${name}`);
- if (name==='bt_baca') {
- analytics().logEvent('baca_berita')
- }
- if (name==='bt_browse') {
- analytics().logEvent('browse_link')
- Linking.openURL(item.link)
- }
- if (name==='bt_salin') {
- analytics().logEvent('salin_link')
- Clipboard.setString(item.link)
- }
- if (name==='bt_kirim') {
- analytics().logEvent('kirim_link')
- Share.share({message:item.link, title:item.judul, url:item.link})
- }
- }}
- />
- {/*
- <Footer style={styles.footer}>
- <FooterTab style={styles.footerTab}>
- <Button style={styles.buttonSumber}
- onPress={() => {this.RBSheet.open()}}
- >
- <Text style={styles.buttonTextSumber}>Sumber</Text>
- </Button>
- <RBSheet
- ref={ref => {
- this.RBSheet = ref;
- }}
- height={120}
- duration={250}
- customStyles={{
- container: {
- justifyContent: "center",
- alignItems: "center",
- backgroundColor: "grey",
- }
- }}
- >
- <LinkToOriginal link={item.link} />
- </RBSheet>
- <Button style={styles.buttonJam}
- >
- <Icon name="time" style={styles.iconJamImpresi} />
- <Text style={styles.textJam} >{jam}</Text>
- </Button>
- <Button style={styles.buttonImpresi}
- >
- <Icon name="eye" style={styles.iconJamImpresi}/>
- <Text style={styles.textImpresi} >{item.impresi}</Text>
- </Button>
- </FooterTab>
- </Footer>
- */}
- </Container>
- );
- }
- }
- const darkStyles = StyleSheet.create({
- container: {
- backgroundColor: '#2E3136'
- },
- img: {
- height: 220,
- width: null,
- flex: 1
- },
- viewJudul: {
- marginHorizontal: 10,
- marginTop: 10
- },
- judul: {
- fontWeight: 'bold',
- fontSize: 20,
- color: 'white'
- },
- viewSumberTgl: {
- flexDirection: 'row',
- justifyContent: 'space-between',
- marginHorizontal: 10,
- marginVertical: 15
- },
- viewHTML: {
- backgroundColor: '#2E3136'
- },
- sumberTgl: {
- fontSize: 12,
- color: 'white'
- },
- html: {
- flex: 1,
- marginHorizontal: 10,
- paddingBottom: 100,
- },
- footer: {
- height: 42
- },
- footerTab: {
- backgroundColor: '#F5F5F7',
- },
- buttonSumber: {
- flex: 1,
- backgroundColor: 'grey',
- height: 42
- },
- buttonTextSumber: {
- textAlign: 'center',
- color: 'white'
- },
- buttonJam: {
- flex: 1,
- flexDirection: 'row',
- height: 42,
- marginHorizontal: 10
- },
- iconJamImpresi: {
- color: 'grey',
- fontSize: 20
- },
- textJam: {
- color: 'grey',
- fontSize: 10,
- right: 20
- },
- buttonImpresi: {
- flex: 1,
- flexDirection: 'row',
- height: 42
- },
- textImpresi: {
- color: 'grey',
- fontSize: 12,
- right: 20
- }
- })
- const lightStyles = StyleSheet.create({
- img: {
- height: 220,
- width: null,
- flex: 1
- },
- viewJudul: {
- marginHorizontal: 10,
- marginTop: 10
- },
- judul: {
- fontWeight: 'bold',
- fontSize: 20
- },
- viewSumberTgl: {
- flexDirection: 'row',
- justifyContent: 'space-between',
- marginHorizontal: 10,
- marginVertical: 10
- },
- viewHTML: {
- backgroundColor: '#F6F6F6'
- },
- sumberTgl: {
- fontSize: 12
- },
- html: {
- flex: 1,
- marginHorizontal: 10,
- paddingBottom: 100
- },
- footer: {
- height: 42
- },
- footerTab: {
- backgroundColor: '#F5F5F7',
- },
- buttonSumber: {
- flex: 1,
- backgroundColor: 'grey',
- height: 42
- },
- buttonTextSumber: {
- textAlign: 'center',
- color: 'white'
- },
- buttonJam: {
- flex: 1,
- flexDirection: 'row',
- height: 42,
- marginHorizontal: 10
- },
- iconJamImpresi: {
- color: 'grey',
- fontSize: 20
- },
- textJam: {
- color: 'grey',
- fontSize: 10,
- right: 20
- },
- buttonImpresi: {
- flex: 1,
- flexDirection: 'row',
- height: 42
- },
- textImpresi: {
- color: 'grey',
- fontSize: 12,
- right: 20
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement