footer.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. <Text>{this.props.count} count</Text>
  34. <View style={styles.filters}>
  35. <TouchableOpacity
  36. onPress={() => this.props.onFilter('ALL')}
  37. style={[styles.filter, filter === 'ALL' && styles.selected]}>
  38. <Text>All</Text>
  39. </TouchableOpacity>
  40. <TouchableOpacity
  41. onPress={() => this.props.onFilter('ACTIVE')}
  42. style={[styles.filter, filter === 'ACTIVE' && styles.selected]}>
  43. <Text>Active</Text>
  44. </TouchableOpacity>
  45. <TouchableOpacity
  46. onPress={() => this.props.onFilter('COMPLETED')}
  47. style={[styles.filter, filter === 'COMPLETED' && styles.selected]}>
  48. <Text>Completed</Text>
  49. </TouchableOpacity>
  50. </View>
  51. </View>
  52. );
  53. }
  54. }
  55. Footer.propTypes = {
  56. count: React.PropTypes.number,
  57. filter: React.PropTypes.string,
  58. onFilter: React.PropTypes.func
  59. };
  60. export default Footer;