diff options
| author | Dustin Mierau <dustin@mierau.me> | 2024-01-08 14:45:58 -0800 |
|---|---|---|
| committer | Dustin Mierau <dustin@mierau.me> | 2024-01-08 14:45:58 -0800 |
| commit | e9bae0328801d5a056f33beb0f764c6d35e518a2 (patch) | |
| tree | fcf853330f8de68948b089a5b15e2ef4c6dbb47c /Hotline/Models/FileInfo.swift | |
| parent | 4349f50167f50b30d7cd71854882ab33ac6ea5ea (diff) | |
Move to a standard SwiftUI window for preview windows so I can add toolbar items from SwiftUI. Not ideal. Added support for previewing text files too.
Diffstat (limited to 'Hotline/Models/FileInfo.swift')
| -rw-r--r-- | Hotline/Models/FileInfo.swift | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Hotline/Models/FileInfo.swift b/Hotline/Models/FileInfo.swift index 0cd9b2b..b8d3d12 100644 --- a/Hotline/Models/FileInfo.swift +++ b/Hotline/Models/FileInfo.swift @@ -16,6 +16,19 @@ import UniformTypeIdentifiers var expanded: Bool = false var children: [FileInfo]? = nil + var isPreviewable: Bool { + let fileExtension = (self.name as NSString).pathExtension + if let fileType = UTType(filenameExtension: fileExtension) { + if fileType.isSubtype(of: .image) { + return true + } + else if fileType.isSubtype(of: .text) { + return true + } + } + return false + } + var isImage: Bool { let fileExtension = (self.name as NSString).pathExtension if let fileType = UTType(filenameExtension: fileExtension) { |