| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- /**
- * 通知功能页面适配器
- * @邠心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';
- 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: colorLight,
- inactiveTintColor: "#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: colorPrimary
- },
- indicator: {
- backgroundColor: colorLight
- }
- })
|