https://github.com/flocked/fzquicklook
Framework For Quicklook Previews
https://github.com/flocked/fzquicklook
appkit cocoa macos quicklook uikit
Last synced: 20 days ago
JSON representation
Framework For Quicklook Previews
- Host: GitHub
- URL: https://github.com/flocked/fzquicklook
- Owner: flocked
- License: mit
- Created: 2023-05-25T11:01:34.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-05-11T00:44:44.000Z (22 days ago)
- Last Synced: 2025-05-13T03:58:40.963Z (20 days ago)
- Topics: appkit, cocoa, macos, quicklook, uikit
- Language: Swift
- Homepage:
- Size: 821 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FZQuicklook
Create previews of files presented either in a panel similar to Finder's Quicklook or in a view.
**For a full documentation take a look at the** [Online Documentation](https://swiftpackageindex.com/flocked/FZQuicklook/documentation/).
## QuicklookPreviewable
A protocol that defines a set of properties you implement to make a preview that can be displayed by `QuicklookPanel` and `QuicklookView`. `URL`, `NSURL` and `AVURLAsset` conform to `QuicklookPreviewable`.
```swift
struct GalleryItem: QuicklookPreviewable {
let title: String
let imageURL: URL
var previewItemURL: URL? {
return imageURL
}
var previewItemTitle: String? {
return title
}
}
QuicklookPanel.shared.preset(aGalleryItem)
```## QuicklookPanel
Presents previews of files in a panel simliar to Finder`s Quicklook.```swift
// URL is compatible `QuicklookPreviewable`
QuicklookPanel.shared.present(fileURLs)
```## QuicklookView
A preview of a file that you can embed into your view hierarchy.
```swift
let quicklookView = QuicklookView(content: fileURL)
```## Quicklook for NSTableView & NSCollectionView
NSCollectionView/NSTableView `isQuicklookPreviewable` enables quicklook of items/cells.There are several ways to provide quicklook previews:
- NSCollectionViewItems's & NSTableCellView's `var quicklookPreview: QuicklookPreviewable?````swift
collectionViewItem.quicklookPreview = URL(fileURLWithPath: "someFile.png")
```
- NSCollectionView's datasource `collectionView(_ collectionView: NSCollectionView, quicklookPreviewForItemAt indexPath: IndexPath)` & NSTableView's datasource `tableView(_ tableView: NSTableView, quicklookPreviewForRow row: Int)````swift
func collectionView(_ collectionView: NSCollectionView, quicklookPreviewForItemAt indexPath: IndexPath) -> QuicklookPreviewable? {
let galleryItem = galleryItems[indexPath.item]
return galleryItem.fileURL
}
```
- A NSCollectionViewDiffableDataSource & NSTableViewDiffableDataSource with an ItemIdentifierType conforming to `QuicklookPreviewable````swift
struct GalleryItem: QuicklookPreviewable {
let title: String
let imageURL: URL
// The file url for quicklook preview.
let previewItemURL: URL? {
return imageURL
}
let previewItemTitle: String? {
return title
}
}
collectionView.dataSource = NSCollectionViewDiffableDataSource(collectionView: collectionView) {
collectionView, indexPath, galleryItem in
// configurate data source
}// …
collectionView.quicklookSelectedItems()
```