Skip to content

Commit

Permalink
linted
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Skiba committed Jul 20, 2016
1 parent a8a7d2e commit a2d3ac6
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 19 deletions.
35 changes: 34 additions & 1 deletion RIGImageGallery.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@
72060F4C1D2FFA6C001281E0 /* Sources */,
72060F4D1D2FFA6C001281E0 /* Frameworks */,
72060F4E1D2FFA6C001281E0 /* Resources */,
7264CA1D1D3FC01C00033FC4 /* Swiftlint */,
);
buildRules = (
);
Expand All @@ -242,6 +243,7 @@
72A828061C68F24500B25CEE /* Frameworks */,
72A828071C68F24500B25CEE /* Resources */,
72BA263B1C6B97A500F1FE22 /* Embed Frameworks */,
7264CA1E1D3FC02E00033FC4 /* SwiftLint */,
);
buildRules = (
);
Expand Down Expand Up @@ -307,8 +309,8 @@
projectDirPath = "";
projectRoot = "";
targets = (
72A828081C68F24500B25CEE /* RIGImageGalleryDemo */,
72BA26511C6B985900F1FE22 /* RIGImageGallery */,
72A828081C68F24500B25CEE /* RIGImageGalleryDemo */,
72060F4F1D2FFA6C001281E0 /* RIGImageGalleryTests */,
);
};
Expand Down Expand Up @@ -340,6 +342,37 @@
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
7264CA1D1D3FC01C00033FC4 /* Swiftlint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = Swiftlint;
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
};
7264CA1E1D3FC02E00033FC4 /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = SwiftLint;
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\nswiftlint\nelse\necho \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
72060F4C1D2FFA6C001281E0 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down
4 changes: 2 additions & 2 deletions RIGImageGallery/RIGAutoCenteringScrollView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ private extension RIGAutoCenteringScrollView {
let vertical: CGFloat
let horizontal: CGFloat

if (contentSize.width < adjustedSize.width) {
if contentSize.width < adjustedSize.width {
horizontal = floor((adjustedSize.width - contentSize.width) * 0.5)
}
else {
horizontal = 0
}

if (contentSize.height < adjustedSize.height) {
if contentSize.height < adjustedSize.height {
vertical = floor((adjustedSize.height - contentSize.height) * 0.5)
}
else {
Expand Down
19 changes: 10 additions & 9 deletions RIGImageGallery/RIGImageGalleryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,29 @@ import UIKit

public class RIGImageGalleryViewController: UIPageViewController {

public typealias GalleryPositionUpdateHandler = (gallery: RIGImageGalleryViewController, position: Int, total: Int) -> ()
public typealias ActionButtonPressedHandler = (gallery: RIGImageGalleryViewController, item: RIGImageGalleryItem) -> ()
public typealias GalleryEventHandler = RIGImageGalleryViewController -> ()
public typealias IndexUpdateHandler = Int -> ()

/// An optional closure to execute if the action button is tapped
public var actionButtonHandler: ((gallery: RIGImageGalleryViewController, item:RIGImageGalleryItem) -> ())?
public var actionButtonHandler: ActionButtonPressedHandler?

/// An optional closure to allow cutom trait collection change handling
public var traitCollectionChangeHandler: (RIGImageGalleryViewController -> ())? {
public var traitCollectionChangeHandler: GalleryEventHandler? {
didSet {
traitCollectionChangeHandler?(self)
}
}

/// An optional closure to execute when the active index is updated
public var indexUpdateHandler: (Int -> ())?
public var indexUpdateHandler: IndexUpdateHandler?

/// An optional closure to handle dismissing the gallery, if this is nil the view will call `dismissViewControllerAnimated(true, completion: nil)`, if this is non-nil, the view controller will not dismiss itself
public var dismissHandler: (RIGImageGalleryViewController -> ())?
public var dismissHandler: GalleryEventHandler?

/// An optional closure to handle updating the count text
public var countUpdateHandler: ((gallery: RIGImageGalleryViewController, position: Int, total: Int) -> ())? {
public var countUpdateHandler: GalleryPositionUpdateHandler? {
didSet {
updateCountText()
}
Expand Down Expand Up @@ -104,8 +109,6 @@ public class RIGImageGalleryViewController: UIPageViewController {

/**
A convenience initializer to return a configured empty RIGImageGalleryViewController
- returns: the RIGImageGalleryViewController
*/
public convenience init() {
self.init(images: [])
Expand All @@ -115,8 +118,6 @@ public class RIGImageGalleryViewController: UIPageViewController {
A convenience initializer to return a configured RIGImageGalleryViewController with an array of images
- parameter images: The images to use in the gallery
- returns: the RIGImageGalleryViewController
*/
public convenience init(images: [RIGImageGalleryItem]) {
self.init(transitionStyle: .Scroll, navigationOrientation: .Horizontal, options: [UIPageViewControllerOptionInterPageSpacingKey: 20])
Expand Down
2 changes: 1 addition & 1 deletion RIGImageGalleryDemo/View Controller/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private extension ViewController {
dismissViewControllerAnimated(true, completion: nil)
}

func actionButtonHandler(_: RIGImageGalleryViewController,galleryItem: RIGImageGalleryItem) {
func actionButtonHandler(_: RIGImageGalleryViewController, galleryItem: RIGImageGalleryItem) {
}

func updateCount(gallery: RIGImageGalleryViewController, position: Int, total: Int) {
Expand Down
6 changes: 3 additions & 3 deletions RIGImageGalleryTests/AutoCenteringScrollViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import XCTest
class AutoCenteringScrollViewTests: XCTestCase {

var scrollView = RIGAutoCenteringScrollView(frame: CGRect())

override func setUp() {
super.setUp()
scrollView = RIGAutoCenteringScrollView(frame: CGRect(x: 0, y: 0, width: 400, height: 400))
}

override func tearDown() {
super.tearDown()
}

func testSettingInsets() {
XCTAssertEqual(scrollView.zoomScale, 1, "The scroll view's zoom scale should start at 1")
XCTAssertEqual(scrollView.minimumZoomScale, 1, "The scroll view's min zoom scale should start at 1")
Expand Down
5 changes: 4 additions & 1 deletion RIGImageGalleryTests/ImageGalleryViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ImageGalleryViewControllerTests: XCTestCase {
imageGallery.viewWillLayoutSubviews()
imageGallery.viewWillAppear(false)
}

override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
Expand Down Expand Up @@ -81,11 +81,14 @@ class ImageGalleryViewControllerTests: XCTestCase {

func testPageViewController() {
XCTAssertNotNil(imageGallery.viewControllers?.first as? RIGSingleImageViewController)
// swiftlint:disable:next force_cast
let firstView = imageGallery.viewControllers!.first as! RIGSingleImageViewController
XCTAssertEqual(firstView.viewerItem, imageGallery.images.first, "The first view should have the first image in the gallery")
XCTAssertNil(imageGallery.pageViewController(imageGallery, viewControllerBeforeViewController: firstView), "The view before the first view should be nil")
// swiftlint:disable:next force_cast
let secondView = imageGallery.pageViewController(imageGallery, viewControllerAfterViewController: firstView) as! RIGSingleImageViewController
XCTAssertEqual(secondView.viewerItem, imageGallery.images[1], "The second view should have the second image in the gallery")
// swiftlint:disable:next force_cast
XCTAssertEqual((imageGallery.pageViewController(imageGallery, viewControllerBeforeViewController: secondView) as! RIGSingleImageViewController).viewerItem, firstView.viewerItem, "the view before the second view should be the first view, which is testable by comparing viewer items")
let thirdView = imageGallery.pageViewController(imageGallery, viewControllerAfterViewController: secondView)!
let fourthView = imageGallery.pageViewController(imageGallery, viewControllerAfterViewController: thirdView)!
Expand Down
2 changes: 1 addition & 1 deletion RIGImageGalleryTests/SingleImageViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SingleImageViewControllerTests: XCTestCase {
override func setUp() {
super.setUp()
}

override func tearDown() {
super.tearDown()
}
Expand Down
2 changes: 1 addition & 1 deletion RIGImageGalleryTests/TestingExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ extension UIImage {

return genericImage
}

}

0 comments on commit a2d3ac6

Please sign in to comment.