Переглянути джерело

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
         let title = textLabel(meeting.title, font: typography.cardTitle, color: palette.textPrimary)
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
         let subtitle = textLabel(meeting.subtitle ?? "Google Calendar", font: typography.cardSubtitle, color: palette.textPrimary)
1976
         let subtitle = textLabel(meeting.subtitle ?? "Google Calendar", font: typography.cardSubtitle, color: palette.textPrimary)
1974
         let time = textLabel(scheduleTimeText(for: meeting), font: typography.cardTime, color: palette.textSecondary)
1977
         let time = textLabel(scheduleTimeText(for: meeting), font: typography.cardTime, color: palette.textSecondary)
1975
         let duration = textLabel(scheduleDurationText(for: meeting), font: NSFont.systemFont(ofSize: 11, weight: .medium), color: palette.textMuted)
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
             title.leadingAnchor.constraint(equalTo: icon.trailingAnchor, constant: 6),
2007
             title.leadingAnchor.constraint(equalTo: icon.trailingAnchor, constant: 6),
2005
             title.centerYAnchor.constraint(equalTo: icon.centerYAnchor),
2008
             title.centerYAnchor.constraint(equalTo: icon.centerYAnchor),
2006
             title.trailingAnchor.constraint(lessThanOrEqualTo: dayChip.leadingAnchor, constant: -8),
2009
             title.trailingAnchor.constraint(lessThanOrEqualTo: dayChip.leadingAnchor, constant: -8),
2010
+            title.widthAnchor.constraint(lessThanOrEqualToConstant: 130),
2007
 
2011
 
2008
             subtitle.leadingAnchor.constraint(equalTo: card.leadingAnchor, constant: 10),
2012
             subtitle.leadingAnchor.constraint(equalTo: card.leadingAnchor, constant: 10),
2009
             subtitle.topAnchor.constraint(equalTo: icon.bottomAnchor, constant: 10),
2013
             subtitle.topAnchor.constraint(equalTo: icon.bottomAnchor, constant: 10),
@@ -2018,8 +2022,11 @@ private extension ViewController {
2018
             duration.trailingAnchor.constraint(lessThanOrEqualTo: card.trailingAnchor, constant: -10)
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
         hit.translatesAutoresizingMaskIntoConstraints = false
2026
         hit.translatesAutoresizingMaskIntoConstraints = false
2027
+        hit.isBordered = false
2028
+        hit.bezelStyle = .regularSquare
2029
+        hit.identifier = NSUserInterfaceItemIdentifier(meeting.meetURL.absoluteString)
2023
         hit.addSubview(card)
2030
         hit.addSubview(card)
2024
         NSLayoutConstraint.activate([
2031
         NSLayoutConstraint.activate([
2025
             card.leadingAnchor.constraint(equalTo: hit.leadingAnchor),
2032
             card.leadingAnchor.constraint(equalTo: hit.leadingAnchor),
@@ -2027,9 +2034,6 @@ private extension ViewController {
2027
             card.topAnchor.constraint(equalTo: hit.topAnchor),
2034
             card.topAnchor.constraint(equalTo: hit.topAnchor),
2028
             card.bottomAnchor.constraint(equalTo: hit.bottomAnchor)
2035
             card.bottomAnchor.constraint(equalTo: hit.bottomAnchor)
2029
         ])
2036
         ])
2030
-        hit.onClick = { [weak self] in
2031
-            self?.openMeetingURL(meeting.meetURL)
2032
-        }
2033
         hit.onHoverChanged = { [weak self] hovering in
2037
         hit.onHoverChanged = { [weak self] hovering in
2034
             guard let self else { return }
2038
             guard let self else { return }
2035
             let base = self.palette.sectionCard
2039
             let base = self.palette.sectionCard
@@ -2621,6 +2625,12 @@ private extension ViewController {
2621
         scrollScheduleCards(direction: 1)
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
     @objc func scheduleConnectButtonPressed(_ sender: NSButton) {
2634
     @objc func scheduleConnectButtonPressed(_ sender: NSButton) {
2625
         scheduleConnectClicked()
2635
         scheduleConnectClicked()
2626
     }
2636
     }