import { window } from "@kit.ArkUI" export interface AvoidType { top?: number, bottom?: number } export class YTAvoid { /** * @type number * @description 顶部安全区高度 */ static readonly SAFE_TOP_KEY: string = 'safeTop' /** * @type number * @description 底部安全区高度 */ static readonly SAFE_BOTTOM_KEY: string = 'bottomTop' static setAvoid(avoid: AvoidType) { if (typeof avoid.top != 'undefined') { AppStorage.setOrCreate(YTAvoid.SAFE_TOP_KEY, px2vp(avoid.top)) } if (typeof avoid.bottom != 'undefined') { AppStorage.setOrCreate(YTAvoid.SAFE_BOTTOM_KEY, px2vp(avoid.bottom)) } } static getTop() { return AppStorage.get(YTAvoid.SAFE_TOP_KEY) } static getBottom() { return AppStorage.get(YTAvoid.SAFE_BOTTOM_KEY) } static setTop(safeTop: number) { AppStorage.setOrCreate(YTAvoid.SAFE_TOP_KEY, safeTop) } static setBottom(safeBottom: number) { AppStorage.setOrCreate(YTAvoid.SAFE_BOTTOM_KEY, safeBottom) } static setStatusBarContentColor(color: string, context: Context) { window.getLastWindow(context, (err, windowClass) => { if (!err) { windowClass.setWindowSystemBarProperties({ statusBarContentColor: color }) } else { // YTLog.error(err) } }) } }