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/Application.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/Application.swift')
| -rw-r--r-- | Hotline/Application.swift | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/Hotline/Application.swift b/Hotline/Application.swift index e08695a..4541ea3 100644 --- a/Hotline/Application.swift +++ b/Hotline/Application.swift @@ -1,5 +1,6 @@ import SwiftUI import SwiftData +import UniformTypeIdentifiers @main struct Application: App { @@ -30,8 +31,8 @@ struct Application: App { .defaultPosition(.center) // MARK: Server Window - WindowGroup(id: "server", for: Server.self) { $server in - ServerView(server: $server) + WindowGroup(id: "server", for: Server.self) { server in + ServerView(server: server) .frame(minWidth: 400, minHeight: 300) .environment(preferences) } defaultValue: { @@ -48,19 +49,31 @@ struct Application: App { } } -// WindowGroup(id: "preview", for: PreviewFileInfo.self) { info in -// FilePreviewView(info: info) -// .frame(minWidth: 400, minHeight: 300) -// } -// .defaultSize(width: 750, height: 700) -// .windowStyle(.hiddenTitleBar) -// .aspectRatio(nil, contentMode: .fit) - // MARK: Settings Window Settings { SettingsView() .environment(preferences) } + + // MARK: Image Preview Window + WindowGroup(id: "preview-image", for: PreviewFileInfo.self) { $info in + FilePreviewImageView(info: $info) + } + .windowResizability(.contentSize) + .windowStyle(.titleBar) + .windowToolbarStyle(.unifiedCompact(showsTitle: true)) + .defaultSize(width: 350, height: 150) + .defaultPosition(.center) + + // MARK: Text Preview Window + WindowGroup(id: "preview-text", for: PreviewFileInfo.self) { $info in + FilePreviewTextView(info: $info) + } + .windowResizability(.automatic) + .windowStyle(.titleBar) + .windowToolbarStyle(.unifiedCompact(showsTitle: true)) + .defaultSize(width: 450, height: 550) + .defaultPosition(.center) #endif } |