Add onSearchCloseRequested prop to react-native-material-ui

This commit is contained in:
Kyle Roach
2018-03-24 08:15:07 -04:00
parent 2e3cfeee51
commit ad2322608d
2 changed files with 27 additions and 1 deletions

View File

@@ -426,6 +426,7 @@ export interface Searchable {
onSearchClosed?(): void;
onSearchPressed?(): void;
onSubmitEditing?(): void;
onSearchCloseRequested?(): void;
}
export interface ToolBarRightElement {

View File

@@ -11,7 +11,8 @@ import {
Checkbox,
Dialog,
DialogDefaultActions,
BottomNavigation
BottomNavigation,
Toolbar
} from 'react-native-material-ui';
const theme = {
@@ -113,3 +114,27 @@ class BottomNavigationExample extends React.Component<null, {active: string}> {
);
}
}
class ToolbarExample extends React.Component<{}, {search: string}> {
state = {
search: ''
};
handleResults(search: string) {
this.setState({ search });
}
render() {
return (
<Toolbar
centerElement="Collections"
searchable={{
autoFocus: true,
placeholder: 'Search',
onChangeText: (text: string) => this.handleResults(text),
onSearchCloseRequested: () => this.handleResults(''),
}}
/>
);
}
}