From f107f98fee0a7a8c9a097eddefcc1f0093a05dab Mon Sep 17 00:00:00 2001 From: Ludvig Eriksson Date: Fri, 27 Apr 2018 10:23:40 +0200 Subject: [PATCH 1/2] Toggles visibility of close button on single tap --- ImageViewer/ImageViewerController.swift | 30 +++++++++++++++---- ImageViewer/Info.plist | 4 ++- .../Resources/ImageViewerController.xib | 5 ++-- SimpleImageViewer.xcodeproj/project.pbxproj | 6 +++- .../xcshareddata/IDEWorkspaceChecks.plist | 8 +++++ .../xcschemes/SimpleImageViewer.xcscheme | 2 +- 6 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 SimpleImageViewer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/ImageViewer/ImageViewerController.swift b/ImageViewer/ImageViewerController.swift index 84fd3dd..b0f4fb8 100644 --- a/ImageViewer/ImageViewerController.swift +++ b/ImageViewer/ImageViewerController.swift @@ -5,7 +5,8 @@ public final class ImageViewerController: UIViewController { @IBOutlet fileprivate var scrollView: UIScrollView! @IBOutlet fileprivate var imageView: UIImageView! @IBOutlet fileprivate var activityIndicator: UIActivityIndicatorView! - + @IBOutlet fileprivate var closeButton: UIButton! + fileprivate var transitionHandler: ImageViewerTransitioningHandler? fileprivate let configuration: ImageViewerConfiguration? @@ -65,10 +66,16 @@ private extension ImageViewerController { } func setupGestureRecognizers() { - let tapGestureRecognizer = UITapGestureRecognizer() - tapGestureRecognizer.numberOfTapsRequired = 2 - tapGestureRecognizer.addTarget(self, action: #selector(imageViewDoubleTapped)) - imageView.addGestureRecognizer(tapGestureRecognizer) + let doubleTapGestureRecognizer = UITapGestureRecognizer() + doubleTapGestureRecognizer.numberOfTapsRequired = 2 + doubleTapGestureRecognizer.addTarget(self, action: #selector(imageViewDoubleTapped)) + imageView.addGestureRecognizer(doubleTapGestureRecognizer) + + let singleTapGestureRecognizer = UITapGestureRecognizer() + singleTapGestureRecognizer.numberOfTapsRequired = 1 + singleTapGestureRecognizer.addTarget(self, action: #selector(imageViewSingleTapped)) + singleTapGestureRecognizer.require(toFail: doubleTapGestureRecognizer) + imageView.addGestureRecognizer(singleTapGestureRecognizer) let panGestureRecognizer = UIPanGestureRecognizer() panGestureRecognizer.addTarget(self, action: #selector(imageViewPanned(_:))) @@ -105,6 +112,19 @@ private extension ImageViewerController { scrollView.setZoomScale(scrollView.maximumZoomScale, animated: true) } } + + @objc func imageViewSingleTapped() { + let presenting = closeButton.isHidden + if presenting { + closeButton.isHidden = false + closeButton.alpha = 0.0 + } + UIView.animate(withDuration: 0.25, animations: { + self.closeButton.alpha = presenting ? 1.0 : 0.0 + }) { _ in + self.closeButton.isHidden = !presenting + } + } @objc func imageViewPanned(_ recognizer: UIPanGestureRecognizer) { guard transitionHandler != nil else { return } diff --git a/ImageViewer/Info.plist b/ImageViewer/Info.plist index a246732..728d01b 100644 --- a/ImageViewer/Info.plist +++ b/ImageViewer/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.1.1 + 1.1.2 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass @@ -24,6 +24,8 @@ LaunchScreen UIMainStoryboardFile Main + UIRequiresFullScreen + UIStatusBarStyle UIStatusBarStyleLightContent UISupportedInterfaceOrientations diff --git a/ImageViewer/Resources/ImageViewerController.xib b/ImageViewer/Resources/ImageViewerController.xib index 07595fc..56d463b 100644 --- a/ImageViewer/Resources/ImageViewerController.xib +++ b/ImageViewer/Resources/ImageViewerController.xib @@ -1,11 +1,11 @@ - + - + @@ -13,6 +13,7 @@ + diff --git a/SimpleImageViewer.xcodeproj/project.pbxproj b/SimpleImageViewer.xcodeproj/project.pbxproj index dbe15e0..70fc3bf 100644 --- a/SimpleImageViewer.xcodeproj/project.pbxproj +++ b/SimpleImageViewer.xcodeproj/project.pbxproj @@ -282,7 +282,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0830; - LastUpgradeCheck = 0900; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = aFrogleap; TargetAttributes = { A02EE5D31EF1897D000EAB41 = { @@ -449,6 +449,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -456,6 +457,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; @@ -506,6 +508,7 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -513,6 +516,7 @@ CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; diff --git a/SimpleImageViewer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SimpleImageViewer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/SimpleImageViewer.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/SimpleImageViewer.xcodeproj/xcshareddata/xcschemes/SimpleImageViewer.xcscheme b/SimpleImageViewer.xcodeproj/xcshareddata/xcschemes/SimpleImageViewer.xcscheme index bf75f27..b8d09c3 100644 --- a/SimpleImageViewer.xcodeproj/xcshareddata/xcschemes/SimpleImageViewer.xcscheme +++ b/SimpleImageViewer.xcodeproj/xcshareddata/xcschemes/SimpleImageViewer.xcscheme @@ -1,6 +1,6 @@ Date: Fri, 27 Apr 2018 10:33:03 +0200 Subject: [PATCH 2/2] Bumped version number to 1.1.2 --- SimpleImageViewer.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimpleImageViewer.podspec b/SimpleImageViewer.podspec index 4e45dc6..c064867 100644 --- a/SimpleImageViewer.podspec +++ b/SimpleImageViewer.podspec @@ -4,7 +4,7 @@ Pod::Spec.new do |s| s.name = "SimpleImageViewer" s.summary = "A snappy image viewer with zoom and interactive dismissal transition." s.requires_arc = true - s.version = "1.1.1" + s.version = "1.1.2" s.license = { :type => "MIT", :file => "LICENSE" } s.author = { "Lucas" => "lucas@afrogleap.com" } s.homepage = "https://github.com/aFrogleap/SimpleImageViewer"