mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-24 00:30:51 +01:00
Change image references to use AppAsserts per our standard
This commit is contained in:
parent
6f962ecb42
commit
6a7d1df423
@ -38,6 +38,30 @@ struct AppAssets {
|
||||
return RSImage(named: "accountFreshRSS")
|
||||
}()
|
||||
|
||||
static var articleExtractor: RSImage! = {
|
||||
return RSImage(named: "articleExtractor")
|
||||
}()
|
||||
|
||||
static var articleExtractorError: RSImage! = {
|
||||
return RSImage(named: "articleExtractorError")
|
||||
}()
|
||||
|
||||
static var articleExtractorProgress1: RSImage! = {
|
||||
return RSImage(named: "articleExtractorProgress1")
|
||||
}()
|
||||
|
||||
static var articleExtractorProgress2: RSImage! = {
|
||||
return RSImage(named: "articleExtractorProgress2")
|
||||
}()
|
||||
|
||||
static var articleExtractorProgress3: RSImage! = {
|
||||
return RSImage(named: "articleExtractorProgress3")
|
||||
}()
|
||||
|
||||
static var articleExtractorProgress4: RSImage! = {
|
||||
return RSImage(named: "articleExtractorProgress4")
|
||||
}()
|
||||
|
||||
static var faviconTemplateImage: RSImage = {
|
||||
return RSImage(named: "faviconTemplateImage")!
|
||||
}()
|
||||
|
@ -33,7 +33,6 @@ class ArticleExtractorButton: NSButton {
|
||||
}
|
||||
|
||||
override func draw(_ dirtyRect: NSRect) {
|
||||
|
||||
super.draw(dirtyRect)
|
||||
|
||||
guard let hostedLayer = self.layer else {
|
||||
@ -52,13 +51,12 @@ class ArticleExtractorButton: NSButton {
|
||||
|
||||
switch true {
|
||||
case isError:
|
||||
addImageSublayer(to: hostedLayer, imageName: "articleExtractorError", opacity: opacity)
|
||||
addImageSublayer(to: hostedLayer, image: AppAssets.articleExtractorError, opacity: opacity)
|
||||
case isInProgress:
|
||||
addProgressSublayer(to: hostedLayer)
|
||||
default:
|
||||
addImageSublayer(to: hostedLayer, imageName: "articleExtractor", opacity: opacity)
|
||||
addImageSublayer(to: hostedLayer, image: AppAssets.articleExtractor, opacity: opacity)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private func makeLayerForImage(_ image: NSImage) -> CALayer {
|
||||
@ -68,25 +66,18 @@ class ArticleExtractorButton: NSButton {
|
||||
return imageLayer
|
||||
}
|
||||
|
||||
private func addImageSublayer(to hostedLayer: CALayer, imageName: String, opacity: Float = 1.0) {
|
||||
|
||||
guard let image = NSImage(named: imageName) else {
|
||||
fatalError("Image doesn't exist: \(imageName)")
|
||||
}
|
||||
|
||||
private func addImageSublayer(to hostedLayer: CALayer, image: NSImage, opacity: Float = 1.0) {
|
||||
let imageLayer = makeLayerForImage(image)
|
||||
imageLayer.contents = image
|
||||
imageLayer.opacity = opacity
|
||||
hostedLayer.addSublayer(imageLayer)
|
||||
|
||||
}
|
||||
|
||||
private func addProgressSublayer(to hostedLayer: CALayer) {
|
||||
|
||||
let imageProgress1 = NSImage(named: "articleExtractorProgress1")
|
||||
let imageProgress2 = NSImage(named: "articleExtractorProgress2")
|
||||
let imageProgress3 = NSImage(named: "articleExtractorProgress3")
|
||||
let imageProgress4 = NSImage(named: "articleExtractorProgress4")
|
||||
let imageProgress1 = AppAssets.articleExtractorProgress1
|
||||
let imageProgress2 = AppAssets.articleExtractorProgress2
|
||||
let imageProgress3 = AppAssets.articleExtractorProgress3
|
||||
let imageProgress4 = AppAssets.articleExtractorProgress4
|
||||
let images = [imageProgress1, imageProgress2, imageProgress3, imageProgress4, imageProgress3, imageProgress2]
|
||||
|
||||
let imageLayer = CALayer()
|
||||
@ -103,7 +94,6 @@ class ArticleExtractorButton: NSButton {
|
||||
animation.repeatCount = HUGE
|
||||
|
||||
imageLayer.add(animation, forKey: "contents")
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user