Skip to content

Commit

Permalink
Merge pull request hyperoslo#134 from mhassanpur/master
Browse files Browse the repository at this point in the history
Fixes Swift 4 errors and warnings
  • Loading branch information
onmyway133 authored Sep 25, 2017
2 parents ec1200f + b5d86f1 commit 5cd6b4b
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "hyperoslo/Hue" "f82ffc7dd55d093d3acc6ce5b3d36ca259091fdd"
github "hyperoslo/Hue" "b0714f1b2a3d8d9e306eef4b8d86a2547baff556"
22 changes: 18 additions & 4 deletions Lightbox.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,12 @@
D523B0A01C43AA2A001AD1EC /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Hyper Interaktiv AS";
TargetAttributes = {
D523B0A81C43AA2A001AD1EC = {
CreatedOnToolsVersion = 7.2;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
};
};
Expand Down Expand Up @@ -262,14 +262,20 @@
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_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_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 @@ -313,14 +319,20 @@
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_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_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 @@ -369,7 +381,8 @@
PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Lightbox;
PRODUCT_NAME = Lightbox;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -392,7 +405,8 @@
PRODUCT_BUNDLE_IDENTIFIER = no.hyper.Lightbox;
PRODUCT_NAME = Lightbox;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -36,6 +37,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
2 changes: 1 addition & 1 deletion Source/Library/LightboxTransition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class LightboxTransition: UIPercentDrivenInteractiveTransition {

// MARK: - Pan gesture recognizer

func handlePanGesture(_ gesture: UIPanGestureRecognizer) {
@objc func handlePanGesture(_ gesture: UIPanGestureRecognizer) {
let translation = gesture.translation(in: scrollView)
let percentage = abs(translation.y) / UIScreen.main.bounds.height / 1.5
let velocity = gesture.velocity(in: scrollView)
Expand Down
22 changes: 11 additions & 11 deletions Source/LightboxConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ open class LightboxConfig {
public static var separatorColor = UIColor(hex: "3D4757")

public static var textAttributes = [
NSFontAttributeName: UIFont.systemFont(ofSize: 12),
NSForegroundColorAttributeName: UIColor(hex: "899AB8"),
NSParagraphStyleAttributeName: {
NSAttributedStringKey.font: UIFont.systemFont(ofSize: 12),
NSAttributedStringKey.foregroundColor: UIColor(hex: "899AB8"),
NSAttributedStringKey.paragraphStyle: {
var style = NSMutableParagraphStyle()
style.alignment = .center
return style
Expand All @@ -55,9 +55,9 @@ open class LightboxConfig {
public static var image: UIImage?

public static var textAttributes = [
NSFontAttributeName: UIFont.boldSystemFont(ofSize: 16),
NSForegroundColorAttributeName: UIColor.white,
NSParagraphStyleAttributeName: {
NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 16),
NSAttributedStringKey.foregroundColor: UIColor.white,
NSAttributedStringKey.paragraphStyle: {
var style = NSMutableParagraphStyle()
style.alignment = .center
return style
Expand All @@ -72,9 +72,9 @@ open class LightboxConfig {
public static var image: UIImage?

public static var textAttributes = [
NSFontAttributeName: UIFont.boldSystemFont(ofSize: 16),
NSForegroundColorAttributeName: UIColor(hex: "FA2F5B"),
NSParagraphStyleAttributeName: {
NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 16),
NSAttributedStringKey.foregroundColor: UIColor(hex: "FA2F5B"),
NSAttributedStringKey.paragraphStyle: {
var style = NSMutableParagraphStyle()
style.alignment = .center
return style
Expand All @@ -89,8 +89,8 @@ open class LightboxConfig {
public static var ellipsisColor = UIColor(hex: "899AB9")

public static var textAttributes = [
NSFontAttributeName: UIFont.systemFont(ofSize: 12),
NSForegroundColorAttributeName: UIColor(hex: "DBDBDB")
NSAttributedStringKey.font: UIFont.systemFont(ofSize: 12),
NSAttributedStringKey.foregroundColor: UIColor(hex: "DBDBDB")
]
}

Expand Down
2 changes: 1 addition & 1 deletion Source/LightboxController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ open class LightboxController: UIViewController {

// MARK: - Actions

func overlayViewDidTap(_ tapGestureRecognizer: UITapGestureRecognizer) {
@objc func overlayViewDidTap(_ tapGestureRecognizer: UITapGestureRecognizer) {
footerView.expand(false)
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Views/FooterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ open class FooterView: UIView {

extension FooterView: LayoutConfigurable {

public func configureLayout() {
@objc public func configureLayout() {
infoLabel.frame = CGRect(x: 17, y: 0, width: frame.width - 17 * 2, height: 35)
infoLabel.configureLayout()
}
Expand Down
6 changes: 3 additions & 3 deletions Source/Views/HeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ open class HeaderView: UIView {

// MARK: - Actions

func deleteButtonDidPress(_ button: UIButton) {
@objc func deleteButtonDidPress(_ button: UIButton) {
delegate?.headerView(self, didPressDeleteButton: button)
}

func closeButtonDidPress(_ button: UIButton) {
@objc func closeButtonDidPress(_ button: UIButton) {
delegate?.headerView(self, didPressCloseButton: button)
}
}
Expand All @@ -98,7 +98,7 @@ open class HeaderView: UIView {

extension HeaderView: LayoutConfigurable {

public func configureLayout() {
@objc public func configureLayout() {
closeButton.frame.origin = CGPoint(
x: bounds.width - closeButton.frame.width - 17, y: 0)

Expand Down
10 changes: 5 additions & 5 deletions Source/Views/InfoLabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ open class InfoLabel: UILabel {

// MARK: - Actions

func labelDidTap(_ tapGestureRecognizer: UITapGestureRecognizer) {
@objc func labelDidTap(_ tapGestureRecognizer: UITapGestureRecognizer) {
shortText = truncatedText
expanded ? collapse() : expand()
}
Expand All @@ -110,7 +110,7 @@ open class InfoLabel: UILabel {

if string.range(of: ellipsis) != nil {
let range = (string as NSString).range(of: ellipsis)
attributedString.addAttribute(NSForegroundColorAttributeName,
attributedString.addAttribute(NSAttributedStringKey.foregroundColor,
value: LightboxConfig.InfoLabel.ellipsisColor, range: range)
}

Expand All @@ -123,12 +123,12 @@ open class InfoLabel: UILabel {
return string.boundingRect(
with: CGSize(width: bounds.size.width, height: CGFloat.greatestFiniteMagnitude),
options: [.usesLineFragmentOrigin, .usesFontLeading],
attributes: [NSFontAttributeName: font],
attributes: [NSAttributedStringKey.font: font],
context: nil).height
}

fileprivate func numberOfLines(_ string: String) -> Int {
let lineHeight = "A".size(attributes: [NSFontAttributeName: font]).height
let lineHeight = "A".size(withAttributes: [NSAttributedStringKey.font: font]).height
let totalHeight = heightForString(string)

return Int(totalHeight / lineHeight)
Expand All @@ -139,7 +139,7 @@ open class InfoLabel: UILabel {

extension InfoLabel: LayoutConfigurable {

public func configureLayout() {
@objc public func configureLayout() {
shortText = truncatedText
expanded ? expand() : collapse()
}
Expand Down
8 changes: 4 additions & 4 deletions Source/Views/PageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class PageView: UIScrollView {

// MARK: - Recognizers

func scrollViewDoubleTapped(_ recognizer: UITapGestureRecognizer) {
@objc func scrollViewDoubleTapped(_ recognizer: UITapGestureRecognizer) {
let pointInView = recognizer.location(in: imageView)
let newZoomScale = zoomScale > minimumZoomScale
? minimumZoomScale
Expand All @@ -118,7 +118,7 @@ class PageView: UIScrollView {
zoom(to: rectToZoomTo, animated: true)
}

func viewTapped(_ recognizer: UITapGestureRecognizer) {
@objc func viewTapped(_ recognizer: UITapGestureRecognizer) {
pageViewDelegate?.pageViewDidTouch(self)
}

Expand Down Expand Up @@ -177,7 +177,7 @@ class PageView: UIScrollView {

// MARK: - Action

func playButtonTouched(_ button: UIButton) {
@objc func playButtonTouched(_ button: UIButton) {
guard let videoURL = image.videoURL else { return }

pageViewDelegate?.pageView(self, didTouchPlayButton: videoURL as URL)
Expand All @@ -198,7 +198,7 @@ class PageView: UIScrollView {

extension PageView: LayoutConfigurable {

func configureLayout() {
@objc func configureLayout() {
contentFrame = frame
contentSize = frame.size
imageView.frame = frame
Expand Down

0 comments on commit 5cd6b4b

Please sign in to comment.