refactored into a new file with traversal
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
952d688cc2
commit
b3f602087d
@ -101,6 +101,7 @@
|
||||
EA6642952BCEBF9500D81DC4 /* TextLinkModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA6642942BCEBF9500D81DC4 /* TextLinkModel.swift */; };
|
||||
EA6F330E2B911E9000BACAB9 /* TextView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA6F330D2B911E9000BACAB9 /* TextView.swift */; };
|
||||
EA78C7962C00CAC200430AD1 /* Groupable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA78C7952C00CAC200430AD1 /* Groupable.swift */; };
|
||||
EA7AE5592C78C7D000107C74 /* ParentViewProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA7AE5582C78C7D000107C74 /* ParentViewProtocol.swift */; };
|
||||
EA81410B2A0E8E3C004F60D2 /* ButtonIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA81410A2A0E8E3C004F60D2 /* ButtonIcon.swift */; };
|
||||
EA8141102A127066004F60D2 /* UIColor+VDSColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA81410F2A127066004F60D2 /* UIColor+VDSColor.swift */; };
|
||||
EA89200428AECF4B006B9984 /* UITextField+Publisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA89200328AECF4B006B9984 /* UITextField+Publisher.swift */; };
|
||||
@ -323,6 +324,7 @@
|
||||
EA78C7952C00CAC200430AD1 /* Groupable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Groupable.swift; sourceTree = "<group>"; };
|
||||
EA78C7A12C0E63D200430AD1 /* vds-dev.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "vds-dev.xcconfig"; sourceTree = "<group>"; };
|
||||
EA78C7A22C0E63DD00430AD1 /* vds.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = vds.xcconfig; sourceTree = "<group>"; };
|
||||
EA7AE5582C78C7D000107C74 /* ParentViewProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ParentViewProtocol.swift; sourceTree = "<group>"; };
|
||||
EA81410A2A0E8E3C004F60D2 /* ButtonIcon.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonIcon.swift; sourceTree = "<group>"; };
|
||||
EA81410F2A127066004F60D2 /* UIColor+VDSColor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+VDSColor.swift"; sourceTree = "<group>"; };
|
||||
EA89200328AECF4B006B9984 /* UITextField+Publisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITextField+Publisher.swift"; sourceTree = "<group>"; };
|
||||
@ -777,6 +779,7 @@
|
||||
EA78C7952C00CAC200430AD1 /* Groupable.swift */,
|
||||
EA33624628931B050071C351 /* Initable.swift */,
|
||||
EA471F392A95587500CE9E58 /* LayoutConstraintable.swift */,
|
||||
EA7AE5582C78C7D000107C74 /* ParentViewProtocol.swift */,
|
||||
EA985C7C297DAED300F2FF2E /* Primitive.swift */,
|
||||
EAF7F0A5289B0CE000B287F5 /* Resetable.swift */,
|
||||
EA3361C8289054C50071C351 /* Surfaceable.swift */,
|
||||
@ -1335,6 +1338,7 @@
|
||||
EAF7F0A4289B017C00B287F5 /* LabelAttributeModel.swift in Sources */,
|
||||
EA0B18022A9E236900F2D0CD /* SelectorGroupBase.swift in Sources */,
|
||||
EA5F86D02A1F936100BC83E4 /* TabsContainer.swift in Sources */,
|
||||
EA7AE5592C78C7D000107C74 /* ParentViewProtocol.swift in Sources */,
|
||||
EAF7F0B1289B177F00B287F5 /* ColorLabelAttribute.swift in Sources */,
|
||||
EAC9258F2911C9DE00091998 /* EntryFieldBase.swift in Sources */,
|
||||
18B9763F2C11BA4A009271DF /* CarouselPaginationModel.swift in Sources */,
|
||||
|
||||
37
VDS/Protocols/ParentViewProtocol.swift
Normal file
37
VDS/Protocols/ParentViewProtocol.swift
Normal file
@ -0,0 +1,37 @@
|
||||
//
|
||||
// ParentViewProtocol.swift
|
||||
// VDS
|
||||
//
|
||||
// Created by Matt Bruce on 8/23/24.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
/// This is used in a View or Control to denote subviews of the ViewProtocol
|
||||
/// type, more or less for composite views/controls.
|
||||
public protocol ParentViewProtocol: ViewProtocol {
|
||||
var children: [any ViewProtocol] { get }
|
||||
}
|
||||
|
||||
extension ParentViewProtocol {
|
||||
|
||||
/// This will get all of the children for yourself as well as all
|
||||
/// of the children within the full tree hierarchy.
|
||||
/// - Returns: All children within the hierachy
|
||||
public func getAllChildren() -> [any ViewProtocol] {
|
||||
var allChildren = [any ViewProtocol]()
|
||||
|
||||
func traverse(view: any ViewProtocol) {
|
||||
if let parentView = view as? any ParentViewProtocol {
|
||||
for child in parentView.children {
|
||||
allChildren.append(child)
|
||||
traverse(view: child)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
traverse(view: self)
|
||||
return children
|
||||
}
|
||||
}
|
||||
@ -9,28 +9,6 @@ import Foundation
|
||||
import UIKit
|
||||
import Combine
|
||||
|
||||
public protocol ParentViewProtocol: ViewProtocol {
|
||||
var children: [any ViewProtocol] { get }
|
||||
}
|
||||
|
||||
extension ParentViewProtocol {
|
||||
public func getAllChildren() -> [any ViewProtocol] {
|
||||
var allChildren = [any ViewProtocol]()
|
||||
|
||||
func traverse(view: any ViewProtocol) {
|
||||
if let parentView = view as? any ParentViewProtocol {
|
||||
for child in parentView.children {
|
||||
allChildren.append(child)
|
||||
traverse(view: child)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
traverse(view: self)
|
||||
return children
|
||||
}
|
||||
}
|
||||
|
||||
public protocol ViewProtocol: AnyObject, Initable, Resettable, Enabling, Surfaceable, AccessibilityUpdatable {
|
||||
/// Set of Subscribers for any Publishers for this Control.
|
||||
var subscribers: Set<AnyCancellable> { get set }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user