tab list fix

This commit is contained in:
Pfeil, Scott Robert 2020-07-20 14:46:56 -04:00
parent 192a590817
commit 2fceb8de9e
2 changed files with 7 additions and 4 deletions

View File

@ -133,11 +133,13 @@ import UIKit
public func selectIndex(_ index: Int, animated: Bool) {
guard let _ = collectionView, tabsModel?.tabs.count ?? 0 > 0 else {
selectedIndex = index
tabsModel?.selectedIndex = index
return
}
MVMCoreDispatchUtility.performBlock(onMainThread: {
let currentIndex = self.selectedIndex
self.selectedIndex = index
self.tabsModel?.selectedIndex = index
self.deselect(indexPath: IndexPath(row: currentIndex, section: 0))
self.selectItem(atIndexPath: IndexPath(row: index, section: 0), animated: animated)
})

View File

@ -45,8 +45,7 @@ import UIKit
public override func reset() {
super.reset()
// TODO: Uncomment when finished with Ryan Tab pr.
//tabs.reset()
tabs.reset()
}
public override class func estimatedHeight(with model: MoleculeModelProtocol, _ delegateObject: MVMCoreUIDelegateObject?) -> CGFloat? {
@ -66,9 +65,11 @@ extension TabsTableViewCell: TabsDelegate {
public func didSelectItem(_ indexPath: IndexPath, tabs: Tabs) {
let index = indexPath.row
if let model = tabsListItemModel, index < model.molecules.count {
if let model = tabsListItemModel,
index < model.molecules.count,
let cellIndexPath = delegateObject?.moleculeDelegate?.getIndexPath(for: model) {
let molecules = model.molecules[index]
delegateObject?.moleculeDelegate?.addMolecules(molecules, indexPath: indexPath, animation: index < previousTabIndex ? .left : .right)
delegateObject?.moleculeDelegate?.addMolecules(molecules, indexPath: cellIndexPath, animation: index < previousTabIndex ? .left : .right)
}
}
}