Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: need text zoom in webview #240

Open
2 of 3 tasks
owencyc opened this issue Nov 27, 2024 · 0 comments
Open
2 of 3 tasks

feat: need text zoom in webview #240

owencyc opened this issue Nov 27, 2024 · 0 comments

Comments

@owencyc
Copy link

owencyc commented Nov 27, 2024

Current problem

I used this method
InAppBrowser.openWebView
to open a web page in main app, and listen some message to handle text zoom

`
import { TextZoom } from '@capacitor/text-zoom'
InAppBrowser.addListener('messageFromWebview', async (event) => {

console.log('messageFromWebview', event.detail)
switch (event.detail.action) {
  case 'getTextZoom':
    let zoom = 1.0
    if (event.detail.type === 'preferred') {
      zoom = (await TextZoom.getPreferred()).value
    } else {
      zoom = (await TextZoom.get()).value
    }
    await InAppBrowser.postMessage({
      detail: {
        zoom: zoom
      }
    })
    break
  case 'setTextZoom':
    if (event.detail.zoom && event.detail.zoom > 0) {
      await TextZoom.set({
        value: event.detail.zoom
      })
    } else {
      showToast(t('action.invalid_zoom'))
    }
    break
  default:
    await Toast.show({
      text: `Native暂不支持此行为${event.detail.action}`
    })
    break
}

})

`

Then called the method on the web page to use text zoom
window.mobileApp.postMessage({ detail: { action: 'setTextZoom' ,zoom:1.2} })
but it didn't work with inappbrowser

Preferred solution

add some option in OpenWebViewOptions, make it support text zoom

Alternative options

No response

Additional context

No response

Before submitting

Fastest way to get this feature added

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant