ViewWallet.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /**
  2. * 钱包卡片组件
  3. * @邠心vbe on 2025/01/17
  4. */
  5. import React from 'react';
  6. import { Pressable, StyleSheet } from 'react-native';
  7. import { View } from 'react-native';
  8. import { ElevationObject } from '../../components/Button';
  9. import Dialog from '../../components/Dialog';
  10. import TextView from '../../components/TextView';
  11. import utils from '../../utils/utils';
  12. import { toTopupPage } from '../payment/PaymentConfig';
  13. const ViewWallet = ({
  14. wallet,
  15. setDefault
  16. }) => {
  17. const dialogText = "A temporary hold of {mm} is placed for standard sessions. For sites with idle fees, an additional hold of the Idle Fee Cap of the site (e.g. S$30.00) may apply."
  18. return (
  19. <View style={styles.cardWallet}>
  20. <View style={ui.flex}>
  21. <TextView style={styles.walletName} numberOfLines={2}>{wallet.walletTypeName}</TextView>
  22. { wallet.defaultPaymentMethod
  23. ? <View style={styles.defaultView}>
  24. <MaterialCommunityIcons
  25. name="credit-card-check-outline"
  26. size={18}
  27. color={textButton}/>
  28. <TextView style={styles.defaultText}>Default</TextView>
  29. </View>
  30. : <Pressable
  31. style={styles.setDefaultView}
  32. onPress={setDefault}>
  33. <MaterialCommunityIcons
  34. name="credit-card-edit-outline"
  35. size={18}
  36. color={textButton}/>
  37. <TextView style={styles.defaultText}>Set Default</TextView>
  38. </Pressable>
  39. }
  40. </View>
  41. <TextView style={styles.walletProvider}>{wallet.walletPrincipalName}</TextView>
  42. { wallet?.walletTypeCode.indexOf("pay_per_use") >= 0
  43. ? <TextView style={styles.walletLabel}>Pre-Auth Amount:</TextView>
  44. : <TextView style={styles.walletLabel}>Current Balance:</TextView>
  45. }
  46. <View style={ui.flexc}>
  47. <TextView style={styles.walletBalance}>{wallet.currentBalance}</TextView>
  48. { wallet?.walletTypeCode.indexOf("pay_per_use") >= 0 &&
  49. <Pressable
  50. style={styles.walletBalanceInfo}
  51. onPress={() => {
  52. let msg = dialogText.replace("{mm}", wallet.currentBalance);
  53. Dialog.showResultDialog(msg, "OK", null);
  54. }}>
  55. <MaterialCommunityIcons
  56. name="information-outline"
  57. size={18}
  58. color={textButton}/>
  59. </Pressable>
  60. }
  61. </View>
  62. { utils.isNotEmpty(wallet.expiresDate) &&
  63. <TextView style={styles.walletLabel}>Expires {wallet.expiresDate}</TextView>
  64. }
  65. { wallet.walletTypeCode == "credit_wallet" &&
  66. <View style={styles.topupView}>
  67. <Pressable
  68. style={styles.setDefaultView}
  69. onPress={() => toTopupPage()}>
  70. <MaterialCommunityIcons
  71. name="credit-card-plus-outline"
  72. size={18}
  73. color={textButton}/>
  74. <TextView style={styles.defaultText}>{$t("wallet.topUp")}</TextView>
  75. </Pressable>
  76. </View>
  77. }
  78. </View>
  79. );
  80. }
  81. export default ViewWallet;
  82. const styles = StyleSheet.create({
  83. cardWallet: {
  84. height: 230,
  85. margin: 16,
  86. padding: 16,
  87. borderRadius: 16,
  88. ...ElevationObject(2),
  89. backgroundColor: colorPrimary
  90. },
  91. walletName: {
  92. flex: 1,
  93. color: textLight,
  94. fontSize: 28,
  95. fontWeight: 'bold',
  96. paddingRight: 16
  97. },
  98. walletProvider: {
  99. color: textLight,
  100. fontSize: 22,
  101. },
  102. walletLabel: {
  103. color: textLight,
  104. opacity: .9,
  105. fontSize: 16,
  106. paddingTop: 16
  107. },
  108. walletBalance: {
  109. color: textLight,
  110. fontSize: 24,
  111. paddingTop: 4,
  112. fontWeight: 'bold'
  113. },
  114. walletBalanceInfo: {
  115. width: 24,
  116. height: 20,
  117. opacity: .8,
  118. marginTop: 4,
  119. marginLeft: 4,
  120. alignItems: "center"
  121. },
  122. setDefaultView: {
  123. height: 28,
  124. ...$padding(4, 12),
  125. borderRadius: 16,
  126. alignItems: 'center',
  127. flexDirection: 'row',
  128. ...ElevationObject(2),
  129. backgroundColor: 'rgba(0,0,0,.9)'
  130. },
  131. defaultView: {
  132. height: 28,
  133. ...$padding(4, 12),
  134. borderRadius: 16,
  135. alignItems: 'center',
  136. flexDirection: 'row',
  137. backgroundColor: 'rgba(0,0,0,.5)'
  138. },
  139. defaultText: {
  140. color: textLight,
  141. fontSize: 13,
  142. paddingLeft: 4
  143. },
  144. topupView: {
  145. paddingTop: 16,
  146. flexDirection: 'row'
  147. }
  148. })