├── .gitignore
├── .swiftpm
└── xcode
│ └── package.xcworkspace
│ └── contents.xcworkspacedata
├── LICENSE
├── Package.resolved
├── Package.swift
├── README.md
└── Source
└── AnimatedImage.swift
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | build/
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | xcuserdata
13 | xcshareddata
14 | *.xccheckout
15 | *.moved-aside
16 | DerivedData
17 | *.hmap
18 | *.ipa
19 | *.xcuserstate
20 |
21 | # CocoaPods
22 | #
23 | # We recommend against adding the Pods directory to your .gitignore. However
24 | # you should judge for yourself, the pros and cons are mentioned at:
25 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
26 | #
27 | Pods/
28 |
29 | # Carthage
30 | #
31 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
32 |
33 | Carthage/Checkouts
34 | Carthage/Build
35 |
36 | .swiftpm
37 | .build
--------------------------------------------------------------------------------
/.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
2 |
3 | [FLAnimatedImage](https://github.com/Flipboard/FLAnimatedImage) plugin for [Nuke](https://github.com/kean/Nuke) that allows you to load and display animated GIFs with [smooth scrolling performance](https://www.youtube.com/watch?v=fEJqQMJrET4) and low memory footprint. You can see it for yourself in a demo, included in the project.
4 |
5 | ## Usage
6 |
7 | All you need to do to enable GIF support is set `isAnimatedImageDataEnabled` to `true`. After you do that, you can start using `FLAnimatedImageView`.
8 |
9 | ```swift
10 | let view = FLAnimatedImageView()
11 | Nuke.loadImage(with: URL(string: "http://.../cat.gif")!, into: view)
12 | ```
13 |
14 | ## Minimum Requirements
15 |
16 | | Nuke FLAnimatedImage Plugin | Swift | Xcode | Platforms |
17 | |----------------------------------------|-----------------------|----------------------|-------------|
18 | | Nuke FLAnimatedImage Plugin 8.0 | Swift 5.3 | Xcode 12.0 | iOS 11.0 / tvOS 11.0 |
19 | | Nuke FLAnimatedImage Plugin 7.0 | Swift 5.1 | Xcode 11.0 | iOS 11.0 |
20 |
21 | ## Dependencies
22 |
23 | - [Nuke ~> 10.0](https://github.com/kean/Nuke)
24 | - [FLAnimatedImage ~> 1.0](https://github.com/Flipboard/FLAnimatedImage)
25 |
26 | ## License
27 |
28 | Nuke is available under the MIT license. See the LICENSE file for more info.
29 |
--------------------------------------------------------------------------------
/Source/AnimatedImage.swift:
--------------------------------------------------------------------------------
1 | // The MIT License (MIT)
2 | //
3 | // Copyright (c) 2016-2021 Alexander Grebenyuk (github.com/kean).
4 |
5 | import UIKit
6 | import FLAnimatedImage
7 | import Nuke
8 |
9 | extension FLAnimatedImageView {
10 | open override func nuke_display(image: UIImage?, data: Data?) {
11 | guard image != nil else {
12 | self.animatedImage = nil
13 | self.image = nil
14 | return
15 | }
16 | if let data = data {
17 | // Display poster image immediately
18 | self.image = image
19 |
20 | // Prepare FLAnimatedImage object asynchronously (it takes a
21 | // noticeable amount of time), and start playback.
22 | DispatchQueue.global().async {
23 | let animatedImage = FLAnimatedImage(animatedGIFData: data)
24 | DispatchQueue.main.async {
25 | // If view is still displaying the same image
26 | if self.image === image {
27 | self.animatedImage = animatedImage
28 | }
29 | }
30 | }
31 | } else {
32 | self.image = image
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------