Skip to content

Commit a0643fd

Browse files
committed
UserStatusScreen: Move and re-style "clear" button
This doesn't yet change the main behavior of the button when pressed, i.e., we still clear the inputs *and* tell the server that we want to unset the status. Soon, we'll have it match the web app by only clearing the inputs. Then the user can apply the change with the submit button, which we'll rename from "Update" to "Save".
1 parent 254b00f commit a0643fd

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

src/user-statuses/UserStatusScreen.js

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* @flow strict-local */
22
import React, { useState, useContext, useCallback } from 'react';
33
import type { Node } from 'react';
4-
import { FlatList, View } from 'react-native';
5-
import { TranslationContext } from '../boot/TranslationProvider';
6-
import { createStyleSheet } from '../styles';
4+
import { FlatList, View, Pressable } from 'react-native';
75

6+
import { TranslationContext } from '../boot/TranslationProvider';
7+
import { createStyleSheet, BRAND_COLOR, HIGHLIGHT_COLOR } from '../styles';
88
import type { RouteProp } from '../react-navigation';
99
import type { AppNavigationProp } from '../nav/AppNavigator';
1010
import { useSelector } from '../react-redux';
@@ -18,7 +18,7 @@ import ZulipButton from '../common/ZulipButton';
1818
import { getZulipFeatureLevel, getAuth, getOwnUserId } from '../selectors';
1919
import { getUserStatus } from './userStatusesModel';
2020
import type { UserStatus } from '../api/modelTypes';
21-
import { IconCancel, IconDone } from '../common/Icons';
21+
import { Icon, IconDone } from '../common/Icons';
2222
import statusSuggestions from './userStatusTextSuggestions';
2323
import * as api from '../api';
2424

@@ -30,11 +30,18 @@ const styles = createStyleSheet({
3030
statusTextInput: {
3131
flex: 1,
3232
},
33-
buttonsWrapper: {
34-
flexDirection: 'row',
33+
clearButton: {
34+
// Min touch-target size
35+
minWidth: 48,
36+
minHeight: 48,
37+
38+
alignItems: 'center',
39+
justifyContent: 'center',
40+
41+
// To match margin between the emoji and text inputs
42+
marginLeft: 4,
3543
},
3644
button: {
37-
flex: 1,
3845
margin: 8,
3946
},
4047
});
@@ -133,6 +140,13 @@ export default function UserStatusScreen(props: Props): Node {
133140
value={textInputValue}
134141
onChangeText={setTextInputValue}
135142
/>
143+
{(emojiInputValue !== null || textInputValue.length > 0) && (
144+
<Pressable style={styles.clearButton} onPress={handlePressClear}>
145+
{({ pressed }) => (
146+
<Icon name="x" size={24} color={pressed ? HIGHLIGHT_COLOR : BRAND_COLOR} />
147+
)}
148+
</Pressable>
149+
)}
136150
</View>
137151
<FlatList
138152
data={statusSuggestions}
@@ -152,21 +166,12 @@ export default function UserStatusScreen(props: Props): Node {
152166
);
153167
}}
154168
/>
155-
<View style={styles.buttonsWrapper}>
156-
<ZulipButton
157-
style={styles.button}
158-
secondary
159-
text="Clear"
160-
onPress={handlePressClear}
161-
Icon={IconCancel}
162-
/>
163-
<ZulipButton
164-
style={styles.button}
165-
text="Update"
166-
onPress={handlePressUpdate}
167-
Icon={IconDone}
168-
/>
169-
</View>
169+
<ZulipButton
170+
style={styles.button}
171+
text="Update"
172+
onPress={handlePressUpdate}
173+
Icon={IconDone}
174+
/>
170175
</Screen>
171176
);
172177
}

0 commit comments

Comments
 (0)