瀏覽代碼

Adjust Schedule pagination to load six cards initially.

Start the Schedule page with a smaller first batch and add a clear Load more action while preserving scroll-triggered pagination for additional cards.

Made-with: Cursor
huzaifahayat12 3 月之前
父節點
當前提交
16b135b01d
共有 1 個文件被更改,包括 32 次插入3 次删除
  1. 32 3
      meetings_app/ViewController.swift

+ 32 - 3
meetings_app/ViewController.swift

@@ -330,7 +330,7 @@ final class ViewController: NSViewController {
     private var schedulePageToDate: Date = Calendar.current.startOfDay(for: Date())
     private var schedulePageFilteredMeetings: [ScheduledMeeting] = []
     private var schedulePageVisibleCount: Int = 0
-    private let schedulePageBatchSize: Int = 20
+    private let schedulePageBatchSize: Int = 6
     private let schedulePageCardsPerRow: Int = 3
     private let schedulePageCardSpacing: CGFloat = 20
     private let schedulePageCardHeight: CGFloat = 182
@@ -4341,6 +4341,10 @@ private extension ViewController {
         scheduleConnectClicked()
     }
 
+    @objc func schedulePageLoadMorePressed(_ sender: NSButton) {
+        appendSchedulePageBatchIfNeeded()
+    }
+
     private func scheduleInitialHeadingText() -> String {
         googleOAuth.loadTokens() == nil ? "Connect Google to see meetings" : "Loading…"
     }
@@ -4626,8 +4630,33 @@ private extension ViewController {
         }
 
         if schedulePageVisibleCount < schedulePageFilteredMeetings.count {
-            let moreLabel = textLabel("Scroll to load more (\(schedulePageVisibleCount)/\(schedulePageFilteredMeetings.count))", font: NSFont.systemFont(ofSize: 12, weight: .medium), color: palette.textMuted)
-            stack.addArrangedSubview(moreLabel)
+            let pagination = NSStackView()
+            pagination.translatesAutoresizingMaskIntoConstraints = false
+            pagination.orientation = .horizontal
+            pagination.alignment = .centerY
+            pagination.spacing = 10
+
+            let moreLabel = textLabel(
+                "Showing \(schedulePageVisibleCount) of \(schedulePageFilteredMeetings.count)",
+                font: NSFont.systemFont(ofSize: 12, weight: .medium),
+                color: palette.textMuted
+            )
+            pagination.addArrangedSubview(moreLabel)
+
+            let spacer = NSView()
+            spacer.translatesAutoresizingMaskIntoConstraints = false
+            spacer.setContentHuggingPriority(.defaultLow, for: .horizontal)
+            pagination.addArrangedSubview(spacer)
+
+            let loadMore = makeSchedulePagePillButton(
+                title: "Load more",
+                action: #selector(schedulePageLoadMorePressed(_:))
+            )
+            loadMore.widthAnchor.constraint(equalToConstant: 118).isActive = true
+            pagination.addArrangedSubview(loadMore)
+
+            stack.addArrangedSubview(pagination)
+            pagination.widthAnchor.constraint(equalTo: stack.widthAnchor).isActive = true
         }
     }