Advertisement
gust94

address container

May 16th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. // ko mike address container
  2. import React, { Component } from 'react';
  3. import {
  4. Platform,
  5. StyleSheet,
  6. Text,
  7. SafeAreaView,
  8. ScrollView,
  9. TouchableOpacity,
  10. View,
  11. Image,
  12. TextInput,
  13. ImageBackground,
  14. } from 'react-native';
  15. import {validateAddressCurrency, dynamicText} from '../common'
  16.  
  17.  
  18. export default class AddressContainer extends Component {
  19. state = {
  20. refundAddress: '',
  21. refundTag: '',
  22. hasInputBoolean: false
  23. }
  24. render() {
  25.  
  26. const {valueCurrency, name, isRefund} = this.props;
  27. const {refundAddress, refundTag, hasInputBoolean} = this.state;
  28.  
  29. const refundAddressValid = validateAddressCurrency(valueCurrency, refundAddress);
  30.  
  31. let isXrp = name === "XRP" ? true : false
  32. let receivePlaceHolder = isXrp ? 'Ripple address' : 'Etherium address'
  33. console.log(`refundAddressValid : ${refundAddressValid}`)
  34. console.log(`hasInputBoolean : ${hasInputBoolean}`)
  35.  
  36. return (
  37. <View style={styles.inputValueContainer} >
  38. {isXrp && <View style={{ flex: 1, flexDirection: 'column' }}>
  39. {!refundAddressValid && hasInputBoolean &&
  40. <Text style={styles.errorLabel}>
  41. {"ADDRESS IS INVALID"}
  42. </Text>}
  43. <TextInput style={styles.inputValueTextField}
  44. underlineColorAndroid={'transparent'}
  45. value={`${refundAddress}`}
  46. placeholder = { isRefund ? 'Refund address' : receivePlaceHolder}
  47. onChangeText={(refundAddress) => {
  48. this.setState({ refundAddress, hasInputBoolean: true })
  49. }}
  50. />
  51. {refundAddressValid && <TextInput style={styles.inputValueTextField}
  52. underlineColorAndroid={'transparent'}
  53. value={`${refundTag}`}
  54. placeholder = {'Tag'}
  55. onChangeText={(refundTag) => {
  56. this.setState({ refundTag })
  57. }}
  58. />}
  59. </View>}
  60.  
  61. {!isXrp && <View style={{ flex: 1, flexDirection: 'column' }}>
  62. {!refundAddressValid && hasInputBoolean &&
  63. <Text style={styles.errorLabel}>
  64. {"ADDRESS IS INVALID"}
  65. </Text>}
  66. <TextInput style={styles.inputValueTextField}
  67. underlineColorAndroid={'transparent'}
  68. value={`${refundAddress}`}
  69. placeholder = { isRefund ? 'Refund address' : receivePlaceHolder}
  70. onChangeText={(refundAddress) => {
  71. this.setState({ refundAddress, hasInputBoolean: true })
  72. }}
  73. />
  74. </View>}
  75. </View>
  76. )
  77. }
  78. }
  79.  
  80. const styles = StyleSheet.create({
  81. inputValueContainer: {
  82. backgroundColor: '#fff',
  83. margin: 16,
  84. borderRadius: 4,
  85. height: 70,
  86. borderWidth: 1,
  87. borderColor: '#4F4F4F',
  88. overflow: 'hidden',
  89. flexDirection: 'row'
  90. },
  91. inputValueTextField: {
  92. marginLeft: 4,
  93. marginRight: 4,
  94. height: 30,
  95. fontSize: 12,
  96. fontWeight: 'normal',
  97. textAlign: 'left',
  98. color: '#000',
  99. },
  100. errorLabel: {
  101. marginTop: 4,
  102. marginLeft: 4,
  103. marginRight: 4,
  104. fontSize: 8,
  105. fontWeight: 'normal',
  106. textAlign: 'left',
  107. color: 'rgb(244,67,54)',
  108. }
  109. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement