footer.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. <TouchableOpacity onPress={this.props.onClearComplete}>
  52. <Text>Clear completed</Text>
  53. </TouchableOpacity>
  54. </View>
  55. );
  56. }
  57. }
  58. Footer.propTypes = {
  59. count: React.PropTypes.number,
  60. filter: React.PropTypes.string,
  61. onClearComplete: React.PropTypes.func,
  62. onFilter: React.PropTypes.func
  63. };
  64. export default Footer;