mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-11-24 08:55:14 +03:00
merged with master
This commit is contained in:
commit
7e961bcc87
@ -15,7 +15,7 @@ export default EStyleSheet.create({
|
||||
paddingHorizontal: 10,
|
||||
justifyContent: 'center',
|
||||
marginRight: 8,
|
||||
height: 20,
|
||||
height: 22,
|
||||
backgroundColor: '$iconColor',
|
||||
borderRadius: 50,
|
||||
},
|
||||
|
@ -38,7 +38,7 @@ class PostDropdownContainer extends Component {
|
||||
|
||||
switch (index) {
|
||||
case '0':
|
||||
writeToClipboard(`https://steemit.com/${content.url}`);
|
||||
writeToClipboard(`https://steemit.com${content.url}`);
|
||||
break;
|
||||
|
||||
case '1':
|
||||
|
@ -1,56 +0,0 @@
|
||||
import React, { Component } from 'react';
|
||||
import {
|
||||
View, Text, TouchableOpacity, Dimensions,
|
||||
} from 'react-native';
|
||||
import HTML from 'react-native-html-renderer';
|
||||
// Components
|
||||
|
||||
// Styles
|
||||
import styles from './postBodyStyles';
|
||||
|
||||
// Constants
|
||||
const DEFAULT_IMAGE = require('../../../../assets/esteem.png');
|
||||
|
||||
class BodyView extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {};
|
||||
}
|
||||
|
||||
// Component Life Cycles
|
||||
|
||||
// Component Functions
|
||||
alterNode(node) {
|
||||
if (node.name == 'img') {
|
||||
node.attribs.style = `max-width: ${Dimensions.get('window').width
|
||||
+ 10}px; left: -10px; width: 100% !important`;
|
||||
} else if (node.name == 'iframe') {
|
||||
node.attribs.style = `max-width: ${Dimensions.get('window').width}px; left: -10px`;
|
||||
node.attribs.height = 200;
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { body } = this.props;
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<HTML
|
||||
html={body}
|
||||
onLinkPress={(evt, href, hrefatr) => this.onLinkPress(evt, href, hrefatr)}
|
||||
containerStyle={{ padding: 10 }}
|
||||
textSelectable
|
||||
tagsStyles={styles}
|
||||
ignoredTags={['script']}
|
||||
debug={false}
|
||||
alterNode={(node) => {
|
||||
this.alterNode(node);
|
||||
}}
|
||||
imagesMaxWidth={Dimensions.get('window').width}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default BodyView;
|
@ -23,10 +23,14 @@ class PostBody extends Component {
|
||||
// Component Functions
|
||||
|
||||
_handleOnLinkPress = (evt, href, hrefatr) => {
|
||||
const { handleOnUserPress } = this.props;
|
||||
const { handleOnUserPress, handleOnPostPress } = this.props;
|
||||
|
||||
if (hrefatr.class === 'markdown-author-link') {
|
||||
!handleOnUserPress ? this._handleOnUserPress(href) : handleOnUserPress(href);
|
||||
} else if (hrefatr.class === 'markdown-post-link') {
|
||||
!handleOnPostPress
|
||||
? this._handleOnPostPress(href, hrefatr.data_author)
|
||||
: handleOnPostPress(href);
|
||||
} else {
|
||||
Linking.canOpenURL(href).then((supported) => {
|
||||
if (supported) {
|
||||
@ -38,6 +42,19 @@ class PostBody extends Component {
|
||||
}
|
||||
};
|
||||
|
||||
_handleOnPostPress = (permlink, author) => {
|
||||
const { navigation } = this.props;
|
||||
|
||||
navigation.navigate({
|
||||
routeName: ROUTES.SCREENS.POST,
|
||||
params: {
|
||||
author,
|
||||
permlink,
|
||||
},
|
||||
key: permlink,
|
||||
});
|
||||
};
|
||||
|
||||
_handleOnUserPress = (username) => {
|
||||
const { navigation } = this.props;
|
||||
|
||||
@ -69,7 +86,6 @@ class PostBody extends Component {
|
||||
const _initialDimensions = isComment
|
||||
? { width: WIDTH - 50, height: 80 }
|
||||
: { width: WIDTH, height: 216 };
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<HTML
|
||||
|
@ -80,12 +80,14 @@ class PostsView extends Component {
|
||||
currentAccountUsername,
|
||||
).then((result) => {
|
||||
const _posts = result;
|
||||
_posts.shift();
|
||||
this.setState({
|
||||
posts: [...posts, ..._posts],
|
||||
startAuthor: result && result[result.length - 1] && result[result.length - 1].author,
|
||||
startPermlink: result && result[result.length - 1] && result[result.length - 1].permlink,
|
||||
});
|
||||
if (_posts.length > 0) {
|
||||
_posts.shift();
|
||||
this.setState({
|
||||
posts: [...posts, ..._posts],
|
||||
startAuthor: result && result[result.length - 1] && result[result.length - 1].author,
|
||||
startPermlink: result && result[result.length - 1] && result[result.length - 1].permlink,
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -11,9 +11,9 @@ import styles from './toggleSwitchStyles';
|
||||
|
||||
class ToggleSwitchView extends Component {
|
||||
/* Props
|
||||
* ------------------------------------------------
|
||||
* @prop { type } name - Description....
|
||||
*/
|
||||
* ------------------------------------------------
|
||||
* @prop { type } name - Description....
|
||||
*/
|
||||
offsetX = new Animated.Value(0);
|
||||
|
||||
constructor(props) {
|
||||
@ -23,7 +23,7 @@ class ToggleSwitchView extends Component {
|
||||
padding: 12,
|
||||
circleWidth: 28,
|
||||
circleHeight: 28,
|
||||
translateX: 32,
|
||||
translateX: 36,
|
||||
isOn: false || props.isOn,
|
||||
};
|
||||
}
|
||||
@ -42,6 +42,7 @@ class ToggleSwitchView extends Component {
|
||||
backgroundColor: 'white',
|
||||
transform: [{ translateX: this.offsetX }],
|
||||
width: circleWidth,
|
||||
marginLeft: 4,
|
||||
height: circleHeight,
|
||||
borderRadius: circleWidth / 2,
|
||||
shadowOpacity: 0.2,
|
||||
|
@ -23,6 +23,7 @@ export default EStyleSheet.create({
|
||||
fontWeight: 'bold',
|
||||
marginBottom: 10,
|
||||
paddingHorizontal: 18,
|
||||
height: 30,
|
||||
},
|
||||
mainButtonWrapper: {
|
||||
flexDirection: 'row',
|
||||
|
@ -46,7 +46,7 @@ class HomeScreen extends PureComponent {
|
||||
<View style={styles.container}>
|
||||
<ScrollableTabView
|
||||
style={styles.tabView}
|
||||
initialPage={!isLoggedIn ? 1 : 0}
|
||||
activeTab={!isLoggedIn ? 1 : 0}
|
||||
renderTabBar={() => (
|
||||
<TabBar
|
||||
style={styles.tabbar}
|
||||
|
@ -7,14 +7,8 @@ import { setUserDataWithPinCode, verifyPinCode } from '../../../providers/steem/
|
||||
|
||||
// Actions & Services
|
||||
import { closePinCodeModal } from '../../../redux/actions/applicationActions';
|
||||
import {
|
||||
getExistUser,
|
||||
setExistUser,
|
||||
getUserData,
|
||||
getUserDataWithUsername,
|
||||
} from '../../../realm/realm';
|
||||
import { getExistUser, setExistUser, getUserDataWithUsername } from '../../../realm/realm';
|
||||
import { updateCurrentAccount } from '../../../redux/actions/accountAction';
|
||||
import { formatAccount } from '../../../utils/user';
|
||||
import { PinCodeScreen } from '..';
|
||||
|
||||
class PinCodeContainer extends Component {
|
||||
|
@ -56,7 +56,7 @@ const RootContainer = () => (WrappedComponent) => {
|
||||
const { dispatch } = this.props;
|
||||
this._pinCodeTimer = setTimeout(() => {
|
||||
dispatch(openPinCodeModal());
|
||||
}, 5 * 60 * 1000);
|
||||
}, 1 * 60 * 1000);
|
||||
};
|
||||
|
||||
_setPinCodeState = (data) => {
|
||||
|
@ -4,7 +4,7 @@ const md = new Remarkable({ html: true, breaks: true, linkify: true });
|
||||
const isVideo = false;
|
||||
const imgCenterRegex = /([<center>]http(s?):)([/|.|\w|\s|-])*\.(?:jpg|gif|png|PNG|GIF|JPG)[</center>]/g;
|
||||
const onlyImageLinkRegex = /([\n]http(s?):)([/|.|\w|\s|-])*\.(?:jpg|gif|png|PNG|GIF|JPG)/g;
|
||||
const onlyImageDoubleLinkRegex = /(\nhttps)(.*)(?=jpg|gif|png|PNG|GIF|JPG|)/g
|
||||
const onlyImageDoubleLinkRegex = /(\nhttps)(.*)(?=jpg|gif|png|PNG|GIF|JPG|)/g;
|
||||
const postRegex = /^https?:\/\/(.*)\/(.*)\/(@[\w.\d-]+)\/(.*)/i;
|
||||
const copiedPostRegex = /\/(.*)\/(@[\w.\d-]+)\/(.*)/i;
|
||||
const youTubeRegex = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([^& \n<]+)(?:[^ \n<]+)?/g;
|
||||
@ -12,6 +12,7 @@ const vimeoRegex = /(https?:\/\/)?(www\.)?(?:vimeo)\.com.*(?:videos|video|channe
|
||||
const dTubeRegex = /(https?:\/\/d.tube.#!\/v\/)(\w+)\/(\w+)/g;
|
||||
const authorNameRegex = /(^|[^a-zA-Z0-9_!#$%&*@@\/]|(^|[^a-zA-Z0-9_+~.-\/]))[@@]([a-z][-\.a-z\d]+[a-z\d])/gi;
|
||||
const tagsRegex = /(^|\s|>)(#[-a-z\d]+)/gi;
|
||||
const centerRegex = /(<center>)/g;
|
||||
|
||||
export const markDown2Html = (input) => {
|
||||
if (!input) {
|
||||
@ -55,6 +56,14 @@ export const markDown2Html = (input) => {
|
||||
output = createImage(output);
|
||||
}
|
||||
|
||||
if (centerRegex.test(output)) {
|
||||
output = centerStyling(output);
|
||||
}
|
||||
|
||||
if (postRegex.test(output)) {
|
||||
output = steemitUrlHandle(output);
|
||||
}
|
||||
|
||||
output = md.render(output);
|
||||
|
||||
return output;
|
||||
@ -77,19 +86,27 @@ export const replaceTags = input => input.replace(tagsRegex, (tag) => {
|
||||
|
||||
export const removeOnlyPTag = input => input;
|
||||
|
||||
const centerStyling = input => input.replace(centerRegex, () => '<center style="text-align:center;">');
|
||||
|
||||
const createCenterImage = input => input.replace(imgCenterRegex, (link) => {
|
||||
let _link = link;
|
||||
|
||||
_link = _link.split('>')[1];
|
||||
_link = _link.split('<')[0];
|
||||
return `><img data-href="${_link}" src="${_link}"><`;
|
||||
_link = _link.split('>')[1];
|
||||
_link = _link.split('<')[0];
|
||||
return `><img data-href="${_link}" src="${_link}"><`;
|
||||
});
|
||||
|
||||
const steemitUrlHandle = input => input.replace(postRegex, (link) => {
|
||||
const postMatch = link.match(postRegex);
|
||||
const tag = postMatch[2];
|
||||
const author = postMatch[3].replace('@', '');
|
||||
const permlink = postMatch[4];
|
||||
|
||||
const createImage = input => input.replace(onlyImageLinkRegex, (link) => {
|
||||
return `<img data-href="${link}" src="${link}">`;
|
||||
return `<a class="markdown-post-link" href="${permlink}" data_tag={${tag}} data_author="${author}">/${permlink}</a>`;
|
||||
});
|
||||
|
||||
const createImage = input => input.replace(onlyImageLinkRegex, link => `<img data-href="${link}" src="${link}">`);
|
||||
|
||||
const createFromDoubleImageLink = input => input.replace(onlyImageDoubleLinkRegex, (link) => {
|
||||
const _link = link.trim();
|
||||
return `<img data-href="${_link}" src="${_link}">`;
|
||||
|
Loading…
Reference in New Issue
Block a user