mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Remove unused LegacyArticleExtractorButton.
This commit is contained in:
@@ -1,111 +0,0 @@
|
||||
//
|
||||
// ArticleExtractorButton.swift
|
||||
// NetNewsWire
|
||||
//
|
||||
// Created by Maurice Parker on 9/18/19.
|
||||
// Copyright © 2019 Ranchero Software. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class LegacyArticleExtractorButton: NSButton {
|
||||
|
||||
var isError = false {
|
||||
didSet {
|
||||
if isError != oldValue {
|
||||
needsDisplay = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var isInProgress = false {
|
||||
didSet {
|
||||
if isInProgress != oldValue {
|
||||
needsDisplay = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override init(frame frameRect: NSRect) {
|
||||
super.init(frame: frameRect)
|
||||
wantsLayer = true
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
wantsLayer = true
|
||||
}
|
||||
|
||||
override func draw(_ dirtyRect: NSRect) {
|
||||
super.draw(dirtyRect)
|
||||
|
||||
guard let hostedLayer = self.layer else {
|
||||
return
|
||||
}
|
||||
|
||||
if let imageLayer = hostedLayer.sublayers?[0] {
|
||||
if needsToDraw(imageLayer.bounds) {
|
||||
imageLayer.removeFromSuperlayer()
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
let opacity: Float = isEnabled ? 1.0 : 0.5
|
||||
|
||||
switch true {
|
||||
case isError:
|
||||
addImageSublayer(to: hostedLayer, image: AppAssets.legacyArticleExtractorError, opacity: opacity)
|
||||
case isInProgress:
|
||||
addAnimatedSublayer(to: hostedLayer)
|
||||
default:
|
||||
if NSApplication.shared.isActive {
|
||||
addImageSublayer(to: hostedLayer, image: AppAssets.legacyArticleExtractor, opacity: opacity)
|
||||
} else {
|
||||
if NSApplication.shared.effectiveAppearance.isDarkMode {
|
||||
addImageSublayer(to: hostedLayer, image: AppAssets.legacyArticleExtractorInactiveDark, opacity: opacity)
|
||||
} else {
|
||||
addImageSublayer(to: hostedLayer, image: AppAssets.legacyArticleExtractorInactiveLight, opacity: opacity)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func makeLayerForImage(_ image: NSImage) -> CALayer {
|
||||
let imageLayer = CALayer()
|
||||
imageLayer.bounds = CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height)
|
||||
imageLayer.position = CGPoint(x: bounds.midX, y: floor(bounds.midY))
|
||||
return imageLayer
|
||||
}
|
||||
|
||||
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 addAnimatedSublayer(to hostedLayer: CALayer) {
|
||||
let imageProgress1 = AppAssets.legacyArticleExtractorProgress1
|
||||
let imageProgress2 = AppAssets.legacyArticleExtractorProgress2
|
||||
let imageProgress3 = AppAssets.legacyArticleExtractorProgress3
|
||||
let imageProgress4 = AppAssets.legacyArticleExtractorProgress4
|
||||
let images = [imageProgress1, imageProgress2, imageProgress3, imageProgress4, imageProgress3, imageProgress2, imageProgress1]
|
||||
|
||||
let imageLayer = CALayer()
|
||||
imageLayer.bounds = CGRect(x: 0, y: 0, width: imageProgress1?.size.width ?? 0, height: imageProgress1?.size.height ?? 0)
|
||||
imageLayer.position = CGPoint(x: bounds.midX, y: floor(bounds.midY))
|
||||
|
||||
hostedLayer.addSublayer(imageLayer)
|
||||
|
||||
let animation = CAKeyframeAnimation(keyPath: "contents")
|
||||
animation.calculationMode = CAAnimationCalculationMode.linear
|
||||
animation.keyTimes = [0, 0.16, 0.32, 0.50, 0.66, 0.82, 1]
|
||||
animation.duration = 2
|
||||
animation.values = images as [Any]
|
||||
animation.repeatCount = HUGE
|
||||
|
||||
imageLayer.add(animation, forKey: "contents")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -371,7 +371,6 @@
|
||||
51FA73A52332BE110090D516 /* ArticleExtractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51FA73A32332BE110090D516 /* ArticleExtractor.swift */; };
|
||||
51FA73A72332BE880090D516 /* ExtractedArticle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51FA73A62332BE880090D516 /* ExtractedArticle.swift */; };
|
||||
51FA73A82332BE880090D516 /* ExtractedArticle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51FA73A62332BE880090D516 /* ExtractedArticle.swift */; };
|
||||
51FA73B72332D5F70090D516 /* LegacyArticleExtractorButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51FA73B62332D5F70090D516 /* LegacyArticleExtractorButton.swift */; };
|
||||
51FD413B2342BD0500880194 /* MasterTimelineUnreadCountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51FD413A2342BD0500880194 /* MasterTimelineUnreadCountView.swift */; };
|
||||
51FE10032345529D0056195D /* UserNotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51FE10022345529D0056195D /* UserNotificationManager.swift */; };
|
||||
51FE10042345529D0056195D /* UserNotificationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51FE10022345529D0056195D /* UserNotificationManager.swift */; };
|
||||
@@ -507,7 +506,6 @@
|
||||
65ED400C235DEF6C0081F399 /* FolderInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841ABA5D20145E9200980E11 /* FolderInspectorViewController.swift */; };
|
||||
65ED400D235DEF6C0081F399 /* SmartFeedDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84DEE56422C32CA4005FC42C /* SmartFeedDelegate.swift */; };
|
||||
65ED400E235DEF6C0081F399 /* ImageDownloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 845213221FCA5B10003B6E93 /* ImageDownloader.swift */; };
|
||||
65ED400F235DEF6C0081F399 /* LegacyArticleExtractorButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51FA73B62332D5F70090D516 /* LegacyArticleExtractorButton.swift */; };
|
||||
65ED4011235DEF6C0081F399 /* AddFolderWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97421ED9EAA9007D329B /* AddFolderWindowController.swift */; };
|
||||
65ED4012235DEF6C0081F399 /* TimelineContainerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8405DDA422168C62008CE1BF /* TimelineContainerViewController.swift */; };
|
||||
65ED4013235DEF6C0081F399 /* MainWIndowKeyboardHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844B5B661FEA18E300C7C76A /* MainWIndowKeyboardHandler.swift */; };
|
||||
@@ -1310,7 +1308,6 @@
|
||||
51F9F3FA23DFB25700A314FD /* Animations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Animations.swift; sourceTree = "<group>"; };
|
||||
51FA73A32332BE110090D516 /* ArticleExtractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArticleExtractor.swift; sourceTree = "<group>"; };
|
||||
51FA73A62332BE880090D516 /* ExtractedArticle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtractedArticle.swift; sourceTree = "<group>"; };
|
||||
51FA73B62332D5F70090D516 /* LegacyArticleExtractorButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegacyArticleExtractorButton.swift; sourceTree = "<group>"; };
|
||||
51FD413A2342BD0500880194 /* MasterTimelineUnreadCountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterTimelineUnreadCountView.swift; sourceTree = "<group>"; };
|
||||
51FE10022345529D0056195D /* UserNotificationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserNotificationManager.swift; sourceTree = "<group>"; };
|
||||
51FFF0C3235EE8E5002762AA /* VibrantButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VibrantButton.swift; sourceTree = "<group>"; };
|
||||
@@ -2264,7 +2261,6 @@
|
||||
519B8D322143397200FA689C /* SharingServiceDelegate.swift */,
|
||||
849EE72020391F560082A1EA /* SharingServicePickerDelegate.swift */,
|
||||
5117715424E1EA0F00A2A836 /* ArticleExtractorButton.swift */,
|
||||
51FA73B62332D5F70090D516 /* LegacyArticleExtractorButton.swift */,
|
||||
847CD6C9232F4CBF00FAC46D /* IconView.swift */,
|
||||
B2C12C6528F4C46800373730 /* URLPasteboardWriter+NetNewsWire.swift */,
|
||||
844B5B6B1FEA224B00C7C76A /* Keyboard */,
|
||||
@@ -4007,7 +4003,6 @@
|
||||
65ED400C235DEF6C0081F399 /* FolderInspectorViewController.swift in Sources */,
|
||||
65ED400D235DEF6C0081F399 /* SmartFeedDelegate.swift in Sources */,
|
||||
65ED400E235DEF6C0081F399 /* ImageDownloader.swift in Sources */,
|
||||
65ED400F235DEF6C0081F399 /* LegacyArticleExtractorButton.swift in Sources */,
|
||||
65ED4011235DEF6C0081F399 /* AddFolderWindowController.swift in Sources */,
|
||||
65ED4012235DEF6C0081F399 /* TimelineContainerViewController.swift in Sources */,
|
||||
65ED4013235DEF6C0081F399 /* MainWIndowKeyboardHandler.swift in Sources */,
|
||||
@@ -4375,7 +4370,6 @@
|
||||
84DEE56522C32CA4005FC42C /* SmartFeedDelegate.swift in Sources */,
|
||||
845213231FCA5B11003B6E93 /* ImageDownloader.swift in Sources */,
|
||||
DF5124CC2A22D62600BBAB1F /* AboutHTML.swift in Sources */,
|
||||
51FA73B72332D5F70090D516 /* LegacyArticleExtractorButton.swift in Sources */,
|
||||
849A97431ED9EAA9007D329B /* AddFolderWindowController.swift in Sources */,
|
||||
8405DDA522168C62008CE1BF /* TimelineContainerViewController.swift in Sources */,
|
||||
844B5B671FEA18E300C7C76A /* MainWIndowKeyboardHandler.swift in Sources */,
|
||||
|
||||
Reference in New Issue
Block a user