From f10c3716273a11eb5c7b1ed3b467099ac680e458 Mon Sep 17 00:00:00 2001 From: menno Date: Fri, 21 May 2021 16:51:50 +0200 Subject: [PATCH 1/3] make sure app can be ran on a device --- Example/Zoomy.xcodeproj/project.pbxproj | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Example/Zoomy.xcodeproj/project.pbxproj b/Example/Zoomy.xcodeproj/project.pbxproj index 51d7f36..446d61a 100644 --- a/Example/Zoomy.xcodeproj/project.pbxproj +++ b/Example/Zoomy.xcodeproj/project.pbxproj @@ -417,18 +417,18 @@ TargetAttributes = { 607FACCF1AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; - DevelopmentTeam = P6ZSWCNHR5; + DevelopmentTeam = 9W484F6894; LastSwiftMigration = 1030; }; 607FACE41AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; - DevelopmentTeam = P6ZSWCNHR5; + DevelopmentTeam = 9W484F6894; LastSwiftMigration = 1030; TestTargetID = 607FACCF1AFB9204008FA782; }; DE9C330C20AB751A00827664 = { CreatedOnToolsVersion = 9.3; - DevelopmentTeam = P6ZSWCNHR5; + DevelopmentTeam = 9W484F6894; LastSwiftMigration = 1030; ProvisioningStyle = Automatic; TestTargetID = 607FACCF1AFB9204008FA782; @@ -780,12 +780,12 @@ baseConfigurationReference = 5732A4C74D221015C6DC4E5A /* Pods-Zoomy_Example.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = P6ZSWCNHR5; + DEVELOPMENT_TEAM = 9W484F6894; INFOPLIST_FILE = Zoomy/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MODULE_NAME = ExampleApp; - PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.lvnkmn.demo.Zoomy-Example"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; }; @@ -796,12 +796,12 @@ baseConfigurationReference = 94FEF20CFD3538E4AFD088A9 /* Pods-Zoomy_Example.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = P6ZSWCNHR5; + DEVELOPMENT_TEAM = 9W484F6894; INFOPLIST_FILE = Zoomy/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MODULE_NAME = ExampleApp; - PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; + PRODUCT_BUNDLE_IDENTIFIER = "org.lvnkmn.demo.Zoomy-Example"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; }; @@ -811,7 +811,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 42BF1574110A897A1BA3B86D /* Pods-Zoomy_Tests.debug.xcconfig */; buildSettings = { - DEVELOPMENT_TEAM = P6ZSWCNHR5; + DEVELOPMENT_TEAM = 9W484F6894; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", @@ -833,7 +833,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = A84BBBF5B0FB542C0D57CF39 /* Pods-Zoomy_Tests.release.xcconfig */; buildSettings = { - DEVELOPMENT_TEAM = P6ZSWCNHR5; + DEVELOPMENT_TEAM = 9W484F6894; FRAMEWORK_SEARCH_PATHS = ( "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", @@ -859,7 +859,7 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; DEBUG_INFORMATION_FORMAT = dwarf; - DEVELOPMENT_TEAM = P6ZSWCNHR5; + DEVELOPMENT_TEAM = 9W484F6894; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = Zoomy_ExampleUITests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; @@ -884,7 +884,7 @@ CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = P6ZSWCNHR5; + DEVELOPMENT_TEAM = 9W484F6894; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = Zoomy_ExampleUITests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 12.0; From 14f61908887a16ab168e6827abf72c0a02338428 Mon Sep 17 00:00:00 2001 From: menno Date: Sat, 22 May 2021 20:56:34 +0200 Subject: [PATCH 2/3] Fix typo's in documentation --- Zoomy/Classes/Structs/ImageZoomControllerSettings.swift | 2 +- Zoomy/Classes/TypeAliasses/TypeAliasses.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Zoomy/Classes/Structs/ImageZoomControllerSettings.swift b/Zoomy/Classes/Structs/ImageZoomControllerSettings.swift index fb6c71a..fa32852 100644 --- a/Zoomy/Classes/Structs/ImageZoomControllerSettings.swift +++ b/Zoomy/Classes/Structs/ImageZoomControllerSettings.swift @@ -8,7 +8,7 @@ public struct ImageZoomControllerSettings: ConfigurableUsingClosure { /// When scale of imageView is below this threshold when initial pinch gesture ends, the overlay will be dismissed public var zoomCancelingThreshold: ImageViewScale = 1.5 - /// The miximum zoomsScale at which an image will be displayed + /// The maximum zoomsScale at which an image will be displayed public var maximumZoomScale: ImageScale = 2 /// Causes the behavior of the ImageZoomController to (temporarily) be disabled when needed diff --git a/Zoomy/Classes/TypeAliasses/TypeAliasses.swift b/Zoomy/Classes/TypeAliasses/TypeAliasses.swift index d1c66fb..fbcd921 100644 --- a/Zoomy/Classes/TypeAliasses/TypeAliasses.swift +++ b/Zoomy/Classes/TypeAliasses/TypeAliasses.swift @@ -11,7 +11,7 @@ import UIKit /// The scale transformation that is applied on an imageView. /// The value of 1 results in the original view size. -/// The value of 2 retulst in twice the original view width and height. +/// The value of 2 retults in twice the original view width and height. /// The value of 0.5 results in half the original view width and height etc. /// /// Note that ImageViewScale is different from the scale of the image, see ImageScale. @@ -19,7 +19,7 @@ public typealias ImageViewScale = CGFloat /// The scale transformation that is applied on an image. /// The value of 1 results in the image size -> 1 pixel per point on screen. -/// The value of 2 retulst in twice the original view width and height -> 2 pixels per point on screen. +/// The value of 2 retults in twice the original view width and height -> 2 pixels per point on screen. /// The value of 0.5 results in half the original view width and height -> 0.5 pixels per point on screen etc. /// /// Note that ImageScale is different from the scale of the imageView, see ImageViewScale. From a2a8124e36d95cd1d869957d40d7f0aacc72e179 Mon Sep 17 00:00:00 2001 From: menno Date: Sun, 23 May 2021 13:19:04 +0200 Subject: [PATCH 3/3] ref #77 - make sure zoombehavior can be configured with minimum zoomscale --- .../Zoomy/ScreenWideImageViewController.swift | 3 ++- .../Classes/Classes/ImageZoomController.swift | 18 ++++++++++++++++-- ...ImageZoomControllerSettings+Equatable.swift | 1 + .../Structs/ImageZoomControllerSettings.swift | 11 +++++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Example/Zoomy/ScreenWideImageViewController.swift b/Example/Zoomy/ScreenWideImageViewController.swift index 91a0324..0cd996b 100644 --- a/Example/Zoomy/ScreenWideImageViewController.swift +++ b/Example/Zoomy/ScreenWideImageViewController.swift @@ -16,7 +16,8 @@ class ScreenWideImageViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - addZoombehavior(for: imageView, settings: Settings().with(actionOnTapOverlay: Action.dismissOverlay)) + addZoombehavior(for: imageView, settings: Settings().with(actionOnTapOverlay: Action.dismissOverlay) + .with(minimumZoomScale: 0)) } override func viewWillDisappear(_ animated: Bool) { diff --git a/Zoomy/Classes/Classes/ImageZoomController.swift b/Zoomy/Classes/Classes/ImageZoomController.swift index b0cc8f3..2e29eea 100644 --- a/Zoomy/Classes/Classes/ImageZoomController.swift +++ b/Zoomy/Classes/Classes/ImageZoomController.swift @@ -19,14 +19,14 @@ public class ImageZoomController: NSObject { weak public private(set) var imageView: Zoomable? /// When zoom gesture ends while currentZoomScale is below minimumZoomScale, the overlay will be dismissed - public private(set) lazy var minimumZoomScale = zoomScale(from: imageView) + public private(set) lazy var minimumZoomScale = neededMinimumZoomScale() // MARK: Internal Properties internal private(set) var image: UIImage? { didSet { guard let image = image else { return } logger.log("Changed to \(image)", atLevel: Loglevel.info) - minimumZoomScale = zoomScale(from: imageView) + minimumZoomScale = neededMinimumZoomScale() initialAbsoluteFrameOfImageView = absoluteFrame(of: imageView?.view) } } @@ -385,6 +385,20 @@ internal extension ImageZoomController { return CGSize(width: image.size.width * zoomScale, height: image.size.height * zoomScale) } + + func neededMinimumZoomScale() -> ImageScale { + let initialZoomScale = zoomScale(from: imageView) + if let minimumZoomScale = settings.minimumZoomScale { + if minimumZoomScale > initialZoomScale { + logger.logError("MinimumZoomScale (\(minimumZoomScale) specified in settings is greater than initial zoom scale (\(initialZoomScale)) and will be ignored") + return initialZoomScale + } else { + return minimumZoomScale + } + } else { + return initialZoomScale + } + } } //MARK: Other diff --git a/Zoomy/Classes/Extensions/ImageZoomControllerSettings+Equatable.swift b/Zoomy/Classes/Extensions/ImageZoomControllerSettings+Equatable.swift index df285d8..3293749 100644 --- a/Zoomy/Classes/Extensions/ImageZoomControllerSettings+Equatable.swift +++ b/Zoomy/Classes/Extensions/ImageZoomControllerSettings+Equatable.swift @@ -4,6 +4,7 @@ extension ImageZoomControllerSettings: Equatable { public static func ==(lhs: ImageZoomControllerSettings, rhs: ImageZoomControllerSettings) -> Bool { return lhs.zoomCancelingThreshold == rhs.zoomCancelingThreshold && + lhs.minimumZoomScale == rhs.minimumZoomScale && lhs.maximumZoomScale == rhs.maximumZoomScale && lhs.isEnabled == rhs.isEnabled && lhs.shouldDisplayBackground == rhs.shouldDisplayBackground && diff --git a/Zoomy/Classes/Structs/ImageZoomControllerSettings.swift b/Zoomy/Classes/Structs/ImageZoomControllerSettings.swift index fa32852..6c15e3c 100644 --- a/Zoomy/Classes/Structs/ImageZoomControllerSettings.swift +++ b/Zoomy/Classes/Structs/ImageZoomControllerSettings.swift @@ -8,6 +8,11 @@ public struct ImageZoomControllerSettings: ConfigurableUsingClosure { /// When scale of imageView is below this threshold when initial pinch gesture ends, the overlay will be dismissed public var zoomCancelingThreshold: ImageViewScale = 1.5 + /// The minimum zoomscale at which an image will be displayed + /// When this value is nil or greater than the initial imageScale, the initialImage scale will be used + /// Since images are often bigger than their initial frame size, this value is typically quite small. + public var minimumZoomScale: ImageScale? = nil + /// The maximum zoomsScale at which an image will be displayed public var maximumZoomScale: ImageScale = 2 @@ -99,6 +104,12 @@ public extension ImageZoomControllerSettings { return settings } + func with(minimumZoomScale: ImageScale?) -> Settings { + var settings = self + settings.minimumZoomScale = minimumZoomScale + return settings + } + func with(maximumZoomScale: ImageScale) -> Settings { var settings = self settings.maximumZoomScale = maximumZoomScale