/** * 通知功能页面适配器 * @邠心vbe on 2023/08/17 */ import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs'; import React, { Component } from 'react'; import { StyleSheet, BackHandler } from 'react-native'; import { PageList } from '../Router'; import Alerts from './Alerts'; import Promotions from './Promotions'; import app from '../../../app.json'; export default class Notification extends Component { constructor(props) { super(props); this.state = { refreshing: false }; this.pageAdapter = [{ title: $t('notification.tabAlerts'), name: "Alerts", component: Alerts }, { title: $t('notification.tabPromotions'), name: "Promotions", component: Promotions }] this.tabBarStyle = { tabBarStyle: styles.tabStyle, tabBarPressColor: rippleColor, tabBarScrollEnabled: false, tabBarIndicatorStyle: styles.indicator, tabBarActiveTintColor: app.isWhitelabel ? textPrimary : colorLight, tabBarInactiveTintColor: app.isWhitelabel ? textSecondary : "#E0E0E0" } this.isHide = false; } componentDidMount() { this.props.navigation.addListener('focus', () => { this.isHide = false; }); this.props.navigation.addListener('blur', () => { this.isHide = true; }); BackHandler.addEventListener('hardwareBackPress', this.backPage) } componentWillUnmount() { BackHandler.removeEventListener("hardwareBackPress", this.backPage) } backPage = () => { //const params = this.props.route.params; if (!this.isHide) { startPage(PageList.home); return true; } } onPullRefresh() { } render() { const Tab = createMaterialTopTabNavigator(); return ( { this.pageAdapter.map((item, index) => )} ); } } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: colorLight }, tabStyle: { backgroundColor: app.isWhitelabel ? colorLight : colorPrimary }, indicator: { backgroundColor: app.isWhitelabel ? colorPrimary : colorLight } })