Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.1k
Correctly preview non-text files#1707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
6f30d9271133899a8500567499153d3893ebd3fe37a12e51c2b59534679755215291c02fd13b47ae71a0ff47ae8d820eb9b5f16147ef31166d7f7d82192c7074cd22b8ef8461a643b43f583df0410f62db80dc31a9ed5adff57cc818134166106b64dc7bcad2e4dd02c2fcacc2d448f6f2ca164c248a9d82ef086eb15141d32436a4238f2c5c5c81b752fe3b40d52c6b24b6ffd2664bd2fbc351afc0a82ccc79b36561d2512aa788f039914b660ac7d0c26711b8c8b32ac22a7c3d31a612e0ba18f04013acb8a639688746425f806151e345fe1f7bbcb88ec2096bb68cf17bc7950d7edb373bb6File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading.Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // | ||
| // AnyFileView.swift | ||
| // CodeEdit | ||
| // | ||
| // Created by Paul Ebose on 2024/5/9. | ||
| // | ||
| import SwiftUI | ||
| import QuickLookUI | ||
| /// A view for previewing any kind of file. | ||
| /// | ||
| /// ```swift | ||
| /// AnyFileView(fileURL) | ||
| /// ``` | ||
| /// If the file cannot be previewed, a file icon thumbnail is shown instead. | ||
| struct AnyFileView: NSViewRepresentable { | ||
| /// URL of the file to preview. You can pass in any file type. | ||
| private let fileURL: URL | ||
| init(_ fileURL: URL) { | ||
| self.fileURL = fileURL | ||
| } | ||
| func makeNSView(context: Context) -> QLPreviewView { | ||
| let qlPreviewView = QLPreviewView() | ||
| qlPreviewView.previewItem = fileURL as any QLPreviewItem | ||
| return qlPreviewView | ||
| } | ||
| func updateNSView(_ qlPreviewView: QLPreviewView, context: Context) { | ||
| qlPreviewView.previewItem = fileURL as any QLPreviewItem | ||
| } | ||
| } |
Uh oh!
There was an error while loading.Please reload this page.