From 37307c53adeb5818906f90fa5ccd56725abd0a34 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Thu, 16 Sep 2021 15:05:54 +0500 Subject: [PATCH] integrated quick profile modal with all post headers and notification avatar --- .../notification/view/notificationView.tsx | 1 + .../view/notificationLineView.js | 16 ++++++++++------ .../postCard/container/postCardContainer.js | 18 ------------------ .../view/postHeaderDescription.js | 17 +++++++---------- .../container/notificationContainer.js | 7 +++++++ .../notification/screen/notificationScreen.js | 2 ++ 6 files changed, 27 insertions(+), 34 deletions(-) diff --git a/src/components/notification/view/notificationView.tsx b/src/components/notification/view/notificationView.tsx index 7f2a38522..853c1e250 100644 --- a/src/components/notification/view/notificationView.tsx +++ b/src/components/notification/view/notificationView.tsx @@ -188,6 +188,7 @@ class NotificationView extends PureComponent { {this.props.handleOnUserPress(item.source)}} /> ) diff --git a/src/components/notificationLine/view/notificationLineView.js b/src/components/notificationLine/view/notificationLineView.js index 259c7d405..d35909280 100644 --- a/src/components/notificationLine/view/notificationLineView.js +++ b/src/components/notificationLine/view/notificationLineView.js @@ -1,6 +1,6 @@ /* eslint-disable react/jsx-one-expression-per-line */ import React, { useState, useEffect } from 'react'; -import { View, Text, Image, TouchableHighlight } from 'react-native'; +import { View, Text, Image, TouchableHighlight, TouchableOpacity } from 'react-native'; import { useIntl } from 'react-intl'; import get from 'lodash/get'; @@ -10,7 +10,7 @@ import { UserAvatar } from '../../userAvatar'; // Styles import styles from './notificationLineStyles'; -const NotificationLineView = ({ notification, handleOnPressNotification }) => { +const NotificationLineView = ({ notification, handleOnPressNotification, handleOnUserPress }) => { const [isRead, setIsRead] = useState(notification.read); const intl = useIntl(); let _title; @@ -58,10 +58,14 @@ const NotificationLineView = ({ notification, handleOnPressNotification }) => { key={`${get(notification, 'id')}${_title}`} style={[styles.notificationWrapper, !isRead && styles.isNewNotification]} > - + + + + {notification.source} diff --git a/src/components/postCard/container/postCardContainer.js b/src/components/postCard/container/postCardContainer.js index 534c4152f..a1c8ff9c9 100644 --- a/src/components/postCard/container/postCardContainer.js +++ b/src/components/postCard/container/postCardContainer.js @@ -80,25 +80,7 @@ const PostCardContainer = ({ const _handleOnUserPress = (username) => { if (_content) { username = username || get(_content, 'author'); - // let params = { - // username: username || get(_content, 'author'), - // reputation: !username && get(_content, 'author_reputation'), - // }; - dispatch(showProfileModal(username)); - - // if ( - // get(currentAccount, 'name') === params.username && - // (pageType === 'main' || pageType === 'ownProfile') - // ) { - // navigation.navigate(ROUTES.TABBAR.PROFILE); - // } else { - // navigation.navigate({ - // routeName: ROUTES.SCREENS.PROFILE, - // params, - // key: get(_content, 'author'), - // }); - // } } }; diff --git a/src/components/postElements/headerDescription/view/postHeaderDescription.js b/src/components/postElements/headerDescription/view/postHeaderDescription.js index fa6b047f4..cc225430b 100644 --- a/src/components/postElements/headerDescription/view/postHeaderDescription.js +++ b/src/components/postElements/headerDescription/view/postHeaderDescription.js @@ -1,5 +1,6 @@ import React, { PureComponent } from 'react'; import { View, Text, TouchableOpacity } from 'react-native'; +import { connect } from 'react-redux'; import { withNavigation } from 'react-navigation'; import { injectIntl } from 'react-intl'; @@ -12,6 +13,7 @@ import styles from './postHeaderDescriptionStyles'; import { default as ROUTES } from '../../../../constants/routeNames'; import { IconButton } from '../../..'; +import { showProfileModal } from '../../../../redux/actions/uiAction'; // Constants const DEFAULT_IMAGE = require('../../../../assets/ecency.png'); @@ -21,19 +23,12 @@ class PostHeaderDescription extends PureComponent { // Component Functions _handleOnUserPress = (username) => { - const { navigation, profileOnPress, reputation } = this.props; + const { profileOnPress, dispatch } = this.props; if (profileOnPress) { profileOnPress(username); } else { - navigation.navigate({ - routeName: ROUTES.SCREENS.PROFILE, - params: { - username, - reputation, - }, - key: username, - }); + dispatch(showProfileModal(username)); } }; @@ -181,4 +176,6 @@ class PostHeaderDescription extends PureComponent { } } -export default withNavigation(injectIntl(PostHeaderDescription)); +const mapStateToProps = () => ({}); + +export default connect(mapStateToProps)(withNavigation(injectIntl(PostHeaderDescription))); diff --git a/src/screens/notification/container/notificationContainer.js b/src/screens/notification/container/notificationContainer.js index c4d8b9f2d..08da60599 100644 --- a/src/screens/notification/container/notificationContainer.js +++ b/src/screens/notification/container/notificationContainer.js @@ -15,6 +15,7 @@ import ROUTES from '../../../constants/routeNames'; // Components import NotificationScreen from '../screen/notificationScreen'; +import { showProfileModal } from '../../../redux/actions/uiAction'; class NotificationContainer extends Component { constructor(props) { @@ -118,6 +119,11 @@ class NotificationContainer extends Component { } }; + _handleOnUserPress = (username) => { + const { dispatch } = this.props; + dispatch(showProfileModal(username)); + }; + _readAllNotification = () => { const { dispatch, intl, isConnected } = this.props; const { notifications } = this.state; @@ -174,6 +180,7 @@ class NotificationContainer extends Component { getActivities={this._getActivities} notifications={notifications} navigateToNotificationRoute={this._navigateToNotificationRoute} + handleOnUserPress={this._handleOnUserPress} readAllNotification={this._readAllNotification} handleLoginPress={this._handleOnPressLogin} isNotificationRefreshing={isRefreshing} diff --git a/src/screens/notification/screen/notificationScreen.js b/src/screens/notification/screen/notificationScreen.js index 74aff39e7..d63701998 100644 --- a/src/screens/notification/screen/notificationScreen.js +++ b/src/screens/notification/screen/notificationScreen.js @@ -16,6 +16,7 @@ const NotificationScreen = ({ getActivities, intl, navigateToNotificationRoute, + handleOnUserPress, readAllNotification, isNotificationRefreshing, changeSelectedFilter, @@ -42,6 +43,7 @@ const NotificationScreen = ({ getActivities={getActivities} notifications={notifications} navigateToNotificationRoute={navigateToNotificationRoute} + handleOnUserPress={handleOnUserPress} readAllNotification={readAllNotification} isNotificationRefreshing={isNotificationRefreshing} changeSelectedFilter={changeSelectedFilter}