-
-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
111 additions
and
167 deletions.
There are no files selected for viewing
196 changes: 93 additions & 103 deletions
196
Sources/PulseUI/Features/Console/ConsoleView-macos.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,93 @@ | ||
// The MIT License (MIT) | ||
// | ||
// Copyright (c) 2020-2024 Alexander Grebenyuk (github.com/kean). | ||
|
||
#if os(macOS) | ||
|
||
import SwiftUI | ||
import CoreData | ||
import Pulse | ||
import Combine | ||
|
||
public struct ConsoleView: View { | ||
@StateObject private var environment: ConsoleEnvironment | ||
|
||
init(environment: ConsoleEnvironment) { | ||
_environment = StateObject(wrappedValue: environment) | ||
} | ||
|
||
public var body: some View { | ||
if #available(macOS 13, *) { | ||
_ConsoleView(environment: environment) | ||
} else { | ||
PlaceholderView(imageName: "xmark.octagon", title: "Unsupported", subtitle: "Pulse requires macOS 13 or later").padding() | ||
} | ||
} | ||
} | ||
|
||
@available(macOS 13, *) | ||
private struct _ConsoleView: View { | ||
@StateObject private var environment: ConsoleEnvironment | ||
@State private var columnVisibility = NavigationSplitViewVisibility.all | ||
|
||
init(environment: ConsoleEnvironment) { | ||
_environment = StateObject(wrappedValue: environment) | ||
} | ||
|
||
public var body: some View { | ||
NavigationSplitView( | ||
columnVisibility: $columnVisibility, | ||
sidebar: { | ||
ConsoleMainView(environment: environment) | ||
.navigationSplitViewColumnWidth(min: 320, ideal: 420, max: 640) | ||
}, | ||
detail: { | ||
EmptyView() | ||
} | ||
) | ||
.injecting(environment) | ||
.navigationTitle("") | ||
} | ||
} | ||
|
||
/// This view contains the console itself along with the details (no sidebar). | ||
@available(macOS 13, *) | ||
@MainActor | ||
private struct ConsoleMainView: View { | ||
let environment: ConsoleEnvironment | ||
|
||
@State private var isSharingStore = false | ||
@State private var isShowingFilters = false | ||
|
||
@EnvironmentObject var router: ConsoleRouter | ||
|
||
var body: some View { | ||
ConsoleListView() | ||
.frame(minWidth: 300, idealWidth: 500, minHeight: 120, idealHeight: 480) | ||
.toolbar { | ||
ToolbarItemGroup(placement: .automatic) { | ||
Button(action: { isSharingStore = true }) { | ||
Image(systemName: "square.and.arrow.up") | ||
} | ||
.help("Share a session") | ||
.popover(isPresented: $isSharingStore, arrowEdge: .bottom) { | ||
ShareStoreView(onDismiss: {}) | ||
.frame(width: 240).fixedSize() | ||
} | ||
|
||
Button(action: { isShowingFilters = true }) { | ||
Label("Show Filters", systemImage: "line.3.horizontal.decrease.circle") | ||
} | ||
.help("Show Filters") | ||
.popover(isPresented: $isShowingFilters) { | ||
ConsoleFiltersView().frame(width: 300).fixedSize() | ||
} | ||
|
||
ConsoleContextMenu() | ||
.popover(isPresented: $router.isShowingSessions) { | ||
SessionsView().frame(width: 300, height: 420) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
#if DEBUG | ||
struct ConsoleView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ConsoleView(store: .mock) | ||
.previewLayout(.fixed(width: 700, height: 400)) | ||
} | ||
} | ||
#endif | ||
#endif | ||
//// The MIT License (MIT) | ||
//// | ||
//// Copyright (c) 2020-2024 Alexander Grebenyuk (github.com/kean). | ||
// | ||
//#if os(macOS) | ||
// | ||
//import SwiftUI | ||
//import CoreData | ||
//import Pulse | ||
//import Combine | ||
// | ||
//public struct ConsoleView: View { | ||
// @StateObject private var environment: ConsoleEnvironment | ||
// | ||
// init(environment: ConsoleEnvironment) { | ||
// _environment = StateObject(wrappedValue: environment) | ||
// } | ||
// | ||
// public var body: some View { | ||
// if #available(macOS 13, *) { | ||
// _ConsoleView(environment: environment) | ||
// } else { | ||
// PlaceholderView(imageName: "xmark.octagon", title: "Unsupported", subtitle: "Pulse requires macOS 13 or later").padding() | ||
// } | ||
// } | ||
//} | ||
// | ||
//@available(macOS 13, *) | ||
//private struct _ConsoleView: View { | ||
// @StateObject private var environment: ConsoleEnvironment | ||
// @State private var columnVisibility = NavigationSplitViewVisibility.all | ||
// | ||
// init(environment: ConsoleEnvironment) { | ||
// _environment = StateObject(wrappedValue: environment) | ||
// } | ||
// | ||
// public var body: some View { | ||
// NavigationStack { | ||
// ConsoleMainView(environment: environment) | ||
// .navigationSplitViewColumnWidth(min: 320, ideal: 420, max: 640) | ||
// } | ||
// .injecting(environment) | ||
// .navigationTitle("") | ||
// } | ||
//} | ||
// | ||
///// This view contains the console itself along with the details (no sidebar). | ||
//@available(macOS 13, *) | ||
//@MainActor | ||
//private struct ConsoleMainView: View { | ||
// let environment: ConsoleEnvironment | ||
// | ||
// @State private var isSharingStore = false | ||
// @State private var isShowingFilters = false | ||
// | ||
// @EnvironmentObject var router: ConsoleRouter | ||
// | ||
// var body: some View { | ||
// ConsoleListView() | ||
// .frame(minWidth: 300, idealWidth: 500, minHeight: 120, idealHeight: 480) | ||
// .toolbar { | ||
// ToolbarItemGroup(placement: .automatic) { | ||
// Button(action: { isSharingStore = true }) { | ||
// Image(systemName: "square.and.arrow.up") | ||
// } | ||
// .help("Share a session") | ||
// .popover(isPresented: $isSharingStore, arrowEdge: .bottom) { | ||
// ShareStoreView(onDismiss: {}) | ||
// .frame(width: 240).fixedSize() | ||
// } | ||
// | ||
// Button(action: { isShowingFilters = true }) { | ||
// Label("Show Filters", systemImage: "line.3.horizontal.decrease.circle") | ||
// } | ||
// .help("Show Filters") | ||
// .popover(isPresented: $isShowingFilters) { | ||
// ConsoleFiltersView().frame(width: 300).fixedSize() | ||
// } | ||
// | ||
// | ||
// } | ||
// } | ||
//} | ||
// | ||
//#if DEBUG | ||
//struct ConsoleView_Previews: PreviewProvider { | ||
// static var previews: some View { | ||
// ConsoleView(store: .mock) | ||
// .previewLayout(.fixed(width: 700, height: 400)) | ||
// } | ||
//} | ||
//#endif | ||
//#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters