MoneyListScreen.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. import * as WebBrowser from "expo-web-browser";
  2. import * as React from "react";
  3. import {
  4. StyleSheet,
  5. } from "react-native";
  6. import { useModel } from "flooks";
  7. import {
  8. Layout,
  9. Text,
  10. useTheme,
  11. Button,
  12. Select,
  13. SelectItem,
  14. IndexPath,
  15. } from "@ui-kitten/components";
  16. import { useFocusEffect } from "@react-navigation/native";
  17. import NavHeaderBar from "../components/NavHeaderBar";
  18. import MoneyRecord from "../components/MoneyRecord";
  19. import ListComponent from "../components/ListComponent";
  20. // 余额
  21. const data = ["2020-03", "2020-04", "2020-05"];
  22. const styles = StyleSheet.create({
  23. container: {
  24. flex: 1,
  25. paddingBottom: 33,
  26. paddingVertical: 40,
  27. alignItems: "center",
  28. },
  29. icon: {
  30. width: 90,
  31. height: 80,
  32. marginBottom: 26,
  33. },
  34. text: {
  35. fontWeight: "500",
  36. marginBottom: 7,
  37. },
  38. button: {
  39. marginTop: 19,
  40. },
  41. lay: {
  42. flexDirection: "row",
  43. paddingHorizontal: 17,
  44. paddingBottom: 20,
  45. },
  46. flex1: {
  47. flex: 1,
  48. flexShrink: 0,
  49. },
  50. money: {
  51. textAlign: "center",
  52. fontWeight: "normal",
  53. },
  54. tiltle: {
  55. fontSize: 12,
  56. color: "#A43506",
  57. alignSelf: "center",
  58. flexShrink: 0,
  59. },
  60. select: {
  61. paddingVertical: 10,
  62. paddingHorizontal: 20,
  63. backgroundColor: "#EEEEEE",
  64. },
  65. list: {
  66. backgroundColor: "#fff",
  67. flex: 1,
  68. },
  69. separatorStyle: {
  70. marginHorizontal: 13,
  71. },
  72. });
  73. export default function MoneyListScreen({ navigation }) {
  74. const theme = useTheme();
  75. const { changeBackground } = useModel("barModel");
  76. const { getUserInfo, money } = useModel("appUserModel");
  77. const { httpGet } = useModel("httpModel", true);
  78. const [selectedIndex, setSelectedIndex] = React.useState(
  79. new IndexPath(data.length - 1)
  80. );
  81. const { userTitle6, OZXEWT, ZJDSDE } = useModel("wordsModel");
  82. const displayValue = data[selectedIndex.row];
  83. useFocusEffect(
  84. React.useCallback(() => {
  85. changeBackground(theme["color-primary-500"]);
  86. getUserInfo();
  87. }, [])
  88. );
  89. // 获取列表
  90. function getList(page, size) {
  91. return httpGet(
  92. "/moneyRecord/my",
  93. {
  94. page,
  95. size,
  96. },
  97. true
  98. );
  99. }
  100. const renderOption = (title, index) => (
  101. <SelectItem key={index} title={title} />
  102. );
  103. const selectElement = () => (
  104. <Layout style={[styles.select]}>
  105. <Select
  106. value={displayValue}
  107. selectedIndex={selectedIndex}
  108. onSelect={index => setSelectedIndex(index)}
  109. >
  110. {data.map(renderOption)}
  111. </Select>
  112. </Layout>
  113. );
  114. const walletItem = ({ item, index }) => (
  115. <MoneyRecord key={index} info={item} />
  116. );
  117. return (
  118. <>
  119. <NavHeaderBar title={userTitle6} />
  120. <Layout
  121. style={[
  122. styles.lay,
  123. {
  124. backgroundColor: theme["color-primary-500"],
  125. borderColor: theme["color-primary-500"],
  126. },
  127. ]}
  128. >
  129. <Text category="c1" style={[styles.flex1, styles.tiltle]}>
  130. {ZJDSDE}
  131. </Text>
  132. <Text
  133. category="h2"
  134. style={[styles.flex1, styles.money]}
  135. status="control"
  136. >
  137. {money || 0}
  138. </Text>
  139. <Button
  140. appearance="ghost"
  141. style={[styles.flex1]}
  142. size="large"
  143. status="control"
  144. onPress={() => {
  145. navigation.navigate("ChooseBank");
  146. }}
  147. >
  148. {OZXEWT}
  149. </Button>
  150. </Layout>
  151. <ListComponent
  152. getInfo={getList}
  153. renderItem={walletItem}
  154. ListHeaderComponent={selectElement}
  155. style={styles.list}
  156. separatorStyle={styles.separatorStyle}
  157. showEmpty
  158. />
  159. </>
  160. );
  161. }