Skip to content

Commit

Permalink
Move subscription Code to BSK (#2473)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/414235014887631/1206582087819536/f

Description:
Moves Subscriptions to BSK
  • Loading branch information
afterxleep authored Feb 14, 2024
1 parent 3fba355 commit 82a8432
Show file tree
Hide file tree
Showing 37 changed files with 85 additions and 1,843 deletions.
122 changes: 17 additions & 105 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/DuckDuckGo/BrowserServicesKit",
"state" : {
"revision" : "3f5e33ec3d75dd2c130cfc6915c0a6e8efeb96f1",
"version" : "106.0.1"
"revision" : "328ce451fd1593809d1470ab5a0b5242a595f88c",
"version" : "107.0.0"
}
},
{
Expand Down
4 changes: 4 additions & 0 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ import Networking
import DDGSync
import SyncDataProviders

#if SUBSCRIPTION
import Subscription
#endif

#if NETWORK_PROTECTION
import NetworkProtection
import WebKit
Expand Down
1 change: 1 addition & 0 deletions DuckDuckGo/DesktopDownloadView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct DesktopDownloadView: View {
}
}
)
// XAI: Move all strings to a Constants enum at the top
.buttonStyle(DesktopDownloadViewButtonStyle(enabled: true))
.padding(.horizontal, padding)
.padding(.top, 24)
Expand Down
13 changes: 10 additions & 3 deletions DuckDuckGo/MainViewController+Segues.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ import Core
import Bookmarks
import BrowserServicesKit
import SwiftUI
import PrivacyDashboard

#if SUBSCRIPTION
import Subscription
#endif

extension MainViewController {

Expand Down Expand Up @@ -235,15 +238,19 @@ extension MainViewController {
syncDataProviders: syncDataProviders,
appSettings: appSettings,
bookmarksDatabase: bookmarksDatabase)
#if SUBSCRIPTION
let settingsViewModel = SettingsViewModel(legacyViewProvider: legacyViewProvider, accountManager: AccountManager())
#else
let settingsViewModel = SettingsViewModel(legacyViewProvider: legacyViewProvider)
#endif

let settingsController = SettingsHostingController(viewModel: settingsViewModel, viewProvider: legacyViewProvider)
settingsController.applyTheme(ThemeManager.shared.currentTheme)

// We are still presenting legacy views, so use a Navcontroller
let navController = UINavigationController(rootViewController: settingsController)
navController.applyTheme(ThemeManager.shared.currentTheme)
settingsController.modalPresentationStyle = .automatic
settingsController.modalPresentationStyle = UIModalPresentationStyle.automatic

present(navController, animated: true) {
completion?(settingsViewModel)
Expand Down
4 changes: 4 additions & 0 deletions DuckDuckGo/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import Persistence
import PrivacyDashboard
import Networking

#if SUBSCRIPTION
import Subscription
#endif

#if NETWORK_PROTECTION
import NetworkProtection
#endif
Expand Down
3 changes: 3 additions & 0 deletions DuckDuckGo/SettingsHostingController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

import UIKit
import SwiftUI
#if SUBSCRIPTION
import Subscription
#endif

class SettingsHostingController: UIHostingController<AnyView> {
var viewModel: SettingsViewModel
Expand Down
1 change: 1 addition & 0 deletions DuckDuckGo/SettingsSubscriptionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import SwiftUI
import UIKit

#if SUBSCRIPTION
import Subscription
@available(iOS 15.0, *)
struct SettingsSubscriptionView: View {

Expand Down
33 changes: 26 additions & 7 deletions DuckDuckGo/SettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import Common
import Combine
import SyncUI

#if SUBSCRIPTION
import Subscription
#endif

#if APP_TRACKING_PROTECTION
import NetworkExtension
#endif
Expand All @@ -42,9 +46,12 @@ final class SettingsViewModel: ObservableObject {
private lazy var animator: FireButtonAnimator = FireButtonAnimator(appSettings: AppUserDefaults())
private var legacyViewProvider: SettingsLegacyViewProvider
private lazy var versionProvider: AppVersion = AppVersion.shared
private var accountManager: AccountManager
private let voiceSearchHelper: VoiceSearchHelperProtocol

#if SUBSCRIPTION
private var accountManager: AccountManager
#endif


#if NETWORK_PROTECTION
private let connectionObserver = ConnectionStatusObserverThroughSession()
#endif
Expand All @@ -56,15 +63,15 @@ final class SettingsViewModel: ObservableObject {
// Defaults
@UserDefaultsWrapper(key: .subscriptionIsActive, defaultValue: false)
static private var cachedHasActiveSubscription: Bool

// Closures to interact with legacy view controllers through the container
var onRequestPushLegacyView: ((UIViewController) -> Void)?
var onRequestPresentLegacyView: ((UIViewController, _ modal: Bool) -> Void)?
var onRequestPopLegacyView: (() -> Void)?
var onRequestDismissSettings: (() -> Void)?

// SwiftUI Programatic Navigation Variables
// Add more views as needed here...
// Add more views as needed here...
@Published var shouldNavigateToDBP = false
@Published var shouldNavigateToITP = false

Expand All @@ -86,7 +93,7 @@ final class SettingsViewModel: ObservableObject {
case networkProtection
#endif
}

var shouldShowNoMicrophonePermissionAlert: Bool = false

// Used to automatically navigate on Appear to a specific section
Expand Down Expand Up @@ -194,7 +201,7 @@ final class SettingsViewModel: ObservableObject {
}
)
}

#if SUBSCRIPTION
// MARK: Default Init
init(state: SettingsState? = nil,
legacyViewProvider: SettingsLegacyViewProvider,
Expand All @@ -207,8 +214,20 @@ final class SettingsViewModel: ObservableObject {
self.voiceSearchHelper = voiceSearchHelper
self.onAppearNavigationTarget = navigateOnAppearDestination
}
#else
// MARK: Default Init
init(state: SettingsState? = nil,
legacyViewProvider: SettingsLegacyViewProvider,
voiceSearchHelper: VoiceSearchHelperProtocol = AppDependencyProvider.shared.voiceSearchHelper,
navigateOnAppearDestination: SettingsSection = .none) {
self.state = SettingsState.defaults
self.legacyViewProvider = legacyViewProvider
self.voiceSearchHelper = voiceSearchHelper
self.onAppearNavigationTarget = navigateOnAppearDestination
}
#endif

}

// MARK: Private methods
extension SettingsViewModel {

Expand Down
211 changes: 0 additions & 211 deletions DuckDuckGo/Subscription/Subscription/AccountManager.swift

This file was deleted.

Loading

0 comments on commit 82a8432

Please sign in to comment.