From 7469a5249f9a5c224e3028394de91c3b1283bd55 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 30 Jan 2024 11:31:06 -0600 Subject: [PATCH 1/2] added fillContainer to model/view Signed-off-by: Matt Bruce --- .../Molecules/HorizontalCombinationViews/Tabs.swift | 1 + .../Molecules/HorizontalCombinationViews/TabsModel.swift | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift index dae0e818..e070b8e6 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/Tabs.swift @@ -68,6 +68,7 @@ import VDS size = viewModel.size selectedIndex = viewModel.selectedIndex surface = viewModel.style ?? .light + fillContainer = viewModel.fillContainer tabModels = viewModel.tabs.compactMap { TabModel(text: $0.label.text) } } } diff --git a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift index 648357b3..24933f45 100644 --- a/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift +++ b/MVMCoreUI/Atomic/Molecules/HorizontalCombinationViews/TabsModel.swift @@ -21,6 +21,7 @@ open class TabsModel: MoleculeModelProtocol { open var orientation: Tabs.Orientation = .horizontal open var indicatorPosition: Tabs.IndicatorPosition = .bottom open var overflow: Tabs.Overflow = .scroll + open var fillContainer: Bool = false open var size: Tabs.Size = .medium public var backgroundColor: Color? @@ -35,6 +36,7 @@ open class TabsModel: MoleculeModelProtocol { case selectedIndex case orientation case indicatorPosition + case fillContainer case overflow case size case style @@ -49,6 +51,11 @@ open class TabsModel: MoleculeModelProtocol { id = try typeContainer.decodeIfPresent(String.self, forKey: .id) ?? UUID().uuidString tabs = try typeContainer.decode([TabItemModel].self, forKey: .tabs) style = try typeContainer.decodeIfPresent(Surface.self, forKey: .style) + + if let fillContainer = try typeContainer.decodeIfPresent(Bool.self, forKey: .fillContainer) { + self.fillContainer = fillContainer + } + if let index = try typeContainer.decodeIfPresent(Int.self, forKey: .selectedIndex) { selectedIndex = index } @@ -76,6 +83,7 @@ open class TabsModel: MoleculeModelProtocol { try container.encode(moleculeName, forKey: .moleculeName) try container.encode(tabs, forKey: .tabs) try container.encode(selectedIndex, forKey: .selectedIndex) + try container.encode(fillContainer, forKey: .fillContainer) try container.encodeIfPresent(style, forKey: .style) try container.encode(orientation, forKey: .orientation) try container.encode(overflow, forKey: .overflow) From d56f34258dd7006feb851f56bc696f778134cc52 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Tue, 30 Jan 2024 11:31:18 -0600 Subject: [PATCH 2/2] added var to determine fillContainer Signed-off-by: Matt Bruce --- MVMCoreUI/Managers/SubNav/SubNavManagerController.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift index c5da68c7..6a959440 100644 --- a/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift +++ b/MVMCoreUI/Managers/SubNav/SubNavManagerController.swift @@ -11,7 +11,9 @@ import MVMCore import VDSColorTokens open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, TabsDelegate, MVMCorePresentationDelegateProtocol, SubNavSwipeNavigationProtocol { - + /// The number of tabs count or less that will turn on the fillContainer + public var fillContainerTabsCount = 2 { didSet { tabs.fillContainer = tabsModel.tabs.count <= fillContainerTabsCount }} + /// The current managed view controller private var viewController: UIViewController @@ -31,7 +33,6 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, public lazy var tabs: Tabs = { let tabs = Tabs(model: tabsModel, delegateObjectIVar, nil) tabs.backgroundColor = (viewController as? PageProtocol)?.pageModel?.navigationBar?.backgroundColor?.uiColor ?? VDSColor.backgroundPrimaryLight - tabs.fillContainer = true tabs.delegate = self return tabs }() @@ -71,6 +72,7 @@ open class SubNavManagerController: ViewController, MVMCoreViewManagerProtocol, func setup(with loadObject: MVMCoreLoadObject, shouldEnableSwipeGestures: Bool) { self.loadObject = loadObject pageType = loadObject.pageType + tabs.fillContainer = tabsModel.tabs.count <= fillContainerTabsCount if shouldEnableSwipeGestures { customInteractor = SubNavInteractor(viewController: self) }