{"id":21700709,"url":"https://github.com/zhipingyang/verticaltree","last_synced_at":"2025-04-12T13:34:37.876Z","repository":{"id":56926014,"uuid":"166915024","full_name":"ZhipingYang/VerticalTree","owner":"ZhipingYang","description":"🥶Provides a vertical drawing of the tree structure which can view information about the tree‘s nodes and supports console debug views \u0026 layers and so on","archived":false,"fork":false,"pushed_at":"2021-04-08T11:09:51.000Z","size":169,"stargazers_count":67,"open_issues_count":0,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-26T08:08:27.289Z","etag":null,"topics":["collapse","indexpath","subtree","tree-structure","treenode","treeview","vertical"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZhipingYang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-22T02:41:59.000Z","updated_at":"2025-02-05T22:17:54.000Z","dependencies_parsed_at":"2022-08-21T04:20:48.198Z","dependency_job_id":null,"html_url":"https://github.com/ZhipingYang/VerticalTree","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhipingYang%2FVerticalTree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhipingYang%2FVerticalTree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhipingYang%2FVerticalTree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhipingYang%2FVerticalTree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZhipingYang","download_url":"https://codeload.github.com/ZhipingYang/VerticalTree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248573749,"owners_count":21126898,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collapse","indexpath","subtree","tree-structure","treenode","treeview","vertical"],"created_at":"2024-11-25T20:16:25.393Z","updated_at":"2025-04-12T13:34:37.850Z","avatar_url":"https://github.com/ZhipingYang.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg width=150 src=\"https://user-images.githubusercontent.com/9360037/56595379-1abc1b00-6621-11e9-912a-b80db0f3792c.png\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\t\u003ca href=\"http://cocoapods.org/pods/VerticalTree\"\u003e\n\t\t\u003cimage alt=\"Version\" src=\"https://img.shields.io/cocoapods/v/VerticalTree.svg?style=flat\"\u003e\n\t\u003c/a\u003e\n\t\u003cimage alt=\"CI Status\" src=\"https://img.shields.io/badge/Swift-5.0-orange.svg\"\u003e\n\t\u003ca href=\"http://cocoapods.org/pods/VerticalTree\"\u003e\n\t\t\u003cimage alt=\"License\" src=\"https://img.shields.io/cocoapods/l/VerticalTree.svg?style=flat\"\u003e\n\t\u003c/a\u003e\n\t\u003ca href=\"http://cocoapods.org/pods/VerticalTree\"\u003e\n\t\t\u003cimage alt=\"Platform\" src=\"https://img.shields.io/cocoapods/p/VerticalTree.svg?style=flat\"\u003e\n\t\u003c/a\u003e\n\t\u003ca href=\"https://travis-ci.com/ZhipingYang/VerticalTree\"\u003e\n\t\t\u003cimage alt=\"CI Status\" src=\"https://travis-ci.com/ZhipingYang/VerticalTree.svg?branch=master\"\u003e\n\t\u003c/a\u003e\n\u003c/p\u003e\n\n\u003e Provides a vertical drawing of the tree structure which can view information about the tree‘s nodes and supports console debug views \u0026 layers and so on\n\n### Install\n\nrequired `iOS \u003e= 9.0` `Swift5.0` with [Cocoapods](https://cocoapods.org/)\n\n```ruby\npod 'VerticalTree'\n```\n\nonly install core functions\n\n```ruby\npod 'VerticalTree/Core'\n```\ninstall prettyPrint extension for view、layer、viewController\n\n```ruby\npod 'VerticalTree/PrettyExtension'\n```\n\n#### file structures\n\n```\n─┬─ \"VerticalTree\"\n ├─┬─ \"Core\": basic functions\n │ ├─── VerticalTreeProtocol\n │ ├─── VerticalTreeProtocolExtension\n │ └─── VerticalTreeNodeWrapper\n ├─┬─ \"UI\": draw a graph of VerticalTree which is foldable\n │ ├─── VerticalTreeCell\n │ ├─── VerticalTreeIndexView\n │ └─── VerticalTreeListController\n └─┬─ \"PrettyExtension\": pretty print in xcode console\n   └─── VerticalTreePrettyPrint\n```\n\n#### core protocols\n\n```swift\n/// base node\npublic protocol BaseNode {\n    associatedtype T: BaseNode\n    var parent: T? { get }\n    var childs: [T] { get }\n}\n\n/// base treeNode structure and position\npublic protocol IndexPathNode: BaseNode {\n    var indexPath: IndexPath { get }\n}\n\n/// Node protocol\npublic protocol VerticalTreeNode: IndexPathNode where Self.T == Self {\n    /// indexViewLegnth\n    var length: TreeNodeLength { get }\n    /// info description\n    var info: Infomation { get }\n    var isFold: Bool { set get }\n}\n```\n\n### Example for UIView\n\n\u003e `UIView` is a tree structure\n\u003e \n\u003e - VerticalTree in tableview\n\u003e - VerticalTree in console log\n\n\u003cp align=\"center\"\u003e\n\u003cimg width=30% src=\"https://user-images.githubusercontent.com/9360037/56594927-48ed2b00-6620-11e9-980e-3bcfef3556a8.jpg\"\u003e \u003cimg width=30% src=\"https://user-images.githubusercontent.com/9360037/56594688-dc722c00-661f-11e9-83f0-3990d13f0947.jpg\"\u003e\n\u003cimg width=36.5% src=\"https://user-images.githubusercontent.com/9360037/56591555-8bf8cf80-661b-11e9-93f8-f2bb374415eb.png\"\u003e\n\u003c/p\u003e\n\n## Using\n### 1. draw the VerticalTree in tableview\n\u003e for example a UITableViewCell structure:\n\n![vertical_tree](https://user-images.githubusercontent.com/9360037/56594078-d891da00-661e-11e9-8403-25178464905e.gif)\n\n```swift\n// in ViewController\nlet treeVC = VerticalTreeListController(source: NodeWrapper(obj: view))\n// then show the treeVC\n```\n\n#### Config Node's info\n\nin NodeWrapper's method\n\n```swift\n/// config current node’s property value and recurrence apply the same rule in childNodes if you want\n///\n/// - Parameters:\n///   - inChild: recurrence config in child or just config current\n///   - config: rules\n/// - Returns: self\n@discardableResult\npublic func changeProperties(inChild: Bool = true, config: (NodeWrapper\u003cObj\u003e) -\u003e Void) -\u003e Self {}\n```\n\nfollow picture: modify UIViewController's Wrapper\n\n\u003cimg width=500 src=\"https://user-images.githubusercontent.com/9360037/56355927-1c917300-620a-11e9-9281-6658245cd321.jpg\"\u003e\n\n```swift\n// default to change all subnode in the same rules unless inChild set false\nlet wrapper = NodeWrapper(obj: keyWindow.rootController).changeProperties {\n    $0.isFold = false\t// all node set unfold in default \n    $0.nodeDescription = \"more infomation that you see now\"\n}\n```\n\n### 2. Text VerticalTree - in Console log\n\n![tree](https://user-images.githubusercontent.com/9360037/56596664-8a330a00-6623-11e9-8e0d-58c2ef7cb9bb.jpg)\n\n\n\u003e UIView as the example to follow the IndexPathNode protocol \u003cbr\u003e\n\u003e see more others extension like CALayer，UIViewController in the demo\n\n```swift\nextension UIView: BaseNode {\n    public var parent: UIView? {\n        return superview\n    }\n    public var childs: [UIView] {\n        return subviews\n    }\n}\n```\nget a wrapper of the view as a root node\n\n```swift\n// in ViewController\nlet rootNode = NodeWrapper(obj: view)\n// print node structure in text\nprint(rootNode.subTreePrettyText())\n```\n\nUsing UIView's Extension as an easier way, check here [VerticalTree/PrettyText](https://github.com/ZhipingYang/VerticalTree/blob/master/class/pretty/VerticalTreePrettyPrint.swift#L19)\n\n```swift\nextension BaseNode where Self: NSObject, Self == Self.T {\n    /// print\n    public func treePrettyPrint(inDebug: Bool = false) {...}\n    /// baseTree‘s structure\n    public func treePrettyText(inDebug: Bool = false) -\u003e String {...}\n    /// get ofTop‘s structure \u0026 highlight position of self\n    public func treePrettyText(ofTop: Self, inDebug: Bool = false) { ... }\n    // get the baseTree of rootNode\n    public var getTreeRoot: Self { ... }\n}\n```\n- print current view as root node\n\n\u003e `view.treePrettyPrint()`\n\n- print view's Window structure\n\n\u003e `view.rootNode.treePrettyPrint()` \n\n- show more infomation\n\n\u003e `view.treePrettyPrint(inDebug: true)`\n\n![image](https://user-images.githubusercontent.com/9360037/56597052-47256680-6624-11e9-90ed-e78181eba479.png)\n\n### BTW\n\n- LLDB debug view \u0026 layer \u0026 controller's hierarchy\n    -  view \u0026 layer\n        - method-1: `po yourObj.value(forKey: \"recursiveDescription\")!`\n        - method-2: `expression -l objc -O -- [`yourObj` recursiveDescription]`\n    - controller\n        - method-1: `po yourController.value(forKey: \"_printHierarchy\")!`\n        - method-2: `expression -l objc -O -- [`yourController` _printHierarchy]`\n\n![image](https://user-images.githubusercontent.com/9360037/56284463-16868e00-6147-11e9-834e-306c10c0926d.png)\n\n## Author\n\nXcodeYang, xcodeyang@gmail.com\n\n## License\n\nVerticalTree is available under the MIT license. See the LICENSE file for more info.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhipingyang%2Fverticaltree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhipingyang%2Fverticaltree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhipingyang%2Fverticaltree/lists"}