forked from Blendman974/faceclaw
Add EvenHub icon to phone preview screen
This commit is contained in:
1 parent
14d1f7f509
commit
ccbf523e9a
8 files changed
+100
-8
No files matched your search
@@ -23,6 +23,9 @@ window.__faceclawEvenHub = { postMessage: function(name, args, id) {
|
||||
export function createEvenHubWebView(session: EvenHubSession): EvenHubWebView {
|
||||
const host = FaceclawEvenHubWebView.new()
|
||||
host.packageIdentifier = session.manifest.packageId
|
||||
// The manager's close callback for the shown phone UI; the native back
|
||||
// button hides the host itself and reports it as a 'hidden' event.
|
||||
let onClose: (() => void) | null = null
|
||||
host.eventHandler = (json: string) => {
|
||||
try {
|
||||
const event = JSON.parse(json)
|
||||
@@ -30,6 +33,7 @@ export function createEvenHubWebView(session: EvenHubSession): EvenHubWebView {
|
||||
session.handleBridgeCall(event.name, event.args, event.id)
|
||||
else if (event.kind === 'loaded') session.webViewLoaded()
|
||||
else if (event.kind === 'error') session.webViewFailed(String(event.message))
|
||||
else if (event.kind === 'hidden') { const close = onClose; onClose = null; close?.() }
|
||||
else if (event.kind === 'console') console.log(`[evenhub:${session.manifest.name}] ${event.message}`)
|
||||
} catch (error) { console.warn(`EvenHub bridge: ${error}`) }
|
||||
}
|
||||
@@ -41,5 +45,6 @@ export function createEvenHubWebView(session: EvenHubSession): EvenHubWebView {
|
||||
}, 0)
|
||||
return { native: host, evaluateJs: js => host.evaluate(js),
|
||||
destroy: () => { clearTimeout(loading); host.destroy() },
|
||||
showOnPhone: () => host.showOnPhone(), hideOnPhone: () => host.hideOnPhone() }
|
||||
showOnPhone: close => { onClose = close; host.showOnPhone() },
|
||||
hideOnPhone: () => { onClose = null; host.hideOnPhone() } }
|
||||
}
|
||||
Reference in new issue
Block a user