Clear search results after closing search as reported on issue #113 (#124)

This commit is contained in:
Daniel Alejandro Dominguez Diaz 2018-05-18 15:13:27 -03:00 committed by akinwale
parent 8db8083e32
commit 28c5b01596
3 changed files with 32 additions and 1 deletions

View file

@ -29,6 +29,7 @@ import { makeSelectClientSetting } from '../redux/selectors/settings';
import Feather from 'react-native-vector-icons/Feather'; import Feather from 'react-native-vector-icons/Feather';
import discoverStyle from '../styles/discover'; import discoverStyle from '../styles/discover';
import searchStyle from '../styles/search'; import searchStyle from '../styles/search';
import SearchRightHeaderIcon from "../component/searchRightHeaderIcon";
const discoverStack = StackNavigator({ const discoverStack = StackNavigator({
Discover: { Discover: {
@ -51,7 +52,7 @@ const discoverStack = StackNavigator({
navigationOptions: ({ navigation }) => ({ navigationOptions: ({ navigation }) => ({
drawerLockMode: 'locked-closed', drawerLockMode: 'locked-closed',
headerTitle: <SearchInput style={searchStyle.searchInput} />, headerTitle: <SearchInput style={searchStyle.searchInput} />,
headerRight: <Feather name="x" size={24} style={discoverStyle.rightHeaderIcon} onPress={() => navigation.dispatch(NavigationActions.back())} /> headerRight: <SearchRightHeaderIcon style={discoverStyle.rightHeaderIcon} size={24} navigation={navigation} />
}) })
} }
}, { }, {

View file

@ -0,0 +1,10 @@
import { connect } from 'react-redux';
import SearchRightHeaderIcon from './view';
import { ACTIONS } from 'lbry-redux';
const perform = dispatch => ({
clearQuery: () => dispatch({
type: ACTIONS.HISTORY_NAVIGATE
})
});
export default connect(null, perform)(SearchRightHeaderIcon);

View file

@ -0,0 +1,20 @@
import React from 'react';
import { NavigationActions } from 'react-navigation';
import Feather from "react-native-vector-icons/Feather";
class SearchRightHeaderIcon extends React.PureComponent {
clearAndGoBack() {
const { navigation } = this.props;
this.props.clearQuery();
navigation.dispatch(NavigationActions.back())
}
render() {
const { style } = this.props;
return <Feather name="x" size={24} style={style} onPress={() => this.clearAndGoBack()} />;
}
}
export default SearchRightHeaderIcon;