Guest User

Untitled

a guest
Nov 20th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { StyleSheet, Text, View, TouchableHighlight, Modal, DatePickerIOS } from 'react-native';
  3.  
  4.  
  5.  
  6. export default class Logitem extends Component {
  7.  
  8. constructor(props) {
  9. super(props);
  10. const { logstringdate, bmi, weight, logdate } = this.props;
  11. this.state = {
  12. date: new Date(),
  13. weight: '80'
  14. };
  15. }
  16.  
  17. state = {
  18. selecteddate: '',
  19. selectedweight: '',
  20. showmodal: false
  21.  
  22. }
  23.  
  24. setModalVisible = (visible) => {
  25. this.setState({showmodal: visible});
  26. }
  27.  
  28. onWeightClick = () => {
  29. this.setState({ selecteddate: this.props.logdate, showmodal: true }, () => {
  30.  
  31. console.log('Value in props==>' + this.props.logdate);
  32. console.log('The selecteddate in the state ==> ' + this.state.selecteddate);
  33. });
  34.  
  35. }
  36.  
  37. onDateChange(date) {
  38. this.setState({
  39. date: date
  40. });
  41. }
  42.  
  43.  
  44.  
  45. render() {
  46.  
  47. return (
  48.  
  49. <View style={styles.containerStyle}>
  50. <Modal
  51. animationType="slide"
  52. transparent={false}
  53. visible={this.state.showmodal}
  54. onRequestClose={() => {alert("Modal has been closed.")}}
  55. >
  56. <View style={{marginTop: 22}}>
  57. <DatePickerIOS
  58. date={this.state.date}
  59. mode="date"
  60. onDateChange={(date) => this.onDateChange(date)}
  61. style={{ height: 150, width: 300 }}
  62. />
  63. </View>
  64. </Modal>
  65. <View style={styles.headerContentStyle}>
  66. <Text>{this.props.logstringdate}</Text>
  67. <Text>{this.props.bmi}</Text>
  68. </View>
  69. <View style={styles.thumbnailContainerStyle}>
  70. <Text onPress={this.onWeightClick}>{this.props.weight}</Text>
  71. </View>
  72. </View>
  73. );
  74.  
  75. }
  76. };
  77.  
  78. const styles = {
  79. containerStyle: {
  80. borderWidth: 1,
  81. borderRadius: 2,
  82. borderColor: '#ddd',
  83. borderBottomWidth: 0,
  84. shadowColor: '#000',
  85. shadowOffset: { width: 0, height: 2},
  86. shadowOpacity: 0.1,
  87. shadowRadius: 2,
  88. elevation: 1,
  89. marginLeft: 5,
  90. marginRight: 5,
  91. marginTop:10,
  92. },
  93. thumbnailContainerStyle: {
  94. justifyContent: 'center',
  95. alignItems: 'center',
  96. marginLeft: 10,
  97. marginRight: 10,
  98. flexDirection: 'row'
  99.  
  100. },
  101. headerContentStyle: {
  102. flexDirection: 'column',
  103. justifyContent: 'space-around'
  104. },
  105. };
Add Comment
Please, Sign In to add comment