cleanup code

This commit is contained in:
2026-07-12 11:39:58 +02:00
parent 3da4c8e466
commit 6e258fdffa
3 changed files with 18 additions and 13 deletions
+14 -3
View File
@@ -6,11 +6,22 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
var window: BarWindow!
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()
self.barController = BarController(config: config, screen: screen, theme: theme, blocks: blocks)
barController.debug = debug
self.barController = BarController(
config: config,
screen: screen,
theme: theme,
blocks: blocks,
debug: debug
)
}
func applicationDidFinishLaunching(_ notification: Notification) {
+2 -8
View File
@@ -5,13 +5,6 @@ final class BarController: ObservableObject {
let config: PHConfig
let screen: NSScreen
let theme: PHTheme
var debug: Bool = false {
didSet {
for block in blocks {
block.debug = debug
}
}
}
@Published var blocks: [PHBlock]
var arrangedBlocks: [PHBlock] {
@@ -22,7 +15,7 @@ final class BarController: ObservableObject {
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.screen = screen
self.theme = theme
@@ -31,6 +24,7 @@ final class BarController: ObservableObject {
for block in blocks {
block.text = text(for: block)
block.style = style(for: block)
block.debug = debug
}
}
}
+2 -2
View File
@@ -23,13 +23,13 @@ struct TextBlockView: View {
.italic(block.text.italic)
.foregroundStyle(block.style.foreground?.uiColor ?? .clear)
.transformEffect(adjustOffset)
.border(bar.debug ? .blue : .clear)
.border(block.debug ? .blue : .clear)
}
.padding(.trailing, block.style.padding?.trailing ?? 0)
.padding(.leading, block.style.padding?.leading ?? 0)
}
.fixedSize(horizontal: true, vertical: false)
.border(bar.debug ? .red : .clear)
.border(block.debug ? .red : .clear)
.onHover { hovering = $0 }
.onAppear {
NSEvent.addLocalMonitorForEvents(matching: [