Guest User

Untitled

a guest
Dec 13th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.62 KB | None | 0 0
  1. import React, { PureComponent } from 'react'
  2. import { View } from 'react-native'
  3. import { connect } from 'react-redux'
  4. import { shape, number } from 'prop-types'
  5. import {
  6. Header,
  7. Balance,
  8. Button,
  9. SimpleUserCard,
  10. SelectAmount,
  11. SelectAmountCell,
  12. TopUpCell
  13. } from '../../../components/common'
  14. import { navigationType } from '../../../prop-types'
  15. import { H } from '../../../config/constants'
  16. import {
  17. WHITE,
  18. WHITE_SMOKE
  19. } from '../../../styles/colors'
  20.  
  21. import { goBack, onScreen, _onChangeState } from '../../../config/helpers'
  22.  
  23. class TopUpBalance extends PureComponent {
  24. state = {
  25. onCheck: true,
  26. disable: false,
  27. one: false,
  28. two: false,
  29. three: false,
  30. four: false,
  31. five: false,
  32. six: false
  33. }
  34.  
  35. _onChangeText = () => {}
  36.  
  37. render() {
  38. const { disable, onCheck, one, two, three, four, five, six } = this.state
  39. const { main, credit } = this.props.user.data.account
  40. return (
  41. <View>
  42. <Header
  43. first="Top Up Balance"
  44. iconLeft="arrow-left"
  45. colorLeft={WHITE}
  46. onPressLeft={this._onGoBack()}
  47. />
  48. <Balance first="Your Balance" amount={main + credit} />
  49. <View style={{ height: H - 105, backgroundColor: WHITE_SMOKE }}>
  50. <SimpleUserCard
  51. first={'081318866101'}
  52. second={'Richie Maryadi'}
  53. />
  54. <SelectAmount
  55. value={''}
  56. onChangeText={this._onChangeText}
  57. onCheck={onCheck}
  58. >
  59. <SelectAmountCell>
  60. <TopUpCell
  61. amount={50000}
  62. onCheck={one}
  63. onPress={this._onChangeState({ ...this.state, one: true, two: false, three: false, four: false, five: false, six: false })}
  64. />
  65. <TopUpCell
  66. amount={100000}
  67. onCheck={two}
  68. left={10}
  69. onPress={this._onChangeState({ ...this.state, one: false, two: true, three: false, four: false, five: false, six: false })}
  70. />
  71. <TopUpCell
  72. amount={200000}
  73. onCheck={three}
  74. left={10}
  75. onPress={this._onChangeState({ ...this.state, one: false, two: false, three: true, four: false, five: false, six: false })}
  76. />
  77. </SelectAmountCell>
  78. <SelectAmountCell>
  79. <TopUpCell
  80. amount={300000}
  81. onCheck={four}
  82. onPress={this._onChangeState({ ...this.state, one: false, two: false, three: false, four: true, five: false, six: false })}
  83. />
  84. <TopUpCell
  85. amount={500000}
  86. onCheck={five}
  87. left={10}
  88. onPress={this._onChangeState({ ...this.state, one: false, two: false, three: false, four: false, five: true, six: false })}
  89. />
  90. <TopUpCell
  91. amount={1000000}
  92. onCheck={six}
  93. left={10}
  94. onPress={this._onChangeState({ ...this.state, one: false, two: false, three: false, four: false, five: false, six: true })}
  95. />
  96. </SelectAmountCell>
  97. </SelectAmount>
  98. <View style={{ position: 'absolute', bottom: 0, width: '100%' }}>
  99. <Button disable={disable} first="Next" />
  100. </View>
  101. </View>
  102. </View>
  103. )
  104. }
  105. }
  106.  
  107. TopUpBalance.propTypes = {
  108. navigation: navigationType.isRequired,
  109. user: shape({
  110. data: shape({
  111. account: shape({
  112. main: number,
  113. credit: number
  114. })
  115. })
  116. })
  117. }
  118.  
  119. const mapStateToProps = ({ user }) => ({
  120. user
  121. })
  122.  
  123. export default connect(mapStateToProps, null)(TopUpBalance)
Add Comment
Please, Sign In to add comment