Skip to content

Commit 9ef2b22

Browse files
committed
ios: fix safe area
1 parent fa03491 commit 9ef2b22

File tree

9 files changed

+21
-11
lines changed

9 files changed

+21
-11
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<meta name="viewport" content="width=device-width, initial-scale=1" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
66
<meta name="theme-color" content="#000000" />
77
<title>BitBoxApp</title>
88
</head>
99
<body>
1010
<div id="root"></div>
1111
<script type="module" src="/src/index.tsx"></script>
1212
</body>
13-
</html>
13+
</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/bottom-navigation/bottom-navigation.module.css

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
position: fixed;
88
width: 100%;
99
height: var(--bottom-navigation-height);
10+
padding-top: calc(var(--space-half) - env(safe-area-inset-bottom, 0));
1011
justify-content: space-between;
1112
}
1213

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,11 @@
5858
}
5959

6060
.header {
61-
height: var(--item-height);
6261
display: flex;
6362
flex-direction: row;
6463
justify-content: space-between;
6564
align-items: center;
66-
padding: 0 var(--space-half);
65+
padding: 13.5px var(--space-half);
6766
border-bottom: solid 1px var(--background);
6867
}
6968

@@ -217,7 +216,7 @@
217216
}
218217

219218
.modal, .modal.small, .modal.medium, .modal.large {
220-
margin-top: var(--space-default);
219+
margin-top: calc(var(--space-default) + var(--space-half) + env(safe-area-inset-top, 0));
221220
max-width: 100vw;
222221
height: 100vh;
223222
/* mobile viewport bug fix */
@@ -236,4 +235,4 @@
236235
.contentContainer.padded {
237236
padding: var(--space-half);
238237
}
239-
}
238+
}

frontends/web/src/components/dropdown/mobile-fullscreen-selector.module.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@
4949
background-color: var(--background);
5050
cursor: default;
5151
display: flex;
52-
height: var(--item-height);
53-
padding: 0 var(--space-half);
52+
padding: 13.5px var(--space-half);
53+
padding-top: calc(13.5px + env(safe-area-inset-top, 0));
5454
position: relative;
5555
}
5656

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/components/view/view.module.css

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
position: fixed;
1111
right: 0;
1212
top: 0;
13+
padding-top: env(safe-area-inset-top, 0);
1314
/* z-index between sidebar (~4000) and wait-dialog (~10000) */
1415
z-index: 5100;
1516
}

frontends/web/src/style/variables.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
--guide-width: 350px;
106106

107107
/* bottom navigation */
108-
--bottom-navigation-height: 70px;
108+
--bottom-navigation-height: calc(70px + env(safe-area-inset-bottom, 0));
109109
}
110110

111111
:root,

0 commit comments

Comments
 (0)