Fixed some issues for markdown

This commit is contained in:
Mustafa Buyukcelebi 2019-11-23 00:02:38 +03:00
parent e7222c8436
commit 7671c655f0
5 changed files with 57 additions and 22 deletions

View File

@ -19,10 +19,12 @@ import WalletDetailsPlaceHolder from './view/placeHolder/walletDetailsPlaceHolde
import WalletUnclaimedPlaceHolder from './view/placeHolder/walletUnclaimedPlaceHolder'; import WalletUnclaimedPlaceHolder from './view/placeHolder/walletUnclaimedPlaceHolder';
import ListPlaceHolder from './view/placeHolder/listPlaceHolderView'; import ListPlaceHolder from './view/placeHolder/listPlaceHolderView';
import BoostPlaceHolder from './view/placeHolder/boostPlaceHolderView'; import BoostPlaceHolder from './view/placeHolder/boostPlaceHolderView';
import CommentPlaceHolder from './view/placeHolder/commentPlaceHolderView';
export { export {
Card, Card,
Chip, Chip,
CommentPlaceHolder,
GrayWrapper, GrayWrapper,
LineBreak, LineBreak,
ListItemPlaceHolder, ListItemPlaceHolder,

View File

@ -0,0 +1,35 @@
import React from 'react';
import { View } from 'react-native';
import Placeholder from 'rn-placeholder';
import { ThemeContainer } from '../../../../containers';
import styles from './listItemPlaceHolderStyles';
const CommentPlaceHolderView = () => {
return (
<ThemeContainer>
{({ isDarkTheme }) => {
const color = isDarkTheme ? '#2e3d51' : '#f5f5f5';
return (
<View style={styles.container}>
<View style={styles.paragraphWithoutMargin}>
<Placeholder.Paragraph
color={color}
lineNumber={3}
textSize={12}
lineSpacing={8}
width="100%"
lastLineWidth="70%"
firstLineWidth="50%"
animate="fade"
/>
</View>
</View>
);
}}
</ThemeContainer>
);
};
export default CommentPlaceHolderView;

View File

@ -16,4 +16,7 @@ export default EStyleSheet.create({
marginTop: 3, marginTop: 3,
flex: 1, flex: 1,
}, },
paragraphWithoutMargin: {
flex: 1,
},
}); });

View File

@ -1,16 +1,16 @@
import React, {Fragment} from 'react'; import React, { Fragment } from 'react';
import {Dimensions, Linking, Alert} from 'react-native'; import { Dimensions, Linking, Alert } from 'react-native';
import {withNavigation} from 'react-navigation'; import { withNavigation } from 'react-navigation';
import {useIntl, injectIntl} from 'react-intl'; import { useIntl, injectIntl } from 'react-intl';
import AutoHeightWebView from 'react-native-autoheight-webview'; import AutoHeightWebView from 'react-native-autoheight-webview';
import EStyleSheet from 'react-native-extended-stylesheet'; import EStyleSheet from 'react-native-extended-stylesheet';
import get from 'lodash/get'; import get from 'lodash/get';
import script from './config.js'; import script from './config.js';
import {PostPlaceHolder, ListItemPlaceHolder} from '../../../basicUIElements'; import { PostPlaceHolder, CommentPlaceHolder } from '../../../basicUIElements';
// Constants // Constants
import {default as ROUTES} from '../../../../constants/routeNames'; import { default as ROUTES } from '../../../../constants/routeNames';
const WIDTH = Dimensions.get('window').width; const WIDTH = Dimensions.get('window').width;
@ -32,16 +32,7 @@ const PostBody = ({
try { try {
const data = JSON.parse(get(event, 'nativeEvent.data')); const data = JSON.parse(get(event, 'nativeEvent.data'));
const { const { type, href, author, category, permlink, tag, proposal, videoHref } = data;
type,
href,
author,
category,
permlink,
tag,
proposal,
videoHref,
} = data;
switch (type) { switch (type) {
case '_external': case '_external':
@ -95,7 +86,7 @@ const PostBody = ({
if (supported) { if (supported) {
Linking.openURL(url); Linking.openURL(url);
} else { } else {
Alert.alert(intl.formatMessage({id: 'alert.failed_to_open'})); Alert.alert(intl.formatMessage({ id: 'alert.failed_to_open' }));
} }
}); });
} }
@ -137,6 +128,8 @@ const PostBody = ({
} }
body { body {
color: ${EStyleSheet.value('$primaryBlack')}; color: ${EStyleSheet.value('$primaryBlack')};
display: flex;
align-items: center;
} }
a { a {
color: ${EStyleSheet.value('$primaryBlue')}; color: ${EStyleSheet.value('$primaryBlue')};
@ -218,14 +211,14 @@ const PostBody = ({
source={{ source={{
html: test, html: test,
}} }}
style={{width: WIDTH - 32}} style={{ width: isComment ? WIDTH - 61 : WIDTH - 32 }}
customStyle={customStyle} customStyle={customStyle}
onMessage={_handleOnLinkPress} onMessage={_handleOnLinkPress}
renderLoading={() =>
isComment ? <ListItemPlaceHolder /> : <PostPlaceHolder />
}
customScript={script.toString()} customScript={script.toString()}
renderLoading={() => (isComment ? <CommentPlaceHolder /> : <PostPlaceHolder />)}
startInLoadingState={true} startInLoadingState={true}
onShouldStartLoadWithRequest={false}
scrollEnabled={false}
/> />
</Fragment> </Fragment>
); );

View File

@ -162,7 +162,9 @@ class PostDisplayView extends PureComponent {
const isGetComment = scrollHeight + 300 > postHeight; const isGetComment = scrollHeight + 300 > postHeight;
const formatedTime = post && getTimeFromNow(post.created); const formatedTime = post && getTimeFromNow(post.created);
if (isGetComment && !isLoadedComments) this.setState({ isLoadedComments: true }); if (isGetComment && !isLoadedComments) {
this.setState({ isLoadedComments: true });
}
if (isPostUnavailable) { if (isPostUnavailable) {
return ( return (