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

swift 4.2 #26

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
35 changes: 28 additions & 7 deletions RIGImageGallery.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -327,12 +327,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0820;
LastUpgradeCheck = 0810;
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = Raizlabs;
TargetAttributes = {
72060F4F1D2FFA6C001281E0 = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 0810;
LastSwiftMigration = 1010;
};
722523671E3276F300D50D16 = {
CreatedOnToolsVersion = 8.2.1;
Expand All @@ -348,7 +348,7 @@
72BA26511C6B985900F1FE22 = {
CreatedOnToolsVersion = 7.2.1;
DevelopmentTeam = 336S848KQ4;
LastSwiftMigration = 0810;
LastSwiftMigration = 1010;
};
};
};
Expand Down Expand Up @@ -519,7 +519,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.raizlabs.RIGImageGalleryTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -532,7 +533,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.raizlabs.RIGImageGalleryTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down Expand Up @@ -577,14 +579,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
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_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
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;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -627,14 +637,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
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_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
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;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -714,7 +732,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -734,7 +753,8 @@
PRODUCT_BUNDLE_IDENTIFIER = com.raizlabs.RIGImageGallery;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -757,6 +777,7 @@
722523701E3276F300D50D16 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
72A827F31C68F17900B25CEE /* Build configuration list for PBXProject "RIGImageGallery" */ = {
isa = XCConfigurationList;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,8 +26,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
codeCoverageEnabled = "YES"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand Down
4 changes: 2 additions & 2 deletions RIGImageGallery/RIGAutoCenteringScrollView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private extension RIGAutoCenteringScrollView {
updateConstraintsIfNeeded()
layoutIfNeeded()

let adjustedFrame = UIEdgeInsetsInsetRect(frame, baseInsets)
let adjustedFrame = frame.inset(by: baseInsets)

let wScale = adjustedFrame.width / image.size.width
let hScale = adjustedFrame.height / image.size.height
Expand Down Expand Up @@ -124,7 +124,7 @@ private extension RIGAutoCenteringScrollView {
guard !contentSize.equalTo(CGSize()) else {
return
}
let adjustedSize = UIEdgeInsetsInsetRect(bounds, baseInsets).size
let adjustedSize = bounds.inset(by: baseInsets).size
let vertical: CGFloat
let horizontal: CGFloat

Expand Down
42 changes: 31 additions & 11 deletions RIGImageGallery/RIGImageGalleryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ open class RIGImageGalleryViewController: UIPageViewController {
return
}
let newView = createNewPage(for: images[currentImage])
let direction: UIPageViewControllerNavigationDirection
let direction: UIPageViewController.NavigationDirection
if self.currentImage < currentImage {
direction = .forward
}
Expand All @@ -100,10 +100,10 @@ open class RIGImageGalleryViewController: UIPageViewController {
}

/// The label used to display the current position in the array
open let countLabel: UILabel = {
public let countLabel: UILabel = {
let counter = UILabel()
counter.textColor = .white
counter.font = UIFont.preferredFont(forTextStyle: UIFontTextStyle.subheadline)
counter.font = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.subheadline)
return counter
}()

Expand All @@ -120,12 +120,15 @@ open class RIGImageGalleryViewController: UIPageViewController {
- parameter images: The images to use in the gallery
*/
public convenience init(images: [RIGImageGalleryItem]) {
self.init(transitionStyle: .scroll, navigationOrientation: .horizontal, options: [UIPageViewControllerOptionInterPageSpacingKey: 20])
self.init(transitionStyle: .scroll, navigationOrientation: .horizontal, options: convertToOptionalUIPageViewControllerOptionsKeyDictionary([convertFromUIPageViewControllerOptionsKey(UIPageViewController.OptionsKey.interPageSpacing): 20]))
self.images = images
}

public override init(transitionStyle style: UIPageViewControllerTransitionStyle, navigationOrientation: UIPageViewControllerNavigationOrientation, options: [String : Any]?) {
super.init(transitionStyle: style, navigationOrientation: navigationOrientation, options: options)
public override init(transitionStyle style: UIPageViewController.TransitionStyle, navigationOrientation: UIPageViewController.NavigationOrientation, options: [UIPageViewController.OptionsKey : Any]?) {
// Local variable inserted by Swift 4.2 migrator.
let options = convertFromOptionalUIPageViewControllerOptionsKeyDictionary(options)

super.init(transitionStyle: style, navigationOrientation: navigationOrientation, options: convertToOptionalUIPageViewControllerOptionsKeyDictionary(options))
dataSource = self
delegate = self
automaticallyAdjustsScrollViewInsets = false
Expand Down Expand Up @@ -213,16 +216,16 @@ extension RIGImageGalleryViewController: UIGestureRecognizerDelegate {

extension RIGImageGalleryViewController {

func toggleBarVisiblity(_ recognizer: UITapGestureRecognizer) {
@objc func toggleBarVisiblity(_ recognizer: UITapGestureRecognizer) {
navigationBarsHidden = !navigationBarsHidden
updateBarStatus(animated: true)
}

func toggleZoom(_ recognizer: UITapGestureRecognizer) {
@objc func toggleZoom(_ recognizer: UITapGestureRecognizer) {
currentImageViewController?.scrollView.toggleZoom()
}

func dismissPhotoView(_ sender: UIBarButtonItem) {
@objc func dismissPhotoView(_ sender: UIBarButtonItem) {
if dismissHandler != nil {
dismissHandler?(self)
}
Expand All @@ -231,7 +234,7 @@ extension RIGImageGalleryViewController {
}
}

func performAction(_ sender: UIBarButtonItem) {
@objc func performAction(_ sender: UIBarButtonItem) {
if let item = currentImageViewController?.viewerItem {
actionButtonHandler?(self, item)
}
Expand Down Expand Up @@ -307,7 +310,7 @@ private extension RIGImageGalleryViewController {
}

func handleImagesUpdate(oldValue: [RIGImageGalleryItem]) {
for viewController in childViewControllers {
for viewController in children {
if let index = indexOf(viewController: viewController, imagesArray: oldValue),
let childView = viewController as? RIGSingleImageViewController, index < images.count {
DispatchQueue.main.async { [unowned self] in
Expand Down Expand Up @@ -335,3 +338,20 @@ private extension RIGImageGalleryViewController {
}

}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertFromOptionalUIPageViewControllerOptionsKeyDictionary(_ input: [UIPageViewController.OptionsKey: Any]?) -> [String: Any]? {
guard let input = input else { return nil }
return Dictionary(uniqueKeysWithValues: input.map {key, value in (key.rawValue, value)})
}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertToOptionalUIPageViewControllerOptionsKeyDictionary(_ input: [String: Any]?) -> [UIPageViewController.OptionsKey: Any]? {
guard let input = input else { return nil }
return Dictionary(uniqueKeysWithValues: input.map { key, value in (UIPageViewController.OptionsKey(rawValue: key), value)})
}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertFromUIPageViewControllerOptionsKey(_ input: UIPageViewController.OptionsKey) -> String {
return input.rawValue
}
4 changes: 2 additions & 2 deletions RIGImageGallery/RIGSingleImageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ open class RIGSingleImageViewController: UIViewController {
}
}

open let scrollView = RIGAutoCenteringScrollView()
public let scrollView = RIGAutoCenteringScrollView()
open var activityIndicator: UIActivityIndicatorView? {
didSet {
oldValue?.removeFromSuperview()
Expand All @@ -42,7 +42,7 @@ open class RIGSingleImageViewController: UIViewController {
view.clipsToBounds = true
view.addSubview(scrollView)
let indicatorView = UIActivityIndicatorView()
indicatorView.activityIndicatorViewStyle = .gray
indicatorView.style = .gray
indicatorView.hidesWhenStopped = true
self.activityIndicator = indicatorView
configureConstraints()
Expand Down