EmailDetailScreen.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { StackScreenProps } from "@react-navigation/stack";
  2. import * as React from "react";
  3. import { RefreshControl } from "react-native";
  4. import { Div, Button, Image, Text, Avatar } from "react-native-magnus";
  5. import { ScrollView } from "react-native-gesture-handler";
  6. import { useModel } from "flooks";
  7. import { RootStackParamList } from "../types";
  8. import { getChatTime } from "../Utils/TimeUtils";
  9. import request from "../utils/RequestUtils";
  10. export default function RegisterScreen({ navigation, route }) {
  11. const { params } = route;
  12. const { emailId } = params;
  13. const { httpGet,httpPost } = useModel("httpModel");
  14. const { data, loading, reload, run } = useRequest(
  15. () => {
  16. return httpGet(`/email/get/${emailId}`);
  17. },
  18. {
  19. refreshDeps: [emailId],
  20. initialData: {},
  21. onSuccess: res => {
  22. if (!res.isRead) {
  23. httpPost(
  24. "/email/save",
  25. {
  26. ...data,
  27. isRead: true,
  28. },
  29. { body: "json" }
  30. );
  31. }
  32. },
  33. }
  34. );
  35. return (
  36. <Div bg="gray100">
  37. <ScrollView
  38. contentContainerStyle={{ flexGrow: 1, backgroundColor: "#f2f2f2" }}
  39. refreshControl={
  40. <RefreshControl refreshing={loading} onRefresh={reload} />
  41. }
  42. >
  43. <Div my={10} px={15} py={5} bg="white">
  44. <Div row justifyContent="space-between" py={10}>
  45. <Text fontSize="xl" fontWeight="bold">
  46. {data.title}
  47. </Text>
  48. <Text>{getChatTime(data.sendTime)}</Text>
  49. </Div>
  50. <Text
  51. py={10}
  52. color="gray600"
  53. borderTopColor="gray100"
  54. borderTopWidth={1}
  55. fontSize="sm"
  56. >
  57. {data.content}
  58. </Text>
  59. </Div>
  60. </ScrollView>
  61. </Div>
  62. );
  63. }