ViewAlerts.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. return (
  66. <VbeSkeleton
  67. style={this.state.loading ? styles.loadingView : styles.container}
  68. viewStyle={styles.container}
  69. isLoading={this.state.loading}
  70. layout={[
  71. {width: '90%', height: 20},
  72. {width: '50%', height: 12, marginTop: 8},
  73. {width: '100%', height: 15, marginTop: 24},
  74. {width: '100%', height: 15, marginTop: 8},
  75. {width: '100%', height: 15, marginTop: 8},
  76. {width: '100%', height: 15, marginTop: 8},
  77. {width: '30%', height: 15, marginTop: 8}
  78. ]}
  79. animationDirection={"horizontalRight"}>
  80. <View style={styles.header}>
  81. <TextView
  82. style={styles.textTitle}>
  83. {this.state.messageInfo.notificationTitle}
  84. </TextView>
  85. <View style={ui.flexc}>
  86. <MaterialCommunityIcons
  87. name="clock-time-four-outline"
  88. color={textSecondary}
  89. size={12}/>
  90. <TextView
  91. style={styles.textDate}
  92. numberOfLines={1}>
  93. {this.state.messageInfo.createTime}
  94. </TextView>
  95. </View>
  96. </View>
  97. <View style={styles.divideView}></View>
  98. <ScrollView
  99. style={ui.flex1}>
  100. <TextView
  101. style={styles.textMessage}
  102. selectable={true}>
  103. {this.state.messageInfo.notificationText}
  104. </TextView>
  105. </ScrollView>
  106. { this.state.messageInfo.notificationType == "Review" &&
  107. <Button
  108. elevation={1}
  109. style={$margin(8, 16, 20)}
  110. text={$t("feedback.submitFeedback")}
  111. onClick={() => this.submitFeedback()}
  112. />
  113. }
  114. </VbeSkeleton>
  115. );
  116. }
  117. }
  118. const styles = StyleSheet.create({
  119. container: {
  120. flex: 1,
  121. backgroundColor: pageBackground
  122. },
  123. loadingView: {
  124. flex: 1,
  125. padding: 16,
  126. justifyContent: 'flex-start',
  127. backgroundColor: pageBackground
  128. },
  129. textTitle: {
  130. color: textPrimary,
  131. fontSize: 14,
  132. fontWeight: 'bold',
  133. paddingBottom: 2
  134. },
  135. textDate: {
  136. color: textSecondary,
  137. fontSize: 12,
  138. paddingLeft: 2
  139. },
  140. header: {
  141. padding: 16,
  142. //...ElevationObject(1),
  143. backgroundColor: pageBackground
  144. },
  145. divideView: {
  146. height: 1,
  147. marginLeft: 16,
  148. marginRight: 16,
  149. backgroundColor: colorPrimary
  150. },
  151. textMessage: {
  152. color: textPrimary,
  153. fontSize: 12,
  154. padding: 16
  155. }
  156. })