BankCard.js 2.3 KB

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