Просмотр исходного кода

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 недель назад: 3
Родитель
Сommit
c77c84d385

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

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

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

@@ -12,6 +12,13 @@ private enum JobListingCardContext {
12 12
     case savedJobsPage
13 13
 }
14 14
 
15
+private enum PremiumSheetLayout {
16
+    /// Grow the sheet past the host content rect on each side to hide compositing hairlines.
17
+    static let overscanPerEdge: CGFloat = 2
18
+    /// Additional growth on the top edge only (pt).
19
+    static let overscanExtraTop: CGFloat = 0.5
20
+}
21
+
15 22
 final class DashboardView: NSView, NSTextFieldDelegate {
16 23
     /// Indeed.com-inspired neutrals and brand blue (white surfaces, `#2557a7` accent, `#2d2d2d` / `#767676` text, `#d4d2d0` borders).
17 24
     private enum Theme {
@@ -398,13 +405,19 @@ final class DashboardView: NSView, NSTextFieldDelegate {
398 405
             return
399 406
         }
400 407
 
401
-        let hostContentSize = hostWindow.contentView?.bounds.size ?? hostWindow.frame.size
402
-        paywallWindow.setContentSize(hostContentSize)
403
-        paywallWindow.minSize = hostContentSize
404
-        paywallWindow.maxSize = hostContentSize
405
-        paywallWindow.styleMask.insert(.fullSizeContentView)
406
-        paywallWindow.titlebarAppearsTransparent = true
407
-        paywallWindow.titleVisibility = .hidden
408
+        paywallWindow.styleMask = [.borderless, .closable, .resizable]
409
+        paywallWindow.isOpaque = true
410
+        paywallWindow.backgroundColor = PremiumPlansWindowController.paywallSheetBackground
411
+
412
+        let hostContentRect = hostWindow.contentRect(forFrameRect: hostWindow.frame)
413
+        let overscan = PremiumSheetLayout.overscanPerEdge
414
+        var expandedContentRect = hostContentRect.insetBy(dx: -overscan, dy: -overscan)
415
+        expandedContentRect.size.height += PremiumSheetLayout.overscanExtraTop
416
+        let paywallFrame = paywallWindow.frameRect(forContentRect: expandedContentRect)
417
+        paywallWindow.setFrame(paywallFrame, display: false)
418
+        let lockedSize = paywallWindow.frame.size
419
+        paywallWindow.minSize = lockedSize
420
+        paywallWindow.maxSize = lockedSize
408 421
 
409 422
         hostWindow.beginSheet(paywallWindow)
410 423
     }