Skip to content

Commit

Permalink
Improve message rendering (#739)
Browse files Browse the repository at this point in the history
  • Loading branch information
borisyankov committed Jun 25, 2017
1 parent f1b916c commit 8898fd8
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
4 changes: 0 additions & 4 deletions src/html/HtmlNodeTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ import HtmlTagPre from './tags/HtmlTagPre';
import HtmlTagStrong from './tags/HtmlTagStrong';
import HtmlTagItalic from './tags/HtmlTagItalic';
import HtmlTagDiv from './tags/HtmlTagDiv';
import HtmlTagBr from './tags/HtmlTagBr';
import { getEmojiUrl } from '../utils/url';

// br', 'blockquote',

const specialTags = {
'span': HtmlTagSpan,
'p': HtmlTagSpan,
Expand All @@ -41,7 +38,6 @@ const specialTags = {
'tr': HtmlTagDiv,
'th': HtmlTagDiv,
'td': HtmlTagDiv,
'br': HtmlTagBr,
};

const stylesFromClassNames = (classNames = '', styleObj) =>
Expand Down
2 changes: 1 addition & 1 deletion src/html/HtmlNodeText.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ type Props = {
export default ({ data, cascadingTextStyle }: Props) => (
<RawLabel
style={cascadingTextStyle}
text={entities.decodeHTML(data).replace(/\n$/, '')}
text={entities.decodeHTML(data).replace(/\n/, '')}
/>
);
10 changes: 7 additions & 3 deletions src/html/HtmlStyles.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@ import { StyleSheet } from 'react-native';

export default StyleSheet.create({
ul: {
width: '100%',
flexDirection: 'column',
paddingTop: 4,
paddingBottom: 4,
},
ol: {
flexDirection: 'column',
},
li: {
flexDirection: 'row',
marginBottom: 4,
},
div: {
flexWrap: 'wrap',
},
p: {
},
li: {
flexDirection: 'row',
marginBottom: 4,
br: {
width: '100%',
},
span: {
},
Expand Down
4 changes: 0 additions & 4 deletions src/html/tags/HtmlTagBr.js

This file was deleted.

9 changes: 6 additions & 3 deletions src/html/tags/HtmlTagLi.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ import renderHtmlChildren from '../renderHtmlChildren';
const BULLET = '\u2022';

const customStyles = StyleSheet.create({
liText: {
text: {
flexWrap: 'wrap',
flex: 1,
width: '100%',
flexDirection: 'row',
}
});

export default ({ style, ...restProps }) => (
<View style={style}>
<View style={[styles.li, style]}>
<HtmlNodeText style={styles.bullet} data={BULLET} />
<View style={customStyles.liText}>
<View style={customStyles.text}>
{renderHtmlChildren({ ...restProps })}
</View>
</View>
Expand Down
11 changes: 7 additions & 4 deletions src/message/MessageFull.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ const styles = StyleSheet.create({
flexDirection: 'column',
marginLeft: 8,
},
messageContentWrapper: {
contentWrapper: {
flexDirection: 'row',
alignItems: 'flex-start',
justifyContent: 'space-between'
justifyContent: 'space-between',
},
inner: {
flex: 1,
},
});

Expand Down Expand Up @@ -72,9 +75,9 @@ class MessageFull extends React.PureComponent {
timestamp={message.timestamp}
twentyFourHourTime={twentyFourHourTime}
/>
<View style={styles.messageContentWrapper}>
<View style={styles.contentWrapper}>
<TouchableWithoutFeedback onLongPress={onLongPress}>
<View>
<View style={styles.inner}>
{children}
</View>
</TouchableWithoutFeedback>
Expand Down

0 comments on commit 8898fd8

Please sign in to comment.