Skip to content

Commit db69ef7

Browse files
committed
ios: fix safe area
1 parent 1ab3d9e commit db69ef7

File tree

5 files changed

+27
-13
lines changed

5 files changed

+27
-13
lines changed

frontends/ios/BitBoxApp/BitBoxApp/WebView.swift

+4
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ struct WebView: UIViewRepresentable {
128128
let webView = WKWebView(frame: .zero, configuration: config)
129129
webView.navigationDelegate = context.coordinator
130130
webView.uiDelegate = context.coordinator
131+
132+
// Disables automatic content inset adjustment to prevent safe area issues
133+
// https://developer.apple.com/documentation/uikit/uiscrollview/contentinsetadjustmentbehavior-swift.property
134+
webView.scrollView.contentInsetAdjustmentBehavior = .never
131135

132136
setHandlers.setMessageHandlers(handlers: MessageHandlers(webView: webView))
133137
let source = """

frontends/web/index.html

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="utf-8" />
5-
<meta name="viewport" content="width=device-width, initial-scale=1" />
6-
<meta name="theme-color" content="#000000" />
7-
<title>BitBoxApp</title>
8-
</head>
9-
<body>
10-
<div id="root"></div>
11-
<script type="module" src="/src/index.tsx"></script>
12-
</body>
13-
</html>
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
7+
<meta name="theme-color" content="#000000" />
8+
<title>BitBoxApp</title>
9+
</head>
10+
11+
<body>
12+
<div id="root"></div>
13+
<script type="module" src="/src/index.tsx"></script>
14+
</body>
15+
16+
</html>

frontends/web/src/app.module.css

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
min-width: 0;
77
/* mobile viewport bug fix */
88
max-height: -webkit-fill-available;
9+
/* iOS safe area handling */
10+
padding-top: env(safe-area-inset-top, 0);
11+
padding-left: env(safe-area-inset-left, 0);
12+
padding-right: env(safe-area-inset-right, 0);
913
}
1014

1115
@media (max-width: 900px) {

frontends/web/src/components/guide/guide.module.css

+3-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
.header {
5252
background-color: var(--color-blue);
5353
flex-shrink: 0;
54-
height: var(--header-height);
55-
padding: 0 var(--space-default);
54+
padding: 23px var(--space-default);
55+
padding-top: calc(23px + env(safe-area-inset-top, 0));
5656
}
5757

5858
.header h2 {
@@ -71,6 +71,7 @@
7171
flex-direction: column;
7272
flex-grow: 1;
7373
padding: 0 var(--space-default);
74+
padding-bottom: env(safe-area-inset-bottom, 0);
7475
}
7576

7677
.content h1 {

frontends/web/src/style/variables.css

+2
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@
103103

104104
/* guide */
105105
--guide-width: 350px;
106+
107+
/* iOS viewport height variable */
106108
}
107109

108110
:root,

0 commit comments

Comments
 (0)