row.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import React, { Component } from "react";
  2. import {
  3. StyleSheet,
  4. Switch,
  5. Text,
  6. TouchableOpacity,
  7. View
  8. } from "react-native";
  9. const styles = StyleSheet.create({
  10. complete: {
  11. textDecorationLine: "line-through"
  12. },
  13. container: {
  14. alignItems: "flex-start",
  15. flexDirection: "row",
  16. justifyContent: "space-between",
  17. padding: 10
  18. },
  19. destroy: {
  20. color: "#cc9a9a",
  21. fontSize: 20
  22. },
  23. text: {
  24. color: "#4d4d4d",
  25. fontSize: 24
  26. },
  27. textWrap: {
  28. flex: 1,
  29. marginHorizontal: 10
  30. }
  31. });
  32. class Row extends Component {
  33. render() {
  34. // console.log("Row.render", this.props);
  35. const { complete } = this.props;
  36. return (
  37. <View style={styles.container}>
  38. <Switch
  39. value={complete}
  40. onValueChange={this.props.onComplete}
  41. />
  42. <View style={styles.textWrap}>
  43. <Text style={[styles.text, complete && styles.complete]}>{this.props.text}</Text>
  44. </View>
  45. <TouchableOpacity onPress={this.props.onRemove}>
  46. <Text style={styles.destroy}>X</Text>
  47. </TouchableOpacity>
  48. </View>
  49. );
  50. }
  51. }
  52. Row.propTypes = {
  53. complete: React.PropTypes.bool,
  54. onComplete: React.PropTypes.func,
  55. onRemove: React.PropTypes.func,
  56. text: React.PropTypes.string
  57. };
  58. export default Row;