ViewAlerts.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /**
  2. * 通知信息详情
  3. * @邠心vbe on 2023/08/17
  4. */
  5. import React, { Component } from 'react';
  6. import { View, StyleSheet, ScrollView } from 'react-native';
  7. import apiNotification from '../../api/apiNotification';
  8. import Button, { ElevationObject } from '../../components/Button';
  9. import Dialog from '../../components/Dialog';
  10. import HeaderTitle from '../../components/HeaderTitle';
  11. import TextView from '../../components/TextView';
  12. import { PageList } from '../Router';
  13. export default class ViewAlerts extends Component {
  14. constructor(props) {
  15. super(props);
  16. this.state = {
  17. id: "",
  18. messageInfo: {
  19. createTime: "",
  20. notificationText: "",
  21. notificationTitle: "",
  22. notificationType: ""
  23. }
  24. };
  25. }
  26. componentDidMount() {
  27. if (this.props.route?.params?.id) {
  28. this.setState({
  29. id: this.props.route?.params?.id
  30. }, () => {
  31. this.readMessage();
  32. })
  33. }
  34. }
  35. readMessage() {
  36. Dialog.showProgressDialog();
  37. apiNotification.readMessage(this.state.id).then(res => {
  38. if (res.data) {
  39. this.setState({
  40. messageInfo: res.data
  41. });
  42. this.setPageTitle();
  43. }
  44. }).catch(err => {
  45. toastShort(err);
  46. }).finally(() => {
  47. Dialog.dismissLoading();
  48. })
  49. }
  50. setPageTitle() {
  51. if (this.state.messageInfo.notificationTitle) {
  52. this.props.navigation.setOptions({
  53. headerTitle: () => (<HeaderTitle title={this.state.messageInfo.notificationTitle}/>)
  54. })
  55. }
  56. }
  57. submitFeedback() {
  58. startPage(PageList.feedback);
  59. }
  60. render() {
  61. return (
  62. <View style={styles.container}>
  63. <View style={styles.header}>
  64. <TextView
  65. style={styles.textTitle}>
  66. {this.state.messageInfo.notificationTitle}
  67. </TextView>
  68. <View style={ui.flexc}>
  69. <MaterialCommunityIcons
  70. name="clock-time-four-outline"
  71. color={textSecondary}
  72. size={12}/>
  73. <TextView
  74. style={styles.textDate}
  75. numberOfLines={1}>
  76. {this.state.messageInfo.createTime}
  77. </TextView>
  78. </View>
  79. </View>
  80. <ScrollView
  81. style={ui.flex1}>
  82. <TextView
  83. style={styles.textMessage}>
  84. {this.state.messageInfo.notificationText}
  85. </TextView>
  86. </ScrollView>
  87. { this.state.messageInfo.notificationType == "Review" &&
  88. <Button
  89. elevation={1}
  90. style={$margin(8, 16, 20)}
  91. text={$t("feedback.submitFeedback")}
  92. onClick={() => this.submitFeedback()}
  93. />
  94. }
  95. </View>
  96. );
  97. }
  98. }
  99. const styles = StyleSheet.create({
  100. container: {
  101. flex: 1,
  102. backgroundColor: pageBackground
  103. },
  104. textTitle: {
  105. color: textPrimary,
  106. fontSize: 18,
  107. fontWeight: 'bold',
  108. paddingBottom: 2
  109. },
  110. textDate: {
  111. color: textSecondary,
  112. fontSize: 10,
  113. paddingLeft: 2
  114. },
  115. header: {
  116. padding: 16,
  117. ...ElevationObject(1),
  118. backgroundColor: pageBackground
  119. },
  120. textMessage: {
  121. color: textPrimary,
  122. fontSize: 14,
  123. padding: 16
  124. }
  125. })