How kevinnzou/compose-webview-multiplatform works
Project's Main Components
• Library Core (Common Module): This includes the shared logic for WebView state management (WebViewState), navigation (WebViewNavigator), JavaScript bridge (WebViewJsBridge), request interception (RequestInterceptor), and web settings (WebSettings).
• Platform-specific Implementations:
• Android: Utilizes a forked version of the Accompanist WebView and custom Android integrations in webview/src/androidMain.
• iOS: Uses WKWebView from Apple, with its code under webview/src/iosMain.
• Desktop: Initially had a JavaFX WebView implementation; later versions use Java CEF Browser / Kotlin CEF Browser with desktop-specific code under webview/src/desktopMain.
• Sample/Example Apps: These directories (sample/androidApp, sample/iosApp, sample/desktopApp) show how to integrate the library into real applications.
• Documentation and Build Tools: Tools like Gradle scripts, CI workflows, and documentation in docs/ and mkdocs.yml support the development and publishing process.
• Integration of external libraries:
• Android’s integration with the forked Accompanist WebView library.
• iOS’s connection to WKWebView.
• Desktop’s connectivity with Java CEF Browser (or Kotlin CEF Browser).
• How the state management (WebViewState) and navigator (WebViewNavigator) interact with the UI layer in Compose, and also how the JavaScript bridge enables bidirectional communication between the WebView content and native code.
Architectural Patterns & Design Principles
• Multiplatform Abstraction: Detail how common interfaces and implementations are shared across platforms, while delegating platform-specific logic to their respective source sets.
• Compose UI Integration: Emphasize that the composable functions provide a declarative approach to constructing the UI, which internally relies on native WebView implementations.
• Extensibility: Show the customizable nature of settings (via WebSettings) and interception (via RequestInterceptor), which are designed to allow consumers to alter behavior without modifying core logic.
• Separation of Concerns: The library neatly separates UI (composables), state management, navigation, native integrations, and utility functionality.
Final Checklist
• Every component (common module, Android, iOS, Desktop, external dependencies, and sample apps) is represented.
• Annotations where appropriate (for example, note version changes such as “From JavaFX to CEF on Desktop”).
• Be as detailed as possible to reflect each architectural element—from user input in the Compose UI to native WebView rendering and back to state updates.