瀏覽代碼

Fix meeting card click handling across schedule carousel.

Use native button actions per card for reliable click behavior on all cards and truncate long titles so the date chip remains visible.

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

+ 14 - 4
meetings_app/ViewController.swift

@@ -1970,6 +1970,9 @@ private extension ViewController {
1970 1970
         ])
1971 1971
 
1972 1972
         let title = textLabel(meeting.title, font: typography.cardTitle, color: palette.textPrimary)
1973
+        title.lineBreakMode = .byTruncatingTail
1974
+        title.maximumNumberOfLines = 1
1975
+        title.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
1973 1976
         let subtitle = textLabel(meeting.subtitle ?? "Google Calendar", font: typography.cardSubtitle, color: palette.textPrimary)
1974 1977
         let time = textLabel(scheduleTimeText(for: meeting), font: typography.cardTime, color: palette.textSecondary)
1975 1978
         let duration = textLabel(scheduleDurationText(for: meeting), font: NSFont.systemFont(ofSize: 11, weight: .medium), color: palette.textMuted)
@@ -2004,6 +2007,7 @@ private extension ViewController {
2004 2007
             title.leadingAnchor.constraint(equalTo: icon.trailingAnchor, constant: 6),
2005 2008
             title.centerYAnchor.constraint(equalTo: icon.centerYAnchor),
2006 2009
             title.trailingAnchor.constraint(lessThanOrEqualTo: dayChip.leadingAnchor, constant: -8),
2010
+            title.widthAnchor.constraint(lessThanOrEqualToConstant: 130),
2007 2011
 
2008 2012
             subtitle.leadingAnchor.constraint(equalTo: card.leadingAnchor, constant: 10),
2009 2013
             subtitle.topAnchor.constraint(equalTo: icon.bottomAnchor, constant: 10),
@@ -2018,8 +2022,11 @@ private extension ViewController {
2018 2022
             duration.trailingAnchor.constraint(lessThanOrEqualTo: card.trailingAnchor, constant: -10)
2019 2023
         ])
2020 2024
 
2021
-        let hit = HoverTrackingView()
2025
+        let hit = HoverButton(title: "", target: self, action: #selector(scheduleCardButtonPressed(_:)))
2022 2026
         hit.translatesAutoresizingMaskIntoConstraints = false
2027
+        hit.isBordered = false
2028
+        hit.bezelStyle = .regularSquare
2029
+        hit.identifier = NSUserInterfaceItemIdentifier(meeting.meetURL.absoluteString)
2023 2030
         hit.addSubview(card)
2024 2031
         NSLayoutConstraint.activate([
2025 2032
             card.leadingAnchor.constraint(equalTo: hit.leadingAnchor),
@@ -2027,9 +2034,6 @@ private extension ViewController {
2027 2034
             card.topAnchor.constraint(equalTo: hit.topAnchor),
2028 2035
             card.bottomAnchor.constraint(equalTo: hit.bottomAnchor)
2029 2036
         ])
2030
-        hit.onClick = { [weak self] in
2031
-            self?.openMeetingURL(meeting.meetURL)
2032
-        }
2033 2037
         hit.onHoverChanged = { [weak self] hovering in
2034 2038
             guard let self else { return }
2035 2039
             let base = self.palette.sectionCard
@@ -2621,6 +2625,12 @@ private extension ViewController {
2621 2625
         scrollScheduleCards(direction: 1)
2622 2626
     }
2623 2627
 
2628
+    @objc func scheduleCardButtonPressed(_ sender: NSButton) {
2629
+        guard let raw = sender.identifier?.rawValue,
2630
+              let url = URL(string: raw) else { return }
2631
+        openMeetingURL(url)
2632
+    }
2633
+
2624 2634
     @objc func scheduleConnectButtonPressed(_ sender: NSButton) {
2625 2635
         scheduleConnectClicked()
2626 2636
     }