From 1a17f2970f17c179c8f754bc58f46d004ef3a739 Mon Sep 17 00:00:00 2001 From: Chris Duarte Date: Mon, 19 Jun 2017 05:46:38 -0700 Subject: [PATCH] Allow navigation to profiles using channel intro icons and names (#644) * Allow navigation to profiles using channel intro icons and names * Add preventDoubleTap --- app/components/channel_intro/channel_intro.js | 41 +++++++++++++++++-- app/components/post_list/post_list.js | 4 +- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/app/components/channel_intro/channel_intro.js b/app/components/channel_intro/channel_intro.js index dd7465800..bf87ed95e 100644 --- a/app/components/channel_intro/channel_intro.js +++ b/app/components/channel_intro/channel_intro.js @@ -6,6 +6,7 @@ import PropTypes from 'prop-types'; import { StyleSheet, Text, + TouchableOpacity, View } from 'react-native'; import {getFullName} from 'mattermost-redux/utils/user_utils'; @@ -13,6 +14,7 @@ import {General} from 'mattermost-redux/constants'; import {injectIntl, intlShape} from 'react-intl'; import ProfilePicture from 'app/components/profile_picture'; +import {preventDoubleTap} from 'app/utils/tap'; import {changeOpacity, makeStyleSheetFromTheme} from 'app/utils/theme'; class ChannelIntro extends PureComponent { @@ -21,9 +23,30 @@ class ChannelIntro extends PureComponent { currentChannelMembers: PropTypes.array.isRequired, currentUser: PropTypes.object.isRequired, intl: intlShape.isRequired, + navigator: PropTypes.object.isRequired, theme: PropTypes.object.isRequired }; + goToUserProfile = (userId) => { + const {intl, navigator, theme} = this.props; + + navigator.push({ + screen: 'UserProfile', + title: intl.formatMessage({id: 'mobile.routes.user_profile', defaultMessage: 'Profile'}), + animated: true, + backButtonTitle: '', + passProps: { + userId + }, + navigatorStyle: { + navBarTextColor: theme.sidebarHeaderTextColor, + navBarBackgroundColor: theme.sidebarHeaderBg, + navBarButtonColor: theme.sidebarHeaderTextColor, + screenBackgroundColor: theme.centerChannelBg + } + }); + }; + getDisplayName = (member) => { if (!member) { return null; @@ -43,8 +66,9 @@ class ChannelIntro extends PureComponent { const style = getStyleSheet(theme); return currentChannelMembers.map((member) => ( - preventDoubleTap(this.goToUserProfile, this, member.id)} style={style.profile} > - + )); }; @@ -62,9 +86,18 @@ class ChannelIntro extends PureComponent { const {currentChannelMembers, theme} = this.props; const style = getStyleSheet(theme); - const names = currentChannelMembers.map((member) => this.getDisplayName(member)); + const names = currentChannelMembers.map((member, index) => ( + preventDoubleTap(this.goToUserProfile, this, member.id)} + > + + {index === currentChannelMembers.length - 1 ? this.getDisplayName(member) : `${this.getDisplayName(member)}, `} + + + )); - return {names.join(', ')}; + return {names}; }; buildDMContent = () => { diff --git a/app/components/post_list/post_list.js b/app/components/post_list/post_list.js index 7641b8785..97e2208ab 100644 --- a/app/components/post_list/post_list.js +++ b/app/components/post_list/post_list.js @@ -101,7 +101,7 @@ export default class PostList extends Component { }; renderChannelIntro = () => { - const {channel, channelIsLoading, posts} = this.props; + const {channel, channelIsLoading, navigator, posts} = this.props; if (channel.hasOwnProperty('id')) { const firstPostHasRendered = channel.total_msg_count ? posts.length > 0 : true; @@ -112,7 +112,7 @@ export default class PostList extends Component { return ( - + ); }