Add an x button to the search to clear the input
parent
8e22ce8e2a
commit
c7560ae2f7
|
@ -7,6 +7,7 @@ import {
|
||||||
TouchableWithoutFeedback,
|
TouchableWithoutFeedback,
|
||||||
View,
|
View,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
|
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||||
import {ScrollView} from '../com/util/Views'
|
import {ScrollView} from '../com/util/Views'
|
||||||
import {observer} from 'mobx-react-lite'
|
import {observer} from 'mobx-react-lite'
|
||||||
import {UserAvatar} from '../com/util/UserAvatar'
|
import {UserAvatar} from '../com/util/UserAvatar'
|
||||||
|
@ -78,6 +79,9 @@ export const Search = observer(({navIdx, visible, params}: ScreenParams) => {
|
||||||
autocompleteView.setActive(false)
|
autocompleteView.setActive(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const onPressClearQuery = () => {
|
||||||
|
setQuery('')
|
||||||
|
}
|
||||||
const onPressCancelSearch = () => {
|
const onPressCancelSearch = () => {
|
||||||
setQuery('')
|
setQuery('')
|
||||||
autocompleteView.setActive(false)
|
autocompleteView.setActive(false)
|
||||||
|
@ -127,6 +131,11 @@ export const Search = observer(({navIdx, visible, params}: ScreenParams) => {
|
||||||
onBlur={() => setIsInputFocused(false)}
|
onBlur={() => setIsInputFocused(false)}
|
||||||
onChangeText={onChangeQuery}
|
onChangeText={onChangeQuery}
|
||||||
/>
|
/>
|
||||||
|
{query ? (
|
||||||
|
<TouchableOpacity onPress={onPressClearQuery}>
|
||||||
|
<FontAwesomeIcon icon="xmark" size={16} style={pal.textLight} />
|
||||||
|
</TouchableOpacity>
|
||||||
|
) : undefined}
|
||||||
</View>
|
</View>
|
||||||
{query || isInputFocused ? (
|
{query || isInputFocused ? (
|
||||||
<View style={styles.headerCancelBtn}>
|
<View style={styles.headerCancelBtn}>
|
||||||
|
|
Loading…
Reference in New Issue