Skip to content

Commit

Permalink
bring up config on click
Browse files Browse the repository at this point in the history
  • Loading branch information
vgmoose committed Oct 24, 2021
1 parent f2a799e commit 6c13dd6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 8 additions & 0 deletions TheNotch/NotchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ struct NotchView: View {
RoundedRectangle(cornerRadius: CGFloat(NotchWindow.notchHeight) / 4.0)
.fill(Color.black)
.frame(width: CGFloat(NotchWindow.notchWidth), height: CGFloat(NotchWindow.notchHeight))
.onTapGesture {
if !NotchWindow.showInDock {
// when the dock icon is hidden, when the view is touched, make config visible
if TheNotchApp.singleton?.window?.isOnActiveSpace ?? false {
TheNotchApp.singleton?.window?.makeKeyAndOrderFront(self)
}
}
}
}
}

Expand Down
13 changes: 11 additions & 2 deletions TheNotch/TheNotchApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,32 @@ import Cocoa
@NSApplicationMain
class TheNotchApp: NSApplication, NSApplicationDelegate {

var window: NSWindow?
static var singleton: TheNotchApp?

override init() {
super.init()
delegate = self
// mainMenu = mainAppMenu
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
window?.makeKeyAndOrderFront(sender)
return true
}

func applicationDidFinishLaunching(_ notification: Notification) {
Swift.print("wasup")
let window = NSWindow(
contentRect: NSRect(x: 0, y: 0, width: 450, height: 200),
styleMask: [.titled, .closable, .miniaturizable, .resizable],
backing: .buffered, defer: false
)
window.center()
window.title = "The Notch"
window.isReleasedWhenClosed = false

let view = ConfigView().padding(20).frame(width: 450, height: 200)
window.contentView = NSHostingView(rootView: view)
Expand All @@ -31,5 +38,7 @@ class TheNotchApp: NSApplication, NSApplicationDelegate {
NotchWindow().makeKeyAndOrderFront(self)
window.makeKeyAndOrderFront(true)

self.window = window
TheNotchApp.singleton = self
}
}

0 comments on commit 6c13dd6

Please sign in to comment.