merged with development

This commit is contained in:
ue 2019-11-07 22:27:07 +03:00
commit 49e032dd79
11 changed files with 153 additions and 141 deletions

View File

@ -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: {

View File

@ -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"

View File

@ -4,5 +4,6 @@ export default EStyleSheet.create({
icon: { icon: {
color: '$iconColor', color: '$iconColor',
marginRight: 2.7, marginRight: 2.7,
fontSize: 25,
}, },
}); });

View File

@ -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',
}, },

View File

@ -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,61 +143,56 @@ class PostBody extends PureComponent {
} }
}; };
render() { const _initialDimensions = isComment
const { body, isComment, textSelectable = true } = this.props; ? { width: WIDTH - 50, height: 80 }
const _initialDimensions = isComment : { width: WIDTH, height: 216 };
? { width: WIDTH - 50, height: 80 }
: { width: WIDTH, height: 216 };
const _customRenderer = { const _customRenderer = {
a: (htmlAttribs, children, convertedCSSStyles, passProps) => { a: (htmlAttribs, children, convertedCSSStyles, passProps) => {
if (passProps.parentWrapper === 'Text') { if (passProps.parentWrapper === 'Text') {
return (
<Text
key={passProps.key}
{...htmlAttribs}
onPress={() => this._handleOnLinkPress(htmlAttribs['data-href'], htmlAttribs)}
>
{children}
</Text>
);
}
return ( return (
<TouchableOpacity <Text
key={passProps.key} key={passProps.key}
{...htmlAttribs} {...htmlAttribs}
onPress={() => this._handleOnLinkPress(htmlAttribs['data-href'], htmlAttribs)} onPress={() => _handleOnLinkPress(htmlAttribs['data-href'], htmlAttribs)}
> >
{children} {children}
</TouchableOpacity> </Text>
); );
}, }
br: (htmlAttribs, children, passProps) => { return (
return <Text {...passProps}>{'\n'}</Text>; <TouchableOpacity
}, key={passProps.key}
}; {...htmlAttribs}
onPress={() => _handleOnLinkPress(htmlAttribs['data-href'], htmlAttribs)}
>
{children}
</TouchableOpacity>
);
},
br: (htmlAttribs, children, passProps) => {
return <Text {...passProps}>{'\n'}</Text>;
},
};
return ( return (
<Fragment> <HTML
<HTML html={body}
html={body} onLinkPress={(evt, href, hrefAtr) => _handleOnLinkPress(evt, href, hrefAtr)}
onLinkPress={(evt, href, hrefatr) => this._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} ignoredTags={['script']}
ignoredTags={['script']} debug={false}
debug={false} staticContentMaxWidth={WIDTH - 33}
staticContentMaxWidth={WIDTH - 33} imagesInitialDimensions={_initialDimensions}
imagesInitialDimensions={_initialDimensions} baseFontStyle={styles.text}
baseFontStyle={styles.text} imagesMaxWidth={isComment ? WIDTH - 50 : WIDTH}
imagesMaxWidth={isComment ? WIDTH - 50 : WIDTH} alterNode={e => _alterNode(e, isComment)}
alterNode={e => this._alterNode(e, isComment)} alterData={e => _alterData(e)}
alterData={e => this._alterData(e)} renderers={_customRenderer}
renderers={_customRenderer} />
/> );
</Fragment> };
);
}
}
export default injectIntl(withNavigation(PostBody)); export default injectIntl(withNavigation(PostBody));

View File

@ -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',

View File

@ -249,12 +249,14 @@ class UpvoteView extends Component {
/> />
</View> </View>
) : ( ) : (
<Icon <View hitSlop={{ top: 10, bottom: 10, left: 10, right: 5 }}>
style={[styles.upvoteIcon, isDownVoted && { color: '#ec8b88' }]} <Icon
active={!isLoggedIn} style={[styles.upvoteIcon, isDownVoted && { color: '#ec8b88' }]}
iconType={isDownVoted ? 'AntDesign' : iconType} active={!isLoggedIn}
name={isDownVoted ? 'downcircle' : iconName} iconType={isDownVoted ? 'AntDesign' : iconType}
/> name={isDownVoted ? 'downcircle' : iconName}
/>
</View>
)} )}
</Fragment> </Fragment>
</TouchableOpacity> </TouchableOpacity>

View File

@ -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;

View File

@ -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} />
), ),
}), }),
}, },

View File

@ -236,21 +236,23 @@ 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') { Object.keys(notificationDetails).map(item => {
await Push.setEnabled(action); const notificationType = item.replace('Notification', '');
this._setPushToken(action ? [1, 2, 3, 4, 5, 6] : notifyTypes);
} else {
Object.keys(notificationDetails).map(item => {
const notificationType = item.replace('Notification', '');
if (notificationType === actionType.replace('notification.', '')) { if (notificationType === actionType.replace('notification.', '')) {
if (action) { if (action) {
notifyTypes.push(notifyTypesConst[notificationType]);
}
} else if (notificationDetails[item]) {
notifyTypes.push(notifyTypesConst[notificationType]); 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); 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) {
const data = { otherAccounts.forEach(item => {
username, const { isNotificationSettingsOpen } = this.props;
token,
system: Platform.OS, const data = {
allows_notify: Number(isNotificationSettingsOpen), username: item.username,
notify_types: notifyTypes, token,
}; system: Platform.OS,
setPushToken(data); allows_notify: Number(isNotificationSettingsOpen),
notify_types: notifyTypes,
};
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));

View File

@ -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>
)} )}
/> />
<TransferFormItem {transferType !== 'powerUp' && (
label={intl.formatMessage({ id: 'transfer.memo' })} <TransferFormItem
rightComponent={() => label={intl.formatMessage({ id: 'transfer.memo' })}
this._renderInput( rightComponent={() =>
intl.formatMessage({ id: 'transfer.memo_placeholder' }), this._renderInput({
'memo', placeholder: intl.formatMessage({ id: 'transfer.memo_placeholder' }),
'default', state: 'memo',
true, keyboardType: 'default',
) isTextArea: true,
} })
/> }
<TransferFormItem />
rightComponent={() => )}
this._renderDescription(intl.formatMessage({ id: 'transfer.memo_desc' })) {transferType !== 'powerUp' && (
} <TransferFormItem
/> rightComponent={() =>
this._renderDescription(intl.formatMessage({ id: 'transfer.memo_desc' }))
}
/>
)}
</View> </View>
<View style={styles.bottomContent}> <View style={styles.bottomContent}>
<MainButton <MainButton