/*
 * @Author: wfl
 * @LastEditors: wfl
 * @description:
 * @updateInfo:
 * @Date: 2022-08-12 18:42:51
 * @LastEditTime: 2022-08-29 14:06:05
 */
import { ikingCore } from 'iking-vue-hooks';
import type { ComputedRef, InjectionKey } from 'vue';

export interface ContentContextProps {
  contentHeight: ComputedRef<number>;
  setPageHeight: (height: number) => Promise<void>;
}

const key: InjectionKey<ContentContextProps> = Symbol();

export function createContentContext(context: ContentContextProps) {
  return ikingCore.createContext<ContentContextProps>(context, key, { native: true });
}

export function useContentContext() {
  return ikingCore.useContext<ContentContextProps>(key);
}
