Closed johndpope closed 6 years ago
I'm sorry, but I don't understand your request.
So it would be neat if there was an integrated textfield that would apply a filter to the tree and just show results.
This is a logic that should be in your datasource. This library simply provides a TreeView. Which are the data displayed by this view are responsibility of the datasource, so if there is any filtering logic you would like to adopt that must be on the implementation side, not on the library.
@gringoireDM - it is possible using protocol
found this today - https://github.com/onekiloparsec/KPCSearchableOutlineView
//
// SearchableNode.swift
// KPCSearchableOutlineView
//
// Created by Cédric Foellmi on 11/12/2016.
// Copyright © 2016 onekiloparsec. All rights reserved.
//
import Foundation
extension IndexPath {
func indexPathByAddingIndexInFront(_ index: Int) -> IndexPath {
let indexPath = IndexPath(index: index)
return indexPath.appending(self)
}
}
public protocol SearchableNode: NSObjectProtocol {
var uuid: UUID { get }
var childNodes: [SearchableNode] { get set }
var originalChildNodes: [SearchableNode] { get set }
var parentNode: SearchableNode? { get }
func searchableContent() -> String
}
public extension Collection where Iterator.Element == SearchableNode {
func indexOf(_ element: Iterator.Element) -> Index? {
return index(where: { $0.uuid == element.uuid })
}
}
public extension SearchableNode {
func indexPath() -> IndexPath {
var indexPath = IndexPath()
var activeNode: SearchableNode = self
while activeNode.parentNode != nil {
if let index = activeNode.parentNode!.childNodes.indexOf(self) {
indexPath = indexPath.indexPathByAddingIndexInFront(index)
activeNode = activeNode.parentNode!
}
else {
break
}
}
return indexPath
}
}
I never said it's not possible. I said that it is not what I'm proposing for this library. what this library does and wants to do is to give a generic Tree View for iOS. Not filtering through its data source. The feature is implementable on the client side, where the library is actually used.
Feel free to extend the features of this class in you project, but I will not add this feature in the main project. This library does not manipulate the dataSource.
need to trawl through the root node for matches. https://github.com/bfeher/SceneKit-COLLADA-Demo/pull/2