diff --git a/apple/OmnivoreKit/Sources/Views/Article/WebAppViewCoordinator.swift b/apple/OmnivoreKit/Sources/Views/Article/WebAppViewCoordinator.swift index cfe31bc1a..7d58582bc 100644 --- a/apple/OmnivoreKit/Sources/Views/Article/WebAppViewCoordinator.swift +++ b/apple/OmnivoreKit/Sources/Views/Article/WebAppViewCoordinator.swift @@ -126,7 +126,7 @@ extension WKWebView { } } - private func injectCookie(cookieString: String?, url: URL) { + func injectCookie(cookieString: String?, url: URL) { if let cookieString = cookieString { for cookie in HTTPCookie.cookies(withResponseHeaderFields: ["Set-Cookie": cookieString], for: url) { configuration.websiteDataStore.httpCookieStore.setCookie(cookie) {} diff --git a/apple/OmnivoreKit/Sources/Views/Web/BasicWebAppView.swift b/apple/OmnivoreKit/Sources/Views/Web/BasicWebAppView.swift index 370760116..d03d5c58f 100644 --- a/apple/OmnivoreKit/Sources/Views/Web/BasicWebAppView.swift +++ b/apple/OmnivoreKit/Sources/Views/Web/BasicWebAppView.swift @@ -18,6 +18,10 @@ import WebKit webView.scrollView.isScrollEnabled = true webView.isOpaque = false webView.backgroundColor = UIColor.clear + if let url = request.url { + let themeID = UITraitCollection.current.userInterfaceStyle == .dark ? "Gray" : "LightGray" + webView.injectCookie(cookieString: "theme=\(themeID); Max-Age=31536000;", url: url) + } return webView } @@ -43,7 +47,14 @@ import WebKit } public func makeNSView(context _: Context) -> WKWebView { - WebView(frame: CGRect.zero) + let webView = WebView(frame: CGRect.zero) + if let url = request.url { + // Dark mode is still rendering a white background on mac for some reason. + // Forcing light mode for now until we figure out a fix + let themeID = "LightGray" // NSApp.effectiveAppearance.name == NSAppearance.Name.darkAqua ? "Gray" : "LightGray" + webView.injectCookie(cookieString: "theme=\(themeID); Max-Age=31536000;", url: url) + } + return webView } public func updateNSView(_ webView: WKWebView, context: Context) { diff --git a/packages/web/components/templates/PrivacyPolicy.tsx b/packages/web/components/templates/PrivacyPolicy.tsx index 5b6a29b7c..a8f7e0e01 100644 --- a/packages/web/components/templates/PrivacyPolicy.tsx +++ b/packages/web/components/templates/PrivacyPolicy.tsx @@ -5,11 +5,15 @@ import { StyledList, } from '../elements/StyledText' -export function PrivacyPolicy(): JSX.Element { +type PrivacyPolicyProps = { + isAppEmbed?: boolean +} + +export function PrivacyPolicy(props: PrivacyPolicyProps): JSX.Element { return ( + ref={scrollRef} + css={{ + overflowY: 'auto', + height: '100%', + width: '100vw', + }} + > + applyStoredTheme(false) // false to skip server sync + return } diff --git a/packages/web/pages/app/terms.tsx b/packages/web/pages/app/terms.tsx index 5abe635f8..fd4325ab7 100644 --- a/packages/web/pages/app/terms.tsx +++ b/packages/web/pages/app/terms.tsx @@ -1,5 +1,7 @@ import { TermsAndConditions } from '../../components/templates/TermsAndConditions' +import { applyStoredTheme } from '../../lib/themeUpdater' export default function Terms(): JSX.Element { - return + applyStoredTheme(false) // false to skip server sync + return }