From 15eb9a34e9399ac7908837c17cd40f1aa7de64fb Mon Sep 17 00:00:00 2001 From: Federico Cappelli Date: Mon, 20 Nov 2023 12:29:11 +0000 Subject: [PATCH] unused files removed, privacy dashboard dependency is now driven by BSK --- DuckDuckGo.xcodeproj/project.pbxproj | 2 - .../xcshareddata/swiftpm/Package.resolved | 15 +- DuckDuckGo/ReportBrokenSiteView.swift | 201 ------------------ .../ReportBrokenSiteViewController.swift | 145 ------------- 4 files changed, 12 insertions(+), 351 deletions(-) delete mode 100644 DuckDuckGo/ReportBrokenSiteView.swift delete mode 100644 DuckDuckGo/ReportBrokenSiteViewController.swift diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index f6773c0fec..d7c28a8d38 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -2423,7 +2423,6 @@ F143C32B1E4A9A4800CFDE3A /* RoundedRectangleView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RoundedRectangleView.swift; path = ../Core/RoundedRectangleView.swift; sourceTree = ""; }; F143C32C1E4A9A4800CFDE3A /* UIViewControllerExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UIViewControllerExtension.swift; path = ../Core/UIViewControllerExtension.swift; sourceTree = ""; }; F143C3451E4AA32D00CFDE3A /* SearchBarExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SearchBarExtension.swift; path = ../Core/SearchBarExtension.swift; sourceTree = ""; }; - F14BEF002B064379007864AC /* BrowserServicesKit */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = BrowserServicesKit; path = ../BrowserServicesKit; sourceTree = ""; }; F14E491E1E391CE900DC037C /* URLExtensionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = URLExtensionTests.swift; sourceTree = ""; }; F159BDA31F0BDB5A00B4A01D /* TabViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TabViewController.swift; sourceTree = ""; }; F15D431F1E706CC500BF2CDC /* AutocompleteViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutocompleteViewController.swift; sourceTree = ""; }; @@ -3574,7 +3573,6 @@ 83ED3B8D1FA8E63700B47556 /* README.md */, 83ED3B8C1FA8E61D00B47556 /* ManualTestsScript.md */, 85A313962028E78A00327D00 /* release_notes.txt */, - F14BEF002B064379007864AC /* BrowserServicesKit */, ); sourceTree = ""; }; diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index f3e1eab524..823b00b9ef 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -10,6 +10,15 @@ "version": "3.0.0" } }, + { + "package": "BrowserServicesKit", + "repositoryURL": "https://github.com/DuckDuckGo/BrowserServicesKit", + "state": { + "branch": "fcappelli/breakage_report_improvements", + "revision": "3beb9e40d9062b330a56b5af77f944a9aa6c39e3", + "version": null + } + }, { "package": "CocoaAsyncSocket", "repositoryURL": "https://github.com/robbiehanson/CocoaAsyncSocket", @@ -95,9 +104,9 @@ "package": "PrivacyDashboardResources", "repositoryURL": "https://github.com/duckduckgo/privacy-dashboard", "state": { - "branch": "shane/ios-form", - "revision": "ad774518f25039ca46d3a7b94e4bf1288f5f581b", - "version": null + "branch": null, + "revision": "59dedf0f4ff1e9147de0806a54c6043861eb0870", + "version": "3.1.0" } }, { diff --git a/DuckDuckGo/ReportBrokenSiteView.swift b/DuckDuckGo/ReportBrokenSiteView.swift deleted file mode 100644 index 14819627c0..0000000000 --- a/DuckDuckGo/ReportBrokenSiteView.swift +++ /dev/null @@ -1,201 +0,0 @@ -// -// ReportBrokenSiteView.swift -// DuckDuckGo -// -// Copyright © 2023 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. -// - -import SwiftUI -import DuckUI -import DesignResourcesKit - -struct ReportBrokenSiteView: View { - - let categories: [BrokenSite.Category] - let submitReport: (BrokenSite.Category?, String) -> Void - let toggleProtection: (Bool) -> Void - @State private var selectedCategory: BrokenSite.Category? - - @State private var description: String = "" - @State private var placeholderText: String = UserText.brokenSiteCommentPlaceholder - - @State var isProtected: Bool - - func submitForm() { - submitReport(selectedCategory, description) - } - - var form: some View { - Form { - - Section { - HStack { - let protectionStatusString = isProtected ? "ON" : "OFF" - let label = UserText.brokenSiteProtectionSwitchLabel.replacingOccurrences(of: "%@", with: protectionStatusString) - - Text(label) - .lineLimit(1) - .daxBodyRegular() - .foregroundColor(Color(designSystemColor: .textPrimary)) - - Spacer() - - Toggle("", isOn: $isProtected) - .labelsHidden() - .onChange(of: isProtected) { value in - toggleProtection(value) - } - } - .listRowBackground(Color(designSystemColor: .container)) -// .frame(maxWidth: .infinity) - - if isProtected { - let baseColor = UIColor(Color(designSystemColor: .accent)).withAlphaComponent(0.18) - let sectionBgColor = Color(baseColor) - Text(UserText.brokenSiteProtectionBanner) - .lineLimit(1) - .daxBodyRegular() - .foregroundColor(Color(designSystemColor: .textPrimary)) - .listRowBackground(sectionBgColor) - } - } - -// Section { - VStack { - Image("Breakage-128") - .resizable() - .aspectRatio(contentMode: .fit) - .frame(width: Const.Size.imageSize, height: Const.Size.imageSize) - - Text(UserText.reportBrokenSiteHeader) - .textCase(nil) - .multilineTextAlignment(.center) - .daxBodyRegular() - .foregroundColor(Color(designSystemColor: .textPrimary)) - } - .frame(maxWidth: .infinity) -// } -// .listRowBackground(Color.clear) - - // TODO: delete (header: Text(UserText.brokenSiteCategoryTitle)) - Section { - Picker("", selection: $selectedCategory) { - Text("Select the type of issue") - .tag(nil as BrokenSite.Category?) - - ForEach(categories) { cat in - Text(cat.categoryText) - .tag(Optional(cat)) - } - } - .frame(maxWidth: .infinity) - .labelsHidden() -// .padding(.leading, Const.Size.pickerPadding) - - // As of July 2023 SwiftUI STILL does not support placeholders for `TextEditor` - // Until that time we have to use this hack to show a placeholder - // https://stackoverflow.com/a/65406506 - ZStack { - if self.description.isEmpty { - TextEditor(text: $placeholderText) - .daxSubheadRegular() - .foregroundColor(Color(UIColor.placeholderText)) - .disabled(true) - } - - TextEditor(text: $description) - .daxSubheadRegular() - } - .padding(.leading, Const.Size.commentFieldPadding) - .frame(minHeight: Const.Size.minCommentHeight) - } - .frame(maxWidth: .infinity) - .listRowBackground(Color(designSystemColor: .container)) - - // TODO: delete (header: Text(UserText.brokenSiteSectionTitle)) -// Section { -// // As of July 2023 SwiftUI STILL does not support placeholders for `TextEditor` -// // Until that time we have to use this hack to show a placeholder -// // https://stackoverflow.com/a/65406506 -// ZStack { -// if self.description.isEmpty { -// TextEditor(text: $placeholderText) -// .daxSubheadRegular() -// .foregroundColor(Color(UIColor.placeholderText)) -// .disabled(true) -// } -// -// TextEditor(text: $description) -// .daxSubheadRegular() -// } -// .padding(.leading, Const.Size.commentFieldPadding) -// .frame(minHeight: Const.Size.minCommentHeight) -// } -// .listRowBackground(Color(designSystemColor: .container)) - - Section { - Button(action: { - submitForm() - }, label: { - Text(UserText.appTPReportSubmit) - }) - .buttonStyle(PrimaryButtonStyle()) - .listRowBackground(Color.clear) - } - .listRowInsets(EdgeInsets()) - - Section { - Text("Reports sent to DuckDuckGo only include info required to help us address your feedback.") - .multilineTextAlignment(.center) - .daxSubheadRegular() - .foregroundColor(Color(designSystemColor: .textPrimary)) - } - .frame(maxWidth: .infinity) - .listRowInsets(EdgeInsets()) - } - } - - @ViewBuilder - var formWithBackground: some View { - if #available(iOS 16, *) { - form - .scrollContentBackground(.hidden) - .background(Color(designSystemColor: .surface)) - } else { - form - .background(Color(designSystemColor: .background)) - } - } - - var body: some View { - formWithBackground - } -} - -private enum Const { - enum Size { - static let imageSize: CGFloat = 128 - static let minCommentHeight: CGFloat = 80 - static let commentFieldPadding: CGFloat = -4 - static let pickerPadding: CGFloat = -12 - static let buttonHeight: CGFloat = 30 - } -} - -struct ReportBrokenSiteView_Previews: PreviewProvider { - static var previews: some View { - ReportBrokenSiteView(categories: BrokenSite.Category.allCases, submitReport: { _, _ in }, toggleProtection: { _ in }, isProtected: true) - } -} diff --git a/DuckDuckGo/ReportBrokenSiteViewController.swift b/DuckDuckGo/ReportBrokenSiteViewController.swift deleted file mode 100644 index 87bfbbce6e..0000000000 --- a/DuckDuckGo/ReportBrokenSiteViewController.swift +++ /dev/null @@ -1,145 +0,0 @@ -// -// ReportBrokenSiteViewController.swift -// DuckDuckGo -// -// Copyright © 2020 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. -// - -import UIKit -import SwiftUI -import BrowserServicesKit - -class ReportBrokenSiteViewController: UIViewController { - -// enum ReportBrokenSiteSource { -// case privacyDashboard -// case -// } - - public var brokenSiteInfo: BrokenSiteInfo? - - var privacyConfigurationManager: PrivacyConfigurationManaging? - var contentBlockingManager: ContentBlockerRulesManager? - private var reportView: ReportBrokenSiteView? -// private let source: - - private let categories: [BrokenSite.Category] = { - var categories = BrokenSite.Category.allCases - categories = categories.filter { $0 != .other } - categories = categories.shuffled() - categories.append(.other) - return categories - }() - -// init(privacyConfigurationManager: PrivacyConfigurationManaging, contentBlockingManager: ContentBlockerRulesManager) { -// super.init( -// self.privacyConfigurationManager = privacyConfigurationManager -// self.contentBlockingManager = contentBlockingManager -// } -// -// required init?(coder: NSCoder) { -// fatalError("init(coder:) has not been implemented") -// } - - override func viewDidLoad() { - super.viewDidLoad() - - applyTheme(ThemeManager.shared.currentTheme) - - reportView = ReportBrokenSiteView(categories: categories, - submitReport: submitForm(category:description:), - toggleProtection: protectionSwitchChangeHandler(enabled:), - isProtected: true) // TODO: here - let hc = UIHostingController(rootView: reportView) - - self.addChild(hc) - self.view.addSubview(hc.view) - hc.didMove(toParent: self) - - hc.view.translatesAutoresizingMaskIntoConstraints = false - hc.view.topAnchor.constraint(equalTo: view.topAnchor).isActive = true - hc.view.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true - hc.view.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true - hc.view.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true - - DispatchQueue.main.async { - self.view.setNeedsLayout() - self.view.layoutIfNeeded() - } - } - - @IBAction func onClosePressed(sender: Any) { - dismiss(animated: true) - } - - func submitForm(category: BrokenSite.Category?, description: String) { - brokenSiteInfo?.send(with: category?.rawValue, description: description) - ActionMessageView.present(message: UserText.feedbackSumbittedConfirmation) - dismiss(animated: true) - } - - func protectionSwitchChangeHandler(enabled: Bool) { - - let domain = "" // TODO: - guard let privacyConfigurationManager = privacyConfigurationManager, - let contentBlockingManager = contentBlockingManager else { - fatalError("Dependencies not configured") - } - - let privacyConfiguration = privacyConfigurationManager.privacyConfig - - if enabled { - privacyConfiguration.userEnabledProtection(forDomain: domain) - ActionMessageView.present(message: UserText.messageProtectionEnabled.format(arguments: domain)) - } else { - privacyConfiguration.userDisabledProtection(forDomain: domain) - ActionMessageView.present(message: UserText.messageProtectionDisabled.format(arguments: domain)) - } - - contentBlockingManager.scheduleCompilation() - -// privacyDashboardController.didStartRulesCompilation() - -// Pixel.fire(pixel: enabled ? .privacyDashboardProtectionEnabled : .privacyDashboardProtectionDisabled) - } -} - -extension ReportBrokenSiteViewController: Themable { - - func decorate(with theme: Theme) { - decorateNavigationBar(with: theme) - - /* - navigationController?.navigationBar.barTintColor = theme.barBackgroundColor - navigationController?.navigationBar.tintColor = theme.navigationBarTintColor - - var titleAttrs = navigationController?.navigationBar.titleTextAttributes ?? [:] - titleAttrs[NSAttributedString.Key.foregroundColor] = theme.navigationBarTitleColor - navigationController?.navigationBar.titleTextAttributes = titleAttrs - - if #available(iOS 15.0, *) { - let appearance = UINavigationBarAppearance() - appearance.shadowColor = .clear - appearance.backgroundColor = theme.backgroundColor - appearance.titleTextAttributes = titleAttrs - - navigationController?.navigationBar.standardAppearance = appearance - navigationController?.navigationBar.scrollEdgeAppearance = appearance - } - */ - - view.backgroundColor = UIColor(Color(designSystemColor: .surface)) - } -}