This commit is contained in:
parent
8db8083e32
commit
28c5b01596
3 changed files with 32 additions and 1 deletions
|
@ -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} />
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
|
10
app/src/component/searchRightHeaderIcon/index.js
Normal file
10
app/src/component/searchRightHeaderIcon/index.js
Normal 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);
|
20
app/src/component/searchRightHeaderIcon/view.js
Normal file
20
app/src/component/searchRightHeaderIcon/view.js
Normal 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;
|
Loading…
Reference in a new issue