diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index 178e9c3d..dae0e818 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -25,7 +25,21 @@ import VDS open var additionalData: [AnyHashable : Any]? //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 @@ -55,17 +69,5 @@ import VDS selectedIndex = viewModel.selectedIndex surface = viewModel.style ?? .light 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) - } - } } } diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index 85e487ae..30585d46 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -8,6 +8,7 @@ import Foundation import MVMCore +import VDSColorTokens open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, TabsDelegate, MVMCorePresentationDelegateProtocol, SubNavSwipeNavigationProtocol { @@ -29,6 +30,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, private var tabsModel: TabsModel public lazy var tabs: Tabs = { let tabs = Tabs(model: tabsModel, delegateObjectIVar, nil) + tabs.fillContainer = true tabs.delegate = self return tabs }() @@ -109,6 +111,9 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, open override func pageShown() { // Currently not calling super until we can decouple page shown logics for managers. hideNavigationBarLine(true) + + //set the tabs backgroundColor + tabs.backgroundColor = (viewController as? PageProtocol)?.pageModel?.navigationBar?.backgroundColor?.uiColor ?? VDSColor.backgroundPrimaryLight } open override func viewWillDisappear(_ animated: Bool) {