Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demo app fixes #182

Merged
merged 1 commit into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Demo/Demo-iOS/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ class ViewController: UIViewController {
}

@IBAction func swapImage(_ sender: AnyObject) {
switch currentGIFName {
case "mugen":
currentGIFName = "earth"
default:
currentGIFName = "mugen"
let gifs = ["mugen", "earth", "nailed"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cycle through all three GIFs (why not).

if let index = gifs.firstIndex(of: currentGIFName) {
let nextIndex = (index + 1) % gifs.count
currentGIFName = gifs[nextIndex]
}
}

Expand All @@ -40,7 +39,7 @@ class ViewController: UIViewController {
}

func animate() {
imageView.animate(withGIFNamed: currentGIFName, animationBlock: {
imageView.animate(withGIFNamed: currentGIFName, preparationBlock: {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

animationBlock is never run because the GIF loops indefinitely. animationBlock is only called once the whole animation has finished. With preparationBlock it works as intended.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

DispatchQueue.main.async {
self.imageDataLabel.text = self.currentGIFName.capitalized + " (\(self.imageView.frameCount) frames / \(String(format: "%.2f", self.imageView.gifLoopDuration))s)"
}
Expand Down
8 changes: 8 additions & 0 deletions Demo/Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
9D98823F19BC69CA00B790C6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D98823E19BC69CA00B790C6 /* ViewController.swift */; };
9D98824419BC69CA00B790C6 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9D98824319BC69CA00B790C6 /* Images.xcassets */; };
9D98825A19BC69F600B790C6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9D98825919BC69F600B790C6 /* Main.storyboard */; };
A5D726E828B53C0800821347 /* earth.gif in Resources */ = {isa = PBXBuildFile; fileRef = A5D726E728B53C0800821347 /* earth.gif */; };
A5D726EC28B5599A00821347 /* nailed.gif in Resources */ = {isa = PBXBuildFile; fileRef = A5D726EB28B5599A00821347 /* nailed.gif */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand Down Expand Up @@ -59,6 +61,8 @@
9D98823E19BC69CA00B790C6 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
9D98824319BC69CA00B790C6 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
9D98825919BC69F600B790C6 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
A5D726E728B53C0800821347 /* earth.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; name = earth.gif; path = ../Tests/Images/earth.gif; sourceTree = SOURCE_ROOT; };
A5D726EB28B5599A00821347 /* nailed.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; name = nailed.gif; path = ../Tests/Images/nailed.gif; sourceTree = SOURCE_ROOT; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -149,7 +153,9 @@
9D98823A19BC69CA00B790C6 /* Supporting Files */ = {
isa = PBXGroup;
children = (
A5D726E728B53C0800821347 /* earth.gif */,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to review this change but before, only the mugen.gif was included in the files so swiping in the demo app didn't work.

Copy link
Owner

@kaishin kaishin Aug 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was only trying the first one in my manual regression tests so never noticed. Thanks!

002A1BFB1D1624D0005ABBD0 /* mugen.gif */,
A5D726EB28B5599A00821347 /* nailed.gif */,
);
path = "Supporting Files";
sourceTree = "<group>";
Expand Down Expand Up @@ -250,6 +256,8 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A5D726E828B53C0800821347 /* earth.gif in Resources */,
A5D726EC28B5599A00821347 /* nailed.gif in Resources */,
9D98824419BC69CA00B790C6 /* Images.xcassets in Resources */,
002A1BFC1D1624D0005ABBD0 /* mugen.gif in Resources */,
0032FE841FFA693500444203 /* LaunchScreen.storyboard in Resources */,
Expand Down
4 changes: 4 additions & 0 deletions Gifu.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
00B8C7961A3650EE00C188E7 /* Gifu.h in Headers */ = {isa = PBXBuildFile; fileRef = 00B8C7951A3650EE00C188E7 /* Gifu.h */; settings = {ATTRIBUTES = (Public, ); }; };
00BF42CC1D99A1DC00C6F28D /* GIFAnimatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00BF42CB1D99A1DC00C6F28D /* GIFAnimatable.swift */; };
00DD26EE1DA9643800A0F683 /* UIImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 00DD26ED1DA9643800A0F683 /* UIImageView.swift */; };
A5D726EA28B53D6400821347 /* earth.gif in Resources */ = {isa = PBXBuildFile; fileRef = A5D726E928B53D6400821347 /* earth.gif */; };
EAF49C7F1A3A4DE000B395DF /* UIImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF49C7E1A3A4DE000B395DF /* UIImage.swift */; };
EAF49CB11A3B6EEB00B395DF /* AnimatedFrame.swift in Sources */ = {isa = PBXBuildFile; fileRef = EAF49CB01A3B6EEB00B395DF /* AnimatedFrame.swift */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -52,6 +53,7 @@
00BF42CB1D99A1DC00C6F28D /* GIFAnimatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GIFAnimatable.swift; sourceTree = "<group>"; };
00C50CFB2392BA9900CBE23C /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
00DD26ED1DA9643800A0F683 /* UIImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIImageView.swift; sourceTree = "<group>"; };
A5D726E928B53D6400821347 /* earth.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = earth.gif; sourceTree = "<group>"; };
EAF49C7E1A3A4DE000B395DF /* UIImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIImage.swift; sourceTree = "<group>"; };
EAF49CB01A3B6EEB00B395DF /* AnimatedFrame.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AnimatedFrame.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -88,6 +90,7 @@
0036ABBA1BBD1D1700C6CC3D /* Images */ = {
isa = PBXGroup;
children = (
A5D726E928B53D6400821347 /* earth.gif */,
0036ABB61BBD1D0B00C6CC3D /* mugen.gif */,
0036ABB81BBD1D1400C6CC3D /* nailed.gif */,
);
Expand Down Expand Up @@ -271,6 +274,7 @@
files = (
0036ABB71BBD1D0B00C6CC3D /* mugen.gif in Resources */,
0036ABB91BBD1D1400C6CC3D /* nailed.gif in Resources */,
A5D726EA28B53D6400821347 /* earth.gif in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down