| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- /**
- * 通知功能页面适配器
- * @邠心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 = {
- style: styles.tabStyle,
- pressColor: rippleColor,
- scrollEnabled: false,
- indicatorStyle: styles.indicator,
- activeTintColor: app.isWhitelabel ? textPrimary : colorLight,
- inactiveTintColor: 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 (
- <Tab.Navigator
- style={styles.container}
- tabBarOptions={this.tabBarStyle}
- lazy={false}
- lazyPreloadDistance={1}>
- { this.pageAdapter.map((item, index) =>
- <Tab.Screen
- key={index}
- name={item.name}
- component={item.component}
- options={{
- title: item.title
- }}
- />
- )}
- </Tab.Navigator>
- );
- }
- }
- const styles = StyleSheet.create({
- container: {
- flex: 1,
- backgroundColor: colorLight
- },
- tabStyle: {
- backgroundColor: app.isWhitelabel ? colorLight : colorPrimary
- },
- indicator: {
- backgroundColor: app.isWhitelabel ? colorPrimary : colorLight
- }
- })
|