页面顶部空白调整
This commit is contained in:
@@ -7,25 +7,24 @@ type TabMainHeaderProps = {
|
||||
extra?: ReactNode;
|
||||
};
|
||||
|
||||
const isH5 = process.env.TARO_ENV === 'h5';
|
||||
|
||||
/** Tab 页顶栏:适配刘海屏 + 微信胶囊避让;H5 不展示标题(与微信系统标题重复) */
|
||||
/**
|
||||
* Tab 页顶栏:仅在有右侧扩展内容时渲染。
|
||||
* 小程序 / H5 标题走系统导航栏,避免自定义顶栏造成顶部留白。
|
||||
*/
|
||||
export default function TabMainHeader({ title, extra }: TabMainHeaderProps) {
|
||||
const metrics = useNavBarMetrics();
|
||||
|
||||
// H5:系统标题已展示;无右侧内容时整栏不渲染,避免顶部留白
|
||||
if (isH5 && !extra) {
|
||||
if (!extra) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<View className="tab-main-header" style={navBarStyle(metrics)} aria-label={title}>
|
||||
{!isH5 ? <Text className="tab-main-header__title">{title}</Text> : null}
|
||||
<View
|
||||
className="tab-main-header__content"
|
||||
style={tabNavContentStyle(metrics)}
|
||||
>
|
||||
{extra ? <View className="tab-main-header__extra">{extra}</View> : null}
|
||||
{process.env.TARO_ENV !== 'h5' ? (
|
||||
<Text className="tab-main-header__title">{title}</Text>
|
||||
) : null}
|
||||
<View className="tab-main-header__content" style={tabNavContentStyle(metrics)}>
|
||||
<View className="tab-main-header__extra">{extra}</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user