Index check before switching tabs.
This commit is contained in:
parent
547c3ad2a4
commit
6e5980af64
@ -84,16 +84,22 @@ import VDSColorTokens
|
|||||||
// MARK: - TabBarProtocol
|
// MARK: - TabBarProtocol
|
||||||
@MainActor
|
@MainActor
|
||||||
public func highlightTab(at index: Int) {
|
public func highlightTab(at index: Int) {
|
||||||
guard let newSelectedItem = items?[index] else { return }
|
guard let items = items, index < items.count else {
|
||||||
|
MVMCoreLoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject(title: nil, messageToLog: "Tab index \(index) is greater than the number of tabs available (\(items?.count ?? 0).", code: 0, domain: ErrorDomainSystem, location: #function)!)
|
||||||
|
return
|
||||||
|
}
|
||||||
tabModel.selectedTab = index
|
tabModel.selectedTab = index
|
||||||
selectedItem = newSelectedItem
|
selectedItem = items[index]
|
||||||
}
|
}
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
public func selectTab(at index: Int) {
|
public func selectTab(at index: Int) {
|
||||||
guard let newSelectedItem = items?[index] else { return }
|
guard let items = items, index < items.count else {
|
||||||
selectedItem = newSelectedItem
|
MVMCoreLoggingHandler.shared()?.addError(toLog: MVMCoreErrorObject(title: nil, messageToLog: "Tab index \(index) is greater than the number of tabs available (\(items?.count ?? 0).", code: 0, domain: ErrorDomainSystem, location: #function)!)
|
||||||
tabBar(self, didSelect: newSelectedItem)
|
return
|
||||||
|
}
|
||||||
|
selectedItem = items[index]
|
||||||
|
tabBar(self, didSelect: items[index])
|
||||||
}
|
}
|
||||||
|
|
||||||
public func currentTabIndex() -> Int { tabModel.selectedTab }
|
public func currentTabIndex() -> Int { tabModel.selectedTab }
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user