Create AppAsset shared class, which will replace the separate Mac and iOS AppAssets classes.

This commit is contained in:
Brent Simmons
2024-07-08 10:07:26 -07:00
parent 89a967106d
commit ba44b94220
21 changed files with 152 additions and 143 deletions

View File

@@ -25,16 +25,16 @@ final class ArticleExtractorButton: NSButton {
switch buttonState {
case .error:
stripAnimatedSublayer()
image = AppAssets.articleExtractorError
image = AppAsset.ArticleExtractor.error
case .animated:
image = nil
needsLayout = true
case .on:
stripAnimatedSublayer()
image = AppAssets.articleExtractorOn
image = AppAsset.ArticleExtractor.on
case .off:
stripAnimatedSublayer()
image = AppAssets.articleExtractorOff
image = AppAsset.ArticleExtractor.off
}
}
}
@@ -66,7 +66,7 @@ final class ArticleExtractorButton: NSButton {
private func commonInit() {
wantsLayer = true
bezelStyle = .texturedRounded
image = AppAssets.articleExtractorOff
image = AppAsset.ArticleExtractor.off
imageScaling = .scaleProportionallyDown
widthAnchor.constraint(equalTo: heightAnchor).isActive = true
}
@@ -85,12 +85,12 @@ final class ArticleExtractorButton: NSButton {
}
private func addAnimatedSublayer(to hostedLayer: CALayer) {
let image1 = AppAssets.articleExtractorOff.tinted(with: NSColor.controlTextColor)
let image2 = AppAssets.articleExtractorOn.tinted(with: NSColor.controlTextColor)
let image1 = AppAsset.ArticleExtractor.off.tinted(with: NSColor.controlTextColor)
let image2 = AppAsset.ArticleExtractor.on.tinted(with: NSColor.controlTextColor)
let images = [image1, image2, image1]
animatedLayer = CALayer()
let imageSize = AppAssets.articleExtractorOff.size
let imageSize = AppAsset.ArticleExtractor.off.size
animatedLayer!.bounds = CGRect(x: 0, y: 0, width: imageSize.width, height: imageSize.height)
animatedLayer!.position = CGPoint(x: bounds.midX, y: bounds.midY)