[NativeBase Tabs for force RTL-Fix

问题描述 投票:0回答:1

当我执行forceRtl时,我对本机基本选项卡有疑问。一切正常,但只有本机基础在初始负载下不显示任何内容。

所以我有一个临时解决方案

javascript react-native native-base
1个回答
0
投票

在native-base / src / basic / Tabs / index.js中

  import { I18nManager } from "react-native"
       renderScrollableContent() {
        const scenes = this._composeScenes();
        const isRTLAndroid = I18nManager.isRTL;

        return (
          <ScrollView
            horizontal
            pagingEnabled
            automaticallyAdjustContentInsets={false}
            keyboardShouldPersistTaps="handled"
            contentOffset={{
              x: this.props.initialPage * this.state.containerWidth
            }}
            ref={scrollView => {
              this.scrollView = scrollView;
            }}
            onScroll={e => {
              const offsetX = e.nativeEvent.contentOffset.x;
              this._updateScrollValue(offsetX / this.state.containerWidth);
            }}
            onMomentumScrollBegin={this._onMomentumScrollBeginAndEnd}
            onMomentumScrollEnd={this._onMomentumScrollBeginAndEnd}
            scrollEventThrottle={16}
            scrollsToTop={false}
            showsHorizontalScrollIndicator={false}
            scrollEnabled={!this.props.locked}
            directionalLockEnabled
            alwaysBounceVertical={false}
            keyboardDismissMode="on-drag"
            {...this.props.contentProps}
          >
          /*******************************************
            If is isRtl do reverse else keep as it is
          ********************************************/
            {isRTLAndroid?scenes.reverse():scenes}
          </ScrollView>
        );
        },

不要忘记在package.json中更改“ main”:“ src / index.js”

© www.soinside.com 2019 - 2024. All rights reserved.