ViewAlerts.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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 HeaderTitle from '../../components/HeaderTitle';
  10. import TextView from '../../components/TextView';
  11. import VbeSkeleton from '../../components/VbeSkeleton';
  12. import { PageList } from '../Router';
  13. export default class ViewAlerts extends Component {
  14. constructor(props) {
  15. super(props);
  16. this.state = {
  17. id: "",
  18. loading: true,
  19. messageInfo: {
  20. createTime: "",
  21. notificationText: "",
  22. notificationTitle: "",
  23. notificationType: ""
  24. }
  25. };
  26. }
  27. componentDidMount() {
  28. if (this.props.route?.params?.id) {
  29. this.setState({
  30. id: this.props.route?.params?.id
  31. }, () => {
  32. this.readMessage();
  33. })
  34. }
  35. }
  36. readMessage() {
  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. }
  45. }).catch(err => {
  46. toastShort(err);
  47. });
  48. }
  49. setPageTitle() {
  50. if (this.state.messageInfo.notificationTitle) {
  51. this.props.navigation.setOptions({
  52. headerTitle: () => (<HeaderTitle title={this.state.messageInfo.notificationTitle}/>)
  53. });
  54. setTimeout(() => {
  55. this.setState({
  56. loading: false
  57. });
  58. }, 300);
  59. }
  60. }
  61. submitFeedback() {
  62. startPage(PageList.feedback);
  63. }
  64. render() {
  65. if (this.state.loading) {
  66. return (
  67. <VbeSkeleton
  68. style={styles.loadingView}
  69. layout={[
  70. {width: '90%', height: 20},
  71. {width: '50%', height: 12, marginTop: 8},
  72. {width: '100%', height: 15, marginTop: 24},
  73. {width: '100%', height: 15, marginTop: 8},
  74. {width: '100%', height: 15, marginTop: 8},
  75. {width: '100%', height: 15, marginTop: 8},
  76. {width: '30%', height: 15, marginTop: 8},
  77. {width: '100%', height: 15, marginTop: 24},
  78. {width: '100%', height: 15, marginTop: 8},
  79. {width: '100%', height: 15, marginTop: 8},
  80. {width: '100%', height: 15, marginTop: 8},
  81. {width: '30%', height: 15, marginTop: 8},
  82. {width: '100%', height: 15, marginTop: 24},
  83. {width: '100%', height: 15, marginTop: 8},
  84. {width: '100%', height: 15, marginTop: 8},
  85. {width: '100%', height: 15, marginTop: 8},
  86. {width: '30%', height: 15, marginTop: 8}
  87. ]}
  88. />
  89. );
  90. }
  91. return (
  92. <View
  93. style={styles.container}>
  94. <View style={styles.header}>
  95. <TextView
  96. style={styles.textTitle}>
  97. {this.state.messageInfo.notificationTitle}
  98. </TextView>
  99. <View style={ui.flexc}>
  100. <MaterialCommunityIcons
  101. name="clock-time-four-outline"
  102. color={textSecondary}
  103. size={12}/>
  104. <TextView
  105. style={styles.textDate}
  106. numberOfLines={1}>
  107. {this.state.messageInfo.createTime}
  108. </TextView>
  109. </View>
  110. </View>
  111. <View style={styles.divideView}></View>
  112. <ScrollView
  113. style={ui.flex1}>
  114. <TextView
  115. style={styles.textMessage}
  116. selectable={true}>
  117. {this.state.messageInfo.notificationText}
  118. </TextView>
  119. </ScrollView>
  120. { this.state.messageInfo.notificationType == "Review" &&
  121. <Button
  122. elevation={1}
  123. style={$margin(8, 16, 20)}
  124. text={$t("feedback.submitFeedback")}
  125. onClick={() => this.submitFeedback()}
  126. />
  127. }
  128. </View>
  129. );
  130. }
  131. }
  132. const styles = StyleSheet.create({
  133. container: {
  134. flex: 1,
  135. backgroundColor: pageBackground
  136. },
  137. loadingView: {
  138. flex: 1,
  139. padding: 16,
  140. justifyContent: 'flex-start',
  141. backgroundColor: pageBackground
  142. },
  143. textTitle: {
  144. color: textPrimary,
  145. fontSize: 14,
  146. fontWeight: 'bold',
  147. paddingBottom: 2
  148. },
  149. textDate: {
  150. color: textSecondary,
  151. fontSize: 12,
  152. paddingLeft: 2
  153. },
  154. header: {
  155. padding: 16,
  156. //...ElevationObject(1),
  157. backgroundColor: pageBackground
  158. },
  159. divideView: {
  160. height: 1,
  161. marginLeft: 16,
  162. marginRight: 16,
  163. backgroundColor: colorPrimary
  164. },
  165. textMessage: {
  166. color: textPrimary,
  167. fontSize: 12,
  168. padding: 16
  169. }
  170. })