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