Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. ...
  2.  
  3. export default class Toolbar extends Component {
  4. constructor(props, context) {
  5. super(props, context);
  6.  
  7. this.state = { isSearchActive: false, searchValue: '' };
  8. }
  9. onSearchPressed = () => {
  10. this.setState({ isSearchActive: true });
  11. }
  12. onSearchTextChanged = (searchValue) => {
  13. this.setState({ searchValue });
  14. }
  15. onSearchClearPressed = () => {
  16. this.onSearchTextChanged('');
  17. }
  18. onSearchClosed = () => {
  19. this.setState({ isSearchActive: false, searchValue: '' });
  20. }
  21. render() {
  22. const { isSearchActive, searchValue } = this.state;
  23.  
  24. return (
  25. <View style={[styles.container, isSearchActive && { backgroundColor: 'white' }]}>
  26. <View style={styles.statusBar} />
  27. <View style={styles.toolbarContainer}>
  28. <LeftElement
  29. isSearchActive={isSearchActive}
  30. onSearchClose={this.onSearchClosed}
  31. />
  32. <CenterElement
  33. title="Animation"
  34. isSearchActive={isSearchActive}
  35. onSearchTextChange={this.onSearchTextChanged}
  36. searchValue={searchValue}
  37. />
  38. <RightElement
  39. isSearchActive={isSearchActive}
  40. onSearchPress={this.onSearchPressed}
  41. searchValue={searchValue}
  42. onSearchClear={this.onSearchClearPressed}
  43. />
  44. </View>
  45. </View>
  46. );
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement