Skip to content

Instantly share code, notes, and snippets.

View jaanus's full-sized avatar

Jaanus Kase jaanus

View GitHub Profile
@jaanus
jaanus / MacCollectionView.swift
Last active March 17, 2025 22:45
NSCollectionView that responds correctly to window resizing
import SwiftUI
import OSLog
/// A collection view that displays a simple scrolling list of SwiftUI items.
///
/// The collection view content should be a simple column, displaying SwiftUI items. The collection view items (particularly heights,
/// because widths are already always full width) should automatically always scale to the SwiftUI item content.
///
/// A lot of this is reusable on iOS. But on macOS, we can resize the window to make the collection view respond to size changes,
/// so initial experimentation is only on macOS.