cleanup code
This commit is contained in:
@@ -6,11 +6,22 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
var window: BarWindow!
|
var window: BarWindow!
|
||||||
private var observers: [IPCObserver] = []
|
private var observers: [IPCObserver] = []
|
||||||
|
|
||||||
init(config: PHConfig, screen: NSScreen, theme: PHTheme, blocks: [PHBlock], debug: Bool = false) {
|
init(
|
||||||
|
config: PHConfig,
|
||||||
|
screen: NSScreen,
|
||||||
|
theme: PHTheme,
|
||||||
|
blocks: [PHBlock],
|
||||||
|
debug: Bool
|
||||||
|
) {
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
self.barController = BarController(config: config, screen: screen, theme: theme, blocks: blocks)
|
self.barController = BarController(
|
||||||
barController.debug = debug
|
config: config,
|
||||||
|
screen: screen,
|
||||||
|
theme: theme,
|
||||||
|
blocks: blocks,
|
||||||
|
debug: debug
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func applicationDidFinishLaunching(_ notification: Notification) {
|
func applicationDidFinishLaunching(_ notification: Notification) {
|
||||||
|
|||||||
@@ -5,13 +5,6 @@ final class BarController: ObservableObject {
|
|||||||
let config: PHConfig
|
let config: PHConfig
|
||||||
let screen: NSScreen
|
let screen: NSScreen
|
||||||
let theme: PHTheme
|
let theme: PHTheme
|
||||||
var debug: Bool = false {
|
|
||||||
didSet {
|
|
||||||
for block in blocks {
|
|
||||||
block.debug = debug
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Published var blocks: [PHBlock]
|
@Published var blocks: [PHBlock]
|
||||||
|
|
||||||
var arrangedBlocks: [PHBlock] {
|
var arrangedBlocks: [PHBlock] {
|
||||||
@@ -22,7 +15,7 @@ final class BarController: ObservableObject {
|
|||||||
blocks.filter { $0.centered == true }
|
blocks.filter { $0.centered == true }
|
||||||
}
|
}
|
||||||
|
|
||||||
init(config: PHConfig, screen: NSScreen, theme: PHTheme, blocks: [PHBlock]) {
|
init(config: PHConfig, screen: NSScreen, theme: PHTheme, blocks: [PHBlock], debug: Bool) {
|
||||||
self.config = config
|
self.config = config
|
||||||
self.screen = screen
|
self.screen = screen
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
@@ -31,6 +24,7 @@ final class BarController: ObservableObject {
|
|||||||
for block in blocks {
|
for block in blocks {
|
||||||
block.text = text(for: block)
|
block.text = text(for: block)
|
||||||
block.style = style(for: block)
|
block.style = style(for: block)
|
||||||
|
block.debug = debug
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ struct TextBlockView: View {
|
|||||||
.italic(block.text.italic)
|
.italic(block.text.italic)
|
||||||
.foregroundStyle(block.style.foreground?.uiColor ?? .clear)
|
.foregroundStyle(block.style.foreground?.uiColor ?? .clear)
|
||||||
.transformEffect(adjustOffset)
|
.transformEffect(adjustOffset)
|
||||||
.border(bar.debug ? .blue : .clear)
|
.border(block.debug ? .blue : .clear)
|
||||||
}
|
}
|
||||||
.padding(.trailing, block.style.padding?.trailing ?? 0)
|
.padding(.trailing, block.style.padding?.trailing ?? 0)
|
||||||
.padding(.leading, block.style.padding?.leading ?? 0)
|
.padding(.leading, block.style.padding?.leading ?? 0)
|
||||||
}
|
}
|
||||||
.fixedSize(horizontal: true, vertical: false)
|
.fixedSize(horizontal: true, vertical: false)
|
||||||
.border(bar.debug ? .red : .clear)
|
.border(block.debug ? .red : .clear)
|
||||||
.onHover { hovering = $0 }
|
.onHover { hovering = $0 }
|
||||||
.onAppear {
|
.onAppear {
|
||||||
NSEvent.addLocalMonitorForEvents(matching: [
|
NSEvent.addLocalMonitorForEvents(matching: [
|
||||||
|
|||||||
Reference in New Issue
Block a user