BankCard.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import React from "react";
  2. import { StyleSheet } from "react-native";
  3. import {
  4. Card,
  5. Text,
  6. Layout,
  7. Avatar,
  8. Icon,
  9. Radio,
  10. } from "@ui-kitten/components";
  11. const styles = StyleSheet.create({
  12. main: {
  13. flexDirection: "row",
  14. alignItems: "center",
  15. backgroundColor: "transparent",
  16. },
  17. avatar: {
  18. width: 33,
  19. height: 33,
  20. backgroundColor: "#eee",
  21. },
  22. center: {
  23. flex: 1,
  24. marginLeft: 14,
  25. backgroundColor: "transparent",
  26. },
  27. text2: {
  28. paddingTop: 5,
  29. },
  30. code: {
  31. alignSelf: "flex-start",
  32. },
  33. icon: {
  34. width: 20,
  35. position: "absolute",
  36. right: 0,
  37. top: "50%",
  38. marginTop: -10,
  39. },
  40. });
  41. export default function BankCard(props) {
  42. const { info, disabled, pressEvent, type, selectId } = props;
  43. const { id, avatar, bankName, cardNo } = info || {};
  44. const checked = React.useMemo(() => {
  45. return selectId === id;
  46. }, [selectId]);
  47. return (
  48. <Card appearance='walletCard' disabled={disabled} onPress={pressEvent}>
  49. <Layout style={styles.main}>
  50. <Avatar
  51. style={styles.avatar}
  52. source={{
  53. uri: avatar,
  54. }}
  55. />
  56. <Layout style={styles.center}>
  57. <Text category='s1'>{bankName}</Text>
  58. <Text category='h1' style={styles.text2}>
  59. {cardNo}
  60. </Text>
  61. </Layout>
  62. {type === "choose" && <Radio checked={checked} />}
  63. {type === "edit" && !disabled && (
  64. <Icon
  65. name='arrow-ios-forward'
  66. fill='#C9C9C9'
  67. style={styles.icon}
  68. />
  69. )}
  70. </Layout>
  71. </Card>
  72. );
  73. }