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 3 semanas
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 {
141 141
     }
142 142
 
143 143
     private func setupLayout() {
144
+        let closeButton = NSButton(title: "", target: self, action: #selector(didTapClose))
145
+        closeButton.translatesAutoresizingMaskIntoConstraints = false
146
+        closeButton.isBordered = false
147
+        closeButton.wantsLayer = true
148
+        closeButton.layer?.cornerRadius = 15
149
+        closeButton.layer?.backgroundColor = NSColor.white.withAlphaComponent(0.92).cgColor
150
+        closeButton.layer?.borderWidth = 1
151
+        closeButton.layer?.borderColor = Theme.divider.cgColor
152
+        closeButton.contentTintColor = Theme.secondaryText
153
+        closeButton.image = NSImage(systemSymbolName: "xmark", accessibilityDescription: "Close")
154
+        closeButton.imageScaling = .scaleProportionallyDown
155
+        closeButton.bezelStyle = .regularSquare
156
+
144 157
         let crownIcon = NSImageView()
145 158
         crownIcon.translatesAutoresizingMaskIntoConstraints = false
146 159
         crownIcon.symbolConfiguration = NSImage.SymbolConfiguration(pointSize: 18, weight: .semibold)
@@ -174,11 +187,16 @@ private final class PremiumPlansViewController: NSViewController {
174 187
         root.translatesAutoresizingMaskIntoConstraints = false
175 188
 
176 189
         view.addSubview(root)
190
+        view.addSubview(closeButton)
177 191
         NSLayoutConstraint.activate([
178 192
             root.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 24),
179 193
             root.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -24),
180 194
             root.topAnchor.constraint(equalTo: view.topAnchor, constant: 20),
181 195
             root.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -16),
196
+            closeButton.topAnchor.constraint(equalTo: view.topAnchor, constant: 14),
197
+            closeButton.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -14),
198
+            closeButton.widthAnchor.constraint(equalToConstant: 30),
199
+            closeButton.heightAnchor.constraint(equalToConstant: 30),
182 200
             cardsRow.widthAnchor.constraint(equalTo: root.widthAnchor),
183 201
             cardsRow.heightAnchor.constraint(equalToConstant: 420),
184 202
             trustRow.widthAnchor.constraint(equalTo: root.widthAnchor),
@@ -484,4 +502,13 @@ private final class PremiumPlansViewController: NSViewController {
484 502
             alert.runModal()
485 503
         }
486 504
     }
505
+
506
+    @objc private func didTapClose() {
507
+        guard let window = view.window else { return }
508
+        if let parent = window.sheetParent {
509
+            parent.endSheet(window)
510
+            return
511
+        }
512
+        window.close()
513
+    }
487 514
 }