Skip to content

Commit

Permalink
Combine notification settings into main settings UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
samsymons committed Mar 3, 2024
1 parent 1bb4180 commit 17bd882
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 195 deletions.
16 changes: 0 additions & 16 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -861,9 +861,7 @@
EE8594992A44791C008A6D06 /* NetworkProtectionTunnelController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE8594982A44791C008A6D06 /* NetworkProtectionTunnelController.swift */; };
EE8E568A2A56BCE400F11DCA /* NetworkProtection in Frameworks */ = {isa = PBXBuildFile; productRef = EE8E56892A56BCE400F11DCA /* NetworkProtection */; };
EE9D68D12AE00CF300B55EF4 /* NetworkProtectionVPNSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE9D68D02AE00CF300B55EF4 /* NetworkProtectionVPNSettingsView.swift */; };
EE9D68D52AE1526600B55EF4 /* NetworkProtectionVPNNotificationsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE9D68D42AE1526600B55EF4 /* NetworkProtectionVPNNotificationsView.swift */; };
EE9D68D82AE15AD600B55EF4 /* UIApplicationExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE9D68D72AE15AD600B55EF4 /* UIApplicationExtension.swift */; };
EE9D68DA2AE1659F00B55EF4 /* NetworkProtectionVPNNotificationsViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE9D68D92AE1659F00B55EF4 /* NetworkProtectionVPNNotificationsViewModel.swift */; };
EE9D68DC2AE16AE100B55EF4 /* NotificationsAuthorizationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE9D68DB2AE16AE100B55EF4 /* NotificationsAuthorizationController.swift */; };
EE9D68DE2AE2A65600B55EF4 /* UserDefaults+NetworkProtection.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE9D68DD2AE2A65600B55EF4 /* UserDefaults+NetworkProtection.swift */; };
EEC02C142B0519DE0045CE11 /* NetworkProtectionVPNLocationViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEC02C132B0519DE0045CE11 /* NetworkProtectionVPNLocationViewModel.swift */; };
Expand Down Expand Up @@ -2525,9 +2523,7 @@
EE7A92862AC6DE4700832A36 /* NetworkProtectionNotificationIdentifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionNotificationIdentifier.swift; sourceTree = "<group>"; };
EE8594982A44791C008A6D06 /* NetworkProtectionTunnelController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionTunnelController.swift; sourceTree = "<group>"; };
EE9D68D02AE00CF300B55EF4 /* NetworkProtectionVPNSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionVPNSettingsView.swift; sourceTree = "<group>"; };
EE9D68D42AE1526600B55EF4 /* NetworkProtectionVPNNotificationsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionVPNNotificationsView.swift; sourceTree = "<group>"; };
EE9D68D72AE15AD600B55EF4 /* UIApplicationExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIApplicationExtension.swift; sourceTree = "<group>"; };
EE9D68D92AE1659F00B55EF4 /* NetworkProtectionVPNNotificationsViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkProtectionVPNNotificationsViewModel.swift; sourceTree = "<group>"; };
EE9D68DB2AE16AE100B55EF4 /* NotificationsAuthorizationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsAuthorizationController.swift; sourceTree = "<group>"; };
EE9D68DD2AE2A65600B55EF4 /* UserDefaults+NetworkProtection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserDefaults+NetworkProtection.swift"; sourceTree = "<group>"; };
EEB8FDB92A990AEE00EBEDCF /* Configuration-Alpha.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Configuration-Alpha.xcconfig"; path = "Configuration/Configuration-Alpha.xcconfig"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4817,21 +4813,11 @@
name = VPNSettings;
sourceTree = "<group>";
};
EE9D68D62AE1527F00B55EF4 /* VPNNotifications */ = {
isa = PBXGroup;
children = (
EE9D68D42AE1526600B55EF4 /* NetworkProtectionVPNNotificationsView.swift */,
EE9D68D92AE1659F00B55EF4 /* NetworkProtectionVPNNotificationsViewModel.swift */,
);
name = VPNNotifications;
sourceTree = "<group>";
};
EECD94B22A28B8580085C66E /* NetworkProtection */ = {
isa = PBXGroup;
children = (
4B37E04E2B928C91009E81CA /* Resources */,
EE01EB412AFC1DE10096AAC9 /* PreferredLocation */,
EE9D68D62AE1527F00B55EF4 /* VPNNotifications */,
EE9D68CF2AE00CE000B55EF4 /* VPNSettings */,
EE458D122ABB651500FC651A /* Debug */,
EE0153E22A6FE031002A8B26 /* Root */,
Expand Down Expand Up @@ -6617,7 +6603,6 @@
C1B7B529289420830098FD6A /* RemoteMessaging.xcdatamodeld in Sources */,
986B16C425E92DF0007D23E8 /* BrowsingMenuViewController.swift in Sources */,
988AC355257E47C100793C64 /* RequeryLogic.swift in Sources */,
EE9D68D52AE1526600B55EF4 /* NetworkProtectionVPNNotificationsView.swift in Sources */,
1E4F4A5A297193DE00625985 /* MainViewController+CookiesManaged.swift in Sources */,
8586A10D24CBA7070049720E /* FindInPageActivity.swift in Sources */,
1E1626072968413B0004127F /* ViewExtension.swift in Sources */,
Expand Down Expand Up @@ -6958,7 +6943,6 @@
F1D796F41E7C2A410019D451 /* BookmarksDelegate.swift in Sources */,
D664C7B92B289AA200CBFA76 /* WKUserContentController+Handler.swift in Sources */,
C1B7B52428941F2A0098FD6A /* RemoteMessageRequest.swift in Sources */,
EE9D68DA2AE1659F00B55EF4 /* NetworkProtectionVPNNotificationsViewModel.swift in Sources */,
1E8AD1D727C2E24E00ABA377 /* DownloadsListRowViewModel.swift in Sources */,
1E865AF0272042DB001C74F3 /* TextSizeSettingsViewController.swift in Sources */,
D6E0C1892B7A2E0D00D5E1E9 /* DesktopDownloadViewModel.swift in Sources */,
Expand Down
8 changes: 1 addition & 7 deletions DuckDuckGo/NetworkProtectionConvenienceInitialisers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ extension NetworkProtectionCodeRedemptionCoordinator {
}
}

extension NetworkProtectionVPNNotificationsViewModel {
extension NetworkProtectionVPNSettingsViewModel {
convenience init() {
self.init(
notificationsAuthorization: NotificationsAuthorizationController(),
Expand All @@ -85,12 +85,6 @@ extension NetworkProtectionVPNNotificationsViewModel {
}
}

extension NetworkProtectionVPNSettingsViewModel {
convenience init() {
self.init(settings: VPNSettings(defaults: .networkProtectionGroupDefaults))
}
}

extension NetworkProtectionLocationListCompositeRepository {
convenience init() {
let settings = VPNSettings(defaults: .networkProtectionGroupDefaults)
Expand Down
3 changes: 0 additions & 3 deletions DuckDuckGo/NetworkProtectionStatusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,6 @@ struct NetworkProtectionStatusView: View {
NavigationLink(UserText.netPVPNSettingsTitle, destination: NetworkProtectionVPNSettingsView())
.daxBodyRegular()
.foregroundColor(.init(designSystemColor: .textPrimary))
NavigationLink(UserText.netPVPNNotificationsTitle, destination: NetworkProtectionVPNNotificationsView())
.daxBodyRegular()
.foregroundColor(.init(designSystemColor: .textPrimary))
} header: {
Text(UserText.netPStatusViewSettingsSectionTitle).foregroundColor(.init(designSystemColor: .textSecondary))
} footer: {
Expand Down
88 changes: 0 additions & 88 deletions DuckDuckGo/NetworkProtectionVPNNotificationsView.swift

This file was deleted.

79 changes: 0 additions & 79 deletions DuckDuckGo/NetworkProtectionVPNNotificationsViewModel.swift

This file was deleted.

51 changes: 50 additions & 1 deletion DuckDuckGo/NetworkProtectionVPNSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ struct NetworkProtectionVPNSettingsView: View {
}
}
.listRowBackground(Color(designSystemColor: .surface))

switch viewModel.viewKind {
case .loading: EmptyView()
case .unauthorized: notificationsUnauthorizedView
case .authorized: notificationAuthorizedView
}

toggleSection(
text: UserText.netPExcludeLocalNetworksSettingTitle,
footerText: UserText.netPExcludeLocalNetworksSettingFooter
Expand All @@ -59,6 +66,7 @@ struct NetworkProtectionVPNSettingsView: View {
viewModel.toggleExcludeLocalNetworks()
}
}

Section {
HStack(spacing: 16) {
Image("Info-Solid-24")
Expand All @@ -72,7 +80,11 @@ struct NetworkProtectionVPNSettingsView: View {
}
}
.applyInsetGroupedListStyle()
.navigationTitle(UserText.netPVPNSettingsTitle)
.navigationTitle(UserText.netPVPNSettingsTitle).onAppear {
Task {
await viewModel.onViewAppeared()
}
}
}

@ViewBuilder
Expand All @@ -98,6 +110,43 @@ struct NetworkProtectionVPNSettingsView: View {
}
.listRowBackground(Color(designSystemColor: .surface))
}

@ViewBuilder
private var notificationsUnauthorizedView: some View {
Section {
Button(UserText.netPTurnOnNotificationsButtonTitle) {
viewModel.turnOnNotifications()
}
.foregroundColor(.init(designSystemColor: .accent))
} footer: {
Text(UserText.netPTurnOnNotificationsSectionFooter)
.foregroundColor(.init(designSystemColor: .textSecondary))
.daxFootnoteRegular()
.padding(.top, 6)
}
.listRowBackground(Color(designSystemColor: .surface))
}

@ViewBuilder
private var notificationAuthorizedView: some View {
Section {
Toggle(
UserText.netPVPNAlertsToggleTitle,
isOn: Binding(
get: { viewModel.alertsEnabled },
set: viewModel.didToggleAlerts(to:)
)
)
.toggleStyle(SwitchToggleStyle(tint: .init(designSystemColor: .accent)))
} footer: {
Text(UserText.netPVPNAlertsToggleSectionFooter)
.foregroundColor(.init(designSystemColor: .textSecondary))
.daxFootnoteRegular()
.padding(.top, 6)
}
.listRowBackground(Color(designSystemColor: .surface))
}

}

#endif
Loading

0 comments on commit 17bd882

Please sign in to comment.