ux: wrap label to overlay width, remove label background
This commit is contained in:
@@ -452,38 +452,25 @@ private struct VibrantLabelView: NSViewRepresentable {
|
|||||||
label.cell?.wraps = true
|
label.cell?.wraps = true
|
||||||
label.cell?.isScrollable = false
|
label.cell?.isScrollable = false
|
||||||
label.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
label.setContentHuggingPriority(.defaultLow, for: .horizontal)
|
||||||
label.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
|
label.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
|
||||||
label.textColor = .labelColor
|
label.textColor = .labelColor
|
||||||
|
|
||||||
let effect = NSVisualEffectView()
|
|
||||||
effect.material = .hudWindow
|
|
||||||
effect.blendingMode = .withinWindow
|
|
||||||
effect.state = .active
|
|
||||||
effect.translatesAutoresizingMaskIntoConstraints = false
|
|
||||||
effect.addSubview(label)
|
|
||||||
|
|
||||||
let container = ClickCatcher(onTap: onTap)
|
let container = ClickCatcher(onTap: onTap)
|
||||||
container.addSubview(effect)
|
container.addSubview(label)
|
||||||
|
|
||||||
label.translatesAutoresizingMaskIntoConstraints = false
|
label.translatesAutoresizingMaskIntoConstraints = false
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
effect.leadingAnchor.constraint(equalTo: container.leadingAnchor),
|
label.leadingAnchor.constraint(equalTo: container.leadingAnchor),
|
||||||
effect.trailingAnchor.constraint(equalTo: container.trailingAnchor),
|
label.trailingAnchor.constraint(equalTo: container.trailingAnchor),
|
||||||
effect.topAnchor.constraint(equalTo: container.topAnchor),
|
label.topAnchor.constraint(equalTo: container.topAnchor),
|
||||||
effect.bottomAnchor.constraint(equalTo: container.bottomAnchor),
|
label.bottomAnchor.constraint(equalTo: container.bottomAnchor),
|
||||||
|
|
||||||
label.leadingAnchor.constraint(equalTo: effect.leadingAnchor),
|
|
||||||
label.trailingAnchor.constraint(equalTo: effect.trailingAnchor),
|
|
||||||
label.topAnchor.constraint(equalTo: effect.topAnchor),
|
|
||||||
label.bottomAnchor.constraint(equalTo: effect.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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user