react-native-collapsible-tab-view icon indicating copy to clipboard operation
react-native-collapsible-tab-view copied to clipboard

SafeAreaView on iOS devices

Open kangyul opened this issue 1 year ago • 7 comments

When using react-native-collapsible-tab-view on iOS devices, the notch and dynamic island (iPhone14 Pro) hide the header and the tab. Is there any way to make it work like SafeAreaView?

kangyul avatar May 24 '23 07:05 kangyul

Same here, I have the same problem, any steps to solve?

jonathanm-tkf avatar May 26 '23 18:05 jonathanm-tkf

I'm not sure I understand how this relates to this library. You could wrap Tabs.Container in a SafeAreaView.

Unless I'm misunderstanding the issue.

andreialecu avatar May 27 '23 06:05 andreialecu

I tried wrapping Tabs.Container in a SafeAreaView but it doesn't work. Instead, the contents in Tabs.Tab disappear. What I did instead as a temporary solution was setting the 'headerShown' to true.

kangyul avatar May 30 '23 00:05 kangyul

@kangyul when you use SafeAreaView did you set flex 1 ?

devoren avatar Jul 04 '23 10:07 devoren

i wrapperd my nav tabs in View, and when my tab is screen with this lib, i add padding top for view. Value i get from import {useSafeAreaInsets} from 'react-native-safe-area-context';

MatLish00010 avatar Jul 14 '23 13:07 MatLish00010

i wrapperd my nav tabs in View, and when my tab is screen with this lib, i add padding top for view. Value i get from import {useSafeAreaInsets} from 'react-native-safe-area-context';

do you found any solution?? i want add insets from useSafeAreaInsets too

hotaryuzaki avatar Jan 15 '24 10:01 hotaryuzaki

@hotaryuzaki Setting the minimum tab height to negative does the trick. In my case, since I want to hide the tab bar, I do: minHeaderHeight={-tabBarHeight}.

 /**
 * Home top tab navigator.
 *
 * @memberof module:HomeTabs
 * @type {React.FC}
 * @function TopTabNavigator
 * @returns {React.ReactElement} The top tab navigator.
 * @requires module:Hooks/i18n.useLanguage
 * @requires module:Hooks/Navigation.useStackHeaderHeight
 * @requires module:Tabs/Constants.TOP_TAB_BAR_HEIGHT
 * @requires module:Tabs/Constants.TOP_TAB_PAGER_PROPS
 * @requires module:HomeHeader
 * @requires module:PostsFeed
 * @requires module:ThreadsFeed
 */
function TabNavigator() {
  const { colors } = useTheme();

  const { t } = useLanguage();

  const headerHeight = useStackHeaderHeight();

  const tabBarHeight = TOP_TAB_BAR_HEIGHT;

  const pagerProps = TOP_TAB_PAGER_PROPS;

  /**
   * Renders the tab bar.
   *
   * @param {import("../../../navigation.d").RenderTopTabBarProps} props
   *   The tab bar props.
   * @returns {React.ReactElement} The tab bar.
   */
  const renderTabBar = (props) => (
    <MaterialTabBar
      {...props}
      activeColor={colors.primary}
      labelStyle={styles.label}
      indicatorStyle={globalStyles.hidden}
    />
  );

  return (
    <Tabs.Container
      lazy={false}
      initialTabName="posts"
      pagerProps={pagerProps}
      allowHeaderOverscroll={false}
      revealHeaderOnScroll
      headerHeight={headerHeight}
      minHeaderHeight={-tabBarHeight}
      tabBarHeight={tabBarHeight}
      snapThreshold={0.5}
      renderHeader={Header}
      renderTabBar={renderTabBar}
      headerContainerStyle={styles.headerContainer}
    >
      <Tabs.Tab
        name="posts"
        label={t("home.topTabNavigator.postsTabTitle")}
      >
        <PostsFeed />
      </Tabs.Tab>

      <Tabs.Tab
        name="threads"
        label={t("home.topTabNavigator.threadsTabTitle")}
      >
        <ThreadsFeed />
      </Tabs.Tab>
    </Tabs.Container>
  );
}

Also, I have been facing some issues with the Refresh Control, since I don't like it rendering at the top of the header in my use case, I just set allowHeaderOverscroll={false}, combined with const { progressViewOffset } = useCollapsibleStyle();:

 const { progressViewOffset } = useCollapsibleStyle();


    /**
     * `RefreshControl` component, used to provide *pull-to-refresh*
     * functionality for the `ScrollView`.
     *
     * @type {React.ReactElement}
     */
    const refreshControl = useMemo(
      () => (
        <RefreshControl
          progressViewOffset={progressViewOffset}
          onRefresh={onRefresh}
        />
      ),
      [progressViewOffset, onRefresh]
    );

VictorioMolina avatar Mar 11 '24 14:03 VictorioMolina