ViewWallet.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 TextView from '../../components/TextView';
  10. import utils from '../../utils/utils';
  11. import { toTopupPage } from '../payment/PaymentConfig';
  12. const ViewWallet = ({
  13. wallet,
  14. setDefault
  15. }) => (
  16. <View style={styles.cardWallet}>
  17. <View style={ui.flex}>
  18. <TextView style={styles.walletName} numberOfLines={2}>{wallet.walletTypeName}</TextView>
  19. { wallet.defaultPaymentMethod
  20. ? <View style={styles.defaultView}>
  21. <MaterialCommunityIcons
  22. name="credit-card-check-outline"
  23. size={18}
  24. color={textButton}/>
  25. <TextView style={styles.defaultText}>Default</TextView>
  26. </View>
  27. : <Pressable
  28. style={styles.setDefaultView}
  29. onPress={setDefault}>
  30. <MaterialCommunityIcons
  31. name="credit-card-edit-outline"
  32. size={18}
  33. color={textButton}/>
  34. <TextView style={styles.defaultText}>Set Default</TextView>
  35. </Pressable>
  36. }
  37. </View>
  38. <TextView style={styles.walletProvider}>{wallet.walletPrincipalName}</TextView>
  39. { wallet?.walletTypeCode.indexOf("pay_per_use") >= 0
  40. ? <TextView style={styles.walletLabel}>Pre-Auth Amount:</TextView>
  41. : <TextView style={styles.walletLabel}>Current Balance:</TextView>
  42. }
  43. <TextView style={styles.walletBalance}>{wallet.currentBalance}</TextView>
  44. { utils.isNotEmpty(wallet.expiresDate) &&
  45. <TextView style={styles.walletLabel}>Expires {wallet.expiresDate}</TextView>
  46. }
  47. { wallet.walletTypeCode == "credit_wallet" &&
  48. <View style={styles.topupView}>
  49. <Pressable
  50. style={styles.setDefaultView}
  51. onPress={() => toTopupPage()}>
  52. <MaterialCommunityIcons
  53. name="credit-card-plus-outline"
  54. size={18}
  55. color={textButton}/>
  56. <TextView style={styles.defaultText}>{$t("wallet.topUp")}</TextView>
  57. </Pressable>
  58. </View>
  59. }
  60. </View>
  61. );
  62. export default ViewWallet;
  63. const styles = StyleSheet.create({
  64. cardWallet: {
  65. height: 220,
  66. margin: 16,
  67. padding: 16,
  68. borderRadius: 16,
  69. ...ElevationObject(2),
  70. backgroundColor: colorPrimary
  71. },
  72. walletName: {
  73. flex: 1,
  74. color: textLight,
  75. fontSize: 28,
  76. fontWeight: 'bold',
  77. paddingRight: 16
  78. },
  79. walletProvider: {
  80. color: textLight,
  81. fontSize: 22,
  82. },
  83. walletLabel: {
  84. color: textLight,
  85. opacity: .9,
  86. fontSize: 16,
  87. paddingTop: 16
  88. },
  89. walletBalance: {
  90. color: textLight,
  91. fontSize: 24,
  92. paddingTop: 4,
  93. fontWeight: 'bold'
  94. },
  95. setDefaultView: {
  96. height: 28,
  97. ...$padding(4, 12),
  98. borderRadius: 16,
  99. alignItems: 'center',
  100. flexDirection: 'row',
  101. ...ElevationObject(2),
  102. backgroundColor: 'rgba(0,0,0,.9)'
  103. },
  104. defaultView: {
  105. height: 28,
  106. ...$padding(4, 12),
  107. borderRadius: 16,
  108. alignItems: 'center',
  109. flexDirection: 'row',
  110. backgroundColor: 'rgba(0,0,0,.5)'
  111. },
  112. defaultText: {
  113. color: textLight,
  114. fontSize: 13,
  115. paddingLeft: 4
  116. },
  117. topupView: {
  118. paddingTop: 16,
  119. flexDirection: 'row'
  120. }
  121. })