Fix lint issues.

This commit is contained in:
Brent Simmons
2025-01-22 22:17:02 -08:00
parent 8f1379360c
commit 40ada2ba5a
91 changed files with 1278 additions and 1350 deletions

View File

@@ -16,9 +16,9 @@ enum ArticleExtractorButtonState {
}
class ArticleExtractorButton: NSButton {
private var animatedLayer: CALayer?
var buttonState: ArticleExtractorButtonState = .off {
didSet {
if buttonState != oldValue {
@@ -39,7 +39,7 @@ class ArticleExtractorButton: NSButton {
}
}
}
override func accessibilityLabel() -> String? {
switch buttonState {
case .error:
@@ -57,12 +57,12 @@ class ArticleExtractorButton: NSButton {
super.init(frame: frameRect)
commonInit()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
commonInit()
}
private func commonInit() {
wantsLayer = true
bezelStyle = .texturedRounded
@@ -70,7 +70,7 @@ class ArticleExtractorButton: NSButton {
imageScaling = .scaleProportionallyDown
widthAnchor.constraint(equalTo: heightAnchor).isActive = true
}
override func layout() {
super.layout()
guard case .animated = buttonState else {
@@ -79,31 +79,31 @@ class ArticleExtractorButton: NSButton {
stripAnimatedSublayer()
addAnimatedSublayer(to: layer!)
}
private func stripAnimatedSublayer() {
animatedLayer?.removeFromSuperlayer()
}
private func addAnimatedSublayer(to hostedLayer: CALayer) {
let image1 = AppAssets.articleExtractorOff.tinted(with: NSColor.controlTextColor)
let image2 = AppAssets.articleExtractorOn.tinted(with: NSColor.controlTextColor)
let images = [image1, image2, image1]
animatedLayer = CALayer()
let imageSize = AppAssets.articleExtractorOff.size
animatedLayer!.bounds = CGRect(x: 0, y: 0, width: imageSize.width, height: imageSize.height)
animatedLayer!.position = CGPoint(x: bounds.midX, y: bounds.midY)
hostedLayer.addSublayer(animatedLayer!)
let animation = CAKeyframeAnimation(keyPath: "contents")
animation.calculationMode = CAAnimationCalculationMode.linear
animation.keyTimes = [0, 0.5, 1]
animation.duration = 2
animation.values = images
animation.repeatCount = HUGE
animatedLayer!.add(animation, forKey: "contents")
}
}