Skip to content

feat(mobile-ui): webview php + fullscreen modes#10

Open
simonhamp wants to merge 1 commit into
feat/webview-elementfrom
feat/webview-php-fullscreen
Open

feat(mobile-ui): webview php + fullscreen modes#10
simonhamp wants to merge 1 commit into
feat/webview-elementfrom
feat/webview-php-fullscreen

Conversation

@simonhamp

Copy link
Copy Markdown
Member

What

Expands <x-webview /> with two bare boolean attributes:

fullscreen

<x-webview fullscreen /> — the v3 default-webview presentation. The PHP element applies fill layout; the iOS renderer additionally extends behind the safe areas (.ignoresSafeArea(.container, edges: .all)). On Android edge-to-edge follows from fill layout plus the shell's transparent system bars.

php

<x-webview php /> — swaps the locked-down sandbox for the app's own enriched Laravel webview: pages served by the embedded PHP runtime with the full window.Native bridge, shared session, and asset pipeline. src becomes an app route path (<x-webview php src="/dashboard" />); omitted, the app's configured start URL loads.

iOS (PHPWebViewContainer): an independent WKWebView wired exactly like the shell's classic webview — PHPSchemeHandler on php://, shared WebView.dataStore (same Laravel session), and the shell's addNativeHelper user scripts (safe-area CSS vars + window.Native). External-scheme links open via the system. Unlike the shell coordinator, ours never toggles NativeUIBridge web/native mode — this webview lives inside the native tree.

Android (PhpWebView): a renderer-owned WebView run through the framework's full WebViewManager.setup() (settings, cookies, http://127.0.0.1 PHP interception, POST-capture bridge, window.Native injection), with two integration hazards defused:

  • setup() claims the process-wide WebViewManager.shared slot → restored to the app's root manager immediately after.
  • The stock client flips NativeUIBridge.isActive = false on every page load — correct for the root webview, fatal for one embedded inside the native tree (it would unmount this very renderer). A delegating PhpEmbedClient keeps everything the stock client does (including the POST-inspector script injection) and re-asserts native-UI mode.

Bug fix

@navigated on the existing webview never fired: _navigated isn't in NativeElementCollector::applyCallbacks' allowlist, so the Blade sugar was silently dropped. The element now wires it itself in applyAttributes.

Verification

  • New tests/WebviewTest.php: 6 collector-driven tests (sandbox defaults, opt-ins, fullscreen prop + fill layout, fullscreen="false", php mode, @navigated registration)
  • Full suite passes against nativephp/mobile 4.0.0-rc.1: 89 tests, 451 assertions
  • Swift parses clean; every cross-module seam was verified against the shell sources (PHPSchemeHandler, WebView.dataStore, addNativeHelper, WebViewManager.shared, MainActivity.instance, companion getStartURL, minSdk ≥ 26 for getWebViewClient())
  • ⚠️ Not yet device-tested — both php-mode renderers are new native code that hasn't rendered a frame on a simulator/device

Note

Stacked on #7 (feat/webview-element) — merge that first; GitHub retargets this to main when the base branch is deleted.

🤖 Generated with Claude Code

`<x-webview php />` swaps the locked-down sandbox for the app's own
enriched Laravel webview — pages served by the embedded PHP runtime with
the full window.Native bridge, shared session store, and asset pipeline.
`src` becomes an app route path; empty/relative falls back to the app's
configured start URL.

iOS builds an independent WKWebView wired like the shell's classic one
(PHPSchemeHandler on php://, shared WebView.dataStore, addNativeHelper
user scripts borrowed from the shell). Android runs the full
WebViewManager.setup() wiring on a renderer-owned WebView, restoring the
process-wide `shared` slot afterwards and wrapping the stock client so
its "page load = web mode" isActive flip can't unmount the native tree
this webview lives inside.

`<x-webview fullscreen />` gives the v3 default-webview presentation:
fill layout from the PHP side plus ignoresSafeArea on iOS.

Also fixes `@navigated` never firing: `_navigated` isn't in the
collector's callback allowlist, so the element now wires it in
applyAttributes itself.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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

Successfully merging this pull request may close these issues.

1 participant