Skip to content
This repository was archived by the owner on Jan 14, 2026. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions packages/stack/src/views/Header/HeaderContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Route,
} from '@react-navigation/native';
import * as React from 'react';
import { Animated, StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
import { Animated, StyleProp, StyleSheet, View, ViewStyle, Platform } from 'react-native';

import {
forNoAnimation,
Expand Down Expand Up @@ -36,6 +36,18 @@ export type Props = {
style?: Animated.WithAnimatedValue<StyleProp<ViewStyle>>;
};

function compareVersion(v1: string, v2: string) {
const a = v1.split('.').map(Number);
const b = v2.split('.').map(Number);
for (let i = 0; i < Math.max(a.length, b.length); i++) {
const num1 = a[i] || 0;
const num2 = b[i] || 0;
if (num1 > num2) return 1;
if (num1 < num2) return -1;
}
return 0;
}

export default function HeaderContainer({
mode,
scenes,
Expand Down Expand Up @@ -63,7 +75,14 @@ export default function HeaderContainer({
headerStyleInterpolator,
} = scene.descriptor.options;

if (headerMode !== mode || !headerShown) {
const rawVersion = typeof Platform.Version === 'string' ? Platform.Version : String(Platform.Version);
const match = rawVersion.match(/(\d+\.\d+\.\d+)/);
const version = match ? match[1] : '0.0.0';
const isHarmony = (Platform.OS as string) === 'harmony';

let shouldHideHeader = isHarmony && compareVersion(version, '6.0.0') >= 0 ? !headerShown && focusedRoute.key !== scene.descriptor.route.key : headerMode !== mode || !headerShown;

if (shouldHideHeader) {
return null;
}

Expand Down