feat: 适配 headerbar ios26

This commit is contained in:
richarjiang
2025-10-14 16:31:19 +08:00
parent cf069f3537
commit 435f5cc65c
41 changed files with 493 additions and 5445 deletions

View File

@@ -0,0 +1,32 @@
import { useSafeAreaInsets } from 'react-native-safe-area-context';
/**
* 获取安全区域距离并添加额外间距的 hook
* @param extraPadding 额外的间距对象,默认所有方向都是 0
* @returns 包含所有方向安全区域距离加上额外间距的对象
*/
export const useSafeAreaWithPadding = (extraPadding: {
top?: number;
bottom?: number;
left?: number;
right?: number;
} = {}) => {
const insets = useSafeAreaInsets();
return {
top: insets.top + (extraPadding.top || 40),
bottom: insets.bottom + (extraPadding.bottom || 0),
left: insets.left + (extraPadding.left || 0),
right: insets.right + (extraPadding.right || 0),
};
};
/**
* 获取安全区域顶部距离的 hook
* @param extraPadding 额外的间距,默认为 20 像素
* @returns 顶部安全区域距离加上额外间距的总值
*/
export const useSafeAreaTop = (extraPadding: number = 50) => {
const insets = useSafeAreaInsets();
return insets.top + extraPadding;
};