Skip to content

Commit

Permalink
Fix connection view background in iOS15
Browse files Browse the repository at this point in the history
  • Loading branch information
rablador committed Jan 21, 2025
1 parent 5b3b433 commit ad41168
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ struct ConnectionView: View {
@State private(set) var isExpanded = false

var action: ButtonPanel.Action?
var onContentUpdate: (() -> Void)?

var body: some View {
Spacer()
Expand All @@ -25,32 +24,26 @@ struct ConnectionView: View {
CustomProgressView(style: .large)
.showIf(connectionViewModel.showsActivityIndicator)

ZStack {
BlurView(style: .dark)
VStack(alignment: .leading, spacing: 0) {
HeaderView(viewModel: connectionViewModel, isExpanded: $isExpanded)
.padding(.bottom, headerViewBottomPadding)

VStack(alignment: .leading, spacing: 0) {
HeaderView(viewModel: connectionViewModel, isExpanded: $isExpanded)
.padding(.bottom, headerViewBottomPadding)
DetailsContainer(
connectionViewModel: connectionViewModel,
indicatorsViewModel: indicatorsViewModel,
isExpanded: $isExpanded
)
.showIf(connectionViewModel.showConnectionDetails)

DetailsContainer(
connectionViewModel: connectionViewModel,
indicatorsViewModel: indicatorsViewModel,
isExpanded: $isExpanded
)
.showIf(connectionViewModel.showConnectionDetails)

ButtonPanel(viewModel: connectionViewModel, action: action)
.padding(.top, 16)
}
.padding(16)
ButtonPanel(viewModel: connectionViewModel, action: action)
.padding(.top, 16)
}
.padding(16)
.background(BlurView(style: .dark))
.cornerRadius(12)
.padding(16)
}
.padding(.bottom, 8) // Some spacing to avoid overlap with the map legal link.
.onChange(of: isExpanded) { _ in
onContentUpdate?()
}
.onReceive(connectionViewModel.combinedState) { _, _ in
// Only update expanded state when connections details should be hidden.
// This will contract the view on eg. disconnect, but leave it as-is on
Expand All @@ -59,8 +52,6 @@ struct ConnectionView: View {
isExpanded = false
return
}

onContentUpdate?()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,11 @@ class TunnelViewController: UIViewController, RootContainment {
)

connectionView = ConnectionView(
connectionViewModel: self.connectionViewViewModel,
indicatorsViewModel: self.indicatorsViewViewModel
connectionViewModel: connectionViewViewModel,
indicatorsViewModel: indicatorsViewViewModel
)

super.init(nibName: nil, bundle: nil)

// When content size is updated in SwiftUI we need to explicitly tell UIKit to
// update its view size. This is not necessary on iOS 16 where we can set
// hostingController.sizingOptions instead.
connectionView.onContentUpdate = { [weak self] in
self?.connectionController?.view.setNeedsUpdateConstraints()
}
}

required init?(coder: NSCoder) {
Expand Down
7 changes: 2 additions & 5 deletions ios/MullvadVPN/Views/BlurView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ struct BlurView: View {
var style: UIBlurEffect.Style

var body: some View {
Spacer()
.overlay {
VisualEffectView(effect: UIBlurEffect(style: style))
.opacity(0.8)
}
VisualEffectView(effect: UIBlurEffect(style: style))
.opacity(0.8)
}
}

0 comments on commit ad41168

Please sign in to comment.