WIP: anchor source badge to card corner
This commit is contained in:
@@ -1434,6 +1434,10 @@ final class ClipboardPanelView: NSVisualEffectView, NSSearchFieldDelegate {
|
||||
cardViews.first?.debugHeaderBadgeIsHidden ?? false
|
||||
}
|
||||
|
||||
var debugFirstCardHeaderBadgeFrame: NSRect {
|
||||
cardViews.first?.debugHeaderBadgeFrame ?? .zero
|
||||
}
|
||||
|
||||
var debugResultCountText: String {
|
||||
statusResultCountLabel.stringValue
|
||||
}
|
||||
@@ -2672,6 +2676,11 @@ private final class ClipboardItemCardView: NSView, NSDraggingSource {
|
||||
headerBadgeView?.isHidden ?? false
|
||||
}
|
||||
|
||||
var debugHeaderBadgeFrame: NSRect {
|
||||
guard let headerBadgeView else { return .zero }
|
||||
return headerBadgeView.convert(headerBadgeView.bounds, to: self)
|
||||
}
|
||||
|
||||
var debugQuickPasteBadgeText: String? {
|
||||
quickPasteBadgeLabel?.stringValue
|
||||
}
|
||||
@@ -2984,7 +2993,6 @@ private final class ClipboardItemCardView: NSView, NSDraggingSource {
|
||||
private var maximumVisibleActionRailWidth: CGFloat {
|
||||
layout.width
|
||||
- Metrics.actionRailLeadingMargin
|
||||
- layout.inset
|
||||
- Metrics.actionRailBadgeGap
|
||||
- headerBadgeSize
|
||||
}
|
||||
@@ -3288,8 +3296,8 @@ private final class ClipboardItemCardView: NSView, NSDraggingSource {
|
||||
labelStack.leadingAnchor.constraint(equalTo: header.leadingAnchor, constant: layout.inset),
|
||||
labelStack.centerYAnchor.constraint(equalTo: header.centerYAnchor),
|
||||
labelStack.trailingAnchor.constraint(lessThanOrEqualTo: badge.leadingAnchor, constant: -12),
|
||||
badge.trailingAnchor.constraint(equalTo: header.trailingAnchor, constant: -layout.inset),
|
||||
badge.centerYAnchor.constraint(equalTo: header.centerYAnchor),
|
||||
badge.trailingAnchor.constraint(equalTo: header.trailingAnchor),
|
||||
badge.topAnchor.constraint(equalTo: header.topAnchor),
|
||||
badge.widthAnchor.constraint(equalToConstant: headerBadgeSize),
|
||||
badge.heightAnchor.constraint(equalToConstant: headerBadgeSize),
|
||||
separator.leadingAnchor.constraint(equalTo: header.leadingAnchor, constant: layout.inset),
|
||||
|
||||
@@ -362,21 +362,28 @@ final class ClipboardPanelViewTests: XCTestCase {
|
||||
let fixture = makePanelFixture()
|
||||
fixture.store.upsert(makeTextItem("Plain text", store: fixture.store))
|
||||
drainMainQueue()
|
||||
fixture.window.contentView?.layoutSubtreeIfNeeded()
|
||||
|
||||
XCTAssertEqual(fixture.view.debugFirstCardVisibleActionLabels, ["Paste", "Copy", "Pin", "Collect", "Add to Stack", "Edit", "Preview", "Delete"])
|
||||
XCTAssertEqual(fixture.view.debugFirstCardVisibleActionRailWidth, 238)
|
||||
XCTAssertFalse(fixture.view.debugFirstCardFooterDetailIsHidden)
|
||||
XCTAssertFalse(fixture.view.debugFirstCardHeaderBadgeIsHidden)
|
||||
XCTAssertEqual(fixture.view.debugFirstCardHeaderBadgeFrame.maxX, 320, accuracy: 0.5)
|
||||
XCTAssertEqual(fixture.view.debugFirstCardHeaderBadgeFrame.maxY, 244, accuracy: 0.5)
|
||||
|
||||
fixture.store.upsert(makeItem(kind: .file, text: "/tmp/report.txt", store: fixture.store))
|
||||
drainMainQueue()
|
||||
fixture.window.contentView?.layoutSubtreeIfNeeded()
|
||||
|
||||
fixture.viewModel.selectFirstItem()
|
||||
fixture.window.contentView?.layoutSubtreeIfNeeded()
|
||||
XCTAssertEqual(fixture.viewModel.visibleItems.first?.kind, .file)
|
||||
XCTAssertEqual(fixture.view.debugFirstCardVisibleActionLabels, ["Paste", "Copy", "Paste Plain Text", "Collect", "Add to Stack", "Preview", "Open", "More"])
|
||||
XCTAssertEqual(fixture.view.debugFirstCardVisibleActionRailWidth, 238)
|
||||
XCTAssertFalse(fixture.view.debugFirstCardFooterDetailIsHidden)
|
||||
XCTAssertFalse(fixture.view.debugFirstCardHeaderBadgeIsHidden)
|
||||
XCTAssertEqual(fixture.view.debugFirstCardHeaderBadgeFrame.maxX, 320, accuracy: 0.5)
|
||||
XCTAssertEqual(fixture.view.debugFirstCardHeaderBadgeFrame.maxY, 244, accuracy: 0.5)
|
||||
}
|
||||
|
||||
func testCompactFileCardActionsFitInsideShelfWithOverflowMenu() {
|
||||
@@ -391,6 +398,8 @@ final class ClipboardPanelViewTests: XCTestCase {
|
||||
XCTAssertEqual(fixture.view.debugFirstCardVisibleActionRailWidth, 196)
|
||||
XCTAssertLessThanOrEqual(fixture.view.debugFirstCardVisibleActionRailWidth, 197)
|
||||
XCTAssertFalse(fixture.view.debugFirstCardHeaderBadgeIsHidden)
|
||||
XCTAssertEqual(fixture.view.debugFirstCardHeaderBadgeFrame.maxX, 264, accuracy: 0.5)
|
||||
XCTAssertEqual(fixture.view.debugFirstCardHeaderBadgeFrame.maxY, 220, accuracy: 0.5)
|
||||
XCTAssertEqual(
|
||||
fixture.view.debugFirstCardMenuTitles,
|
||||
["Paste", "Copy", "Paste Plain Text", "Copy Plain Text", "Rename...", "Add to Stack", "Quick Look", "Pin", "Add to Collection", "Capture Rules", "-", "Open", "Reveal in Finder", "-", "Delete"]
|
||||
|
||||
Reference in New Issue
Block a user