Skip to content

Commit

Permalink
Image markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolmello committed Jul 31, 2018
1 parent 0e50619 commit 6df2445
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
1 change: 0 additions & 1 deletion app/containers/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Icon from 'react-native-vector-icons/MaterialIcons';
import database from '../lib/realm';
import { selectServerRequest } from '../actions/server';
import { logout } from '../actions/login';
import { appStart } from '../actions';
import Avatar from '../containers/Avatar';
import Status from '../containers/status';
import Touch from '../utils/touch';
Expand Down
16 changes: 3 additions & 13 deletions app/containers/message/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,10 @@ import React from 'react';
import FastImage from 'react-native-fast-image';
import { TouchableOpacity, StyleSheet } from 'react-native';
import { connect } from 'react-redux';

import PhotoModal from './PhotoModal';
import Markdown from './Markdown';

const styles = StyleSheet.create({
button: {
flex: 1,
flexDirection: 'column'
},
image: {
width: 320,
height: 200
// resizeMode: 'cover'
}
});
import styles from './styles';

@connect(state => ({
baseUrl: state.settings.Site_Url || state.server ? state.server.server : ''
Expand Down Expand Up @@ -52,7 +42,7 @@ export default class extends React.PureComponent {
<TouchableOpacity
key='image'
onPress={() => this._onPressButton()}
style={styles.button}
style={styles.imageContainer}
>
<FastImage
style={styles.image}
Expand Down
6 changes: 5 additions & 1 deletion app/containers/message/Markdown.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Text, Platform } from 'react-native';
import { Text, Platform, Image } from 'react-native';
import PropTypes from 'prop-types';
import { emojify } from 'react-emojione';
import { connect } from 'react-redux';
Expand Down Expand Up @@ -66,6 +66,10 @@ export default class Markdown extends React.Component {
return null;
},
blocklink: () => {},
image: node => (
// TODO: should use Image component
<Image key={node.key} style={styles.inlineImage} source={{ uri: node.attributes.src }} />
),
...rules
}}
style={{
Expand Down
14 changes: 14 additions & 0 deletions app/containers/message/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,19 @@ export default StyleSheet.create({
flexDirection: 'row',
alignItems: 'flex-start',
justifyContent: 'flex-start'
},
imageContainer: {
flex: 1,
flexDirection: 'column'
},
image: {
width: '100%',
maxWidth: 400,
height: 300
},
inlineImage: {
width: 300,
height: 300,
resizeMode: 'contain'
}
});

0 comments on commit 6df2445

Please sign in to comment.