Skip to content

Commit

Permalink
Support button and physics configuration. Closes #97
Browse files Browse the repository at this point in the history
  • Loading branch information
JanGorman committed Dec 5, 2018
1 parent b248139 commit 58f1062
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Agrume.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "Agrume"
s.version = "5.2.3"
s.version = "5.2.4"
s.summary = "An iOS image viewer written in Swift."
s.swift_version = "4.2"

Expand Down
55 changes: 33 additions & 22 deletions Agrume.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
771DA7322179E26000541206 /* SwiftyGif.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 771DA7312179E24900541206 /* SwiftyGif.framework */; };
94318E541D32612D0096215A /* AgrumeServiceLocator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94318E531D32612D0096215A /* AgrumeServiceLocator.swift */; };
F2539BA120F22E7700062C80 /* AgrumeOverlayView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2539BA020F22E7700062C80 /* AgrumeOverlayView.swift */; };
F2609E23209F047200E0E93D /* AgrumeDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = F2609E22209F047200E0E93D /* AgrumeDataSource.swift */; };
Expand All @@ -23,27 +22,34 @@
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
771DA72C2179E24900541206 /* PBXContainerItemProxy */ = {
F20B98AF21B8687600585F48 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 771DA7262179E24800541206 /* SwiftyGif.xcodeproj */;
containerPortal = F20B98A921B8687600585F48 /* SwiftyGif.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = FA29E9321CA9340E00E579D5;
remoteInfo = SwiftyGifExample;
};
771DA72E2179E24900541206 /* PBXContainerItemProxy */ = {
F20B98B121B8687600585F48 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 771DA7262179E24800541206 /* SwiftyGif.xcodeproj */;
containerPortal = F20B98A921B8687600585F48 /* SwiftyGif.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = FA29E9461CA9340F00E579D5;
remoteInfo = SwiftyGifTests;
};
771DA7302179E24900541206 /* PBXContainerItemProxy */ = {
F20B98B321B8687600585F48 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 771DA7262179E24800541206 /* SwiftyGif.xcodeproj */;
containerPortal = F20B98A921B8687600585F48 /* SwiftyGif.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 3B18BAF41E289899009C125A;
remoteInfo = SwiftyGif;
};
F20B98B521B8688200585F48 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F20B98A921B8687600585F48 /* SwiftyGif.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 3B18BAF31E289899009C125A;
remoteInfo = SwiftyGif;
};
F2A51FFB1B10E00700924912 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = F2A51FE51B10E00700924912 /* Project object */;
Expand All @@ -54,8 +60,8 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
771DA7262179E24800541206 /* SwiftyGif.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SwiftyGif.xcodeproj; path = Frameworks/SwiftyGif/SwiftyGif.xcodeproj; sourceTree = "<group>"; };
94318E531D32612D0096215A /* AgrumeServiceLocator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AgrumeServiceLocator.swift; sourceTree = "<group>"; };
F20B98A921B8687600585F48 /* SwiftyGif.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SwiftyGif.xcodeproj; path = Frameworks/SwiftyGif/SwiftyGif.xcodeproj; sourceTree = "<group>"; };
F2539BA020F22E7700062C80 /* AgrumeOverlayView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgrumeOverlayView.swift; sourceTree = "<group>"; };
F2609E22209F047200E0E93D /* AgrumeDataSource.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgrumeDataSource.swift; sourceTree = "<group>"; };
F2609E25209F06F800E0E93D /* AgrumeImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgrumeImage.swift; sourceTree = "<group>"; };
Expand All @@ -77,7 +83,6 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
771DA7322179E26000541206 /* SwiftyGif.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -92,12 +97,12 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
771DA7272179E24800541206 /* Products */ = {
F20B98AA21B8687600585F48 /* Products */ = {
isa = PBXGroup;
children = (
771DA72D2179E24900541206 /* SwiftyGifExample.app */,
771DA72F2179E24900541206 /* SwiftyGifTests.xctest */,
771DA7312179E24900541206 /* SwiftyGif.framework */,
F20B98B021B8687600585F48 /* SwiftyGifExample.app */,
F20B98B221B8687600585F48 /* SwiftyGifTests.xctest */,
F20B98B421B8687600585F48 /* SwiftyGif.framework */,
);
name = Products;
sourceTree = "<group>";
Expand All @@ -112,7 +117,7 @@
F2A51FE41B10E00700924912 = {
isa = PBXGroup;
children = (
771DA7262179E24800541206 /* SwiftyGif.xcodeproj */,
F20B98A921B8687600585F48 /* SwiftyGif.xcodeproj */,
F2A51FF01B10E00700924912 /* Agrume */,
F2A51FFD1B10E00700924912 /* AgrumeTests */,
F2A51FEF1B10E00700924912 /* Products */,
Expand Down Expand Up @@ -201,6 +206,7 @@
buildRules = (
);
dependencies = (
F20B98B621B8688200585F48 /* PBXTargetDependency */,
);
name = Agrume;
productName = Agrume;
Expand Down Expand Up @@ -258,8 +264,8 @@
projectDirPath = "";
projectReferences = (
{
ProductGroup = 771DA7272179E24800541206 /* Products */;
ProjectRef = 771DA7262179E24800541206 /* SwiftyGif.xcodeproj */;
ProductGroup = F20B98AA21B8687600585F48 /* Products */;
ProjectRef = F20B98A921B8687600585F48 /* SwiftyGif.xcodeproj */;
},
);
projectRoot = "";
Expand All @@ -271,25 +277,25 @@
/* End PBXProject section */

/* Begin PBXReferenceProxy section */
771DA72D2179E24900541206 /* SwiftyGifExample.app */ = {
F20B98B021B8687600585F48 /* SwiftyGifExample.app */ = {
isa = PBXReferenceProxy;
fileType = wrapper.application;
path = SwiftyGifExample.app;
remoteRef = 771DA72C2179E24900541206 /* PBXContainerItemProxy */;
remoteRef = F20B98AF21B8687600585F48 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
771DA72F2179E24900541206 /* SwiftyGifTests.xctest */ = {
F20B98B221B8687600585F48 /* SwiftyGifTests.xctest */ = {
isa = PBXReferenceProxy;
fileType = wrapper.cfbundle;
path = SwiftyGifTests.xctest;
remoteRef = 771DA72E2179E24900541206 /* PBXContainerItemProxy */;
remoteRef = F20B98B121B8687600585F48 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
771DA7312179E24900541206 /* SwiftyGif.framework */ = {
F20B98B421B8687600585F48 /* SwiftyGif.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = SwiftyGif.framework;
remoteRef = 771DA7302179E24900541206 /* PBXContainerItemProxy */;
remoteRef = F20B98B321B8687600585F48 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
Expand Down Expand Up @@ -356,6 +362,11 @@
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
F20B98B621B8688200585F48 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
name = SwiftyGif;
targetProxy = F20B98B521B8688200585F48 /* PBXContainerItemProxy */;
};
F2A51FFC1B10E00700924912 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = F2A51FED1B10E00700924912 /* Agrume */;
Expand Down
12 changes: 8 additions & 4 deletions Agrume/Agrume.swift
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public final class Agrume: UIViewController {
backgroundImageView.image = backgroundSnapshot
view.addSubview(backgroundImageView)

if case .blurred(_) = background {
if case .blurred = background {
blurContainerView.addSubview(blurView)
}
view.addSubview(blurContainerView)
Expand Down Expand Up @@ -258,13 +258,16 @@ public final class Agrume: UIViewController {
}

private func addOverlayView() {
if case .withButton(let button) = dismissal {
switch dismissal {
case .withButton(let button), .withPhysicsAndButton(let button):
let overlayView = AgrumeOverlayView(closeButton: button)
overlayView.delegate = self
overlayView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
overlayView.frame = view.bounds
view.addSubview(overlayView)
self.overlayView = overlayView
default:
break
}
}

Expand Down Expand Up @@ -336,9 +339,10 @@ extension Agrume: UICollectionViewDataSource {
let cell: AgrumeCell = collectionView.dequeue(indexPath: indexPath)

cell.tapBehavior = tapBehavior
if case .withPhysics = dismissal {
switch dismissal {
case .withPhysics, .withPhysicsAndButton:
cell.hasPhysics = true
} else {
case .withButton:
cell.hasPhysics = false
}

Expand Down
2 changes: 2 additions & 0 deletions Agrume/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public enum Background {
///
/// - withPhysics: Allow dragging the images and "throwing" them off screen to dismiss Agrume
/// - withButton: Overlay with a close button. Pass an optional `UIBarButtonItem` to control the look
/// - withPhysicsAndButton: Combines both behaviours. Physics and the close button all in one
public enum Dismissal {
case withPhysics
case withButton(UIBarButtonItem?)
case withPhysicsAndButton(UIBarButtonItem?)
}

0 comments on commit 58f1062

Please sign in to comment.