diff options
| author | Emīls <emils@mullvad.net> | 2025-01-17 12:50:45 +0100 |
|---|---|---|
| committer | Emīls <emils@mullvad.net> | 2025-01-17 12:50:45 +0100 |
| commit | c89b219bb382be365b60868c5b40f669c1292941 (patch) | |
| tree | 499257df60e0ed2c912c2807d90699e2ba9a6cda | |
| parent | 1f73c82cabc54c11751ba94fcbf942fa95eb6802 (diff) | |
| parent | 3b7982f7d32741b08775aeca13f1e42f2aa8f7ac (diff) | |
| download | mullvadvpn-c89b219bb382be365b60868c5b40f669c1292941.tar.xz mullvadvpn-c89b219bb382be365b60868c5b40f669c1292941.zip | |
Merge branch 'fix-daita-view-on-ios15'
| -rw-r--r-- | ios/CHANGELOG.md | 2 | ||||
| -rw-r--r-- | ios/MullvadVPN/Coordinators/Settings/Views/SettingsInfoContainerView.swift | 8 | ||||
| -rw-r--r-- | ios/MullvadVPN/Coordinators/Settings/Views/SettingsInfoView.swift | 130 |
3 files changed, 96 insertions, 44 deletions
diff --git a/ios/CHANGELOG.md b/ios/CHANGELOG.md index b18f669447..01f57d4267 100644 --- a/ios/CHANGELOG.md +++ b/ios/CHANGELOG.md @@ -22,6 +22,8 @@ Line wrap the file at 100 chars. Th * **Security**: in case of vulnerabilities. ## Unreleased +### Fixed +- Broken DAITA settings view on iOS 15. ## [2025.1 - 2025-01-14] ### Added diff --git a/ios/MullvadVPN/Coordinators/Settings/Views/SettingsInfoContainerView.swift b/ios/MullvadVPN/Coordinators/Settings/Views/SettingsInfoContainerView.swift index 1247930dfa..df09e5690a 100644 --- a/ios/MullvadVPN/Coordinators/Settings/Views/SettingsInfoContainerView.swift +++ b/ios/MullvadVPN/Coordinators/Settings/Views/SettingsInfoContainerView.swift @@ -16,16 +16,12 @@ struct SettingsInfoContainerView<Content: View>: View { } var body: some View { - ZStack { - List { + ScrollView { + VStack { content - .listRowInsets(EdgeInsets()) - .listRowSeparator(.hidden) - .listRowBackground(Color(.secondaryColor)) .padding(.top, UIMetrics.contentInsets.top) .padding(.bottom, UIMetrics.contentInsets.bottom) } - .listStyle(.plain) } .background(Color(.secondaryColor)) } diff --git a/ios/MullvadVPN/Coordinators/Settings/Views/SettingsInfoView.swift b/ios/MullvadVPN/Coordinators/Settings/Views/SettingsInfoView.swift index 62f4eeb3c3..7b46b25857 100644 --- a/ios/MullvadVPN/Coordinators/Settings/Views/SettingsInfoView.swift +++ b/ios/MullvadVPN/Coordinators/Settings/Views/SettingsInfoView.swift @@ -19,7 +19,6 @@ struct SettingsInfoViewModelPage: Hashable { struct SettingsInfoView: View { let viewModel: SettingsInfoViewModel - @State var height: CGFloat = 0 // Extra spacing to allow for some room around the page indicators. var pageIndicatorSpacing: CGFloat { @@ -27,51 +26,44 @@ struct SettingsInfoView: View { } var body: some View { - TabView { - ForEach(viewModel.pages, id: \.self) { page in - VStack { - contentView(for: page) - Spacer() - } - .padding(UIMetrics.SettingsInfoView.layoutMargins) + ZStack { + TabView { + contentView() } - } - .frame( - height: height + pageIndicatorSpacing - ) - .tabViewStyle(.page) - .foregroundColor(Color(.primaryTextColor)) - .background { - Color(.secondaryColor) - preRenderViewSize() + .padding(UIMetrics.SettingsInfoView.layoutMargins) + .tabViewStyle(.page) + .foregroundColor(Color(.primaryTextColor)) + .background { + Color(.secondaryColor) + } + hiddenViewToStretchHeightInsideScrollView() } } - private func contentView(for page: SettingsInfoViewModelPage) -> some View { - VStack(alignment: .leading, spacing: 16) { - Image(page.image) - .resizable() - .aspectRatio(contentMode: .fit) - Text(page.body) - .font(.subheadline) - .opacity(0.6) +// A TabView inside a Scrollview has no height. This hidden view stretches the TabView to have the size of the heighest page. + private func hiddenViewToStretchHeightInsideScrollView() -> some View { + return ZStack { + contentView() } + .padding(UIMetrics.SettingsInfoView.layoutMargins) + .padding(.bottom, 1) + .hidden() } - // Renders the content of each page, determining the maximum height between them - // when laid out on screen. Since we only want this to update the real view - // this function should be called from a .background() and its contents hidden. - private func preRenderViewSize() -> some View { - ZStack { - ForEach(viewModel.pages, id: \.self) { page in - contentView(for: page) - } - } - .hidden() - .sizeOfView { size in - if size.height > height { - height = size.height + private func contentView() -> some View { + ForEach(viewModel.pages, id: \.self) { page in + VStack { + VStack(alignment: .leading, spacing: 16) { + Image(page.image) + .resizable() + .aspectRatio(contentMode: .fit) + Text(page.body) + .font(.subheadline) + .opacity(0.6) + } + Spacer() } + .padding(.bottom, pageIndicatorSpacing) } } } @@ -112,3 +104,65 @@ struct SettingsInfoView: View { ] )) } + +#Preview("Single inside Scrollview") { + ScrollView { + SettingsInfoView(viewModel: SettingsInfoViewModel( + pages: [ + SettingsInfoViewModelPage( + body: """ + Multihop routes your traffic into one WireGuard server and out another, making it \ + harder to trace. This results in increased latency but increases anonymity online. + """, + image: .multihopIllustration + ), + ] + )) + } +} + +#Preview("Multiple inside Scrollview") { + ScrollView { + SettingsInfoView(viewModel: SettingsInfoViewModel( + pages: [ + SettingsInfoViewModelPage( + body: NSLocalizedString( + "SETTINGS_INFO_DAITA_PAGE_1", + tableName: "Settings", + value: """ + DAITA (Defense against AI-guided Traffic Analysis) hides patterns in \ + your encrypted VPN traffic. + + By using sophisticated AI it’s possible to analyze the traffic of data \ + packets going in and out of your device (even if the traffic is encrypted). + + If an observer monitors these data packets, DAITA makes it significantly \ + harder for them to identify which websites you are visiting or with whom \ + you are communicating. + """, + comment: "" + ), + image: .daitaOffIllustration + ), + SettingsInfoViewModelPage( + body: NSLocalizedString( + "SETTINGS_INFO_DAITA_PAGE_2", + tableName: "Settings", + value: """ + DAITA does this by carefully adding network noise and making all network \ + packets the same size. + + Not all our servers are DAITA-enabled. Therefore, we use multihop \ + automatically to enable DAITA with any server. + + Attention: Be cautious if you have a limited data plan as this feature \ + will increase your network traffic. + """, + comment: "" + ), + image: .daitaOnIllustration + ), + ] + )) + } +} |
