mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-24 22:03:21 +03:00
merged with development
This commit is contained in:
commit
287cd7f596
@ -16,7 +16,7 @@ export default EStyleSheet.create({
|
|||||||
zIndex: 1,
|
zIndex: 1,
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
marginHorizontal: 19,
|
marginHorizontal: 20,
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
},
|
},
|
||||||
navItem: {
|
navItem: {
|
||||||
|
@ -48,7 +48,7 @@ export default class TitleAreaView extends Component {
|
|||||||
const { text, height } = this.state;
|
const { text, height } = this.state;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={globalStyles.containerHorizontal16}>
|
<View style={[globalStyles.containerHorizontal16, { height: Math.max(35, height) }]}>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={[styles.textInput, { height: Math.max(35, height) }]}
|
style={[styles.textInput, { height: Math.max(35, height) }]}
|
||||||
placeholderTextColor="#c1c5c7"
|
placeholderTextColor="#c1c5c7"
|
||||||
|
@ -4,5 +4,6 @@ export default EStyleSheet.create({
|
|||||||
icon: {
|
icon: {
|
||||||
color: '$iconColor',
|
color: '$iconColor',
|
||||||
marginRight: 2.7,
|
marginRight: 2.7,
|
||||||
|
fontSize: 25,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -2,7 +2,7 @@ import EStyleSheet from 'react-native-extended-stylesheet';
|
|||||||
|
|
||||||
export default EStyleSheet.create({
|
export default EStyleSheet.create({
|
||||||
text: {
|
text: {
|
||||||
fontSize: 14,
|
fontSize: 16,
|
||||||
color: '$primaryBlack',
|
color: '$primaryBlack',
|
||||||
fontFamily: '$primaryFont',
|
fontFamily: '$primaryFont',
|
||||||
},
|
},
|
||||||
|
@ -1,48 +1,50 @@
|
|||||||
import React, { PureComponent, Fragment } from 'react';
|
import React from 'react';
|
||||||
import { Dimensions, Linking, Alert, TouchableOpacity, Text } from 'react-native';
|
import { Dimensions, Linking, Alert, TouchableOpacity, Text } from 'react-native';
|
||||||
import { withNavigation } from 'react-navigation';
|
import { withNavigation } from 'react-navigation';
|
||||||
import { injectIntl } from 'react-intl';
|
import { useIntl, injectIntl } from 'react-intl';
|
||||||
|
|
||||||
import HTML from 'react-native-render-html';
|
import HTML from 'react-native-render-html';
|
||||||
import { getParentsTagsRecursively } from 'react-native-render-html/src/HTMLUtils';
|
import { getParentsTagsRecursively } from 'react-native-render-html/src/HTMLUtils';
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
import { default as ROUTES } from '../../../../constants/routeNames';
|
||||||
|
|
||||||
// Styles
|
// Styles
|
||||||
import styles from './postBodyStyles';
|
import styles from './postBodyStyles';
|
||||||
|
|
||||||
// Constants
|
|
||||||
import { default as ROUTES } from '../../../../constants/routeNames';
|
|
||||||
// Components
|
|
||||||
|
|
||||||
const WIDTH = Dimensions.get('window').width;
|
const WIDTH = Dimensions.get('window').width;
|
||||||
|
|
||||||
class PostBody extends PureComponent {
|
const PostBody = ({
|
||||||
// Component Life Cycles
|
navigation,
|
||||||
|
body,
|
||||||
|
isComment,
|
||||||
|
textSelectable = true,
|
||||||
|
handleOnUserPress,
|
||||||
|
handleOnPostPress,
|
||||||
|
}) => {
|
||||||
|
const intl = useIntl();
|
||||||
|
|
||||||
// Component Functions
|
const _handleOnLinkPress = (href, hrefAtr) => {
|
||||||
|
if (hrefAtr.class === 'markdown-author-link') {
|
||||||
_handleOnLinkPress = (href, hrefatr) => {
|
|
||||||
const { handleOnUserPress, handleOnPostPress } = this.props;
|
|
||||||
|
|
||||||
if (hrefatr.class === 'markdown-author-link') {
|
|
||||||
if (!handleOnUserPress) {
|
if (!handleOnUserPress) {
|
||||||
this._handleOnUserPress(hrefatr['data-author']);
|
_handleOnUserPress(hrefAtr['data-author']);
|
||||||
} else {
|
} else {
|
||||||
handleOnUserPress(hrefatr['data-author']);
|
handleOnUserPress(hrefAtr['data-author']);
|
||||||
}
|
}
|
||||||
} else if (hrefatr.class === 'markdown-post-link') {
|
} else if (hrefAtr.class === 'markdown-post-link') {
|
||||||
if (!handleOnPostPress) {
|
if (!handleOnPostPress) {
|
||||||
this._handleOnPostPress(hrefatr['data-permlink'], hrefatr['data-author']);
|
_handleOnPostPress(hrefAtr['data-permlink'], hrefAtr['data-author']);
|
||||||
} else {
|
} else {
|
||||||
handleOnPostPress(hrefatr['data-permlink']);
|
handleOnPostPress(hrefAtr['data-permlink']);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this._handleBrowserLink(href);
|
_handleBrowserLink(href);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_handleBrowserLink = async url => {
|
const _handleBrowserLink = async url => {
|
||||||
if (!url) return;
|
if (!url) {
|
||||||
const { intl } = this.props;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Linking.canOpenURL(url).then(supported => {
|
Linking.canOpenURL(url).then(supported => {
|
||||||
if (supported) {
|
if (supported) {
|
||||||
@ -53,9 +55,7 @@ class PostBody extends PureComponent {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
_handleOnPostPress = (permlink, author) => {
|
const _handleOnPostPress = (permlink, author) => {
|
||||||
const { navigation } = this.props;
|
|
||||||
|
|
||||||
if (permlink) {
|
if (permlink) {
|
||||||
navigation.navigate({
|
navigation.navigate({
|
||||||
routeName: ROUTES.SCREENS.POST,
|
routeName: ROUTES.SCREENS.POST,
|
||||||
@ -68,9 +68,7 @@ class PostBody extends PureComponent {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_handleOnUserPress = username => {
|
const _handleOnUserPress = username => {
|
||||||
const { navigation } = this.props;
|
|
||||||
|
|
||||||
if (username) {
|
if (username) {
|
||||||
navigation.navigate({
|
navigation.navigate({
|
||||||
routeName: ROUTES.SCREENS.PROFILE,
|
routeName: ROUTES.SCREENS.PROFILE,
|
||||||
@ -80,33 +78,35 @@ class PostBody extends PureComponent {
|
|||||||
key: username,
|
key: username,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Alert.alert('Opps!', 'Wrong link :(');
|
Alert.alert('Opss!', 'Wrong link.');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_hasParentTag = (node, name) => {
|
const _hasParentTag = (node, name) => {
|
||||||
if (!node.parent) return false;
|
if (!node.parent) {
|
||||||
if (node.name === name) return true;
|
return false;
|
||||||
return this._hasParentTag(node.parent, name);
|
}
|
||||||
|
|
||||||
|
if (node.name === name) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _hasParentTag(node.parent, name);
|
||||||
};
|
};
|
||||||
|
|
||||||
_alterNode = (node, isComment) => {
|
const _alterNode = (node, isComment) => {
|
||||||
if (isComment) {
|
if (isComment) {
|
||||||
if (node.name === 'img') {
|
if (node.name === 'img') {
|
||||||
node.attribs.style = `max-width: ${WIDTH - 50}px; height: 100px; width: ${WIDTH -
|
node.attribs.style = `max-width: ${WIDTH - 50}px; height: 100px; width: ${WIDTH -
|
||||||
50}px; text-align: center;`;
|
50}px; text-align: center;`;
|
||||||
}
|
}
|
||||||
// else if (node.name === 'iframe') {
|
|
||||||
// node.attribs.style = `max-width: ${WIDTH}px; left: -30px`;
|
|
||||||
// node.attribs.height = 216;
|
|
||||||
// }
|
|
||||||
} else if (node.name === 'a') {
|
} else if (node.name === 'a') {
|
||||||
node.attribs.style = 'text-decoration: underline';
|
node.attribs.style = 'text-decoration: underline';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.name === 'img') {
|
if (node.name === 'img') {
|
||||||
node.attribs.style = 'text-align: center;';
|
node.attribs.style = 'text-align: center;';
|
||||||
if (this._hasParentTag(node, 'td')) {
|
if (_hasParentTag(node, 'td')) {
|
||||||
node.attribs.style = `max-width: ${WIDTH / 2 - 20}px; `;
|
node.attribs.style = `max-width: ${WIDTH / 2 - 20}px; `;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ class PostBody extends PureComponent {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_alterData = node => {
|
const _alterData = node => {
|
||||||
if (
|
if (
|
||||||
node.type === 'text' &&
|
node.type === 'text' &&
|
||||||
node.data.includes('markdown-author-link') &&
|
node.data.includes('markdown-author-link') &&
|
||||||
@ -143,8 +143,6 @@ class PostBody extends PureComponent {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
|
||||||
const { body, isComment, textSelectable = true } = this.props;
|
|
||||||
const _initialDimensions = isComment
|
const _initialDimensions = isComment
|
||||||
? { width: WIDTH - 50, height: 80 }
|
? { width: WIDTH - 50, height: 80 }
|
||||||
: { width: WIDTH, height: 216 };
|
: { width: WIDTH, height: 216 };
|
||||||
@ -156,7 +154,7 @@ class PostBody extends PureComponent {
|
|||||||
<Text
|
<Text
|
||||||
key={passProps.key}
|
key={passProps.key}
|
||||||
{...htmlAttribs}
|
{...htmlAttribs}
|
||||||
onPress={() => this._handleOnLinkPress(htmlAttribs['data-href'], htmlAttribs)}
|
onPress={() => _handleOnLinkPress(htmlAttribs['data-href'], htmlAttribs)}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Text>
|
</Text>
|
||||||
@ -166,7 +164,7 @@ class PostBody extends PureComponent {
|
|||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
key={passProps.key}
|
key={passProps.key}
|
||||||
{...htmlAttribs}
|
{...htmlAttribs}
|
||||||
onPress={() => this._handleOnLinkPress(htmlAttribs['data-href'], htmlAttribs)}
|
onPress={() => _handleOnLinkPress(htmlAttribs['data-href'], htmlAttribs)}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
@ -178,10 +176,9 @@ class PostBody extends PureComponent {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
|
||||||
<HTML
|
<HTML
|
||||||
html={body}
|
html={body}
|
||||||
onLinkPress={(evt, href, hrefatr) => this._handleOnLinkPress(evt, href, hrefatr)}
|
onLinkPress={(evt, href, hrefAtr) => _handleOnLinkPress(evt, href, hrefAtr)}
|
||||||
containerStyle={isComment ? styles.commentContainer : styles.container}
|
containerStyle={isComment ? styles.commentContainer : styles.container}
|
||||||
textSelectable={textSelectable}
|
textSelectable={textSelectable}
|
||||||
tagsStyles={isComment ? { img: { height: 120 } } : styles}
|
tagsStyles={isComment ? { img: { height: 120 } } : styles}
|
||||||
@ -191,13 +188,11 @@ class PostBody extends PureComponent {
|
|||||||
imagesInitialDimensions={_initialDimensions}
|
imagesInitialDimensions={_initialDimensions}
|
||||||
baseFontStyle={styles.text}
|
baseFontStyle={styles.text}
|
||||||
imagesMaxWidth={isComment ? WIDTH - 50 : WIDTH}
|
imagesMaxWidth={isComment ? WIDTH - 50 : WIDTH}
|
||||||
alterNode={e => this._alterNode(e, isComment)}
|
alterNode={e => _alterNode(e, isComment)}
|
||||||
alterData={e => this._alterData(e)}
|
alterData={e => _alterData(e)}
|
||||||
renderers={_customRenderer}
|
renderers={_customRenderer}
|
||||||
/>
|
/>
|
||||||
</Fragment>
|
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
export default injectIntl(withNavigation(PostBody));
|
export default injectIntl(withNavigation(PostBody));
|
||||||
|
@ -9,8 +9,9 @@ export default EStyleSheet.create({
|
|||||||
},
|
},
|
||||||
upvoteIcon: {
|
upvoteIcon: {
|
||||||
alignSelf: 'center',
|
alignSelf: 'center',
|
||||||
fontSize: 20,
|
fontSize: 24,
|
||||||
color: '$primaryBlue',
|
color: '$primaryBlue',
|
||||||
|
marginRight: 5,
|
||||||
},
|
},
|
||||||
popoverSlider: {
|
popoverSlider: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
|
@ -249,12 +249,14 @@ class UpvoteView extends Component {
|
|||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
) : (
|
) : (
|
||||||
|
<View hitSlop={{ top: 10, bottom: 10, left: 10, right: 5 }}>
|
||||||
<Icon
|
<Icon
|
||||||
style={[styles.upvoteIcon, isDownVoted && { color: '#ec8b88' }]}
|
style={[styles.upvoteIcon, isDownVoted && { color: '#ec8b88' }]}
|
||||||
active={!isLoggedIn}
|
active={!isLoggedIn}
|
||||||
iconType={isDownVoted ? 'AntDesign' : iconType}
|
iconType={isDownVoted ? 'AntDesign' : iconType}
|
||||||
name={isDownVoted ? 'downcircle' : iconName}
|
name={isDownVoted ? 'downcircle' : iconName}
|
||||||
/>
|
/>
|
||||||
|
</View>
|
||||||
)}
|
)}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
@ -61,7 +61,9 @@ class UserAvatarView extends Component {
|
|||||||
let _size;
|
let _size;
|
||||||
const _avatar = username
|
const _avatar = username
|
||||||
? {
|
? {
|
||||||
uri: avatarUrl || (name === username ? avatar : getResizedAvatar(username, imageSize)),
|
uri:
|
||||||
|
avatarUrl ||
|
||||||
|
(name === username && avatar ? avatar : getResizedAvatar(username, imageSize)),
|
||||||
}
|
}
|
||||||
: DEFAULT_IMAGE;
|
: DEFAULT_IMAGE;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ const BaseNavigator = createBottomTabNavigator(
|
|||||||
screen: Profile,
|
screen: Profile,
|
||||||
navigationOptions: () => ({
|
navigationOptions: () => ({
|
||||||
tabBarIcon: ({ tintColor }) => (
|
tabBarIcon: ({ tintColor }) => (
|
||||||
<Icon iconType="MaterialIcons" name="credit-card" color={tintColor} size={26} />
|
<Icon iconType="MaterialIcons" name="person-outline" color={tintColor} size={26} />
|
||||||
),
|
),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -236,10 +236,6 @@ class SettingsContainer extends Component {
|
|||||||
dispatch(changeNotificationSettings({ action, type: actionType }));
|
dispatch(changeNotificationSettings({ action, type: actionType }));
|
||||||
setNotificationSettings({ action, type: actionType });
|
setNotificationSettings({ action, type: actionType });
|
||||||
|
|
||||||
if (actionType === 'notification') {
|
|
||||||
await Push.setEnabled(action);
|
|
||||||
this._setPushToken(action ? [1, 2, 3, 4, 5, 6] : notifyTypes);
|
|
||||||
} else {
|
|
||||||
Object.keys(notificationDetails).map(item => {
|
Object.keys(notificationDetails).map(item => {
|
||||||
const notificationType = item.replace('Notification', '');
|
const notificationType = item.replace('Notification', '');
|
||||||
|
|
||||||
@ -251,6 +247,12 @@ class SettingsContainer extends Component {
|
|||||||
notifyTypes.push(notifyTypesConst[notificationType]);
|
notifyTypes.push(notifyTypesConst[notificationType]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
notifyTypes.sort();
|
||||||
|
|
||||||
|
if (actionType === 'notification') {
|
||||||
|
await Push.setEnabled(action);
|
||||||
|
this._setPushToken(action ? notifyTypes : []);
|
||||||
|
} else {
|
||||||
this._setPushToken(notifyTypes);
|
this._setPushToken(notifyTypes);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -286,21 +288,25 @@ class SettingsContainer extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
_setPushToken = async notifyTypes => {
|
_setPushToken = async notifyTypes => {
|
||||||
const { isNotificationSettingsOpen, isLoggedIn, username } = this.props;
|
const { isLoggedIn, otherAccounts = [] } = this.props;
|
||||||
|
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
const token = await AppCenter.getInstallId();
|
const token = await AppCenter.getInstallId();
|
||||||
|
|
||||||
getExistUser().then(isExistUser => {
|
getExistUser().then(isExistUser => {
|
||||||
if (isExistUser) {
|
if (isExistUser) {
|
||||||
|
otherAccounts.forEach(item => {
|
||||||
|
const { isNotificationSettingsOpen } = this.props;
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
username,
|
username: item.username,
|
||||||
token,
|
token,
|
||||||
system: Platform.OS,
|
system: Platform.OS,
|
||||||
allows_notify: Number(isNotificationSettingsOpen),
|
allows_notify: Number(isNotificationSettingsOpen),
|
||||||
notify_types: notifyTypes,
|
notify_types: notifyTypes,
|
||||||
};
|
};
|
||||||
setPushToken(data);
|
setPushToken(data);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -401,6 +407,7 @@ const mapStateToProps = state => ({
|
|||||||
|
|
||||||
username: state.account.currentAccount && state.account.currentAccount.name,
|
username: state.account.currentAccount && state.account.currentAccount.name,
|
||||||
currentAccount: state.account.currentAccount,
|
currentAccount: state.account.currentAccount,
|
||||||
|
otherAccounts: state.account.otherAccounts,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default injectIntl(connect(mapStateToProps)(SettingsContainer));
|
export default injectIntl(connect(mapStateToProps)(SettingsContainer));
|
||||||
|
@ -31,10 +31,10 @@ class TransferView extends Component {
|
|||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
from: props.currentAccountName,
|
from: props.currentAccountName,
|
||||||
destination: '',
|
destination: props.transferType === 'powerUp' ? props.currentAccountName : '',
|
||||||
amount: '',
|
amount: '',
|
||||||
memo: '',
|
memo: '',
|
||||||
isUsernameValid: false,
|
isUsernameValid: props.transferType === 'powerUp' && props.currentAccountName ? true : false,
|
||||||
steemConnectTransfer: false,
|
steemConnectTransfer: false,
|
||||||
isTransfering: false,
|
isTransfering: false,
|
||||||
};
|
};
|
||||||
@ -217,22 +217,26 @@ class TransferView extends Component {
|
|||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
{transferType !== 'powerUp' && (
|
||||||
<TransferFormItem
|
<TransferFormItem
|
||||||
label={intl.formatMessage({ id: 'transfer.memo' })}
|
label={intl.formatMessage({ id: 'transfer.memo' })}
|
||||||
rightComponent={() =>
|
rightComponent={() =>
|
||||||
this._renderInput(
|
this._renderInput({
|
||||||
intl.formatMessage({ id: 'transfer.memo_placeholder' }),
|
placeholder: intl.formatMessage({ id: 'transfer.memo_placeholder' }),
|
||||||
'memo',
|
state: 'memo',
|
||||||
'default',
|
keyboardType: 'default',
|
||||||
true,
|
isTextArea: true,
|
||||||
)
|
})
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
{transferType !== 'powerUp' && (
|
||||||
<TransferFormItem
|
<TransferFormItem
|
||||||
rightComponent={() =>
|
rightComponent={() =>
|
||||||
this._renderDescription(intl.formatMessage({ id: 'transfer.memo_desc' }))
|
this._renderDescription(intl.formatMessage({ id: 'transfer.memo_desc' }))
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.bottomContent}>
|
<View style={styles.bottomContent}>
|
||||||
<MainButton
|
<MainButton
|
||||||
|
Loading…
Reference in New Issue
Block a user