Skip to content

Commit

Permalink
Subscriptions > Personal info Removal (#2468)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/72649045549333/1205043809052693/f

Description:

Adds links to MacOS and Windows browser dowload from Personal Information renewal
Removes all waitlist functionality related to macOS and Windows browser. (Use a simple SwiftUI View instead as there's no waitlist anymore)
  • Loading branch information
afterxleep authored Feb 13, 2024
1 parent 85a08dd commit 3fba355
Show file tree
Hide file tree
Showing 34 changed files with 651 additions and 1,529 deletions.
86 changes: 33 additions & 53 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

12 changes: 0 additions & 12 deletions DuckDuckGo/AppDelegate+Waitlists.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ extension AppDelegate {
}

func checkWaitlists() {
checkWindowsWaitlist()

#if NETWORK_PROTECTION
checkNetworkProtectionWaitlist()
Expand All @@ -43,13 +42,6 @@ extension AppDelegate {

}

private func checkWindowsWaitlist() {
WindowsBrowserWaitlist.shared.fetchInviteCodeIfAvailable { error in
guard error == nil else { return }
WindowsBrowserWaitlist.shared.sendInviteCodeAvailableNotification()
}
}

#if NETWORK_PROTECTION
private func checkNetworkProtectionWaitlist() {
let accessController = NetworkProtectionAccessController()
Expand Down Expand Up @@ -96,10 +88,6 @@ extension AppDelegate {

private func checkWaitlistBackgroundTasks() {
BGTaskScheduler.shared.getPendingTaskRequests { tasks in
let hasWindowsBrowserWaitlistTask = tasks.contains { $0.identifier == WindowsBrowserWaitlist.backgroundRefreshTaskIdentifier }
if !hasWindowsBrowserWaitlistTask {
WindowsBrowserWaitlist.shared.scheduleBackgroundRefreshTask()
}

#if NETWORK_PROTECTION
let hasVPNWaitlistTask = tasks.contains { $0.identifier == VPNWaitlist.backgroundRefreshTaskIdentifier }
Expand Down
9 changes: 0 additions & 9 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Task handler registration needs to happen before the end of `didFinishLaunching`, otherwise submitting a task can throw an exception.
// Having both in `didBecomeActive` can sometimes cause the exception when running on a physical device, so registration happens here.
AppConfigurationFetch.registerBackgroundRefreshTaskHandler()
WindowsBrowserWaitlist.shared.registerBackgroundRefreshTaskHandler()

#if NETWORK_PROTECTION
VPNWaitlist.shared.registerBackgroundRefreshTaskHandler()
Expand Down Expand Up @@ -805,9 +804,6 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
withCompletionHandler completionHandler: @escaping () -> Void) {
if response.actionIdentifier == UNNotificationDefaultActionIdentifier {
let identifier = response.notification.request.identifier
if identifier == WindowsBrowserWaitlist.notificationIdentifier {
presentWindowsBrowserWaitlistSettingsModal()
}

#if NETWORK_PROTECTION
if NetworkProtectionNotificationIdentifier(rawValue: identifier) != nil {
Expand All @@ -823,11 +819,6 @@ extension AppDelegate: UNUserNotificationCenterDelegate {

completionHandler()
}

private func presentWindowsBrowserWaitlistSettingsModal() {
let waitlistViewController = WindowsWaitlistViewController(nibName: nil, bundle: nil)
presentSettings(with: waitlistViewController)
}

#if NETWORK_PROTECTION
private func presentNetworkProtectionWaitlistModal() {
Expand Down
121 changes: 19 additions & 102 deletions DuckDuckGo/Debug.storyboard

Large diffs are not rendered by default.

84 changes: 84 additions & 0 deletions DuckDuckGo/DesktopDownloadPlatformConstants.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//
// DesktopDownloadPlatformConstants.swift
// DuckDuckGo
//
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

enum DesktopDownloadPlatform {
case windows
case mac
}

struct DesktopDownloadPlatformConstants {
let platform: DesktopDownloadPlatform

var imageName: String {
switch platform {
case .windows:
return "WindowsWaitlistJoinWaitlist"
case .mac:
return "WaitlistMacComputer"
}
}
var title: String {
switch platform {
case .windows:
return UserText.windowsWaitlistTryDuckDuckGoForWindowsDownload
case .mac:
return UserText.macWaitlistTryDuckDuckGoForMac
}
}
var summary: String {
switch platform {
case .windows:
return UserText.windowsWaitlistSummary
case .mac:
return UserText.macWaitlistSummary
}
}
var onYourString: String {
switch platform {
case .windows:
return UserText.windowsWaitlistOnYourComputerGoTo
case .mac:
return UserText.macWaitlistOnYourMacGoTo
}
}
var downloadURL: String {
switch platform {
case .windows:
return "duckduckgo.com/windows"
case .mac:
return "duckduckgo.com/mac"
}
}
var otherPlatformText: String {
switch platform {
case .windows:
return UserText.windowsWaitlistMac
case .mac:
return UserText.macWaitlistWindows
}
}
var viewTitle: String {
switch platform {
case .windows:
return UserText.windowsWaitlistTitle
case .mac:
return UserText.macBrowserTitle
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//
// WaitlistViews.swift
// DesktopDownloadView.swift
// DuckDuckGo
//
// Copyright © 2023 DuckDuckGo. All rights reserved.
// Copyright © 2024 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,62 +17,53 @@
// limitations under the License.
//

import Foundation
import SwiftUI
import Waitlist

struct WaitlistDownloadBrowserContentView: View {

let action: WaitlistViewActionHandler
let constants: BrowserDownloadLinkConstants

init(platform: BrowserDownloadLink, action: @escaping WaitlistViewActionHandler) {
self.action = action
self.constants = BrowserDownloadLinkConstants(platform: platform)
}
struct DesktopDownloadView: View {

@StateObject var viewModel: DesktopDownloadViewModel
@State private var shareButtonFrame: CGRect = .zero
@State private var isShareSheetVisible = false

let padding = UIDevice.current.localizedModel == "iPad" ? 100.0 : 0.0

var body: some View {
GeometryReader { proxy in
ScrollView {
VStack(alignment: .center, spacing: 8) {
HeaderView(imageName: constants.imageName, title: constants.title)
headerView

Text(constants.summary)
Text(viewModel.browserDetails.summary)
.daxBodyRegular()
.foregroundColor(.waitlistTextSecondary)
.multilineTextAlignment(.center)
.lineSpacing(6)
.padding(.horizontal, padding)

Text(constants.onYourString)
Text(viewModel.browserDetails.onYourString)
.daxBodyRegular()
.foregroundColor(.waitlistTextSecondary)
.multilineTextAlignment(.center)
.lineSpacing(6)
.padding(.top, 18)

Text(constants.downloadURL)
menuView
.daxHeadline()
.foregroundColor(.waitlistBlue)
.menuController(UserText.macWaitlistCopy) {
action(.copyDownloadURLToPasteboard)
}
.fixedSize()

Button(
action: {
action(.openShareSheet(shareButtonFrame))
self.isShareSheetVisible = true
}, label: {
HStack {
Image("Share-16")
Text(UserText.macWaitlistShareLink)
Text(viewModel.browserDetails.downloadURL)
}
}
)
.buttonStyle(RoundedButtonStyle(enabled: true))
.buttonStyle(DesktopDownloadViewButtonStyle(enabled: true))
.padding(.horizontal, padding)
.padding(.top, 24)
.background(
Expand All @@ -86,14 +77,19 @@ struct WaitlistDownloadBrowserContentView: View {
self.shareButtonFrame = newFrame
}
}
.sheet(isPresented: $isShareSheetVisible) {
DesktopDownloadShareSheet(items: [viewModel.downloadURL])
}

Spacer(minLength: 24)

Button(
action: {
action(.custom(constants.customAction))
withAnimation {
viewModel.switchPlatform()
}
}, label: {
Text(constants.otherPlatformText)
Text(viewModel.browserDetails.otherPlatformText)
.daxHeadline()
.foregroundColor(.waitlistBlue)
.multilineTextAlignment(.center)
Expand All @@ -106,6 +102,42 @@ struct WaitlistDownloadBrowserContentView: View {
.padding([.leading, .trailing], 24)
.frame(minHeight: proxy.size.height)
}
.navigationTitle(viewModel.browserDetails.viewTitle)
}
}

@ViewBuilder
private var headerView: some View {
VStack(spacing: 18) {
Image(viewModel.browserDetails.imageName)

Text(viewModel.browserDetails.title)
.daxTitle2()
.foregroundColor(.waitlistTextPrimary)
.lineSpacing(6)
.multilineTextAlignment(.center)
.fixMultilineScrollableText()
}
.padding(.top, 24)
.padding(.bottom, 12)
}

@ViewBuilder
private var menuView: some View {

// The .menuController modifier prevents the Text view from
// updating when viewModel.browserDetails.downloadURL changes
// so this is a hack to render another view
if viewModel.browserDetails.platform == .mac {
Text(viewModel.browserDetails.downloadURL)
.menuController(UserText.macWaitlistCopy) {
viewModel.copyLink()
}
} else {
Text(viewModel.browserDetails.downloadURL)
.menuController(UserText.macWaitlistCopy) {
viewModel.copyLink()
}
}
}
}
Expand All @@ -115,68 +147,12 @@ private struct ShareButtonFramePreferenceKey: PreferenceKey {
static func reduce(value: inout CGRect, nextValue: () -> CGRect) {}
}

enum BrowserDownloadLink {
case windows
case mac
}

struct BrowserDownloadLinkConstants {
let platform: BrowserDownloadLink
struct DesktopDownloadShareSheet: UIViewControllerRepresentable {
var items: [Any]

var imageName: String {
switch platform {
case .windows:
return "WindowsWaitlistJoinWaitlist"
case .mac:
return "WaitlistMacComputer"
}
}
var title: String {
switch platform {
case .windows:
return UserText.windowsWaitlistTryDuckDuckGoForWindowsDownload
case .mac:
return UserText.macWaitlistTryDuckDuckGoForMac
}
}
var summary: String {
switch platform {
case .windows:
return UserText.windowsWaitlistSummary
case .mac:
return UserText.macWaitlistSummary
}
}
var onYourString: String {
switch platform {
case .windows:
return UserText.windowsWaitlistOnYourComputerGoTo
case .mac:
return UserText.macWaitlistOnYourMacGoTo
}
}
var downloadURL: String {
switch platform {
case .windows:
return "duckduckgo.com/windows"
case .mac:
return "duckduckgo.com/mac"
}
}
var customAction: WaitlistViewModel.ViewCustomAction {
switch platform {
case .windows:
return .openMacBrowserWaitlist
case .mac:
return .openWindowsBrowserWaitlist
}
}
var otherPlatformText: String {
switch platform {
case .windows:
return UserText.windowsWaitlistMac
case .mac:
return UserText.macWaitlistWindows
}
func makeUIViewController(context: Context) -> UIActivityViewController {
UIActivityViewController(activityItems: items, applicationActivities: nil)
}

func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {}
}
Loading

0 comments on commit 3fba355

Please sign in to comment.