Skip to content

Commit f0f3ac0

Browse files
committed
updated
1 parent a8b55dc commit f0f3ac0

File tree

6 files changed

+126
-70
lines changed

6 files changed

+126
-70
lines changed

Example/Example.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@
395395
"@executable_path/../Frameworks",
396396
);
397397
MARKETING_VERSION = 1.0;
398+
OTHER_LDFLAGS = "-v";
398399
PRODUCT_BUNDLE_IDENTIFIER = com.muffinstory.advancedCollectionTableViewExample;
399400
PRODUCT_NAME = "$(TARGET_NAME)";
400401
SWIFT_EMIT_LOC_STRINGS = YES;
@@ -424,6 +425,7 @@
424425
"@executable_path/../Frameworks",
425426
);
426427
MARKETING_VERSION = 1.0;
428+
OTHER_LDFLAGS = "-v";
427429
PRODUCT_BUNDLE_IDENTIFIER = com.muffinstory.advancedCollectionTableViewExample;
428430
PRODUCT_NAME = "$(TARGET_NAME)";
429431
SWIFT_EMIT_LOC_STRINGS = YES;

Example/Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"originHash" : "9a3fc9d4e8c660ad4f02d3fe7cb14be2d4a8737c02d84fc43a36ece1c84e8b31",
32
"pins" : [
43
{
54
"identity" : "fzquicklook",
@@ -16,7 +15,7 @@
1615
"location" : "https://github.com/flocked/FZSwiftUtils.git",
1716
"state" : {
1817
"branch" : "main",
19-
"revision" : "53d5e5eddef6ad50801f6fa8ec7ba0f7cdb0b8f7"
18+
"revision" : "46706eedbacdc373b75c12c61a876a69e310858c"
2019
}
2120
},
2221
{
@@ -25,9 +24,9 @@
2524
"location" : "https://github.com/flocked/FZUIKit.git",
2625
"state" : {
2726
"branch" : "main",
28-
"revision" : "ddf86d023537b66d0d857e18b0312a5bdf41c0a0"
27+
"revision" : "5f12b512d332c17440af0bebb25ffa295b6702ff"
2928
}
3029
}
3130
],
32-
"version" : 3
31+
"version" : 2
3332
}

Example/Example.xcodeproj/xcuserdata/florianzand.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,4 @@
33
uuid = "D2B010BE-3534-4443-8561-CB5D17ED66BC"
44
type = "1"
55
version = "2.0">
6-
<Breakpoints>
7-
<BreakpointProxy
8-
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
9-
<BreakpointContent
10-
uuid = "ECF54206-5C3A-488C-B7B6-35FC90C650FE"
11-
shouldBeEnabled = "Yes"
12-
ignoreCount = "0"
13-
continueAfterRunningActions = "No"
14-
filePath = "../../../../Library/Developer/Xcode/DerivedData/CollectionViewTemplate-hbzgtugoftebbnctjkkxcohzifsf/SourcePackages/checkouts/AdvancedCollectionTableView/Sources/AdvancedCollectionTableView/Configuration/Configurations/CollectionViewContentConfiguration/NSItemContentConfiguration.swift"
15-
startingColumnNumber = "9223372036854775807"
16-
endingColumnNumber = "9223372036854775807"
17-
startingLineNumber = "113"
18-
endingLineNumber = "113"
19-
landmarkName = "TextTransform"
20-
landmarkType = "13">
21-
</BreakpointContent>
22-
</BreakpointProxy>
23-
</Breakpoints>
246
</Bucket>

Sources/AdvancedCollectionTableView/Configuration/Configurations/NSItemContentConfiguration/NSItemContentView.swift

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,33 @@ open class NSItemContentView: NSView, NSContentView, EditingContentView {
4949
configuration is NSItemContentConfiguration
5050
}
5151

52+
/**
53+
A guide for positioning the primary text in the content view.
54+
55+
If the configuration doesn’t specify primary text, the value of this property is `nil`.
56+
57+
If you apply a new configuration without primary text to the content view, the system removes this layout guide from the view and deactivates any constraints associated with it.
58+
*/
59+
public internal(set) var textLayoutGuide: NSLayoutGuide?
60+
61+
/**
62+
A guide for positioning the secondary text in the content view.
63+
64+
If the configuration doesn’t specify secondary text, the value of this property is `nil`.
65+
66+
If you apply a new configuration without secondary text to the content view, the system removes this layout guide from the view and deactivates any constraints associated with it.
67+
*/
68+
public internal(set) var secondaryTextLayoutGuide: NSLayoutGuide?
69+
70+
/**
71+
A guide for positioning the image or view in the content view.
72+
73+
If the configuration doesn’t specify an image or view, the value of this property is `nil`.
74+
75+
If you apply a new configuration without image or view to the content view, the system removes this layout guide from the view and deactivates any constraints associated with it.
76+
*/
77+
public internal(set) var contentLayoutGuide: NSLayoutGuide?
78+
5279
func isHovering(at location: CGPoint) -> Bool {
5380
return (contentView.frame.contains(location) && contentView.isHidden == false) ||
5481
CGRect(0, 0, max(textField.bounds.width, secondaryTextField.bounds.width), contentView.frame.y).contains(location)
@@ -179,5 +206,33 @@ open class NSItemContentView: NSView, NSContentView, EditingContentView {
179206
secondaryTextFieldConstraint = secondaryTextField.leftAnchor.constraint(equalTo: stackView.leftAnchor).activate()
180207
}
181208
}
209+
updateLayoutGuides()
210+
}
211+
212+
func updateLayoutGuides() {
213+
if !appliedConfiguration.hasText, let guide = textLayoutGuide {
214+
removeLayoutGuide(guide)
215+
textLayoutGuide = nil
216+
} else if appliedConfiguration.hasText, textLayoutGuide == nil {
217+
textLayoutGuide = NSLayoutGuide()
218+
addLayoutGuide(textLayoutGuide!)
219+
textLayoutGuide?.constraint(to: textField)
220+
}
221+
if !appliedConfiguration.hasSecondaryText, let guide = secondaryTextLayoutGuide {
222+
removeLayoutGuide(guide)
223+
secondaryTextLayoutGuide = nil
224+
} else if appliedConfiguration.hasSecondaryText, secondaryTextLayoutGuide == nil {
225+
secondaryTextLayoutGuide = NSLayoutGuide()
226+
addLayoutGuide(secondaryTextLayoutGuide!)
227+
secondaryTextLayoutGuide?.constraint(to: secondaryTextField)
228+
}
229+
if !appliedConfiguration.hasContent, let guide = contentLayoutGuide {
230+
removeLayoutGuide(guide)
231+
contentLayoutGuide = nil
232+
} else if appliedConfiguration.hasContent, contentLayoutGuide == nil {
233+
contentLayoutGuide = NSLayoutGuide()
234+
addLayoutGuide(contentLayoutGuide!)
235+
contentLayoutGuide?.constraint(to: contentView)
236+
}
182237
}
183238
}

Sources/AdvancedCollectionTableView/Configuration/Configurations/NSListContentConfiguration/NSListContentView.swift

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,32 @@ open class NSListContentView: NSView, NSContentView, EditingContentView {
4343
}
4444
}
4545

46+
/**
47+
A guide for positioning the primary text in the content view.
48+
49+
If the configuration doesn’t specify primary text, the value of this property is `nil`.
50+
51+
If you apply a new configuration without primary text to the content view, the system removes this layout guide from the view and deactivates any constraints associated with it.
52+
*/
53+
public internal(set) var textLayoutGuide: NSLayoutGuide?
54+
55+
/**
56+
A guide for positioning the secondary text in the content view.
57+
58+
If the configuration doesn’t specify secondary text, the value of this property is `nil`.
59+
60+
If you apply a new configuration without secondary text to the content view, the system removes this layout guide from the view and deactivates any constraints associated with it.
61+
*/
62+
public internal(set) var secondaryTextLayoutGuide: NSLayoutGuide?
63+
64+
/**
65+
A guide for positioning the image in the content view.
66+
67+
If the configuration doesn’t specify an image, the value of this property is `nil`.
68+
69+
If you apply a new configuration without secondary text to the content view, the system removes this layout guide from the view and deactivates any constraints associated with it.
70+
*/
71+
public internal(set) var imageLayoutGuide: NSLayoutGuide?
4672
/**
4773
Determines whether the view is compatible with the provided configuration.
4874

@@ -96,10 +122,6 @@ open class NSListContentView: NSView, NSContentView, EditingContentView {
96122
secondaryTextField.isEnabled = appliedConfiguration.isEnabled
97123
secondaryTextField.properties = appliedConfiguration.secondaryTextProperties
98124
secondaryTextField.updateText(appliedConfiguration.secondaryText, appliedConfiguration.secondaryAttributedText, appliedConfiguration.secondaryPlaceholderText, appliedConfiguration.secondaryAttributedPlaceholderText)
99-
100-
if isAnimating, imageView.image != appliedConfiguration.image || imageView.properties != appliedConfiguration.imageProperties {
101-
imageView.transition(.fade(duration: NSAnimationContext.current.duration))
102-
}
103125
imageView.image = appliedConfiguration.image
104126
imageView.properties = appliedConfiguration.imageProperties
105127

@@ -174,6 +196,34 @@ open class NSListContentView: NSView, NSContentView, EditingContentView {
174196
animator(isAnimating).rotation = _rotation
175197
}
176198
animator(isAnimating).alphaValue = appliedConfiguration.alpha
199+
updateLayoutGuides()
200+
}
201+
202+
func updateLayoutGuides() {
203+
if !appliedConfiguration.hasText, let guide = textLayoutGuide {
204+
removeLayoutGuide(guide)
205+
textLayoutGuide = nil
206+
} else if appliedConfiguration.hasText, textLayoutGuide == nil {
207+
textLayoutGuide = NSLayoutGuide()
208+
addLayoutGuide(textLayoutGuide!)
209+
textLayoutGuide?.constraint(to: textField)
210+
}
211+
if !appliedConfiguration.hasSecondaryText, let guide = secondaryTextLayoutGuide {
212+
removeLayoutGuide(guide)
213+
secondaryTextLayoutGuide = nil
214+
} else if appliedConfiguration.hasSecondaryText, secondaryTextLayoutGuide == nil {
215+
secondaryTextLayoutGuide = NSLayoutGuide()
216+
addLayoutGuide(secondaryTextLayoutGuide!)
217+
secondaryTextLayoutGuide?.constraint(to: secondaryTextField)
218+
}
219+
if appliedConfiguration.image == nil, let guide = imageLayoutGuide {
220+
removeLayoutGuide(guide)
221+
imageLayoutGuide = nil
222+
} else if appliedConfiguration.image != nil, imageLayoutGuide == nil {
223+
imageLayoutGuide = NSLayoutGuide()
224+
addLayoutGuide(imageLayoutGuide!)
225+
imageLayoutGuide?.constraint(to: imageView)
226+
}
177227
}
178228

179229
func updateAccesoryViews() {

Sources/AdvancedCollectionTableView/DiffableDataSource/NSTableView/TableViewDiffableDataSource.swift

Lines changed: 12 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -442,35 +442,7 @@ open class TableViewDiffableDataSource<Section, Item>: NSObject, NSTableViewData
442442
tableView.registerForDraggedTypes([.itemID, .fileURL, .tiff, .png, .string, .URL])
443443
tableView.isQuicklookPreviewable = Item.self is QuicklookPreviewable.Type
444444
tableView.setDraggingSourceOperationMask(.copy, forLocal: false)
445-
446-
if tableView.responds(to: #selector(NSTableView.draggingSession(_:movedTo:))) {
447-
do {
448-
try tableView.replaceMethod(
449-
#selector(NSTableView.draggingSession(_:movedTo:)),
450-
methodSignature: (@convention(c) (AnyObject, Selector, NSDraggingSession, NSPoint) -> ()).self,
451-
hookSignature: (@convention(block) (AnyObject, NSDraggingSession, NSPoint) -> ()).self) { store in {
452-
object, session, point in
453-
Swift.print("draggingSession movedTo", point)
454-
store.original(object, #selector(NSView.mouseDown(with:)), session, point)
455-
}
456-
}
457-
} catch {
458-
debugPrint(error)
459-
}
460-
} else {
461-
do {
462-
try tableView.addMethod(
463-
#selector(NSTableView.draggingSession(_:movedTo:)),
464-
methodSignature: (@convention(c) (AnyObject, Selector, NSDraggingSession, NSPoint) -> ()).self,
465-
hookSignature: (@convention(block) (AnyObject, NSDraggingSession, NSPoint) -> ()).self) { store in {
466-
object, session, point in
467-
Swift.print("draggingSession movedTo", point)
468-
}
469-
}
470-
} catch {
471-
debugPrint(error)
472-
}
473-
}
445+
tableView.setDraggingSourceOperationMask(.copy, forLocal: true)
474446
}
475447

476448
/**
@@ -495,14 +467,18 @@ open class TableViewDiffableDataSource<Section, Item>: NSObject, NSTableViewData
495467
// MARK: Dropping
496468

497469
open func tableView(_ tableView: NSTableView, validateDrop draggingInfo: NSDraggingInfo, proposedRow row: Int, proposedDropOperation dropOperation: NSTableView.DropOperation) -> NSDragOperation {
498-
if draggingInfo.draggingSource as? NSTableView === tableView {
499-
500-
} else {
501-
502-
}
503-
504470
canDrop = false
505471
dropTargetRow = nil
472+
if draggingInfo.draggingSource as? NSTableView !== tableView, let canDrop = droppingHandlers.canDrop, !(row == 0 && sectionRowIndexes.contains(row) && dropOperation == .above), (!sectionRowIndexes.contains(row) || (!sectionRowIndexes.contains(row+1) && dropOperation == .above) ) {
473+
let content = draggingInfo.draggingPasteboard.content
474+
dropTargetRow = dropOperation == .on ? row : nil
475+
let target = dropOperation == .on ? item(forRow: row) : nil
476+
if !content.isEmpty, canDrop(content, target) {
477+
self.canDrop = true
478+
return .copy
479+
}
480+
}
481+
506482
if !dragingRowIndexes.isEmpty {
507483
if reorderingHandlers.droppable, let canDrop = reorderingHandlers.canDrop, dropOperation == .on {
508484
if dragingRowIndexes.count == 1, dragingRowIndexes.first == row {
@@ -555,15 +531,7 @@ open class TableViewDiffableDataSource<Section, Item>: NSObject, NSTableViewData
555531
return moveSectionTransaction(to: row) != nil ? .move : []
556532
}
557533

558-
if draggingInfo.draggingSource as? NSTableView !== tableView, let canDrop = droppingHandlers.canDrop, !(row == 0 && sectionRowIndexes.contains(row) && dropOperation == .above), (!sectionRowIndexes.contains(row) || (!sectionRowIndexes.contains(row+1) && dropOperation == .above) ) {
559-
let content = draggingInfo.draggingPasteboard.content
560-
dropTargetRow = dropOperation == .on ? row : nil
561-
let target = dropOperation == .on ? item(forRow: row) : nil
562-
if !content.isEmpty, canDrop(content, target) {
563-
self.canDrop = true
564-
return .copy
565-
}
566-
}
534+
567535
return []
568536
}
569537

0 commit comments

Comments
 (0)