Эх сурвалжийг харах

Polish premium paywall sheet edge rendering

Use a borderless opaque paywall window with a sheet background color
that matches the paywall gradient so titled-window chrome does not
leave corner gaps. When presenting the sheet, size it slightly past
the host content rect with configurable per-edge overscan and an
extra half-point on the top to mask compositing hairlines.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 2 сар өмнө
parent
commit
c77c84d385

+ 8 - 14
App for Indeed/Controllers/PremiumPlansWindowController.swift

@@ -2,26 +2,22 @@ import Cocoa
 import StoreKit
 
 final class PremiumPlansWindowController: NSWindowController {
+    /// Matches `PremiumPlansViewController.Theme.pageStart` so the window backing fills sheet corners.
+    static let paywallSheetBackground = NSColor(srgbRed: 249 / 255, green: 252 / 255, blue: 255 / 255, alpha: 1)
+
     init() {
         let viewController = PremiumPlansViewController()
         let window = NSWindow(contentViewController: viewController)
         window.title = "Premium Plans"
-        window.styleMask = [.titled, .closable, .miniaturizable, .resizable]
-        window.styleMask.insert(.fullSizeContentView)
-        window.titlebarAppearsTransparent = true
-        window.titleVisibility = .hidden
-        window.isOpaque = false
-        window.backgroundColor = .clear
+        // Borderless avoids titled-window chrome: its rounded titlebar frame often leaves dark wedges at
+        // the corners when combined with a custom full-bleed paywall (this window is only shown as a sheet).
+        window.styleMask = [.borderless, .closable, .resizable]
+        window.isOpaque = true
+        window.backgroundColor = Self.paywallSheetBackground
         window.setContentSize(NSSize(width: 1160, height: 760))
         window.minSize = NSSize(width: 980, height: 680)
         window.center()
         super.init(window: window)
-
-        if let frameView = window.contentView?.superview {
-            frameView.wantsLayer = true
-            frameView.layer?.cornerRadius = 18
-            frameView.layer?.masksToBounds = true
-        }
     }
 
     @available(*, unavailable)
@@ -498,8 +494,6 @@ private final class PremiumPlansViewController: NSViewController {
     override func loadView() {
         view = NSView()
         view.wantsLayer = true
-        view.layer?.cornerRadius = 18
-        view.layer?.masksToBounds = true
         pageGradient.colors = [Theme.pageStart.cgColor, Theme.pageEnd.cgColor]
         pageGradient.startPoint = CGPoint(x: 0, y: 1)
         pageGradient.endPoint = CGPoint(x: 1, y: 0)

+ 20 - 7
App for Indeed/Views/DashboardView.swift

@@ -12,6 +12,13 @@ private enum JobListingCardContext {
     case savedJobsPage
 }
 
+private enum PremiumSheetLayout {
+    /// Grow the sheet past the host content rect on each side to hide compositing hairlines.
+    static let overscanPerEdge: CGFloat = 2
+    /// Additional growth on the top edge only (pt).
+    static let overscanExtraTop: CGFloat = 0.5
+}
+
 final class DashboardView: NSView, NSTextFieldDelegate {
     /// Indeed.com-inspired neutrals and brand blue (white surfaces, `#2557a7` accent, `#2d2d2d` / `#767676` text, `#d4d2d0` borders).
     private enum Theme {
@@ -398,13 +405,19 @@ final class DashboardView: NSView, NSTextFieldDelegate {
             return
         }
 
-        let hostContentSize = hostWindow.contentView?.bounds.size ?? hostWindow.frame.size
-        paywallWindow.setContentSize(hostContentSize)
-        paywallWindow.minSize = hostContentSize
-        paywallWindow.maxSize = hostContentSize
-        paywallWindow.styleMask.insert(.fullSizeContentView)
-        paywallWindow.titlebarAppearsTransparent = true
-        paywallWindow.titleVisibility = .hidden
+        paywallWindow.styleMask = [.borderless, .closable, .resizable]
+        paywallWindow.isOpaque = true
+        paywallWindow.backgroundColor = PremiumPlansWindowController.paywallSheetBackground
+
+        let hostContentRect = hostWindow.contentRect(forFrameRect: hostWindow.frame)
+        let overscan = PremiumSheetLayout.overscanPerEdge
+        var expandedContentRect = hostContentRect.insetBy(dx: -overscan, dy: -overscan)
+        expandedContentRect.size.height += PremiumSheetLayout.overscanExtraTop
+        let paywallFrame = paywallWindow.frameRect(forContentRect: expandedContentRect)
+        paywallWindow.setFrame(paywallFrame, display: false)
+        let lockedSize = paywallWindow.frame.size
+        paywallWindow.minSize = lockedSize
+        paywallWindow.maxSize = lockedSize
 
         hostWindow.beginSheet(paywallWindow)
     }