Преглед на файлове

Settings: premium-gated notifications UI and layout fix

Show the reminders block only for premium users via a notifications
stack whose visibility tracks entitlements. Rebuild the embedded
settings view when premium status changes so the page stays in sync.
Fix Auto Layout by adding the notifications stack to the parent before
pinning its width to the outer stack (avoids missing common ancestor).

Co-authored-by: Cursor <cursoragent@cursor.com>
huzaifahayat12 преди 2 месеца
родител
ревизия
a69acff557
променени са 1 файла, в които са добавени 38 реда и са изтрити 8 реда
  1. 38 8
      zoom_app/ViewController.swift

+ 38 - 8
zoom_app/ViewController.swift

@@ -311,6 +311,7 @@ class ViewController: NSViewController {
     private weak var meetingSearchResultsStack: NSStackView?
     private weak var meetingSearchEmptyLabel: NSTextField?
     private weak var homeSettingsView: NSView?
+    private weak var homeSettingsHostColumn: NSView?
     private weak var schedulerRootView: NSView?
     private weak var schedulerMonthLabel: NSTextField?
     private weak var schedulerCalendarGridStack: NSStackView?
@@ -358,6 +359,7 @@ class ViewController: NSViewController {
     private weak var settingsReminders1HourRow: NSView?
     private weak var settingsUpgradeButton: NSButton?
     private weak var settingsUpgradeTitleLabel: NSTextField?
+    private weak var settingsNotificationsBlock: NSStackView?
     private weak var settingsGoogleActionButton: NSButton?
     private weak var topBarPremiumButton: NSButton?
     private weak var topBarAuthButton: NSButton?
@@ -3393,14 +3395,20 @@ class ViewController: NSViewController {
 
         stack.setCustomSpacing(24, after: upgradeButton)
 
-        if storeKitCoordinator.hasPremiumAccess {
-            let notificationsTitle = textLabel("Notifications", font: .systemFont(ofSize: 16, weight: .semibold), color: primaryText)
-            stack.addArrangedSubview(notificationsTitle)
-            let remindersSection = makeSettingsRemindersSection()
-            stack.addArrangedSubview(remindersSection)
-            remindersSection.widthAnchor.constraint(equalTo: stack.widthAnchor).isActive = true
-            stack.setCustomSpacing(24, after: remindersSection)
-        }
+        let notificationsTitle = textLabel("Notifications", font: .systemFont(ofSize: 16, weight: .semibold), color: primaryText)
+        let remindersSection = makeSettingsRemindersSection()
+        let notificationsBlock = NSStackView()
+        notificationsBlock.translatesAutoresizingMaskIntoConstraints = false
+        notificationsBlock.orientation = .vertical
+        notificationsBlock.spacing = 18
+        notificationsBlock.alignment = .leading
+        notificationsBlock.addArrangedSubview(notificationsTitle)
+        notificationsBlock.addArrangedSubview(remindersSection)
+        remindersSection.widthAnchor.constraint(equalTo: notificationsBlock.widthAnchor).isActive = true
+        stack.addArrangedSubview(notificationsBlock)
+        notificationsBlock.widthAnchor.constraint(equalTo: stack.widthAnchor).isActive = true
+        settingsNotificationsBlock = notificationsBlock
+        stack.setCustomSpacing(24, after: notificationsBlock)
 
         let legalTitle = textLabel("Help & Legal", font: .systemFont(ofSize: 16, weight: .semibold), color: primaryText)
         stack.addArrangedSubview(legalTitle)
@@ -3444,6 +3452,23 @@ class ViewController: NSViewController {
         return panel
     }
 
+    @MainActor
+    private func rebuildHomeSettingsViewPreservingSelection() {
+        guard let column = homeSettingsHostColumn else { return }
+        homeSettingsView?.removeFromSuperview()
+        let newSettings = makeSettingsView()
+        newSettings.translatesAutoresizingMaskIntoConstraints = false
+        column.addSubview(newSettings)
+        NSLayoutConstraint.activate([
+            newSettings.topAnchor.constraint(equalTo: column.topAnchor),
+            newSettings.leadingAnchor.constraint(equalTo: column.leadingAnchor),
+            newSettings.trailingAnchor.constraint(equalTo: column.trailingAnchor),
+            newSettings.bottomAnchor.constraint(equalTo: column.bottomAnchor)
+        ])
+        homeSettingsView = newSettings
+        updateSelectedHomeSectionUI()
+    }
+
     private enum SettingsAction: Int {
         case shareApp = 1
         case upgrade = 2
@@ -3750,6 +3775,9 @@ class ViewController: NSViewController {
                 let wasPremium = self.lastKnownPremiumAccess
                 self.lastKnownPremiumAccess = newIsPremium
                 self.updatePremiumButtons()
+                if wasPremium != newIsPremium {
+                    self.rebuildHomeSettingsViewPreservingSelection()
+                }
                 self.reconcileDesktopWidgetsForPremiumAccess()
                 if (wasPremium == false) && newIsPremium {
                     self.startMeetingsAutoRefresh()
@@ -3813,6 +3841,7 @@ class ViewController: NSViewController {
         settingsUpgradeButton?.isHidden = hasLifetimePremium
         settingsUpgradeButton?.isEnabled = hasLifetimePremium == false
         settingsUpgradeButton?.alphaValue = hasLifetimePremium ? 0.6 : 1.0
+        settingsNotificationsBlock?.isHidden = isPremium == false
         updatePremiumLockedSections()
         if isPremium == false, isUserLoggedIn() {
             applyMeetings([])
@@ -5922,6 +5951,7 @@ class ViewController: NSViewController {
         homeMeetingsPanel = panel
         homePlaceholderLabel = placeholder
         homeSettingsView = settingsView
+        homeSettingsHostColumn = mainContentColumn
         meetingsPageRootView = meetingsPageView
         widgetsPageRootView = widgetsPageView
         schedulerRootView = schedulerRoot