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