diff --git a/.gitmodules b/.gitmodules index a4527d8f..646bf85f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "Gifu"] - path = Gifu - url = git://github.com/kaishin/Gifu.git [submodule "Embassy"] path = Embassy url = https://github.com/envoy/Embassy.git diff --git a/Gifu b/Gifu deleted file mode 160000 index 9b1a6461..00000000 --- a/Gifu +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9b1a6461aa3b5f66cb0ed3a50c5523db0b4fb007 diff --git a/Tusker.xcodeproj/project.pbxproj b/Tusker.xcodeproj/project.pbxproj index f4db11cc..20a94ae1 100644 --- a/Tusker.xcodeproj/project.pbxproj +++ b/Tusker.xcodeproj/project.pbxproj @@ -274,8 +274,6 @@ D6B81F3C2560365300F6E31D /* RefreshableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6B81F3B2560365300F6E31D /* RefreshableViewController.swift */; }; D6B81F442560390300F6E31D /* MenuController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6B81F432560390300F6E31D /* MenuController.swift */; }; D6B8DB342182A59300424AF7 /* UIAlertController+Visibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6B8DB332182A59300424AF7 /* UIAlertController+Visibility.swift */; }; - D6BC874521961F73006163F1 /* Gifu.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6BC874421961F73006163F1 /* Gifu.framework */; }; - D6BC874621961F73006163F1 /* Gifu.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D6BC874421961F73006163F1 /* Gifu.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; D6BC8748219738E1006163F1 /* EnhancedTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BC8747219738E1006163F1 /* EnhancedTableViewController.swift */; }; D6BC9DB1232C61BC002CA326 /* NotificationsPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BC9DB0232C61BC002CA326 /* NotificationsPageViewController.swift */; }; D6BC9DB3232D4C07002CA326 /* WellnessPrefsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BC9DB2232D4C07002CA326 /* WellnessPrefsView.swift */; }; @@ -309,6 +307,7 @@ D6D4DDE5212518A200E1C4BB /* TuskerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6D4DDE4212518A200E1C4BB /* TuskerTests.swift */; }; D6D4DDF0212518A200E1C4BB /* TuskerUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6D4DDEF212518A200E1C4BB /* TuskerUITests.swift */; }; D6DD2A3F273C1F4900386A6C /* ComposeAttachmentImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6DD2A3E273C1F4900386A6C /* ComposeAttachmentImage.swift */; }; + D6DD2A45273D6C5700386A6C /* GIFImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6DD2A44273D6C5700386A6C /* GIFImageView.swift */; }; D6DD353D22F28CD000A9563A /* ContentWarningCopyMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6DD353C22F28CD000A9563A /* ContentWarningCopyMode.swift */; }; D6DD353F22F502EC00A9563A /* Preferences+Notification.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6DD353E22F502EC00A9563A /* Preferences+Notification.swift */; }; D6DEA0DE268400C300FE896A /* ConfirmLoadMoreTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6DEA0DC268400C300FE896A /* ConfirmLoadMoreTableViewCell.swift */; }; @@ -406,7 +405,6 @@ dstSubfolderSpec = 10; files = ( D61099C12144B0CC00432DC2 /* Pachyderm.framework in Embed Frameworks */, - D6BC874621961F73006163F1 /* Gifu.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -681,7 +679,6 @@ D6B81F3B2560365300F6E31D /* RefreshableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RefreshableViewController.swift; sourceTree = ""; }; D6B81F432560390300F6E31D /* MenuController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuController.swift; sourceTree = ""; }; D6B8DB332182A59300424AF7 /* UIAlertController+Visibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIAlertController+Visibility.swift"; sourceTree = ""; }; - D6BC874421961F73006163F1 /* Gifu.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Gifu.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D6BC8747219738E1006163F1 /* EnhancedTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EnhancedTableViewController.swift; sourceTree = ""; }; D6BC9DB0232C61BC002CA326 /* NotificationsPageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationsPageViewController.swift; sourceTree = ""; }; D6BC9DB2232D4C07002CA326 /* WellnessPrefsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WellnessPrefsView.swift; sourceTree = ""; }; @@ -721,6 +718,7 @@ D6D4DDEF212518A200E1C4BB /* TuskerUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TuskerUITests.swift; sourceTree = ""; }; D6D4DDF1212518A200E1C4BB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; D6DD2A3E273C1F4900386A6C /* ComposeAttachmentImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeAttachmentImage.swift; sourceTree = ""; }; + D6DD2A44273D6C5700386A6C /* GIFImageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GIFImageView.swift; sourceTree = ""; }; D6DD353C22F28CD000A9563A /* ContentWarningCopyMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentWarningCopyMode.swift; sourceTree = ""; }; D6DD353E22F502EC00A9563A /* Preferences+Notification.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Preferences+Notification.swift"; sourceTree = ""; }; D6DEA0DC268400C300FE896A /* ConfirmLoadMoreTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfirmLoadMoreTableViewCell.swift; sourceTree = ""; }; @@ -780,7 +778,6 @@ D61099C02144B0CC00432DC2 /* Pachyderm.framework in Frameworks */, D6B0539F23BD2BA300A066FA /* SheetController in Frameworks */, D69CCBBF249E6EFD000AF167 /* CrashReporter in Frameworks */, - D6BC874521961F73006163F1 /* Gifu.framework in Frameworks */, D60CFFDB24A290BA00D00083 /* SwiftSoup in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1480,6 +1477,7 @@ D6969E9F240C8384002843CE /* EmojiLabel.swift */, D67C1794266D57D10070F250 /* FastAccountSwitcherIndicatorView.swift */, D6EAE0DA2550CC8A002DB0AC /* FocusableTextField.swift */, + D6DD2A44273D6C5700386A6C /* GIFImageView.swift */, D641C77E213DC78A004B4513 /* InlineTextAttachment.swift */, D620483323D3801D008A63EF /* LinkTextView.swift */, D68E6F58253C9969001A1B4C /* MultiSourceEmojiLabel.swift */, @@ -1546,7 +1544,6 @@ D6D4DDC3212518A000E1C4BB = { isa = PBXGroup; children = ( - D6BC874421961F73006163F1 /* Gifu.framework */, D61099AC2144B0CC00432DC2 /* Pachyderm */, D61099B92144B0CC00432DC2 /* PachydermTests */, D6D4DDCE212518A000E1C4BB /* Tusker */, @@ -2191,6 +2188,7 @@ D69693F42585941A00F4E116 /* UIWindowSceneDelegate+Close.swift in Sources */, D6C143DA253510F4007DC240 /* ComposeEmojiTextField.swift in Sources */, D6DD2A3F273C1F4900386A6C /* ComposeAttachmentImage.swift in Sources */, + D6DD2A45273D6C5700386A6C /* GIFImageView.swift in Sources */, 0427033822B30F5F000D31B6 /* BehaviorPrefsView.swift in Sources */, D627943923A553B600D38C68 /* UnbookmarkStatusActivity.swift in Sources */, D64D0AAD2128D88B005A6F37 /* LocalData.swift in Sources */, diff --git a/Tusker.xcworkspace/contents.xcworkspacedata b/Tusker.xcworkspace/contents.xcworkspacedata index b46d306a..452f061e 100644 --- a/Tusker.xcworkspace/contents.xcworkspacedata +++ b/Tusker.xcworkspace/contents.xcworkspacedata @@ -7,9 +7,6 @@ - - diff --git a/Tusker/Screens/Attachment Gallery/AttachmentPreviewViewController.swift b/Tusker/Screens/Attachment Gallery/AttachmentPreviewViewController.swift index 2c723efd..3f351c36 100644 --- a/Tusker/Screens/Attachment Gallery/AttachmentPreviewViewController.swift +++ b/Tusker/Screens/Attachment Gallery/AttachmentPreviewViewController.swift @@ -8,7 +8,6 @@ import UIKit import Pachyderm -import Gifu class AttachmentPreviewViewController: UIViewController { diff --git a/Tusker/Screens/Large Image/LargeImageContentView.swift b/Tusker/Screens/Large Image/LargeImageContentView.swift index e15b9eb4..7ac94922 100644 --- a/Tusker/Screens/Large Image/LargeImageContentView.swift +++ b/Tusker/Screens/Large Image/LargeImageContentView.swift @@ -7,7 +7,6 @@ // import UIKit -import Gifu import Pachyderm import AVFoundation @@ -18,11 +17,8 @@ protocol LargeImageContentView: UIView { func grayscaleStateChanged() } -class LargeImageImageContentView: UIImageView, GIFAnimatable, LargeImageContentView { - lazy var animator: Animator? = { - return Animator(withDelegate: self) - }() - +class LargeImageImageContentView: GIFImageView, LargeImageContentView { + var animationImage: UIImage? { image! } let animationGifData: Data? @@ -54,12 +50,6 @@ class LargeImageImageContentView: UIImageView, GIFAnimatable, LargeImageContentV fatalError("init(coder:) has not been implemented") } - override public func display(_ layer: CALayer) { - super.display(layer) - - updateImageIfNeeded() - } - func grayscaleStateChanged() { guard let data = sourceData else { return diff --git a/Tusker/Screens/Large Image/Transitions/LargeImageExpandAnimationController.swift b/Tusker/Screens/Large Image/Transitions/LargeImageExpandAnimationController.swift index cf364e3d..bb6eea69 100644 --- a/Tusker/Screens/Large Image/Transitions/LargeImageExpandAnimationController.swift +++ b/Tusker/Screens/Large Image/Transitions/LargeImageExpandAnimationController.swift @@ -7,7 +7,6 @@ // import UIKit -import Gifu protocol LargeImageAnimatableViewController: UIViewController { var animationSourceView: UIImageView? { get } diff --git a/Tusker/Screens/Large Image/Transitions/LargeImageShrinkAnimationController.swift b/Tusker/Screens/Large Image/Transitions/LargeImageShrinkAnimationController.swift index cad711e6..acd1ba39 100644 --- a/Tusker/Screens/Large Image/Transitions/LargeImageShrinkAnimationController.swift +++ b/Tusker/Screens/Large Image/Transitions/LargeImageShrinkAnimationController.swift @@ -7,7 +7,6 @@ // import UIKit -import Gifu class LargeImageShrinkAnimationController: NSObject, UIViewControllerAnimatedTransitioning { diff --git a/Tusker/Views/Attachments/AttachmentView.swift b/Tusker/Views/Attachments/AttachmentView.swift index cb987c62..83738761 100644 --- a/Tusker/Views/Attachments/AttachmentView.swift +++ b/Tusker/Views/Attachments/AttachmentView.swift @@ -8,7 +8,6 @@ import UIKit import Pachyderm -import Gifu import AVFoundation protocol AttachmentViewDelegate: AnyObject { @@ -16,7 +15,7 @@ protocol AttachmentViewDelegate: AnyObject { func attachmentViewPresent(_ vc: UIViewController, animated: Bool) } -class AttachmentView: UIImageView, GIFAnimatable { +class AttachmentView: GIFImageView { weak var delegate: AttachmentViewDelegate? @@ -44,8 +43,6 @@ class AttachmentView: UIImageView, GIFAnimatable { private var isGrayscale = false - public lazy var animator: Animator? = Animator(withDelegate: self) - init(attachment: Attachment, index: Int, expectedSize: CGSize) { super.init(image: nil) commonInit() @@ -293,12 +290,6 @@ class AttachmentView: UIImageView, GIFAnimatable { } } - override func display(_ layer: CALayer) { - super.display(layer) - - updateImageIfNeeded() - } - func showGallery() { if let delegate = delegate, let gallery = delegate.attachmentViewGallery(startingAt: index) { diff --git a/Tusker/Views/GIFImageView.swift b/Tusker/Views/GIFImageView.swift new file mode 100644 index 00000000..b01f60bb --- /dev/null +++ b/Tusker/Views/GIFImageView.swift @@ -0,0 +1,34 @@ +// +// GIFImageView.swift +// Tusker +// +// Created by Shadowfacts on 11/11/21. +// Copyright © 2021 Shadowfacts. All rights reserved. +// + +import UIKit + +class GIFImageView: UIImageView { + + private(set) var isAnimatingGIF: Bool = false + private var shouldStopAnimatingGIF = false + + + func animate(withGIFData data: Data) { + CGAnimateImageDataWithBlock(data as CFData, nil) { [weak self] (frameIndex, frame, stop) in + guard let self = self else { + stop.pointee = true + return + } + self.image = UIImage(cgImage: frame) + stop.pointee = self.shouldStopAnimatingGIF + } + isAnimatingGIF = true + } + + func stopAnimatingGIF() { + shouldStopAnimatingGIF = true + isAnimatingGIF = false + } + +}