Files
i-want-to-heal/src/nativeDualScreen.ts
T
2026-06-17 20:04:36 -04:00

43 lines
987 B
TypeScript

import { Capacitor, registerPlugin } from '@capacitor/core'
export type AndroidDisplay = {
id: number
name: string
width: number
height: number
refreshRate: number
isCurrent: boolean
isPresentation: boolean
}
type DualScreenNativePlugin = {
getDisplays: () => Promise<{
currentDisplayId: number
displays: AndroidDisplay[]
}>
openTopDisplay: (options?: { displayId?: number }) => Promise<AndroidDisplay & {
opened: boolean
}>
closeTopDisplay: () => Promise<void>
}
const nativePlugin = registerPlugin<DualScreenNativePlugin>('DualScreen')
export function hasNativeDualScreenBridge() {
return Capacitor.isNativePlatform()
}
export function getNativeDisplays() {
return nativePlugin.getDisplays()
}
export function openNativeTopDisplay(displayId?: number) {
return nativePlugin.openTopDisplay(
displayId === undefined ? undefined : { displayId },
)
}
export function closeNativeTopDisplay() {
return nativePlugin.closeTopDisplay()
}