Верхняя и нижняя навигация в React Native - PullRequest
0 голосов
/ 08 марта 2020

Как я могу получить верхнюю и нижнюю навигацию с реакцией на родную вкладку. До сих пор я достиг, чтобы получить нижнюю или верхнюю навигацию отдельно. Компонент главной вкладки:

favoritesTab = () => (
<View style={styles.container}>
  <Favorites />
</View>
  )

  stockTab = () => (
    <View style={styles.container}>
      <Stock />
    </View>
  )

  newsTab = () => (
    <View>
      <News />
    </View>
  )

Редуктор для главной вкладки (полезная нагрузка является индексом в действии):

import { Actions } from '../../../constants'

const initialState = {
  index: 0,
  previousIndex: 0,
  routes: [
    { key: 'favorites', title: 'Favorites', icon: 'md-heart' },
    { key: 'search', title: 'Search', icon: 'md-search' },
    { key: 'news', title: 'News', icon: 'logo-news' },
  ]
}

export const tabs = (state = initialState, action) => {
  switch (action.type) {
    case Actions.SET_TAB:
      return { ...state, index: action.payload, previousIndex: state.index }
    default:
      return state
  }
}

Компонент вкладки новостей:

businessTab = () => (
        <View style={styles.container}> <Business /> </View>
    )
    generalTab = () => (
        <View style={styles.container}> <General /> </View>
    )
    scienceTab = () => (
        <View style={styles.container}> <Science /> </View>
    )
    techTab = () => (
        <View style={styles.container}> <Tech /> </View>
    )
News Reducer:
sceneMapNews = SceneMap({
        business: this.businessTab,
        general: this.generalTab,
        science: this.scienceTab,
        tech: this.techTab,
    })

    tabBarNews = props => (
        <TabBar
          {...props}
          indicatorStyle={styles.indicatorStyle}
          labelStyle={styles.labelStyle}

          style={styles.tabBar}
          useNativeDriver={true}
          //scrollEnabled={true}
          tabStyle={{ paddingHorizontal: 0, paddingVertical: 8, width: 84 }}
          renderIcon={this.renderIcon}
        />
      )

Компонент вкладок новостей так же, как редуктор основных вкладок. но c с разными ключами и названиями. Итак, как я могу объединить мои 2 маршрутизатора?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...