EmailDetailScreen.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 { useRequest } from 'ahooks';
  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 { data, loading, reload, run } = useRequest(`/email/get/${emailId}`, {
  14. refreshDeps: [emailId],
  15. initialData: {},
  16. onSuccess: (res) => {
  17. if (!res.isRead) {
  18. request.post('/email/save', {
  19. data: {
  20. ...data,
  21. isRead: true,
  22. },
  23. });
  24. }
  25. },
  26. });
  27. return (
  28. <Div bg="gray100">
  29. <ScrollView
  30. contentContainerStyle={{ flexGrow: 1, backgroundColor: '#f2f2f2' }}
  31. refreshControl={
  32. <RefreshControl refreshing={loading} onRefresh={reload} />
  33. }
  34. >
  35. <Div my={10} px={15} py={5} bg="white">
  36. <Div row justifyContent="space-between" py={10}>
  37. <Text fontSize="xl" fontWeight="bold">
  38. {data.title}
  39. </Text>
  40. <Text>{getChatTime(data.sendTime)}</Text>
  41. </Div>
  42. <Text
  43. py={10}
  44. color="gray600"
  45. borderTopColor="gray100"
  46. borderTopWidth={1}
  47. fontSize="sm"
  48. >
  49. {data.content}
  50. </Text>
  51. </Div>
  52. </ScrollView>
  53. </Div>
  54. );
  55. }