footer.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import React, { Component } from 'react';
  2. import {
  3. StyleSheet,
  4. Text,
  5. TouchableOpacity,
  6. View
  7. } from 'react-native';
  8. const styles = StyleSheet.create({
  9. container: {
  10. alignItems: "center",
  11. flexDirection: "row",
  12. justifyContent: "space-between",
  13. padding: 16
  14. },
  15. filter: {
  16. borderColor: "transparent",
  17. borderRadius: 5,
  18. borderWidth: 1,
  19. padding: 8
  20. },
  21. filters: {
  22. flexDirection: "row"
  23. },
  24. selected: {
  25. borderColor: "rgba(175, 47, 47, 0.2)"
  26. }
  27. });
  28. class Footer extends Component {
  29. render() {
  30. const { filter } = this.props;
  31. return (
  32. <View style={styles.container}>
  33. <View style={styles.filters}>
  34. <TouchableOpacity
  35. onPress={() => this.props.onFilter('ALL')}
  36. style={[styles.filter, filter === 'ALL' && styles.selected]}>
  37. <Text>All</Text>
  38. </TouchableOpacity>
  39. <TouchableOpacity
  40. onPress={() => this.props.onFilter('ACTIVE')}
  41. style={[styles.filter, filter === 'ACTIVE' && styles.selected]}>
  42. <Text>Active</Text>
  43. </TouchableOpacity>
  44. <TouchableOpacity
  45. onPress={() => this.props.onFilter('COMPLETED')}
  46. style={[styles.filter, filter === 'COMPLETED' && styles.selected]}>
  47. <Text>Completed</Text>
  48. </TouchableOpacity>
  49. </View>
  50. </View>
  51. );
  52. }
  53. }
  54. Footer.propTypes = {
  55. filter: React.PropTypes.string,
  56. onFilter: React.PropTypes.func
  57. };
  58. export default Footer;