GoodsCardVertical.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import React from "react";
  2. import { StyleSheet, Dimensions } from "react-native";
  3. import {
  4. Modal,
  5. Card,
  6. Text,
  7. Button,
  8. Layout,
  9. Avatar,
  10. } from "@ui-kitten/components";
  11. import { useModel } from "flooks";
  12. const width = Dimensions.get("window").width;
  13. export default function GoodsCard(props) {
  14. const { add, remove } = useModel("wordsModel");
  15. const { info } = props;
  16. const { id, img, name, introduction, totalSales, discountAmount, amount } =
  17. info || {};
  18. return (
  19. <Card
  20. style={styles.card}
  21. disabled={true}
  22. appearance='goodsCard'
  23. direction='vertical'
  24. >
  25. {!!id ? (
  26. <Layout style={styles.layout}>
  27. <Avatar
  28. style={styles.avatar}
  29. shape='square'
  30. source={{
  31. uri: img,
  32. }}
  33. />
  34. <Layout style={styles.main}>
  35. <Text
  36. category='s1'
  37. ellipsizeMode='tail'
  38. numberOfLines={1}
  39. >
  40. {name}
  41. </Text>
  42. <Text category='c1' status='info' style={styles.sub}>
  43. 月售 {totalSales}
  44. </Text>
  45. <Text category='h6' status='danger'>
  46. ¥{discountAmount}{" "}
  47. <Text
  48. category='label'
  49. status='info'
  50. style={{ textDecorationLine: "line-through" }}
  51. >
  52. ¥{amount}
  53. </Text>
  54. </Text>
  55. </Layout>
  56. <Button
  57. status='danger'
  58. onPress={props.removeEvent}
  59. style={styles.remove}
  60. >
  61. {remove}
  62. </Button>
  63. </Layout>
  64. ) : (
  65. <Layout style={styles.layout} />
  66. )}
  67. </Card>
  68. );
  69. }
  70. const styles = StyleSheet.create({
  71. card: {
  72. width: (width - 35) / 2,
  73. },
  74. layout: {
  75. // flexDirection: "row",
  76. },
  77. avatar: {
  78. width: (width - 35) / 2,
  79. height: (width - 35) / 2,
  80. },
  81. main: {
  82. padding: 6,
  83. },
  84. butContent: {
  85. marginLeft: 6,
  86. },
  87. fontColor: {
  88. color: "#B5B5B5",
  89. },
  90. price: {
  91. marginTop: 5,
  92. },
  93. sub: {
  94. marginTop: 2,
  95. },
  96. remove: {
  97. minHeight: 33,
  98. minWidth: 33,
  99. position: "absolute",
  100. right: 11,
  101. bottom: 4,
  102. },
  103. });