ViewWallet.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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={1}>{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. <TextView style={styles.walletLabel}>Current Balance:</TextView>
  40. <TextView style={styles.walletBalance}>{wallet.currentBalance}</TextView>
  41. { utils.isNotEmpty(wallet.expiresDate) &&
  42. <TextView style={styles.walletLabel}>Expires {wallet.expiresDate}</TextView>
  43. }
  44. { wallet.walletTypeCode == "credit_wallet" &&
  45. <View style={styles.topupView}>
  46. <Pressable
  47. style={styles.setDefaultView}
  48. onPress={() => toTopupPage()}>
  49. <MaterialCommunityIcons
  50. name="credit-card-plus-outline"
  51. size={18}
  52. color={textButton}/>
  53. <TextView style={styles.defaultText}>{$t("wallet.topUp")}</TextView>
  54. </Pressable>
  55. </View>
  56. }
  57. </View>
  58. );
  59. export default ViewWallet;
  60. const styles = StyleSheet.create({
  61. cardWallet: {
  62. height: 194,
  63. margin: 16,
  64. padding: 16,
  65. borderRadius: 16,
  66. ...ElevationObject(2),
  67. backgroundColor: colorAccent
  68. },
  69. walletName: {
  70. flex: 1,
  71. color: textLight,
  72. fontSize: 22,
  73. fontWeight: 'bold',
  74. paddingRight: 16
  75. },
  76. walletProvider: {
  77. color: textLight,
  78. fontSize: 18,
  79. },
  80. walletLabel: {
  81. color: textLight,
  82. opacity: .9,
  83. fontSize: 13,
  84. paddingTop: 16
  85. },
  86. walletBalance: {
  87. color: textLight,
  88. fontSize: 20,
  89. paddingTop: 4,
  90. fontWeight: 'bold'
  91. },
  92. setDefaultView: {
  93. height: 28,
  94. ...$padding(4, 12),
  95. borderRadius: 16,
  96. alignItems: 'center',
  97. flexDirection: 'row',
  98. ...ElevationObject(2),
  99. backgroundColor: 'rgba(0,0,0,.9)'
  100. },
  101. defaultView: {
  102. height: 28,
  103. ...$padding(4, 12),
  104. borderRadius: 16,
  105. alignItems: 'center',
  106. flexDirection: 'row',
  107. backgroundColor: 'rgba(0,0,0,.5)'
  108. },
  109. defaultText: {
  110. color: textLight,
  111. fontSize: 12,
  112. paddingLeft: 4
  113. },
  114. topupView: {
  115. paddingTop: 16,
  116. flexDirection: 'row'
  117. }
  118. })