Quellcode durchsuchen

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 vor 1 Woche
Ursprung
Commit
16b135b01d
1 geänderte Dateien mit 32 neuen und 3 gelöschten Zeilen
  1. 32 3
      meetings_app/ViewController.swift

+ 32 - 3
meetings_app/ViewController.swift

@@ -330,7 +330,7 @@ final class ViewController: NSViewController {
330 330
     private var schedulePageToDate: Date = Calendar.current.startOfDay(for: Date())
331 331
     private var schedulePageFilteredMeetings: [ScheduledMeeting] = []
332 332
     private var schedulePageVisibleCount: Int = 0
333
-    private let schedulePageBatchSize: Int = 20
333
+    private let schedulePageBatchSize: Int = 6
334 334
     private let schedulePageCardsPerRow: Int = 3
335 335
     private let schedulePageCardSpacing: CGFloat = 20
336 336
     private let schedulePageCardHeight: CGFloat = 182
@@ -4341,6 +4341,10 @@ private extension ViewController {
4341 4341
         scheduleConnectClicked()
4342 4342
     }
4343 4343
 
4344
+    @objc func schedulePageLoadMorePressed(_ sender: NSButton) {
4345
+        appendSchedulePageBatchIfNeeded()
4346
+    }
4347
+
4344 4348
     private func scheduleInitialHeadingText() -> String {
4345 4349
         googleOAuth.loadTokens() == nil ? "Connect Google to see meetings" : "Loading…"
4346 4350
     }
@@ -4626,8 +4630,33 @@ private extension ViewController {
4626 4630
         }
4627 4631
 
4628 4632
         if schedulePageVisibleCount < schedulePageFilteredMeetings.count {
4629
-            let moreLabel = textLabel("Scroll to load more (\(schedulePageVisibleCount)/\(schedulePageFilteredMeetings.count))", font: NSFont.systemFont(ofSize: 12, weight: .medium), color: palette.textMuted)
4630
-            stack.addArrangedSubview(moreLabel)
4633
+            let pagination = NSStackView()
4634
+            pagination.translatesAutoresizingMaskIntoConstraints = false
4635
+            pagination.orientation = .horizontal
4636
+            pagination.alignment = .centerY
4637
+            pagination.spacing = 10
4638
+
4639
+            let moreLabel = textLabel(
4640
+                "Showing \(schedulePageVisibleCount) of \(schedulePageFilteredMeetings.count)",
4641
+                font: NSFont.systemFont(ofSize: 12, weight: .medium),
4642
+                color: palette.textMuted
4643
+            )
4644
+            pagination.addArrangedSubview(moreLabel)
4645
+
4646
+            let spacer = NSView()
4647
+            spacer.translatesAutoresizingMaskIntoConstraints = false
4648
+            spacer.setContentHuggingPriority(.defaultLow, for: .horizontal)
4649
+            pagination.addArrangedSubview(spacer)
4650
+
4651
+            let loadMore = makeSchedulePagePillButton(
4652
+                title: "Load more",
4653
+                action: #selector(schedulePageLoadMorePressed(_:))
4654
+            )
4655
+            loadMore.widthAnchor.constraint(equalToConstant: 118).isActive = true
4656
+            pagination.addArrangedSubview(loadMore)
4657
+
4658
+            stack.addArrangedSubview(pagination)
4659
+            pagination.widthAnchor.constraint(equalTo: stack.widthAnchor).isActive = true
4631 4660
         }
4632 4661
     }
4633 4662