/** * 活动详情 * @邠心vbe on 2023/08/17 */ import React, { Component } from 'react'; import { View, StyleSheet, Image, ScrollView, Linking, Animated, Easing } from 'react-native'; import Swiper from 'react-native-swiper'; import apiArticle from '../../api/apiArticle'; import TextView from '../../components/TextView'; import VbeSkeleton from '../../components/VbeSkeleton'; import utils from '../../utils/utils'; import { PagerView } from './ViewUtil'; import MyStatusBar from '../../components/MyStatusBar'; import Toolbar, { BackButton } from '../../components/Toolbar'; export default class ViewCampaign extends Component { constructor(props) { super(props); this.state = { id: "", loading: true, showTitleBar: false, messageInfo: { articleTypeName: "", articleTitle: "", articleContent: "" }, opacity: new Animated.Value(0) }; } componentDidMount() { if (this.props.route?.params?.id) { this.setState({ id: this.props.route?.params?.id }, () => { this.readMessage(); }) } MyStatusBar.setStatusBarTheme(MyStatusBar.LIGHT_STYLE); this.props.navigation.addListener('beforeRemove', (e) => { MyStatusBar.setStatusBarTheme(MyStatusBar.DEFAULT_STYLE); }); } readMessage() { apiArticle.readMessage(this.state.id).then(res => { if (res.data) { this.setState({ messageInfo: res.data }); this.setPageTitle(); } }).catch(err => { toastShort(err); }); } setPageTitle() { if (this.state.messageInfo.articleTitle) { /*this.props.navigation.setOptions({ headerTitle: () => () })*/ setTimeout(() => { this.setState({ loading: false }); }, 300); } } accessLink(url) { Linking.openURL(utils.getImageUrl(url)) } getColorByType(type) { switch (type) { case "Ended": return { backgroundColor: "#E11919" } case "Upcoming": return { backgroundColor: "#FFAA2C" } } } onScrollView(e) { if (e.nativeEvent.contentOffset) { const isR = e.nativeEvent.contentOffset.y >= $vw(95); if (isR != this.state.showTitleBar) { this.setState({ showTitleBar: isR }); if (isR) { this.startTitleAnimate(); } else { this.hideTitleAnimate(); } MyStatusBar.setStatusBarTheme(isR ? MyStatusBar.DEFAULT_STYLE : MyStatusBar.LIGHT_STYLE); } } } startTitleAnimate() { Animated.timing(this.state.opacity, { toValue: 1, duration: 250, easing: Easing.linear, useNativeDriver: true }).start(() => { }); } hideTitleAnimate() { Animated.timing(this.state.opacity, { toValue: 0, duration: 250, easing: Easing.linear, useNativeDriver: true }).start(() => { }); } render() { if (this.state.loading) { return ( ) } return ( <> this.onScrollView(e)} scrollEventThrottle={16} contentContainerStyle={$padding(0,0,32)}> { utils.isNotEmpty(this.state.messageInfo.articleImages) && } removeClippedSubviews={false}> { this.state.messageInfo.articleImages.map((item, index) => { return ( ); })} } {this.state.messageInfo.campaignMark} {this.state.messageInfo.campaignMark} {this.state.messageInfo.articleTitle} {this.state.messageInfo.createTime} {this.state.messageInfo.articleViews} {$t("notification.labelSummary")} {$t("notification.startTime")} {this.state.messageInfo.startTime} {$t("notification.endTime")} {this.state.messageInfo.endTime} {$t("notification.labelDetails")} {this.state.messageInfo.articleContent} { utils.isNotEmpty(this.state.messageInfo.articleLinks) && <> {$t("notification.labelLinks")} { this.state.messageInfo.articleLinks.map((item, index) => {index + 1}. this.accessLink(item.articleLink)}>{item.articleLinkName} )} } { !this.state.showTitleBar && } ); } } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: pageBackground }, toolbar: { top: 0, left: 0, right: 0, zIndex: 2, position: 'absolute' }, backIcon: { width: 48, height: toolbarSize, zIndex: 2, marginLeft: isIOS ? 0 : 2, alignItems: 'center', justifyContent: 'center' }, loadingView: { flex: 1, padding: 16, justifyContent: 'flex-start', backgroundColor: pageBackground }, textTitle: { color: textPrimary, fontSize: 18, fontWeight: 'bold', paddingBottom: 2 }, textDate: { flex: 1, color: textSecondary, fontSize: 10, paddingLeft: 2 }, textView: { color: textSecondary, fontSize: 10, paddingLeft: 4 }, header: { padding: 16, backgroundColor: pageBackground }, textSummary: { color: textPrimary, fontSize: 14, ...$padding(0, 16, 8) }, textMessage: { color: textPrimary, fontSize: 14, ...$padding(0, 16, 16) }, labelTypeText: { color: textLight, height: 16, fontSize: 10, borderRadius: 4, marginTop: 3, ...$padding(0, 6), position: 'absolute', backgroundColor: "#1ABD00" }, hideText: { height: 16, opacity: 0, fontSize: 10, ...$padding(2, 8), }, textLinkTitle: { color: textPrimary, fontSize: 16, fontWeight: 'bold', padding: 16 }, itemLink: { ...$padding(0, 16, 8), flexDirection: 'row' }, linkIndex: { fontSize: 14, paddingRight: 2 }, linkHyper: { ...ui.link, fontSize: 14, textDecorationLine: 'underline' }, linkActive: { color: "#FF3B30" } })