Skip to content
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
13 changes: 13 additions & 0 deletions Sources/ButtonBarPagerTabStripViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public struct ButtonBarPagerTabStripSettings {
}

open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, PagerTabStripDataSource, PagerTabStripIsProgressiveDelegate, UICollectionViewDelegate, UICollectionViewDataSource {

private var shouldUpdateContent = true

public var settings = ButtonBarPagerTabStripSettings()

Expand Down Expand Up @@ -192,12 +194,23 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa
// MARK: - Public Methods

open override func reloadPagerTabStripView() {
shouldUpdateContent = false
super.reloadPagerTabStripView()
shouldUpdateContent = true

guard isViewLoaded else { return }
buttonBarView.reloadData()
cachedCellWidths = calculateWidths()
buttonBarView.layoutIfNeeded()
updateContent()
buttonBarView.moveTo(index: currentIndex, animated: false, swipeDirection: .none, pagerScroll: .yes)
}

open override func updateContent() {
if shouldUpdateContent {
super.updateContent()
}
}

open func calculateStretchedCellWidths(_ minimumCellWidths: [CGFloat], suggestedStretchedCellWidth: CGFloat, previousNumberOfLargeCells: Int) -> CGFloat {
var numberOfLargeCells = 0
Expand Down
5 changes: 4 additions & 1 deletion Sources/ButtonBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ open class ButtonBarView: UICollectionView {
open func move(fromIndex: Int, toIndex: Int, progressPercentage: CGFloat, pagerScroll: PagerScroll) {
selectedIndex = progressPercentage > 0.5 ? toIndex : fromIndex

let fromFrame = layoutAttributesForItem(at: IndexPath(item: fromIndex, section: 0))!.frame
var fromFrame = CGRect.zero
if let layout = layoutAttributesForItem(at: IndexPath(item: fromIndex, section: 0)) {
fromFrame = layout.frame
}
let numberOfItems = dataSource!.collectionView(self, numberOfItemsInSection: 0)

var toFrame: CGRect
Expand Down