row.js 1.0 KB

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