1 // Copyright 2015-present 650 Industries. All rights reserved. 2 3 @objc 4 public class DevMenuItemsContainer: NSObject, DevMenuItemsContainerProtocol { 5 private var items: [DevMenuScreenItem] = [] 6 7 public func getRootItems() -> [DevMenuScreenItem] { 8 return items.sorted { $0.importance > $1.importance } 9 } 10 11 public func getAllItems() -> [DevMenuScreenItem] { 12 var result: [DevMenuScreenItem] = [] 13 for item in items { 14 result.append(item) 15 if let container = item as? DevMenuItemsContainerProtocol { 16 result.append(contentsOf: container.getAllItems()) 17 } 18 } 19 return result.sorted { $0.importance > $1.importance } 20 } 21 22 @objc 23 public func addItem(_ item: DevMenuScreenItem) { 24 items.append(item) 25 } 26 27 func serializeItems() -> [[String : Any]] { 28 return getRootItems().map({ $0.serialize() }) 29 } 30 } 31