40 lines
1.6 KiB
React
40 lines
1.6 KiB
React
// Metro module 5603 (f5604).
|
|
import { memo, useCallback, useContext } from "react";
|
|
import { useSafeAreaInsets } from "./Module1584";
|
|
import debounce from "./debounce_5604";
|
|
import { StackActions } from "./Module1481";
|
|
import Module5605 from "./Module5605";
|
|
import { HeaderShownContext, getHeaderTitle } from "./Module5579";
|
|
import HeaderSegment from "./HeaderSegment";
|
|
export default memo(function Header(props) {
|
|
const { back, layout, progress, options, route, navigation, styleInterpolator } = props;
|
|
const safeAreaInsets = useSafeAreaInsets();
|
|
let headerBackTitle = options.headerBackTitle !== void 0 ? options.headerBackTitle : back ? back.title : void 0;
|
|
const callback = useCallback(debounce(() => {
|
|
if (navigation.isFocused() && navigation.canGoBack()) {
|
|
navigation.dispatch({
|
|
...StackActions.pop(),
|
|
source: route.key
|
|
});
|
|
}
|
|
}, 50), [navigation, route.key]);
|
|
const context = useContext(Module5605);
|
|
const context2 = useContext(HeaderShownContext);
|
|
const headerStatusBarHeight = options.headerStatusBarHeight !== void 0 ? options.headerStatusBarHeight : context ? 0 : context2 ? 0 : safeAreaInsets.top;
|
|
const props2 = {
|
|
...options,
|
|
title: getHeaderTitle(options, route.name),
|
|
progress,
|
|
layout,
|
|
modal: context
|
|
};
|
|
if (options.headerBackTitle !== void 0) {
|
|
headerBackTitle = options.headerBackTitle;
|
|
}
|
|
props2.headerBackTitle = headerBackTitle;
|
|
props2.headerStatusBarHeight = headerStatusBarHeight;
|
|
props2.onGoBack = back ? callback : void 0;
|
|
props2.styleInterpolator = styleInterpolator;
|
|
return <HeaderSegment {...props2} />;
|
|
});
|