MoneyRecord.js 1.8 KB

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