From eea5c7cb7578e771727aa2fd9120950a166e02b2 Mon Sep 17 00:00:00 2001 From: Shane Osbourne Date: Tue, 7 Jan 2025 15:43:54 +0000 Subject: [PATCH] dashboard: fixing the white flicker (#1147) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Please review the release process for BrowserServicesKit [here](https://app.asana.com/0/1200194497630846/1200837094583426). **Required**: Task/Issue URL: https://app.asana.com/0/0/1209097550105014/f iOS PR: https://github.com/duckduckgo/iOS/pull/3774 macOS PR: https://github.com/duckduckgo/macos-browser/pull/3705 What kind of version bump will this require?: Major/Minor/Patch **Optional**: Tech Design URL: CC: **Description**: **Steps to test this PR**: 1. It’s in the macOS PR https://github.com/duckduckgo/macos-browser/pull/3705 1. **OS Testing**: * [ ] iOS 14 * [ ] iOS 15 * [ ] iOS 16 * [ ] macOS 10.15 * [ ] macOS 11 * [ ] macOS 12 --- ###### Internal references: [Software Engineering Expectations](https://app.asana.com/0/59792373528535/199064865822552) [Technical Design Template](https://app.asana.com/0/59792373528535/184709971311943) --- .../PrivacyDashboardController.swift | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Sources/PrivacyDashboard/PrivacyDashboardController.swift b/Sources/PrivacyDashboard/PrivacyDashboardController.swift index 988c4cd20..7f1bc6d7c 100644 --- a/Sources/PrivacyDashboard/PrivacyDashboardController.swift +++ b/Sources/PrivacyDashboard/PrivacyDashboardController.swift @@ -68,6 +68,24 @@ public protocol PrivacyDashboardControllerDelegate: AnyObject { @Published public var theme: PrivacyDashboardTheme? @Published public var allowedPermissions: [AllowedPermission] = [] public var preferredLocale: String? + public var dashboardHtmlName: String { + #if os(iOS) + return "ios" + #else + return "macos" + #endif + } + public lazy var dashboardHtml: String = { + guard let file = Bundle.privacyDashboardResourcesBundle.path(forResource: dashboardHtmlName, ofType: "html", inDirectory: "html") else { + assertionFailure("HTML for the PrivacyDashboard was not found") + return "" + } + guard let html = try? String(contentsOfFile: file) else { + assertionFailure("Should be able to load HTML as a string") + return "" + } + return html + }() public private(set) weak var privacyInfo: PrivacyInfo? private let entryPoint: PrivacyDashboardEntryPoint @@ -124,7 +142,7 @@ public protocol PrivacyDashboardControllerDelegate: AnyObject { private func loadStartScreen() { let url = PrivacyDashboardURLBuilder(configuration: .startScreen(entryPoint: entryPoint, variant: variant)).build() - webView?.loadFileURL(url, allowingReadAccessTo: url.deletingLastPathComponent().deletingLastPathComponent()) + webView?.loadHTMLString(dashboardHtml, baseURL: url.deletingLastPathComponent()) } public func updatePrivacyInfo(_ privacyInfo: PrivacyInfo?) {