skiptools / skip-web Goto Github PK
View Code? Open in Web Editor NEWEmbedded WebView for Skip apps
License: GNU Lesser General Public License v3.0
Embedded WebView for Skip apps
License: GNU Lesser General Public License v3.0
It is common to want to load a locally-bundled HTML resource and load it in a web view, like so:
WebView(url: Bundle.main.url(forResource: "index", withExtension: "html", subdirectory: "about"))
This works in iOS, but on Android the load fails with the error:
The webpage at jar:file:/data/app/~~id/base.apk!/pgk/Resources/about/index.html could not be loaded because:
net::ERR_UNKOWN_URL_SCHEME
The problem is that the Android web view doesn't automatically handle the jar:file:
scheme.
If Skip resources were bundles as Android resources (which they aren't: they are traditional Java resources), then we might be able to transform local file loads into file://android_assets/
or file://android_res/
schemes, but this is expressly recommended against at https://developer.android.com/develop/ui/views/layout/webapps/load-local-content#antipatterns
The correct solution will probably be to implement a WebViewAssetLoader
, as per https://developer.android.com/develop/ui/views/layout/webapps/load-local-content#assetloader . This would enable the customization of resource loading, and we could use the same mechanism to implement bespoke content loading schemes (e.g., loading content from a zip archive). Parity with WKWebView
could be achieved through the WKNavigationDelegate
decidePolicyFor
delegate.
For the time being, the only workaround is to manually load the contents of the file into memory and load the HTML, like so:
WebView(html: try String(contentsOf: Bundle.main.url(forResource: "index", withExtension: "html", subdirectory: "about")))
This is very limited, though, because peer resources (e.g., scripts, stylesheets, and images) will not be resolved, so the HTML must be completely self-contained.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.