Explorar el Código

Fix subscription sheet close button behavior.

Add a top-right close button to the premium plans page and dismiss the sheet via endSheet so the button reliably closes the subscription flow.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 hace 2 meses
padre
commit
8b60b7ed4b
Se han modificado 1 ficheros con 27 adiciones y 0 borrados
  1. 27 0
      App for Indeed/Controllers/PremiumPlansWindowController.swift

+ 27 - 0
App for Indeed/Controllers/PremiumPlansWindowController.swift

@@ -141,6 +141,19 @@ private final class PremiumPlansViewController: NSViewController {
     }
 
     private func setupLayout() {
+        let closeButton = NSButton(title: "", target: self, action: #selector(didTapClose))
+        closeButton.translatesAutoresizingMaskIntoConstraints = false
+        closeButton.isBordered = false
+        closeButton.wantsLayer = true
+        closeButton.layer?.cornerRadius = 15
+        closeButton.layer?.backgroundColor = NSColor.white.withAlphaComponent(0.92).cgColor
+        closeButton.layer?.borderWidth = 1
+        closeButton.layer?.borderColor = Theme.divider.cgColor
+        closeButton.contentTintColor = Theme.secondaryText
+        closeButton.image = NSImage(systemSymbolName: "xmark", accessibilityDescription: "Close")
+        closeButton.imageScaling = .scaleProportionallyDown
+        closeButton.bezelStyle = .regularSquare
+
         let crownIcon = NSImageView()
         crownIcon.translatesAutoresizingMaskIntoConstraints = false
         crownIcon.symbolConfiguration = NSImage.SymbolConfiguration(pointSize: 18, weight: .semibold)
@@ -174,11 +187,16 @@ private final class PremiumPlansViewController: NSViewController {
         root.translatesAutoresizingMaskIntoConstraints = false
 
         view.addSubview(root)
+        view.addSubview(closeButton)
         NSLayoutConstraint.activate([
             root.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 24),
             root.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -24),
             root.topAnchor.constraint(equalTo: view.topAnchor, constant: 20),
             root.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -16),
+            closeButton.topAnchor.constraint(equalTo: view.topAnchor, constant: 14),
+            closeButton.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -14),
+            closeButton.widthAnchor.constraint(equalToConstant: 30),
+            closeButton.heightAnchor.constraint(equalToConstant: 30),
             cardsRow.widthAnchor.constraint(equalTo: root.widthAnchor),
             cardsRow.heightAnchor.constraint(equalToConstant: 420),
             trustRow.widthAnchor.constraint(equalTo: root.widthAnchor),
@@ -484,4 +502,13 @@ private final class PremiumPlansViewController: NSViewController {
             alert.runModal()
         }
     }
+
+    @objc private func didTapClose() {
+        guard let window = view.window else { return }
+        if let parent = window.sheetParent {
+            parent.endSheet(window)
+            return
+        }
+        window.close()
+    }
 }