tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
79.91k stars 2.37k forks source link

[feat] Support transparent webviews on mobile #10152

Open johanholmerin opened 2 weeks ago

johanholmerin commented 2 weeks ago

Describe the problem

wry supports creating transparent webviews on both mobile and desktop, but AFAICT the tauri method is only enabled on desktop. I've only used v2 but from looking at the docs this might have been possible in v1?

Describe the solution you'd like

Enable calling WebviewWindowBuilder::transparent on mobile

Alternatives considered

No response

Additional context

No response

pewsheen commented 2 weeks ago

Current WebviewWindowBuilder::transparent seems bound to Tao's window transparent and Wry's webview transparent, but tao's is not compatible with mobile. I think we should find a way to configure it separately (split window transparent and webview transparent).

And I think the transparent should work with setting transparent: true in tauri.conf.json 🤔

johanholmerin commented 2 weeks ago

Yes, the static config seems to work.

For my use case(rendering a transparent webview on top of a window) it would be enough to add this code:

#[cfg(any(target_os = "ios", target_os = "android"))]
impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilder<'a, R, M> {
  pub fn transparent(mut self, transparent: bool) -> Self {
    self.webview_builder = self.webview_builder.transparent(transparent);
    self
  }
}