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

carousel bug fixes #63

Merged
merged 6 commits into from
Oct 19, 2017
Merged
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## Master

## 3.2.1 (2017-10-19)

##### Bug Fixes

* Fixes issue with loading the first image when a page isn't specified in the presentation completion block
* Fixes unit tests

## 3.2.0 (2017-10-18)

##### Enhancements
2 changes: 1 addition & 1 deletion Example/SwiftPhotoGallery/Info.plist
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.2.0</string>
<string>3.2.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
4 changes: 3 additions & 1 deletion Example/SwiftPhotoGallery/MainCollectionViewController.swift
Original file line number Diff line number Diff line change
@@ -53,7 +53,9 @@ class MainCollectionViewController: UICollectionViewController {
gallery.modalPresentationStyle = .custom
gallery.transitioningDelegate = self

// present(gallery, animated: true, completion: nil)
/// Load the first page like this:

// present(gallery, animated: true, completion: nil)

/// Or load on a specific page like this:

2 changes: 1 addition & 1 deletion Example/Tests/Info.plist
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>3.2.0</string>
<string>3.2.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
4 changes: 3 additions & 1 deletion Example/Tests/SwiftPhotoGalleryTests.swift
Original file line number Diff line number Diff line change
@@ -25,7 +25,8 @@ class SwiftPhotoGalleryTests: XCTestCase {

func testProgramaticInitialization() {
testGallery.viewDidLoad()

testGallery.isRevolvingCarouselEnabled = false

expect(self.testGallery.delegate).toNot(beNil())
expect(self.testGallery.delegate) === testHelper

@@ -44,6 +45,7 @@ class SwiftPhotoGalleryTests: XCTestCase {

func testFirstImagesLoadedAfterInitialization() {
testGallery.viewDidLoad()
testGallery.isRevolvingCarouselEnabled = false

let indexPath = IndexPath(item: 0, section: 0)
testGallery.imageCollectionView.reloadItems(at: [indexPath])
19 changes: 16 additions & 3 deletions Pod/Classes/SwiftPhotoGallery.swift
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ import UIKit
public class SwiftPhotoGallery: UIViewController {

fileprivate var animateImageTransition = false
fileprivate var isViewFirstAppearing = true

public weak var dataSource: SwiftPhotoGalleryDataSource?
public weak var delegate: SwiftPhotoGalleryDelegate?
@@ -72,10 +73,11 @@ public class SwiftPhotoGallery: UIViewController {
}
get {
pageBeforeRotation = Int(imageCollectionView.contentOffset.x / imageCollectionView.frame.size.width)
guard isRevolvingCarouselEnabled else {
if isRevolvingCarouselEnabled {
return Int(imageCollectionView.contentOffset.x / imageCollectionView.frame.size.width) - 1
} else {
return Int(imageCollectionView.contentOffset.x / imageCollectionView.frame.size.width)
}
return Int(imageCollectionView.contentOffset.x / imageCollectionView.frame.size.width) - 1
}
}

@@ -170,6 +172,13 @@ public class SwiftPhotoGallery: UIViewController {
setupGestureRecognizers()
}

public override func viewDidAppear(_ animated: Bool) {
if currentPage < 0 {
currentPage = 0
isViewFirstAppearing = false
}
}

#if os(iOS)
public override var prefersStatusBarHidden: Bool {
get {
@@ -416,7 +425,11 @@ extension SwiftPhotoGallery: UICollectionViewDataSource {
cell.image = getImage(currentPage: 0)
case UICollectionElementKindSectionHeader:
cell = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionElementKindSectionHeader, withReuseIdentifier: "SwiftPhotoGalleryCell", for: indexPath) as! SwiftPhotoGalleryCell
cell.image = getImage(currentPage: numberOfImages - 1)
if isViewFirstAppearing {
cell.image = getImage(currentPage: 0)
} else {
cell.image = getImage(currentPage: numberOfImages - 1)
}
default:
assertionFailure("Unexpected element kind")
}
2 changes: 1 addition & 1 deletion SwiftPhotoGallery.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Pod::Spec.new do |s|
s.name = "SwiftPhotoGallery"
s.version = "3.2.0"
s.version = "3.2.1"
s.summary = "Photo gallery for iOS and tvOS written in Swift"
s.description = <<-DESC
"Photo gallery for iOS and tvOS written in Swift. Photos can be panned and zoomed (iOS). Includes a customizable page indicator, support for any orientation (iOS), and supports images of varying sizes. Includes unit tests."