2025-11-26 01:06:21 +00:00
|
|
|
import {Capacitor} from "@capacitor/core"
|
2025-11-25 23:30:40 +00:00
|
|
|
import {Keyboard} from "@capacitor/keyboard"
|
2025-11-26 01:06:21 +00:00
|
|
|
import {noop} from "@welshman/lib"
|
2025-11-25 23:30:40 +00:00
|
|
|
|
|
|
|
|
export const syncKeyboard = () => {
|
|
|
|
|
if (!Capacitor.isNativePlatform()) return noop
|
|
|
|
|
|
|
|
|
|
const showListener = Keyboard.addListener("keyboardWillShow", () => {
|
|
|
|
|
document.body.classList.add("keyboard-open")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const hideListener = Keyboard.addListener("keyboardWillHide", () => {
|
|
|
|
|
document.body.classList.remove("keyboard-open")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
showListener.then(listener => listener.remove())
|
|
|
|
|
hideListener.then(listener => listener.remove())
|
|
|
|
|
document.body.classList.remove("keyboard-open")
|
|
|
|
|
}
|
|
|
|
|
}
|