import type { CSSProperties } from 'react'; import type { getSystemInfoSync } from '@tarojs/taro'; export type SystemInfo = ReturnType & { foldState?: string; isFoldable?: boolean; avoidAreas?: Array<{ left?: number; top?: number; x?: number; y?: number; width?: number; height?: number; }>; lengthScaleRatio?: number; deviceOrientation?: string; }; export type DuoOverlayScope = 'window' | 'base'; export type DuoPopupKind = 'center' | 'bottom' | 'top' | 'none'; export interface DuoRect { left: number; top: number; width: number; height: number; } export interface DuoOverlayLayoutOptions { overlayScope?: DuoOverlayScope; /** 内部布局状态:导航栏覆盖成功后,全窗横向布局包含原导航栏区域。 */ navigationBarHidden?: boolean; /** * center 弹层的 max-width(CSS px):默认 295(Popup); * 传 null 表示不写内联 max-width,沿用组件自己的 CSS(Dialog / Toast 自带宽度规则) */ centerMaxWidth?: number | null; } export interface DuoOverlayLayoutResult { enabled: boolean; windowRect: DuoRect; baseRect: DuoRect; overlayRect: DuoRect; popupStyle: CSSProperties; /** * 折叠中缝的 x 坐标(CSS px)。仅在半折叠横屏(中缝把内容区分成左右两半)时有值,其余为 null。 * 目前只知道中缝位置,不知道中缝宽度。 */ hingeX: number | null; } export declare const LANDSCAPE_ORIENTATIONS: Set; export declare const ACTIVE_FOLD_STATES: Set; export declare const FOLD_STATE_ALIASES: Record; export declare function normalizeFoldState(state: unknown): string | undefined; export declare function isDuoFoldFieldPresent(info: SystemInfo): boolean; export declare function isDuoLayoutEnabled(info: SystemInfo): boolean; export declare function isLandscapeOrientation(info: SystemInfo): boolean; export declare function readDuoLengthScaleRatio(info: SystemInfo): number; /** * getSystemInfo 返回的 window / screen / avoidAreas 是「屏幕 dp」, * 而写进 style 的 px 会被引擎再乘 lengthScaleRatio 渲染(实测 iPhone Duo 上 * 页面容器 CSS 宽 933 = windowWidth 867 / 0.929)。 * 所以所有由系统信息算出的长度,都要先除以 lengthScaleRatio 换成 CSS px, * 否则蒙层 / 弹层会整体偏小约 7%(全开时蒙层补不满,半折叠时离中缝差一截)。 */ export declare function toCssPx(info: SystemInfo, dp: number): number; export declare function windowRectFromInfo(info: SystemInfo): DuoRect; /** * 避让区(如折叠中缝)落在中缝右侧时,把 base 右边界收到避让区左边。 * hingeX 与 base 宽度使用同一个中缝坐标(screenWidth / 2),保证判定一致。 */ export declare function clipBaseRectForAvoidAreas(base: DuoRect, avoidAreas: SystemInfo['avoidAreas'], hingeX: number): DuoRect; /** * 半折叠横屏时折叠中缝的 x(CSS px),其余状态返回 null。 * 折叠中缝在整块屏幕的一半处;window 可能比 screen 窄(如右侧状态栏列), * 所以按 screenWidth 取一半。 */ export declare function computeHingeX(info: SystemInfo): number | null; export declare function computeBaseRect(info: SystemInfo): DuoRect; export declare function computeOverlayRect(windowRect: DuoRect, baseRect: DuoRect, scope: DuoOverlayScope): DuoRect; /** * 半弹面板最大宽度:设计稿 653dp × lengthScaleRatio(屏幕 dp)。 * 换算成 CSS px 后 ratio 约掉,直接是 653。 */ export declare const HALF_SHEET_MAX_CSS_PX = 653; /** 与 popup.scss 中 center 的 max-width 保持一致 */ export declare const CENTER_POPUP_MAX_WIDTH = 295; export declare function computePopupStyle(kind: DuoPopupKind, info: SystemInfo, baseRect: DuoRect, options?: DuoOverlayLayoutOptions): CSSProperties; /** * base 范围蒙层:只限定 left/top/width,纵向沿用 CSS 的 height: 100%。 * 固定定位容器的高度可能略大于 windowHeight(安全区等), * 写死 height 会导致蒙层底部补不全。 */ export declare function rectToOverlayStyle(rect: DuoRect): CSSProperties; export declare function resolveDuoOverlayLayout(info: SystemInfo, kind: DuoPopupKind, options?: DuoOverlayLayoutOptions): DuoOverlayLayoutResult; /** * 两次布局之间是否值得做过渡。 * none 在「整窗」时 popupStyle 为空(无固定定位),与收进 base 之间无法插值,直接跳变。 * 闭合和平铺状态均要求直接居中展示,不需要动效滑动到居中状态; * 仅在由居中形态切换到微弯形态(to.hingeX !== null)时允许平滑过渡到左侧屏。 */ export declare function shouldAnimateDuoLayout(from: DuoOverlayLayoutResult, to: DuoOverlayLayoutResult): boolean; /** * 在 from → to 之间按 t(0~1)线性插值:baseRect 与 popupStyle 中的数值字段。 * 直接插值 left / width,而不是叠加 transform,所以宽度变化(如 bottom 竖屏 → 半折叠横屏) * 也能平滑,并且不依赖「多个 transform 函数拼接」的引擎行为。 */ export declare function interpolateDuoLayout(from: DuoOverlayLayoutResult, to: DuoOverlayLayoutResult, t: number): DuoOverlayLayoutResult;