1
1
/* @flow strict-local */
2
2
import React , { useState , useContext , useCallback } from 'react' ;
3
3
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' ;
7
5
6
+ import { TranslationContext } from '../boot/TranslationProvider' ;
7
+ import { createStyleSheet , BRAND_COLOR , HIGHLIGHT_COLOR } from '../styles' ;
8
8
import type { RouteProp } from '../react-navigation' ;
9
9
import type { AppNavigationProp } from '../nav/AppNavigator' ;
10
10
import { useSelector } from '../react-redux' ;
@@ -18,7 +18,7 @@ import ZulipButton from '../common/ZulipButton';
18
18
import { getZulipFeatureLevel , getAuth , getOwnUserId } from '../selectors' ;
19
19
import { getUserStatus } from './userStatusesModel' ;
20
20
import type { UserStatus } from '../api/modelTypes' ;
21
- import { IconCancel , IconDone } from '../common/Icons' ;
21
+ import { Icon , IconDone } from '../common/Icons' ;
22
22
import statusSuggestions from './userStatusTextSuggestions' ;
23
23
import * as api from '../api' ;
24
24
@@ -30,11 +30,18 @@ const styles = createStyleSheet({
30
30
statusTextInput : {
31
31
flex : 1 ,
32
32
} ,
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 ,
35
43
} ,
36
44
button : {
37
- flex : 1 ,
38
45
margin : 8 ,
39
46
} ,
40
47
} ) ;
@@ -133,6 +140,13 @@ export default function UserStatusScreen(props: Props): Node {
133
140
value = { textInputValue }
134
141
onChangeText = { setTextInputValue }
135
142
/>
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
+ ) }
136
150
</ View >
137
151
< FlatList
138
152
data = { statusSuggestions }
@@ -152,21 +166,12 @@ export default function UserStatusScreen(props: Props): Node {
152
166
) ;
153
167
} }
154
168
/>
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
+ />
170
175
</ Screen >
171
176
) ;
172
177
}
0 commit comments