Skip to content

Commit ce8cca3

Browse files
chrisbobbegnprice
authored andcommitted
ProfileScreen: Put status and set-your-status link in the same row
Before this, we were separating the line that showed the user's status from the line that led to the UI to change the status (a button linking to UserStatusScreen) -- with the "Invisible mode" switch in between. Now, it's a single NestedNavRow that shows the emoji and status text, if any. Tapping it leads to the UserStatusScreen. Also reword the user-status screen's title a bit to avoid the awkward user-facing word "user": #5665 (comment)
1 parent b21cc41 commit ce8cca3

File tree

4 files changed

+45
-37
lines changed

4 files changed

+45
-37
lines changed

src/account-info/AccountDetails.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const componentStyles = createStyleSheet({
4444
type Props = $ReadOnly<{|
4545
user: UserOrBot,
4646
showEmail: boolean,
47+
showStatus: boolean,
4748
|}>;
4849

4950
const getRoleText = (role: Role): LocalizableText => {
@@ -62,7 +63,7 @@ const getRoleText = (role: Role): LocalizableText => {
6263
};
6364

6465
export default function AccountDetails(props: Props): Node {
65-
const { user, showEmail } = props;
66+
const { user, showEmail, showStatus } = props;
6667

6768
const userStatusText = useSelector(state => getUserStatus(state, props.user.user_id).status_text);
6869
const userStatusEmoji = useSelector(
@@ -112,22 +113,24 @@ export default function AccountDetails(props: Props): Node {
112113
</View>
113114
)
114115
}
115-
<View style={componentStyles.statusWrapper}>
116-
{userStatusEmoji && (
117-
<Emoji
118-
code={userStatusEmoji.emoji_code}
119-
type={emojiTypeFromReactionType(userStatusEmoji.reaction_type)}
120-
size={24}
121-
/>
122-
)}
123-
{userStatusEmoji && userStatusText !== null && <View style={{ width: 2 }} />}
124-
{userStatusText !== null && (
125-
<ZulipText
126-
style={[styles.largerText, componentStyles.statusText]}
127-
text={userStatusText}
128-
/>
129-
)}
130-
</View>
116+
{showStatus && (
117+
<View style={componentStyles.statusWrapper}>
118+
{userStatusEmoji && (
119+
<Emoji
120+
code={userStatusEmoji.emoji_code}
121+
type={emojiTypeFromReactionType(userStatusEmoji.reaction_type)}
122+
size={24}
123+
/>
124+
)}
125+
{userStatusEmoji && userStatusText !== null && <View style={{ width: 2 }} />}
126+
{userStatusText !== null && (
127+
<ZulipText
128+
style={[styles.largerText, componentStyles.statusText]}
129+
text={userStatusText}
130+
/>
131+
)}
132+
</View>
133+
)}
131134
</ComponentList>
132135
);
133136
}

src/account-info/AccountDetailsScreen.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default function AccountDetailsScreen(props: Props): Node {
7474

7575
return (
7676
<Screen title={title}>
77-
<AccountDetails user={user} showEmail />
77+
<AccountDetails user={user} showEmail showStatus />
7878
<View style={styles.itemWrapper}>
7979
<ActivityText style={globalStyles.largerText} user={user} />
8080
</View>

src/account-info/ProfileScreen.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import { getUserStatus } from '../user-statuses/userStatusesModel';
2424
import SwitchRow from '../common/SwitchRow';
2525
import * as api from '../api';
2626
import { identityOfAccount } from '../account/accountMisc';
27+
import NestedNavRow from '../common/NestedNavRow';
28+
import { emojiTypeFromReactionType } from '../emoji/data';
2729

2830
const styles = createStyleSheet({
2931
buttonRow: {
@@ -36,20 +38,6 @@ const styles = createStyleSheet({
3638
},
3739
});
3840

39-
function SetStatusButton(props: {||}) {
40-
const navigation = useNavigation();
41-
return (
42-
<ZulipButton
43-
style={styles.button}
44-
secondary
45-
text="Set a status"
46-
onPress={() => {
47-
navigation.push('user-status');
48-
}}
49-
/>
50-
);
51-
}
52-
5341
function ProfileButton(props: {| +ownUserId: UserId |}) {
5442
const navigation = useNavigation();
5543
return (
@@ -130,18 +118,39 @@ type Props = $ReadOnly<{|
130118
* The profile/settings/account screen we offer among the main tabs of the app.
131119
*/
132120
export default function ProfileScreen(props: Props): Node {
121+
const navigation = useNavigation();
122+
133123
const auth = useSelector(getAuth);
134124
const zulipFeatureLevel = useSelector(getZulipFeatureLevel);
135125
const ownUser = useSelector(getOwnUser);
136126
const ownUserId = useSelector(getOwnUserId);
137127
const presenceEnabled = useSelector(state => getRealm(state).presenceEnabled);
138128
const awayStatus = useSelector(state => getUserStatus(state, ownUserId).away);
129+
const userStatus = useSelector(state => getUserStatus(state, ownUserId));
130+
131+
const { status_emoji, status_text } = userStatus;
139132

140133
return (
141134
<SafeAreaView mode="padding" edges={['top']} style={{ flex: 1 }}>
142135
<OfflineNoticePlaceholder />
143136
<ScrollView>
144-
<AccountDetails user={ownUser} showEmail={false} />
137+
<AccountDetails user={ownUser} showEmail={false} showStatus={false} />
138+
<NestedNavRow
139+
leftElement={
140+
status_emoji != null
141+
? {
142+
type: 'emoji',
143+
emojiCode: status_emoji.emoji_code,
144+
emojiType: emojiTypeFromReactionType(status_emoji.reaction_type),
145+
}
146+
: undefined
147+
}
148+
title="Set your status"
149+
subtitle={status_text != null ? { text: '{_}', values: { _: status_text } } : undefined}
150+
onPress={() => {
151+
navigation.push('user-status');
152+
}}
153+
/>
145154
{zulipFeatureLevel >= 148 ? (
146155
<SwitchRow
147156
label="Invisible mode"
@@ -162,9 +171,6 @@ export default function ProfileScreen(props: Props): Node {
162171
}}
163172
/>
164173
)}
165-
<View style={styles.buttonRow}>
166-
<SetStatusButton />
167-
</View>
168174
<View style={styles.buttonRow}>
169175
<ProfileButton ownUserId={ownUser.user_id} />
170176
</View>

static/translations/messages_en.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@
334334
"See who reacted": "See who reacted",
335335
"Muted user": "Muted user",
336336
"Only organization admins are allowed to post to this stream.": "Only organization admins are allowed to post to this stream.",
337-
"Set a status": "Set a status",
338337
"Connecting...": "Connecting...",
339338
"Set your status": "Set your status",
340339
"Muted": "Muted",

0 commit comments

Comments
 (0)