Merge branch 'feature/atomic_vds_tabs' into feature/vds_batch_two

This commit is contained in:
Matt Bruce 2024-01-19 16:02:39 -06:00
commit e0adf8b55d
2 changed files with 20 additions and 13 deletions

View File

@ -25,7 +25,21 @@ import VDS
open var additionalData: [AnyHashable : Any]? open var additionalData: [AnyHashable : Any]?
//delegate //delegate
weak public var delegate: TabsDelegate? weak public var delegate: TabsDelegate? {
didSet {
if let delegate {
onTabDidSelect = { [weak self] index in
guard let self else { return }
delegate.didSelectItem(.init(row: index, section: 0), tabs: self)
}
onTabShouldSelect = { [weak self] index in
guard let self else { return true }
return delegate.shouldSelectItem(.init(row: index, section: 0), tabs: self)
}
}
}
}
//------------------------------------------------- //-------------------------------------------------
// MARK: - Layout Views // MARK: - Layout Views
@ -55,17 +69,5 @@ import VDS
selectedIndex = viewModel.selectedIndex selectedIndex = viewModel.selectedIndex
surface = viewModel.style ?? .light surface = viewModel.style ?? .light
tabModels = viewModel.tabs.compactMap { TabModel(text: $0.label.text) } tabModels = viewModel.tabs.compactMap { TabModel(text: $0.label.text) }
if let delegate {
onTabDidSelect = { [weak self] index in
guard let self else { return }
delegate.didSelectItem(.init(row: index, section: 0), tabs: self)
}
onTabShouldSelect = { [weak self] index in
guard let self else { return true }
return delegate.shouldSelectItem(.init(row: index, section: 0), tabs: self)
}
}
} }
} }

View File

@ -8,6 +8,7 @@
import Foundation import Foundation
import MVMCore import MVMCore
import VDSColorTokens
open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, TabsDelegate, MVMCorePresentationDelegateProtocol, SubNavSwipeNavigationProtocol { open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, TabsDelegate, MVMCorePresentationDelegateProtocol, SubNavSwipeNavigationProtocol {
@ -29,6 +30,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol,
private var tabsModel: TabsModel private var tabsModel: TabsModel
public lazy var tabs: Tabs = { public lazy var tabs: Tabs = {
let tabs = Tabs(model: tabsModel, delegateObjectIVar, nil) let tabs = Tabs(model: tabsModel, delegateObjectIVar, nil)
tabs.fillContainer = true
tabs.delegate = self tabs.delegate = self
return tabs return tabs
}() }()
@ -109,6 +111,9 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol,
open override func pageShown() { open override func pageShown() {
// Currently not calling super until we can decouple page shown logics for managers. // Currently not calling super until we can decouple page shown logics for managers.
hideNavigationBarLine(true) hideNavigationBarLine(true)
//set the tabs backgroundColor
tabs.backgroundColor = (viewController as? PageProtocol)?.pageModel?.navigationBar?.backgroundColor?.uiColor ?? VDSColor.backgroundPrimaryLight
} }
open override func viewWillDisappear(_ animated: Bool) { open override func viewWillDisappear(_ animated: Bool) {