fix: adjust background color and scroll view insets for improved layout

This commit is contained in:
Sarto
2026-05-08 13:37:32 +03:30
parent d169af9e08
commit 476bebfe85
2 changed files with 13 additions and 2 deletions
+7 -2
View File
@@ -5,10 +5,15 @@ struct ContentView: View {
var body: some View {
ZStack {
Color.black.ignoresSafeArea()
// Background fills the notch + home-indicator area with the
// same color as the page so there's no visible band; the
// WebView itself stays *inside* the safe area so the page's
// CSS env(safe-area-inset-*) returns 0 and we don't end up
// double-padding (system inset + body padding).
Color(red: 0.07, green: 0.09, blue: 0.13).ignoresSafeArea()
if server.port > 0 {
WebView(url: URL(string: "http://127.0.0.1:\(server.port)")!)
.ignoresSafeArea()
.ignoresSafeArea(.keyboard)
} else if let err = server.lastError {
VStack(spacing: 12) {
Text("startup failed").font(.headline).foregroundColor(.white)
+6
View File
@@ -19,6 +19,12 @@ struct WebView: UIViewRepresentable {
let view = WKWebView(frame: .zero, configuration: cfg)
view.allowsBackForwardNavigationGestures = true
view.scrollView.bounces = true
// Don't double-pad the bottom: the page already adds
// env(safe-area-inset-bottom) via CSS; the WebView's automatic
// content inset would stack on top and leave a huge gap.
view.scrollView.contentInsetAdjustmentBehavior = .never
view.scrollView.contentInset = .zero
view.scrollView.scrollIndicatorInsets = .zero
view.navigationDelegate = context.coordinator
context.coordinator.webView = view