Skip to content

Commit 2db36ec

Browse files
committed
MainTabsScreen: Add Users icon to bottom nav
Fixes: #5495
1 parent c35b883 commit 2db36ec

File tree

3 files changed

+70
-2
lines changed

3 files changed

+70
-2
lines changed

src/main/MainTabsScreen.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ import type { AppNavigationMethods, AppNavigationProp } from '../nav/AppNavigato
1313
import { bottomTabNavigatorConfig } from '../styles/tabs';
1414
import HomeScreen from './HomeScreen';
1515
import PmConversationsScreen from '../pm-conversations/PmConversationsScreen';
16-
import { IconInbox, IconStream, IconPeople } from '../common/Icons';
16+
import { IconInbox, IconStream, IconPeople, IconPrivateChat } from '../common/Icons';
1717
import OwnAvatar from '../common/OwnAvatar';
1818
import OfflineNotice from '../common/OfflineNotice';
1919
import ProfileScreen from '../account-info/ProfileScreen';
2020
import styles, { BRAND_COLOR, ThemeContext } from '../styles';
2121
import SubscriptionsScreen from '../streams/SubscriptionsScreen';
22+
import UsersScreen from '../users/UsersScreen';
23+
import UsersProfileScreen from '../users/UsersProfileScreen';
2224

2325
export type MainTabsNavigatorParamList = {|
2426
+home: RouteParamsOf<typeof HomeScreen>,
@@ -77,14 +79,22 @@ export default function MainTabsScreen(props: Props): Node {
7779
component={PmConversationsScreen}
7880
options={{
7981
tabBarLabel: 'Private messages',
80-
tabBarIcon: ({ color }) => <IconPeople size={24} color={color} />,
82+
tabBarIcon: ({ color }) => <IconPrivateChat size={24} color={color} />,
8183
tabBarBadge: unreadPmsCount > 0 ? unreadPmsCount : undefined,
8284
tabBarBadgeStyle: {
8385
color: 'white',
8486
backgroundColor: BRAND_COLOR,
8587
},
8688
}}
8789
/>
90+
<Tab.Screen
91+
name="users"
92+
component={UsersProfileScreen}
93+
options={{
94+
tabBarLabel: 'Users',
95+
tabBarIcon: ({ color }) => <IconPeople size={24} color={color} />,
96+
}}
97+
/>
8898
<Tab.Screen
8999
name="profile"
90100
component={ProfileScreen}

src/users/UsersProfileCard.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* @flow strict-local */
2+
3+
import React, { useCallback } from 'react';
4+
import type { Node } from 'react';
5+
6+
import type { UserOrBot } from '../types';
7+
import { useSelector, useDispatch } from '../react-redux';
8+
import UserList from './UserList';
9+
import { getUsers, getPresence } from '../selectors';
10+
import { navigateBack, doNarrow } from '../actions';
11+
import { useNavigation } from '../react-navigation';
12+
import { AccountDetailsScreen } from '../account-info/AccountDetailsScreen';
13+
14+
type Props = $ReadOnly<{|
15+
filter: string,
16+
|}>;
17+
18+
export default function UsersProfileCard(props: Props): Node {
19+
const { filter } = props;
20+
const dispatch = useDispatch();
21+
const users = useSelector(getUsers);
22+
const presences = useSelector(getPresence);
23+
24+
const navigation = useNavigation();
25+
const handleUserNarrow = useCallback(
26+
(user: UserOrBot) => {
27+
navigation.push('account-details', {userId: user.user_id});
28+
},
29+
[navigation],
30+
);
31+
32+
return (
33+
<UserList users={users} filter={filter} presences={presences} onPress={handleUserNarrow} />
34+
);
35+
}

src/users/UsersProfileScreen.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* @flow strict-local */
2+
import React, { useState } from 'react';
3+
import type { Node } from 'react';
4+
import { View } from 'react-native';
5+
import { SafeAreaView } from 'react-native-safe-area-context';
6+
7+
import type { RouteProp } from '../react-navigation';
8+
import type { AppNavigationProp } from '../nav/AppNavigator';
9+
import Screen from '../common/Screen';
10+
import UsersProfileCard from './UsersProfileCard';
11+
12+
type Props = $ReadOnly<{|
13+
navigation: AppNavigationProp<'users'>,
14+
route: op<'users', void>,
15+
|}>;
16+
17+
export default function UsersInfoScreen(props: Props): Node {
18+
return (
19+
<SafeAreaView mode="padding" edges={['top']} style={{ flex: 1 }} scrollEnabled={false}>
20+
<UsersProfileCard filter="" />
21+
</SafeAreaView>
22+
);
23+
}

0 commit comments

Comments
 (0)