Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up legacy VPN navigation #3266

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,6 @@
EE01EB402AFBD0000096AAC9 /* NetworkProtectionVPNSettingsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE01EB3F2AFBD0000096AAC9 /* NetworkProtectionVPNSettingsViewModel.swift */; };
EE01EB432AFC1E0A0096AAC9 /* NetworkProtectionVPNLocationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE01EB422AFC1E0A0096AAC9 /* NetworkProtectionVPNLocationView.swift */; };
EE0798C52B179936000A4F64 /* NetworkProtectionVPNCountryLabelsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE0798C42B179936000A4F64 /* NetworkProtectionVPNCountryLabelsModel.swift */; };
EE276BEA2A77F823009167B6 /* NetworkProtectionRootViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE276BE92A77F823009167B6 /* NetworkProtectionRootViewController.swift */; };
EE3766DE2AC5945500AAB575 /* NetworkProtectionUNNotificationPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE3766DD2AC5945500AAB575 /* NetworkProtectionUNNotificationPresenter.swift */; };
EE3B226B29DE0F110082298A /* MockInternalUserStoring.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE3B226A29DE0F110082298A /* MockInternalUserStoring.swift */; };
EE3B226C29DE0FD30082298A /* MockInternalUserStoring.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE3B226A29DE0F110082298A /* MockInternalUserStoring.swift */; };
Expand Down Expand Up @@ -2706,7 +2705,6 @@
EE01EB3F2AFBD0000096AAC9 /* NetworkProtectionVPNSettingsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionVPNSettingsViewModel.swift; sourceTree = "<group>"; };
EE01EB422AFC1E0A0096AAC9 /* NetworkProtectionVPNLocationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionVPNLocationView.swift; sourceTree = "<group>"; };
EE0798C42B179936000A4F64 /* NetworkProtectionVPNCountryLabelsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionVPNCountryLabelsModel.swift; sourceTree = "<group>"; };
EE276BE92A77F823009167B6 /* NetworkProtectionRootViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionRootViewController.swift; sourceTree = "<group>"; };
EE3766DD2AC5945500AAB575 /* NetworkProtectionUNNotificationPresenter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionUNNotificationPresenter.swift; sourceTree = "<group>"; };
EE3B226A29DE0F110082298A /* MockInternalUserStoring.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockInternalUserStoring.swift; sourceTree = "<group>"; };
EE3B98EA2A9634CC002F63A0 /* DuckDuckGoAlpha.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DuckDuckGoAlpha.entitlements; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5155,7 +5153,6 @@
isa = PBXGroup;
children = (
EE0153EC2A6FF9E6002A8B26 /* NetworkProtectionRootView.swift */,
EE276BE92A77F823009167B6 /* NetworkProtectionRootViewController.swift */,
);
name = Root;
sourceTree = "<group>";
Expand Down Expand Up @@ -7098,7 +7095,6 @@
6F691CCA2C4979EC002E9553 /* FavoritesTooltip.swift in Sources */,
D65625952C22D382006EF297 /* TabViewController.swift in Sources */,
8C4838B5221C8F7F008A6739 /* GestureToolbarButton.swift in Sources */,
EE276BEA2A77F823009167B6 /* NetworkProtectionRootViewController.swift in Sources */,
310ECFDD282A8BB0005029B3 /* EnableAutofillSettingsTableViewCell.swift in Sources */,
6F9FFE2A2C57ADB100A238BE /* EditableShortcutsView.swift in Sources */,
1E908BF329827C480008C8F3 /* AutoconsentManagement.swift in Sources */,
Expand Down
6 changes: 2 additions & 4 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1031,10 +1031,8 @@ extension AppDelegate: UNUserNotificationCenterDelegate {

func presentNetworkProtectionStatusSettingsModal() {
Task {
if case .success(let hasEntitlements) = await accountManager.hasEntitlement(forProductName: .networkProtection),
hasEntitlements {
let networkProtectionRoot = NetworkProtectionRootViewController()
presentSettings(with: networkProtectionRoot)
if case .success(let hasEntitlements) = await accountManager.hasEntitlement(forProductName: .networkProtection), hasEntitlements {
(window?.rootViewController as? MainViewController)?.segueToVPN()
} else {
(window?.rootViewController as? MainViewController)?.segueToPrivacyPro()
}
Expand Down
8 changes: 8 additions & 0 deletions DuckDuckGo/MainViewController+Segues.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,14 @@ extension MainViewController {
}
}

func segueToVPN() {
os_log(#function, log: .generalLog, type: .debug)
hideAllHighlightsIfNeeded()
launchSettings {
$0.triggerDeepLinkNavigation(to: .netP)
}
}

func segueToDebugSettings() {
os_log(#function, log: .generalLog, type: .debug)
hideAllHighlightsIfNeeded()
Expand Down
13 changes: 8 additions & 5 deletions DuckDuckGo/NetworkProtectionRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
import SwiftUI
import NetworkProtection
import Subscription
import Core

struct NetworkProtectionRootView: View {

let statusViewModel: NetworkProtectionStatusViewModel

init() {
Expand All @@ -33,11 +35,12 @@ struct NetworkProtectionRootView: View {
serverInfoObserver: AppDependencyProvider.shared.serverInfoObserver,
locationListRepository: locationListRepository)
}

var body: some View {
if AppDependencyProvider.shared.vpnFeatureVisibility.isPrivacyProLaunched() {
quanganhdo marked this conversation as resolved.
Show resolved Hide resolved
NetworkProtectionStatusView(
statusModel: statusViewModel
)
}
NetworkProtectionStatusView(statusModel: statusViewModel)
.navigationTitle(UserText.netPNavTitle)
.onFirstAppear {
Pixel.fire(pixel: .privacyProVPNSettings)
}
}
}
50 changes: 0 additions & 50 deletions DuckDuckGo/NetworkProtectionRootViewController.swift

This file was deleted.

5 changes: 2 additions & 3 deletions DuckDuckGo/SettingsLegacyViewProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class SettingsLegacyViewProvider: ObservableObject {
fireproofSites,
autoclearData,
keyboard,
netP,
feedback, debug
feedback,
debug
}

private func instantiate(_ identifier: String, fromStoryboard name: String) -> UIViewController {
Expand All @@ -81,7 +81,6 @@ class SettingsLegacyViewProvider: ObservableObject {
var autoclearData: UIViewController { instantiate("AutoClearSettingsViewController", fromStoryboard: "Settings") }
var keyboard: UIViewController { instantiate("Keyboard", fromStoryboard: "Settings") }
var feedback: UIViewController { instantiate("Feedback", fromStoryboard: "Feedback") }
var netP: UIViewController { NetworkProtectionRootViewController() }

@MainActor
var syncSettings: UIViewController {
Expand Down
16 changes: 2 additions & 14 deletions DuckDuckGo/SettingsRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ struct SettingsRootView: View {
DispatchQueue.main.async {
self.shouldDisplayDeepLinkPush = true
}
case.UIKitView:
DispatchQueue.main.async {
triggerLegacyLink(link)
}
}
})

Expand Down Expand Up @@ -129,19 +125,11 @@ struct SettingsRootView: View {
onDisappear: {})
case .duckPlayer:
SettingsDuckPlayerView().environmentObject(viewModel)
default:
EmptyView()
}
quanganhdo marked this conversation as resolved.
Show resolved Hide resolved
}

private func triggerLegacyLink(_ link: SettingsViewModel.SettingsDeepLinkSection) {
switch link {
case .netP:
viewModel.presentLegacyView(.netP)
default:
return
NetworkProtectionRootView()
}
}

}

struct InsetGroupedListStyleModifier: ViewModifier {
Expand Down
14 changes: 8 additions & 6 deletions DuckDuckGo/SettingsSubscriptionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct SettingsSubscriptionView: View {
@EnvironmentObject var subscriptionNavigationCoordinator: SubscriptionNavigationCoordinator
@State var isShowingDBP = false
@State var isShowingITP = false
@State var isShowingVPN = false
@State var isShowingRestoreFlow = false
@State var isShowingGoogleView = false
@State var isShowingStripeView = false
Expand Down Expand Up @@ -155,12 +156,13 @@ struct SettingsSubscriptionView: View {
private var subscriptionDetailsView: some View {

if viewModel.state.subscription.entitlements.contains(.networkProtection) {
SettingsCellView(label: UserText.settingsPProVPNTitle,
image: Image("SettingsPrivacyProVPN"),
action: { viewModel.presentLegacyView(.netP) },
statusIndicator: StatusIndicatorView(status: viewModel.state.networkProtectionConnected ? .on : .off),
disclosureIndicator: true,
isButton: true)
NavigationLink(destination: NetworkProtectionRootView(), isActive: $isShowingVPN) {
SettingsCellView(
label: UserText.settingsPProVPNTitle,
image: Image("SettingsPrivacyProVPN"),
statusIndicator: StatusIndicatorView(status: viewModel.state.networkProtectionConnected ? .on : .off)
)
}
}

if viewModel.state.subscription.entitlements.contains(.dataBrokerProtection) {
Expand Down
13 changes: 1 addition & 12 deletions DuckDuckGo/SettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -598,10 +598,6 @@ extension SettingsViewModel {

case .autoconsent:
pushViewController(legacyViewProvider.autoConsent)

case .netP:
firePixel(.privacyProVPNSettings)
pushViewController(legacyViewProvider.netP)
}
}

Expand Down Expand Up @@ -654,13 +650,7 @@ extension SettingsViewModel {
// Default to .sheet, specify .push where needed
var type: DeepLinkType {
switch self {
// Specify cases that require .push presentation
// Example:
// case .dbp:
// return .sheet
case .netP:
return .UIKitView
default:
case .netP, .dbp, .itr, .subscriptionFlow, .restoreFlow, .duckPlayer:
return .navigationLink
}
}
Expand All @@ -670,7 +660,6 @@ extension SettingsViewModel {
enum DeepLinkType {
case sheet
case navigationLink
case UIKitView
}

// Navigate to a section in settings
Expand Down
Loading