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