refactored names for Tabs and related classes
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
2f7315db86
commit
a18d2e2e00
@ -11,7 +11,8 @@ import Combine
|
||||
|
||||
extension Tabs {
|
||||
|
||||
open class TabItem: View {
|
||||
@objc(VDSTab)
|
||||
open class Tab: View {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Public Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -9,6 +9,7 @@ import Foundation
|
||||
import UIKit
|
||||
import VDSColorTokens
|
||||
|
||||
@objc(VDSTabs)
|
||||
open class Tabs: View {
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -95,7 +96,7 @@ open class Tabs: View {
|
||||
|
||||
open var tabSpacing: CGFloat { tabStackView.spacing }
|
||||
|
||||
open var tabItems: [TabItem] = []
|
||||
open var tabViews: [Tab] = []
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Private Properties
|
||||
@ -154,24 +155,24 @@ open class Tabs: View {
|
||||
|
||||
private func updateTabItems(with models: [TabModel]) {
|
||||
// Clear existing tab items
|
||||
for tabItem in tabItems {
|
||||
for tabItem in tabViews {
|
||||
tabItem.removeFromSuperview()
|
||||
}
|
||||
tabItems.removeAll()
|
||||
tabViews.removeAll()
|
||||
// Create new tab items from the models
|
||||
for model in models {
|
||||
let tabItem = TabItem()
|
||||
let tabItem = Tab()
|
||||
tabItem.text = model.text
|
||||
tabItem.onClick = model.onClick
|
||||
tabItem.width = model.width
|
||||
tabItems.append(tabItem)
|
||||
tabViews.append(tabItem)
|
||||
tabStackView.addArrangedSubview(tabItem)
|
||||
|
||||
tabItem
|
||||
.publisher(for: UITapGestureRecognizer())
|
||||
.sink { [weak self] gesture in
|
||||
guard let self, let tabItem = gesture.view as? TabItem else { return }
|
||||
if let selectedIndex = tabItems.firstIndex(of: tabItem) {
|
||||
guard let self, let tabItem = gesture.view as? Tab else { return }
|
||||
if let selectedIndex = tabViews.firstIndex(of: tabItem) {
|
||||
self.selectedIndex = selectedIndex
|
||||
self.onTabChange?(selectedIndex)
|
||||
}
|
||||
@ -182,8 +183,8 @@ open class Tabs: View {
|
||||
}
|
||||
|
||||
private func scrollToSelectedIndex(animated: Bool) {
|
||||
if orientation == .horizontal && self.overflow == .scroll, selectedIndex < tabItems.count {
|
||||
let selectedTab = tabItems[selectedIndex]
|
||||
if orientation == .horizontal && self.overflow == .scroll, selectedIndex < tabViews.count {
|
||||
let selectedTab = tabViews[selectedIndex]
|
||||
scrollView.scrollRectToVisible(selectedTab.frame, animated: animated)
|
||||
}
|
||||
}
|
||||
@ -203,7 +204,7 @@ open class Tabs: View {
|
||||
tabStackView.spacing = orientation == .horizontal ? VDSLayout.Spacing.space6X.value : VDSLayout.Spacing.space4X.value
|
||||
|
||||
// Update tab appearance based on properties
|
||||
for (index, tabItem) in tabItems.enumerated() {
|
||||
for (index, tabItem) in tabViews.enumerated() {
|
||||
tabItem.selected = selectedIndex == index
|
||||
tabItem.index = index
|
||||
tabItem.minWidth = minWidth
|
||||
@ -212,7 +213,7 @@ open class Tabs: View {
|
||||
tabItem.orientation = orientation
|
||||
tabItem.surface = surface
|
||||
tabItem.indicatorPosition = indicatorPosition
|
||||
tabItem.accessibilityLabel = "\(tabItem.text) \(tabItem.selected ? "selected" : "unselected") \(index+1) of \(tabItems.count)"
|
||||
tabItem.accessibilityLabel = "\(tabItem.text) \(tabItem.selected ? "selected" : "unselected") \(index+1) of \(tabViews.count)"
|
||||
}
|
||||
|
||||
// Deactivate old constraint
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
@objc(VDSTabsContainer)
|
||||
open class TabsContainer: View {
|
||||
//--------------------------------------------------
|
||||
// MARK: - Enums
|
||||
|
||||
Loading…
Reference in New Issue
Block a user