ux: brighten display label and wrap properly

main
Peter Steinberger 2025-12-08 19:15:58 +01:00
parent 768d550ee2
commit 7cb31581d5
1 changed files with 13 additions and 21 deletions

View File

@ -448,36 +448,28 @@ private struct VibrantLabelView: NSViewRepresentable {
label.drawsBackground = false label.drawsBackground = false
label.lineBreakMode = .byWordWrapping label.lineBreakMode = .byWordWrapping
label.maximumNumberOfLines = 0 label.maximumNumberOfLines = 0
label.usesSingleLineMode = false
label.cell?.wraps = true
label.cell?.isScrollable = false
label.setContentHuggingPriority(.defaultLow, for: .horizontal) label.setContentHuggingPriority(.defaultLow, for: .horizontal)
label.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) label.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
label.allowsDefaultTighteningForTruncation = false label.textColor = .labelColor
let effect = NSVisualEffectView()
effect.material = .hudWindow
effect.blendingMode = .withinWindow
effect.state = .active
effect.translatesAutoresizingMaskIntoConstraints = false
effect.addSubview(label)
label.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
label.leadingAnchor.constraint(equalTo: effect.leadingAnchor),
label.trailingAnchor.constraint(equalTo: effect.trailingAnchor),
label.topAnchor.constraint(equalTo: effect.topAnchor),
label.bottomAnchor.constraint(equalTo: effect.bottomAnchor),
])
let container = ClickCatcher(onTap: onTap) let container = ClickCatcher(onTap: onTap)
container.addSubview(effect) container.addSubview(label)
effect.frame = container.bounds label.translatesAutoresizingMaskIntoConstraints = false
effect.autoresizingMask = [.width, .height] NSLayoutConstraint.activate([
label.leadingAnchor.constraint(equalTo: container.leadingAnchor),
label.trailingAnchor.constraint(equalTo: container.trailingAnchor),
label.topAnchor.constraint(equalTo: container.topAnchor),
label.bottomAnchor.constraint(equalTo: container.bottomAnchor),
])
return container return container
} }
func updateNSView(_ nsView: NSView, context: Context) { func updateNSView(_ nsView: NSView, context: Context) {
guard let container = nsView as? ClickCatcher, guard let container = nsView as? ClickCatcher,
let effect = container.subviews.first as? NSVisualEffectView, let label = container.subviews.first as? NSTextField else { return }
let label = effect.subviews.first as? NSTextField else { return }
label.attributedStringValue = self.attributed label.attributedStringValue = self.attributed
} }