Files
discord-decomp/_bundle/Header.jsx
T
2026-11-01 12:12:55 +02:00

170 lines
6.4 KiB
React

// Metro module 5157 (f5158).
import _objectWithoutProperties from "./_objectWithoutProperties";
import { useContext } from "react";
import { Animated, StyleSheet, View, Platform } from "react-native";
import { useSafeAreaInsets, useSafeAreaFrame } from "./Module1584";
import Module5158 from "./Module5158";
import getDefaultHeaderHeight from "./getDefaultHeaderHeight";
import HeaderTitle from "./HeaderTitle";
import HeaderBackground from "./HeaderBackground";
const _excluded = ["height", "minHeight", "maxHeight", "backgroundColor", "borderBottomColor", "borderBottomEndRadius", "borderBottomLeftRadius", "borderBottomRightRadius", "borderBottomStartRadius", "borderBottomWidth", "borderColor", "borderEndColor", "borderEndWidth", "borderLeftColor", "borderLeftWidth", "borderRadius", "borderRightColor", "borderRightWidth", "borderStartColor", "borderStartWidth", "borderStyle", "borderTopColor", "borderTopEndRadius", "borderTopLeftRadius", "borderTopRightRadius", "borderTopStartRadius", "borderTopWidth", "borderWidth", "boxShadow", "elevation", "shadowColor", "shadowOffset", "shadowOpacity", "shadowRadius", "opacity", "transform"];
Platform;
const styles = StyleSheet.create({
content: {
flex: 1,
flexDirection: "row",
alignItems: "stretch"
},
title: {
marginHorizontal: 16,
justifyContent: "center"
},
left: {
justifyContent: "center",
alignItems: "flex-start"
},
right: {
justifyContent: "center",
alignItems: "flex-end"
},
expand: {
flexGrow: 1,
flexBasis: 0
}
});
export default function Header(props) {
let maxWidth;
const safeAreaInsets = useSafeAreaInsets();
const safeAreaFrame = useSafeAreaFrame();
const context = useContext(Module5158);
const top = safeAreaInsets.top;
const { layout = safeAreaFrame, modal = false, title } = props;
let headerTitle = props.headerTitle;
const { headerTitleAlign = "left", headerLeft, headerLeftLabelVisible, headerTransparent, headerTintColor, headerBackground, headerRight, headerTitleAllowFontScaling, headerTitleStyle, headerLeftContainerStyle, headerRightContainerStyle, headerTitleContainerStyle, headerBackgroundContainerStyle } = props;
let headerStyle = props.headerStyle;
const { headerShadowVisible, headerPressColor, headerPressOpacity, headerStatusBarHeight = context ? 0 : top } = props;
const defaultHeaderHeight = getDefaultHeaderHeight(layout, modal, headerStatusBarHeight);
const height2 = headerStatusBarHeight;
if (!headerStyle) {
headerStyle = {};
}
const r67 = StyleSheet.flatten(headerStyle);
const { height = defaultHeaderHeight, minHeight, maxHeight, backgroundColor, borderBottomColor, borderBottomEndRadius, borderBottomLeftRadius, borderBottomRightRadius, borderBottomStartRadius, borderBottomWidth, borderColor, borderEndColor, borderEndWidth, borderLeftColor, borderLeftWidth, borderRadius, borderRightColor, borderRightWidth, borderStartColor, borderStartWidth, borderStyle, borderTopColor, borderTopEndRadius, borderTopLeftRadius, borderTopRightRadius, borderTopStartRadius, borderTopWidth, borderWidth, boxShadow, elevation, shadowColor, shadowOffset, shadowOpacity, shadowRadius, opacity, transform } = r67;
_objectWithoutProperties(r67, _excluded);
const r97 = {
backgroundColor,
borderBottomColor,
borderBottomEndRadius,
borderBottomLeftRadius,
borderBottomRightRadius,
borderBottomStartRadius,
borderBottomWidth,
borderColor,
borderEndColor,
borderEndWidth,
borderLeftColor,
borderLeftWidth,
borderRadius,
borderRightColor,
borderRightWidth,
borderStartColor,
borderStartWidth,
borderStyle,
borderTopColor,
borderTopEndRadius,
borderTopLeftRadius,
borderTopRightRadius,
borderTopStartRadius,
borderTopWidth,
borderWidth,
boxShadow,
elevation,
shadowColor,
shadowOffset,
shadowOpacity,
shadowRadius,
opacity,
transform
};
for (const key in r97) {
if (r97[key] === void 0) {
delete r97[key];
}
}
const style = [r97, headerShadowVisible === false && {
elevation: 0,
shadowOpacity: 0,
borderBottomWidth: 0
}];
const children = headerLeft ? headerLeft({
tintColor: headerTintColor,
pressColor: headerPressColor,
pressOpacity: headerPressOpacity,
labelVisible: headerLeftLabelVisible
}) : null;
const r108 = headerRight ? headerRight({
tintColor: headerTintColor,
pressColor: headerPressColor,
pressOpacity: headerPressOpacity
}) : null;
if (typeof headerTitle !== "function") {
headerTitle = (a0) => <HeaderTitle {...a0} />;
}
const r129 = [<Animated.View pointerEvents="box-none" style={[StyleSheet.absoluteFill, {
zIndex: 0
}, headerBackgroundContainerStyle]}>
{headerBackground ? headerBackground({
style
}) : headerTransparent ? null : <HeaderBackground style={style} />}
</Animated.View>, ,];
const View2 = Animated.View;
const children2 = [<View pointerEvents="none" style={{
height: height2
}} />, ,];
const View3 = Animated.View;
const style2 = [styles.left, , , ,];
const r6 = headerTitleAlign === "center";
style2[1] = r6 && styles.expand;
style2[2] = {
marginStart: safeAreaInsets.left
};
style2[3] = headerLeftContainerStyle;
const r151 = [<View3 pointerEvents="box-none" style={style2}>{children}</View3>, , ,];
const View4 = Animated.View;
const style3 = [styles.title, , ,];
const width = layout.width;
let r156 = 16;
if (r6) {
if (children) {
r156 = headerLeftLabelVisible !== false ? 80 : 32;
}
maxWidth = width - 2 * (r156 + Math.max(safeAreaInsets.left, safeAreaInsets.right));
} else {
maxWidth = width - ((children ? 72 : 16) + (r108 ? 72 : 16) + safeAreaInsets.left - safeAreaInsets.right);
}
style3[1] = {
maxWidth
};
style3[2] = headerTitleContainerStyle;
r151[1] = <View4 pointerEvents="box-none" style={style3}>
{headerTitle({
children: title,
allowFontScaling: headerTitleAllowFontScaling,
tintColor: headerTintColor,
style: headerTitleStyle
})}
</View4>;
r151[2] = <Animated.View pointerEvents="box-none" style={[styles.right, styles.expand, {
marginEnd: safeAreaInsets.right
}, headerRightContainerStyle]}>{r108}</Animated.View>;
children2[1] = <View pointerEvents="box-none" style={styles.content}>{r151}</View>;
r129[1] = <View2 pointerEvents="box-none" style={[{
height,
minHeight,
maxHeight,
opacity,
transform
}]}>{children2}</View2>;
return <>{r129}</>;
};