1- import React , { useCallback } from 'react' ;
1+ import React , { useCallback , useRef } from 'react' ;
22import { FlatList , StyleSheet , TextInput , TouchableOpacity , View } from 'react-native' ;
33import { Search , useTheme } from 'stream-chat-react-native' ;
44
@@ -41,6 +41,12 @@ const styles = StyleSheet.create({
4141 navigationButton : {
4242 paddingRight : 8 ,
4343 } ,
44+ searchButton : {
45+ alignItems : 'center' ,
46+ justifyContent : 'center' ,
47+ paddingLeft : 8 ,
48+ paddingRight : 4 ,
49+ } ,
4450 userGridItemContainer : { marginHorizontal : 8 , width : 64 } ,
4551} ) ;
4652
@@ -70,6 +76,7 @@ type Props = {
7076
7177export const NewGroupChannelAddMemberScreen : React . FC < Props > = ( { navigation } ) => {
7278 const { chatClient } = useAppContext ( ) ;
79+ const searchInputRef = useRef < TextInput > ( null ) ;
7380
7481 const {
7582 theme : { semantics } ,
@@ -97,6 +104,10 @@ export const NewGroupChannelAddMemberScreen: React.FC<Props> = ({ navigation })
97104 navigation . navigate ( 'NewGroupChannelAssignNameScreen' ) ;
98105 } ;
99106
107+ const focusSearchInput = useCallback ( ( ) => {
108+ searchInputRef . current ?. focus ( ) ;
109+ } , [ ] ) ;
110+
100111 if ( ! chatClient ) {
101112 return null ;
102113 }
@@ -122,12 +133,12 @@ export const NewGroupChannelAddMemberScreen: React.FC<Props> = ({ navigation })
122133 } ,
123134 ] }
124135 >
125- < Search pathFill = { black } />
126136 < TextInput
127137 onChangeText = { onChangeSearchText }
128138 onFocus = { onFocusInput }
129139 placeholder = 'Search'
130140 placeholderTextColor = { grey }
141+ ref = { searchInputRef }
131142 style = { [
132143 styles . inputBox ,
133144 {
@@ -136,6 +147,9 @@ export const NewGroupChannelAddMemberScreen: React.FC<Props> = ({ navigation })
136147 ] }
137148 value = { searchText }
138149 />
150+ < TouchableOpacity hitSlop = { 8 } onPress = { focusSearchInput } style = { styles . searchButton } >
151+ < Search height = { 20 } pathFill = { black } width = { 20 } />
152+ </ TouchableOpacity >
139153 </ View >
140154 < FlatList
141155 data = { selectedUsers }
0 commit comments