From 2f8f71d0410f59d5d303a4c221a628630168bfe2 Mon Sep 17 00:00:00 2001 From: Dustin Mierau Date: Fri, 5 Jan 2024 19:46:13 -0800 Subject: Add image preview to Files so you don't have to download images to view them, works with animated GIFs too. Added cmd-R shortcut for Servers window. More work on login view. --- Hotline/Models/FileInfo.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Hotline/Models/FileInfo.swift') diff --git a/Hotline/Models/FileInfo.swift b/Hotline/Models/FileInfo.swift index 9caa976..0cd9b2b 100644 --- a/Hotline/Models/FileInfo.swift +++ b/Hotline/Models/FileInfo.swift @@ -1,4 +1,5 @@ import SwiftUI +import UniformTypeIdentifiers @Observable class FileInfo: Identifiable, Hashable { let id: UUID @@ -15,6 +16,16 @@ import SwiftUI var expanded: Bool = false var children: [FileInfo]? = nil + var isImage: Bool { + let fileExtension = (self.name as NSString).pathExtension + if let fileType = UTType(filenameExtension: fileExtension) { + if fileType.isSubtype(of: .image) { + return true + } + } + return false + } + init(hotlineFile: HotlineFile) { self.id = UUID() self.path = hotlineFile.path -- cgit