diff --git a/Client/Frontend/Browser/BrowserViewController/BrowserViewController+Menu.swift b/Client/Frontend/Browser/BrowserViewController/BrowserViewController+Menu.swift index 9bca783af15..d0b7532d19d 100644 --- a/Client/Frontend/Browser/BrowserViewController/BrowserViewController+Menu.swift +++ b/Client/Frontend/Browser/BrowserViewController/BrowserViewController+Menu.swift @@ -11,10 +11,17 @@ import Shared extension BrowserViewController { func featuresMenuSection(_ menuController: MenuViewController) -> some View { VStack(spacing: 0) { - VPNMenuButton(vpnProductInfo: self.vpnProductInfo) { vc in - (self.presentedViewController as? MenuViewController)? - .pushViewController(vc, animated: true) - } + VPNMenuButton(vpnProductInfo: self.vpnProductInfo, + displayVPNDestination: { vc in + (self.presentedViewController as? MenuViewController)? + .pushViewController(vc, animated: true) + }, + enableInstalledVPN: { [unowned menuController] in + /// Donate Enable VPN Activity for suggestions + let enableVPNActivity = ActivityShortcutManager.shared.createShortcutActivity(type: .enableBraveVPN) + menuController.userActivity = enableVPNActivity + enableVPNActivity.becomeCurrent() + }) } } diff --git a/Client/Frontend/Browser/Playlist/BrowserViewController+Playlist.swift b/Client/Frontend/Browser/Playlist/BrowserViewController+Playlist.swift index 7bfcf22a671..4996f42c4c2 100644 --- a/Client/Frontend/Browser/Playlist/BrowserViewController+Playlist.swift +++ b/Client/Frontend/Browser/Playlist/BrowserViewController+Playlist.swift @@ -75,6 +75,12 @@ extension BrowserViewController: PlaylistHelperDelegate { private func openPlaylist() { let playlistController = (UIApplication.shared.delegate as? AppDelegate)?.playlistRestorationController ?? PlaylistViewController() playlistController.modalPresentationStyle = .fullScreen + + /// Donate Open Playlist Activity for suggestions + let openPlaylist = ActivityShortcutManager.shared.createShortcutActivity(type: .openPlayList) + self.userActivity = openPlaylist + openPlaylist.becomeCurrent() + present(playlistController, animated: true) } diff --git a/Client/Frontend/Browser/Toolbars/BottomToolbar/Menu/Bookmarks/BookmarksViewController.swift b/Client/Frontend/Browser/Toolbars/BottomToolbar/Menu/Bookmarks/BookmarksViewController.swift index bed6e5f935c..e42553120c7 100644 --- a/Client/Frontend/Browser/Toolbars/BottomToolbar/Menu/Bookmarks/BookmarksViewController.swift +++ b/Client/Frontend/Browser/Toolbars/BottomToolbar/Menu/Bookmarks/BookmarksViewController.swift @@ -444,7 +444,7 @@ class BookmarksViewController: SiteTableViewController, ToolbarUrlActionsProtoco if !self.isPrivateBrowsing { ActivityShortcutManager.shared.donateCustomIntent(for: .openBookmarks, with: url.absoluteString) } - self.toolbarUrlActionsDelegate?.select(url: url, visitType: .bookmark) + self.toolbarUrlActionsDelegate?.select(url: url, isBookmark: true) } } } diff --git a/Client/Frontend/Browser/Toolbars/BottomToolbar/Menu/HistoryViewController.swift b/Client/Frontend/Browser/Toolbars/BottomToolbar/Menu/HistoryViewController.swift index 383523fe53d..4a3c5905b36 100644 --- a/Client/Frontend/Browser/Toolbars/BottomToolbar/Menu/HistoryViewController.swift +++ b/Client/Frontend/Browser/Toolbars/BottomToolbar/Menu/HistoryViewController.swift @@ -136,12 +136,12 @@ class HistoryViewController: SiteTableViewController, ToolbarUrlActionsProtocol if let u = site?.url, let url = URL(string: u) { dismiss(animated: true) { - /// Donate Custom Intent Open History + // Donate Custom Intent Open History if !self.isPrivateBrowsing { ActivityShortcutManager.shared.donateCustomIntent(for: .openHistory, with: url.absoluteString) } - self.toolbarUrlActionsDelegate?.select(url: url, visitType: .typed) + self.toolbarUrlActionsDelegate?.select(url: url, isBookmark: false) } } tableView.deselectRow(at: indexPath, animated: true) diff --git a/Client/Frontend/Browser/Toolbars/BottomToolbar/Menu/MenuViewController.swift b/Client/Frontend/Browser/Toolbars/BottomToolbar/Menu/MenuViewController.swift index 7e3bddda4b0..f9319a00f29 100644 --- a/Client/Frontend/Browser/Toolbars/BottomToolbar/Menu/MenuViewController.swift +++ b/Client/Frontend/Browser/Toolbars/BottomToolbar/Menu/MenuViewController.swift @@ -204,52 +204,9 @@ extension MenuViewController: PanModalPresentable { var allowsExtendedPanScrolling: Bool { true } - var cornerRadius: CGFloat { 10.0 } - - private func openVPNAction(menuCell: MenuCell) { - let enabled = !menuCell.toggleButton.isOn - let vpnState = BraveVPN.vpnState - - /// Connecting to the vpn takes a while, that's why we have to show a spinner until it finishes. - if enabled { - menuCell.isLoading = true - } - - if !VPNProductInfo.isComplete { - let alert = - UIAlertController(title: Strings.VPN.errorCantGetPricesTitle, - message: Strings.VPN.errorCantGetPricesBody, - preferredStyle: .alert) - alert.addAction(.init(title: Strings.OKString, style: .default)) - dismissView() - bvc.present(alert, animated: true) - // Reattempt to connect to the App Store to get VPN prices. - bvc.vpnProductInfo.load() - return - } - - switch BraveVPN.vpnState { - case .notPurchased, .purchased, .expired: - guard let vc = vpnState.enableVPNDestinationVC else { return } - open(vc, doneButton: DoneButton(style: .cancel, position: .left), allowSwipeToDismiss: true) - case .installed: - // Do not modify UISwitch state here, update it based on vpn status observer. - if enabled { - BraveVPN.reconnect() - - /// Donate Enable VPN Activity for suggestions - let enableVPNActivity = ActivityShortcutManager.shared.createShortcutActivity(type: .enableBraveVPN) - self.userActivity = enableVPNActivity - enableVPNActivity.becomeCurrent() - } else { - BraveVPN.disconnect() - } - } - } - var anchorModalToLongForm: Bool { isPresentingInnerMenu } @@ -260,20 +217,6 @@ extension MenuViewController: PanModalPresentable { var dragIndicatorBackgroundColor: UIColor { UIColor(white: 0.95, alpha: 1.0) } - - private func openPlaylist() { - let playlistController = (UIApplication.shared.delegate as? AppDelegate)?.playlistRestorationController ?? PlaylistViewController() - playlistController.modalPresentationStyle = .fullScreen - - /// Donate Open Playlist Activity for suggestions - let openPlaylist = ActivityShortcutManager.shared.createShortcutActivity(type: .openPlayList) - self.userActivity = openPlaylist - openPlaylist.becomeCurrent() - - dismissView() - bvc.present(playlistController, animated: true) - } - var transitionDuration: Double { 0.35 } diff --git a/Client/Frontend/Browser/Toolbars/BottomToolbar/Menu/VPNMenuButton.swift b/Client/Frontend/Browser/Toolbars/BottomToolbar/Menu/VPNMenuButton.swift index f9b85d2955d..c9e7c3103ab 100644 --- a/Client/Frontend/Browser/Toolbars/BottomToolbar/Menu/VPNMenuButton.swift +++ b/Client/Frontend/Browser/Toolbars/BottomToolbar/Menu/VPNMenuButton.swift @@ -15,6 +15,9 @@ struct VPNMenuButton: View { /// A closure executed when the parent must display a VPN-specific view controller due to some /// user action var displayVPNDestination: (UIViewController) -> Void + /// A closure executed when VPN is toggled and status is installed. This will be used to set + /// current activity for user + var enableInstalledVPN: () -> Void @State private var isVPNStatusChanging: Bool = BraveVPN.reconnectPending @State private var isVPNEnabled = BraveVPN.isConnected @@ -43,7 +46,12 @@ struct VPNMenuButton: View { case .installed: isVPNStatusChanging = true // Do not modify UISwitch state here, update it based on vpn status observer. - enabled ? BraveVPN.reconnect() : BraveVPN.disconnect() + if enabled { + BraveVPN.reconnect() + enableInstalledVPN() + } else { + BraveVPN.disconnect() + } } } diff --git a/Client/Frontend/Settings/SettingsViewController.swift b/Client/Frontend/Settings/SettingsViewController.swift index ab1b0c98ab3..dcd54da6bdc 100644 --- a/Client/Frontend/Settings/SettingsViewController.swift +++ b/Client/Frontend/Settings/SettingsViewController.swift @@ -230,8 +230,7 @@ class SettingsViewController: TableViewController { cellClass: MultilineValue1Cell.self), .boolRow(title: Strings.bookmarksLastVisitedFolderTitle, option: Preferences.General.showLastVisitedBookmarksFolder, image: #imageLiteral(resourceName: "menu_folder_open").template), Row(text: Strings.Shortcuts.shortcutSettingsTitle, selection: { [unowned self] in - let viewController = ShortcutSettingsViewController(self.theme) - self.navigationController?.pushViewController(viewController, animated: true) + self.navigationController?.pushViewController(ShortcutSettingsViewController(), animated: true) }, image: #imageLiteral(resourceName: "settings-siri-shortcuts").template, accessory: .disclosureIndicator, cellClass: MultilineValue1Cell.self) ] ) diff --git a/Client/Frontend/Settings/ShortcutSettingsViewController.swift b/Client/Frontend/Settings/ShortcutSettingsViewController.swift index 0e133584f6e..633863bde88 100644 --- a/Client/Frontend/Settings/ShortcutSettingsViewController.swift +++ b/Client/Frontend/Settings/ShortcutSettingsViewController.swift @@ -12,14 +12,10 @@ import IntentsUI // MARK: - ShortcutSettingsViewController class ShortcutSettingsViewController: TableViewController { - - let theme: Theme - + // MARK: Lifecycle - init(_ theme: Theme) { - self.theme = theme - + init() { super.init(style: .insetGrouped) }