Skip to content

Commit dd141d2

Browse files
committed
updated
1 parent cc9a608 commit dd141d2

File tree

16 files changed

+195
-198
lines changed

16 files changed

+195
-198
lines changed

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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Example/MainViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// ViewController.swift
2+
// MainViewController.swift
33
//
44
//
55
// Created by Florian Zand on 19.01.23.

Example/Example/Model/OutlineItem.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ struct OutlineItem: Hashable, ExpressibleByStringLiteral, CustomStringConvertibl
1414
self.title = title
1515
}
1616

17-
var description: String {
18-
title
19-
}
20-
2117
init(stringLiteral value: String) {
2218
self.title = value
2319
}
20+
21+
var description: String {
22+
title
23+
}
2424
}

Example/Example/Model/SidebarItem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class SidebarItem: NSObject, Identifiable {
1717
self.title = title
1818
self.symbolName = symbolName
1919
}
20-
20+
2121
static let sampleItems1 = [SidebarItem("Messages", symbolName: "message.fill"),
2222
SidebarItem("Photos", symbolName: "photo"),
2323
SidebarItem("Videos", symbolName: "film")]

Example/Example/OutlineSidebarViewController.swift

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
import AppKit
99
import AdvancedCollectionTableView
10-
import FZUIKit
1110

1211
class OutlineSidebarViewController: NSViewController {
1312
typealias DataSource = OutlineViewDiffableDataSource<OutlineItem>
1413
typealias CellRegistration = NSTableView.CellRegistration<NSTableCellView, OutlineItem>
1514

15+
1616
@IBOutlet var outlineView: NSOutlineView!
1717

1818
lazy var dataSource = DataSource(outlineView: outlineView, cellRegistration: cellRegistration)
@@ -22,34 +22,28 @@ class OutlineSidebarViewController: NSViewController {
2222
}
2323

2424
lazy var cellRegistration = CellRegistration { tableCell, _, _, outlineItem in
25-
var configuration = NSListContentConfiguration.sidebar()
25+
var configuration = tableCell.defaultContentConfiguration()
2626
configuration.text = outlineItem.title
2727
tableCell.contentConfiguration = configuration
2828
}
2929

3030
override func viewDidLoad() {
3131
super.viewDidLoad()
32-
32+
3333
outlineView.dataSource = dataSource
34+
dataSource.applyGroupItemCellRegistration(cellRegistration)
3435

3536
/// Enables reordering selected rows by dragging them.
3637
dataSource.reorderingHandlers.canReorder = { _,_ in return true }
3738

3839
/// Enables deleting selected items via backspace key.
3940
dataSource.deletingHandlers.canDelete = { items in return items }
40-
41-
dataSource.droppingHandlers.canDrop = { _,parent in parent == nil }
42-
dataSource.droppingHandlers.items = { content,_ in
43-
return content.strings.compactMap({ OutlineItem("\($0)") })
44-
45-
}
46-
41+
4742
applySnapshot()
4843
}
4944

5045
func applySnapshot() {
5146
var snapshot = dataSource.emptySnapshot()
52-
5347
let rootItems: [OutlineItem] = ["Root 1", "Root 2", "Root 3", "Root 4", "Root 5"]
5448
snapshot.append(rootItems)
5549
rootItems.forEach { rootItem in
@@ -61,7 +55,7 @@ class OutlineSidebarViewController: NSViewController {
6155
}
6256
}
6357
dataSource.apply(snapshot, .withoutAnimation)
64-
dataSource.expand(rootItems[0])
58+
dataSource.expand(rootItems)
6559
}
6660

6761
@IBAction func segmentedPressed(_ segmentedControl: NSSegmentedControl) {
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
//
22
// SplitViewController.swift
3-
// Example
3+
//
44
//
55
// Created by Florian Zand on 20.01.25.
66
//
77

88
import Cocoa
9-
import FZUIKit
109

1110
class SplitViewController: NSSplitViewController {
12-
1311
func swapSidebar() {
1412
splitViewItems[0].isCollapsed = true
1513
splitViewItems.swapAt(0, 2)
1614
splitViewItems[0].isCollapsed = false
1715
}
18-
1916
}

Example/Example/TableSidebarViewController.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ class TableSidebarViewController: NSViewController {
2121
/// `defaultContentConfiguration` returns a table cell content configuration with default styling based on the table view it's displayed at (in this case a sidebar table).
2222
var configuration = tableCell.defaultContentConfiguration()
2323
configuration.text = sidebarItem.title
24-
// configuration.secondaryText = "sdsd\n"
25-
configuration.secondaryTextProperties.maximumNumberOfLines = 0
26-
// configuration.image = NSImage(systemSymbolName: sidebarItem.symbolName)
24+
configuration.image = NSImage(systemSymbolName: sidebarItem.symbolName)
2725
if sidebarItem.isFavorite {
2826
configuration.badge = .symbolImage("star.fill", color: .systemYellow, backgroundColor: nil)
2927
}
@@ -87,13 +85,3 @@ class TableSidebarViewController: NSViewController {
8785
segmentedControl.selectedSegment = 0
8886
}
8987
}
90-
91-
struct Handlers {
92-
var options: ((_ draggingInfo: any NSDraggingInfo)->(NSSpringLoadingOptions))?
93-
}
94-
95-
protocol AAAAa {
96-
97-
func options(_ draggingInfo: any NSDraggingInfo) -> NSSpringLoadingOptions
98-
99-
}

Sources/AdvancedCollectionTableView/Configuration/Extensions/NSTableView+/NSTableCellVew+.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,12 @@ extension NSTableCellView {
8888
if let contentView = contentView as? NSListContentView {
8989
textField = contentView.textField
9090
imageView = contentView.imageView
91+
} else {
92+
textField = nil
93+
imageView = nil
9194
}
9295
*/
96+
9397
}
9498
setNeedsDisplay()
9599
contentView?.setNeedsDisplay()
@@ -232,7 +236,15 @@ extension NSTableCellView {
232236
}
233237

234238
var isGroupRowCell: Bool {
235-
rowView?.isGroupRowStyle == true
239+
guard let rowView = rowView else { return false }
240+
let isGroup = rowView.identifier != "_GroupCellRowView" ? rowView.isGroupRowStyle : (rowView.superview as? NSTableRowView)?.isGroupRowStyle == true
241+
if isGroup, rowView.superview is NSTableRowView {
242+
if let contentView = contentView as? NSListContentView {
243+
Swift.print("CHECK", contentView.textField.stringValue, textField != nil)
244+
245+
}
246+
}
247+
return rowView.identifier != "_GroupCellRowView" ? rowView.isGroupRowStyle : (rowView.superview as? NSTableRowView)?.isGroupRowStyle == true
236248
}
237249

238250
var isReordering: Bool {

Sources/AdvancedCollectionTableView/Configuration/Extensions/NSTableView+/NSTableRowView+.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ extension NSTableRowView {
241241
set { setAssociatedValue(newValue, key: "isSelectedObservation") }
242242
}
243243

244-
func observeRowView() {
244+
public func observeRowView() {
245245
observeSelection()
246246
if contentConfiguration != nil || configurationUpdateHandler != nil {
247247
guard tableViewObservation == nil else { return }

Sources/AdvancedCollectionTableView/DiffableDataSource/NSCollectionView/CollectionViewDiffableDataSource.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ open class CollectionViewDiffableDataSource<Section: Identifiable & Hashable, El
102102
}
103103
return menu
104104
}
105-
} else {
105+
} else if oldValue != nil {
106106
collectionView.menuProvider = nil
107107
}
108108
}
@@ -123,7 +123,7 @@ open class CollectionViewDiffableDataSource<Section: Identifiable & Hashable, El
123123
guard let self = self, let handler = self.rightClickHandler else { return }
124124
handler(self.collectionView.rightClickIndexPaths(for: event).compactMap({ self.element(for:$0) }))
125125
}
126-
} else {
126+
} else if oldValue != nil {
127127
collectionView.mouseHandlers.rightDown = nil
128128
}
129129
}

0 commit comments

Comments
 (0)