Skip to content

Commit

Permalink
Merge branch 'release/4.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
menno committed May 23, 2021
2 parents fc1bb67 + a2a8124 commit 38dc99d
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 17 deletions.
22 changes: 11 additions & 11 deletions Example/Zoomy.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand All @@ -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)",
Expand All @@ -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)",
Expand All @@ -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;
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion Example/Zoomy/ScreenWideImageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
18 changes: 16 additions & 2 deletions Zoomy/Classes/Classes/ImageZoomController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
13 changes: 12 additions & 1 deletion Zoomy/Classes/Structs/ImageZoomControllerSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ 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 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

/// Causes the behavior of the ImageZoomController to (temporarily) be disabled when needed
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Zoomy/Classes/TypeAliasses/TypeAliasses.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ 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.
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.
Expand Down

0 comments on commit 38dc99d

Please sign in to comment.