Skip to content

Commit

Permalink
Switched to Settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
grigorye committed Jun 25, 2023
1 parent 2dad973 commit 91f7c85
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
7 changes: 4 additions & 3 deletions Targets/TMBuddy/Sources/Content/Standalone/ContentView.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import SwiftUI
import Foundation
import SFSafeSymbols

struct ContentView: View {

Expand All @@ -16,22 +17,22 @@ struct ContentView: View {
TabView(selection: $selection) {
SandboxAccessView.new()
.tabItem {
Text("Setup")
Label("Setup", systemSymbol: .gear)
}
.padding()
.tag(Tab.setup)

FoldersTab.new()
.tabItem {
Text("Folders")
Label("Folders", systemSymbol: .folder)
}
.padding()
.tag(Tab.folders)

LegendView.new()
.frame(minHeight: 240)
.tabItem {
Text("Legend")
Label("Legend", systemSymbol: .paintpalette)
}
.tag(Tab.legend)
}
Expand Down
8 changes: 5 additions & 3 deletions Targets/TMBuddy/Sources/Main/TMBuddyApp.swift
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import SwiftUI

@available(macOS 11.0, *)
@main
struct TMBuddyApp: App {
@NSApplicationDelegateAdaptor private var appDelegate: AppDelegate

var body: some Scene {
WindowGroup {
Settings {
mainWindowContentView().fixedSize()
}
}
}

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

func applicationDidFinishLaunching(_ aNotification: Notification) {
dump(Bundle.main.bundlePath, name: "bundlePath")
onLaunch()
applicationLoadActivity = beginActivity((), name: "applicationLoad")
mainWindow().makeKeyAndOrderFront(nil)
openSettings()
}

func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
Expand Down
18 changes: 18 additions & 0 deletions Targets/TMBuddy/Sources/Utilities/OpeningSettings.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import AppKit
import Foundation

@MainActor
func openSettings() {
if #available(macOS 13, *) {
app.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil)
} else {
app.sendAction(Selector(("showPreferencesWindow:")), to: nil, from: nil)
}
app.activate(ignoringOtherApps: true)
app.sendAction(#selector(NSWindow.orderFrontRegardless), to: nil, from: nil)
}

#if !IMP
@MainActor
let app = NSApp!
#endif

0 comments on commit 91f7c85

Please sign in to comment.