Skip to content

Commit b942a25

Browse files
Steffen ErnstSteffen Ernst
Steffen Ernst
authored and
Steffen Ernst
committed
Fix daita and multihop view for iOS 16 and 17
1 parent 0b2d585 commit b942a25

File tree

1 file changed

+24
-33
lines changed

1 file changed

+24
-33
lines changed

ios/MullvadVPN/Coordinators/Settings/Views/SettingsInfoView.swift

+24-33
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,39 @@ struct SettingsInfoViewModelPage: Hashable {
1919

2020
struct SettingsInfoView: View {
2121
let viewModel: SettingsInfoViewModel
22-
@State var height: CGFloat = 0
2322

2423
// Extra spacing to allow for some room around the page indicators.
2524
var pageIndicatorSpacing: CGFloat {
2625
viewModel.pages.count > 1 ? 72 : 24
2726
}
2827

2928
var body: some View {
30-
TabView {
31-
ForEach(viewModel.pages, id: \.self) { page in
32-
VStack {
33-
contentView(for: page)
34-
Spacer()
29+
ZStack {
30+
// Renders (and hide) the content of each page, to push the view to the maximum possible size.
31+
VStack {
32+
ZStack {
33+
ForEach(viewModel.pages, id: \.self) { page in
34+
contentView(for: page)
35+
}
3536
}
36-
.padding(UIMetrics.SettingsInfoView.layoutMargins)
37+
Spacer()
38+
.frame(height: pageIndicatorSpacing)
39+
}
40+
.hidden()
41+
TabView {
42+
ForEach(viewModel.pages, id: \.self) { page in
43+
VStack {
44+
contentView(for: page)
45+
Spacer()
46+
}
47+
.padding(UIMetrics.SettingsInfoView.layoutMargins)
48+
}
49+
}
50+
.tabViewStyle(.page)
51+
.foregroundColor(Color(.primaryTextColor))
52+
.background {
53+
Color(.secondaryColor)
3754
}
38-
}
39-
.frame(
40-
height: height + pageIndicatorSpacing
41-
)
42-
.tabViewStyle(.page)
43-
.foregroundColor(Color(.primaryTextColor))
44-
.background {
45-
Color(.secondaryColor)
46-
preRenderViewSize()
4755
}
4856
}
4957

@@ -57,23 +65,6 @@ struct SettingsInfoView: View {
5765
.opacity(0.6)
5866
}
5967
}
60-
61-
// Renders the content of each page, determining the maximum height between them
62-
// when laid out on screen. Since we only want this to update the real view
63-
// this function should be called from a .background() and its contents hidden.
64-
private func preRenderViewSize() -> some View {
65-
ZStack {
66-
ForEach(viewModel.pages, id: \.self) { page in
67-
contentView(for: page)
68-
}
69-
}
70-
.hidden()
71-
.sizeOfView { size in
72-
if size.height > height {
73-
height = size.height
74-
}
75-
}
76-
}
7768
}
7869

7970
#Preview("Single page") {

0 commit comments

Comments
 (0)