Skip to content

Commit

Permalink
Clean up connection view animations
Browse files Browse the repository at this point in the history
  • Loading branch information
SteffenErn committed Jan 30, 2025
1 parent b6dc7e7 commit 96ea06d
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 188 deletions.
22 changes: 3 additions & 19 deletions ios/MullvadVPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
44075DFB2CDA4F7400F61139 /* UDPOverTCPObfuscationSettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44075DFA2CDA4F7400F61139 /* UDPOverTCPObfuscationSettingsViewModel.swift */; };
440E5AB02CDBD67D00B09614 /* StatefulPreviewWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 440E5AAF2CDBD67D00B09614 /* StatefulPreviewWrapper.swift */; };
440E5AB42CDCF24500B09614 /* TunnelObfuscationSettingsWatchingObservableObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = 440E5AB32CDCF24500B09614 /* TunnelObfuscationSettingsWatchingObservableObject.swift */; };
4419AA892D282687001B13C9 /* DetailsContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4419AA882D282687001B13C9 /* DetailsContainer.swift */; };
4419AA8B2D2826E5001B13C9 /* DetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4419AA8A2D2826E5001B13C9 /* DetailsView.swift */; };
4419AA8E2D2828A4001B13C9 /* HeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4419AA8D2D2828A4001B13C9 /* HeaderView.swift */; };
4422C0712CCFF6790001A385 /* UDPOverTCPObfuscationSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4422C0702CCFF6790001A385 /* UDPOverTCPObfuscationSettingsView.swift */; };
Expand Down Expand Up @@ -1015,7 +1014,6 @@
F0B495762D02025200CFEC2A /* ChipContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B495752D02025200CFEC2A /* ChipContainerView.swift */; };
F0B495782D02038B00CFEC2A /* ChipViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B495772D02038B00CFEC2A /* ChipViewModelProtocol.swift */; };
F0B4957A2D02F49200CFEC2A /* ChipFeature.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B495792D02F41F00CFEC2A /* ChipFeature.swift */; };
F0B4957C2D03154200CFEC2A /* FeatureIndicatorsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B4957B2D03154200CFEC2A /* FeatureIndicatorsView.swift */; };
F0B894EF2BF751C500817A42 /* RelayWithLocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B894EE2BF751C500817A42 /* RelayWithLocation.swift */; };
F0B894F12BF751E300817A42 /* RelayWithDistance.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B894F02BF751E300817A42 /* RelayWithDistance.swift */; };
F0B894F32BF7526700817A42 /* RelaySelector+Wireguard.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B894F22BF7526700817A42 /* RelaySelector+Wireguard.swift */; };
Expand Down Expand Up @@ -1460,7 +1458,6 @@
44075DFA2CDA4F7400F61139 /* UDPOverTCPObfuscationSettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UDPOverTCPObfuscationSettingsViewModel.swift; sourceTree = "<group>"; };
440E5AAF2CDBD67D00B09614 /* StatefulPreviewWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatefulPreviewWrapper.swift; sourceTree = "<group>"; };
440E5AB32CDCF24500B09614 /* TunnelObfuscationSettingsWatchingObservableObject.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelObfuscationSettingsWatchingObservableObject.swift; sourceTree = "<group>"; };
4419AA882D282687001B13C9 /* DetailsContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailsContainer.swift; sourceTree = "<group>"; };
4419AA8A2D2826E5001B13C9 /* DetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailsView.swift; sourceTree = "<group>"; };
4419AA8D2D2828A4001B13C9 /* HeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderView.swift; sourceTree = "<group>"; };
4422C0702CCFF6790001A385 /* UDPOverTCPObfuscationSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UDPOverTCPObfuscationSettingsView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2283,7 +2280,6 @@
F0B495752D02025200CFEC2A /* ChipContainerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChipContainerView.swift; sourceTree = "<group>"; };
F0B495772D02038B00CFEC2A /* ChipViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChipViewModelProtocol.swift; sourceTree = "<group>"; };
F0B495792D02F41F00CFEC2A /* ChipFeature.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChipFeature.swift; sourceTree = "<group>"; };
F0B4957B2D03154200CFEC2A /* FeatureIndicatorsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureIndicatorsView.swift; sourceTree = "<group>"; };
F0B894EE2BF751C500817A42 /* RelayWithLocation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayWithLocation.swift; sourceTree = "<group>"; };
F0B894F02BF751E300817A42 /* RelayWithDistance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayWithDistance.swift; sourceTree = "<group>"; };
F0B894F22BF7526700817A42 /* RelaySelector+Wireguard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RelaySelector+Wireguard.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2722,15 +2718,14 @@
4419AA862D28264D001B13C9 /* ConnectionView */ = {
isa = PBXGroup;
children = (
44E1F7572D3EA82C003A60FF /* DestinationDescriber.swift */,
F0ADF1CF2D01B50B00299F09 /* ChipView */,
7AA130972CFF364F00640DF9 /* FeatureIndicators */,
449E9A6E2D283C7400F8574A /* ButtonPanel.swift */,
F0ADF1CF2D01B50B00299F09 /* ChipView */,
7AA130982CFF365A00640DF9 /* ConnectionView.swift */,
449E9A6C2D283A2500F8574A /* ConnectionViewComponentPreview.swift */,
7A0EAEA32D06DF8200D3EB8B /* ConnectionViewViewModel.swift */,
4419AA882D282687001B13C9 /* DetailsContainer.swift */,
44E1F7572D3EA82C003A60FF /* DestinationDescriber.swift */,
4419AA8A2D2826E5001B13C9 /* DetailsView.swift */,
F0ADF1D22D01B6B400299F09 /* FeatureIndicatorsViewModel.swift */,
4419AA8D2D2828A4001B13C9 /* HeaderView.swift */,
);
path = ConnectionView;
Expand Down Expand Up @@ -4124,15 +4119,6 @@
path = SelectLocation;
sourceTree = "<group>";
};
7AA130972CFF364F00640DF9 /* FeatureIndicators */ = {
isa = PBXGroup;
children = (
F0B4957B2D03154200CFEC2A /* FeatureIndicatorsView.swift */,
F0ADF1D22D01B6B400299F09 /* FeatureIndicatorsViewModel.swift */,
);
path = FeatureIndicators;
sourceTree = "<group>";
};
7AD63A422CDA661B00445268 /* Extensions */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -6149,7 +6135,6 @@
587EB66A270EFACB00123C75 /* CharacterSet+IPAddress.swift in Sources */,
5888AD83227B11080051EB06 /* LocationCell.swift in Sources */,
5891BF1C25E3E3EB006D6FB0 /* Bundle+ProductVersion.swift in Sources */,
4419AA892D282687001B13C9 /* DetailsContainer.swift in Sources */,
5878A26F2907E7E00096FC88 /* ProblemReportInteractor.swift in Sources */,
7AB4CCBB2B691BBB006037F5 /* IPOverrideInteractor.swift in Sources */,
7A3353912AAA014400F0A71C /* SimulatorVPNConnection.swift in Sources */,
Expand Down Expand Up @@ -6225,7 +6210,6 @@
586C0D782B039CC000E7CDD7 /* AccessMethodProtocolPicker.swift in Sources */,
58677710290975E9006F721F /* SettingsInteractorFactory.swift in Sources */,
7A9CCCC02A96302800DD6A34 /* ProfileVoucherCoordinator.swift in Sources */,
F0B4957C2D03154200CFEC2A /* FeatureIndicatorsView.swift in Sources */,
7A9CCCBC2A96302800DD6A34 /* ChangeLogCoordinator.swift in Sources */,
58B26E282943527300D5980C /* SystemNotificationProvider.swift in Sources */,
F0ADF1D52D01DCFD00299F09 /* ChipView.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import SwiftUI

struct ChipModel: Identifiable, Hashable {
struct ChipModel: Identifiable {
var id: String { name }
let name: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,50 +23,55 @@ struct ConnectionView: View {
var body: some View {
Spacer()
.accessibilityIdentifier(AccessibilityIdentifier.connectionView.asString)

VStack(alignment: .leading, spacing: 16) {
VStack(alignment: .leading, spacing: 16) {
HeaderView(viewModel: connectionViewModel, isExpanded: $isExpanded)

if showConnectionDetailsAnimated {
if isExpandedAnimatied {
Divider()
.background(UIColor.secondaryTextColor.color)
}
if isExpandedAnimatied || !indicatorsViewModel.chips.isEmpty {
ScrollView {
VStack(alignment: .leading, spacing: 0) {
if !indicatorsViewModel.chips.isEmpty && isExpandedAnimatied {
Text(LocalizedStringKey("Active features"))
.font(.footnote.weight(.semibold))
.foregroundStyle(UIColor.primaryTextColor.color.opacity(0.6))
.padding(.bottom, isExpandedAnimatied ? 8 : 0)
}
ChipContainerView(viewModel: indicatorsViewModel, isExpanded: $isExpanded)
if isExpandedAnimatied {
DetailsView(viewModel: connectionViewModel)
.padding(.top, indicatorsViewModel.chips.isEmpty ? 0 : 16)
}
}
.sizeOfView { size in
withAnimation {
scrollViewHeight = size.height
}
}
Divider()
.background(UIColor.secondaryTextColor.color)
.showIf(isExpandedAnimatied)

ScrollView {
VStack(alignment: .leading, spacing: 0) {
Text(LocalizedStringKey("Active features"))
.font(.footnote.weight(.semibold))
.foregroundStyle(UIColor.primaryTextColor.color.opacity(0.6))
.padding(.bottom, isExpandedAnimatied ? 8 : 0)
.showIf(!indicatorsViewModel.chips.isEmpty && isExpandedAnimatied)

ChipContainerView(viewModel: indicatorsViewModel, isExpanded: $isExpanded)

DetailsView(viewModel: connectionViewModel)
.padding(.top, indicatorsViewModel.chips.isEmpty ? 0 : 16)
.showIf(isExpandedAnimatied)
}
.frame(maxHeight: scrollViewHeight)
.apply {
if #available(iOS 16.4, *) {
$0.scrollBounceBehavior(.basedOnSize)
} else {
$0
.sizeOfView { size in
withAnimation {
scrollViewHeight = size.height
}
}
}
.frame(maxHeight: scrollViewHeight)
.apply {
if #available(iOS 16.4, *) {
$0.scrollBounceBehavior(.basedOnSize)
} else {
$0
}
}
.showIf(isExpandedAnimatied || !indicatorsViewModel.chips.isEmpty)
}
}
.transformEffect(.identity)

ButtonPanel(viewModel: connectionViewModel, action: action)
}
.padding()
.background(BlurView(style: .dark))
.cornerRadius(12)
.padding()
.onChange(of: isExpanded) { newValue in
withAnimation {
isExpandedAnimatied = newValue
Expand All @@ -80,9 +85,6 @@ struct ConnectionView: View {
showConnectionDetailsAnimated = newValue
}
}
.background(BlurView(style: .dark))
.cornerRadius(12)
.padding()
}
}

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extension ConnectionView {

@State var titleForCountryAndCity: LocalizedStringKey?
@State var titleForServer: LocalizedStringKey?
@State var showConnectionDetails = false

var body: some View {
HStack(alignment: .top) {
VStack(alignment: .leading, spacing: 0) {
Expand Down Expand Up @@ -66,11 +66,6 @@ extension ConnectionView {
titleForServer = newValue
}
})
.onChange(of: viewModel.showsConnectionDetails) { newValue in
withAnimation {
showConnectionDetails = newValue
}
}
}
}
}
Expand Down

0 comments on commit 96ea06d

Please sign in to comment.