diff --git a/FileBrowser/FileBrowser.swift b/FileBrowser/FileBrowser.swift index aad61e3..875ac68 100644 --- a/FileBrowser/FileBrowser.swift +++ b/FileBrowser/FileBrowser.swift @@ -52,7 +52,9 @@ open class FileBrowser: UINavigationController { let validInitialPath = initialPath ?? FileParser.sharedInstance.documentsURL() - let fileListViewController = FileListViewController(initialPath: validInitialPath, showCancelButton: showCancelButton) + let fileListViewController = FileListViewController(initialPath: validInitialPath, + showCancelButton: showCancelButton, + allowEditing: allowEditing) fileListViewController.allowEditing = allowEditing self.init(rootViewController: fileListViewController) self.view.backgroundColor = UIColor.white diff --git a/FileBrowser/FileListTableView.swift b/FileBrowser/FileListTableView.swift index 2caba43..058644e 100644 --- a/FileBrowser/FileListTableView.swift +++ b/FileBrowser/FileListTableView.swift @@ -43,7 +43,7 @@ extension FileListViewController: UITableViewDataSource, UITableViewDelegate { let selectedFile = fileForIndexPath(indexPath) searchController.isActive = false if selectedFile.isDirectory { - let fileListViewController = FileListViewController(initialPath: selectedFile.filePath) + let fileListViewController = FileListViewController(initialPath: selectedFile.filePath, allowEditing: allowEditing) fileListViewController.didSelectFile = didSelectFile self.navigationController?.pushViewController(fileListViewController, animated: true) } diff --git a/FileBrowser/FileListViewController.swift b/FileBrowser/FileListViewController.swift index 936a9bd..dd924c0 100644 --- a/FileBrowser/FileListViewController.swift +++ b/FileBrowser/FileListViewController.swift @@ -35,18 +35,19 @@ class FileListViewController: UIViewController { //MARK: Lifecycle - convenience init (initialPath: URL) { - self.init(initialPath: initialPath, showCancelButton: true) + convenience init (initialPath: URL, allowEditing: Bool = false) { + self.init(initialPath: initialPath, showCancelButton: true, allowEditing: allowEditing) } - convenience init (initialPath: URL, showCancelButton: Bool) { + convenience init (initialPath: URL, showCancelButton: Bool, allowEditing: Bool = false) { self.init(nibName: "FileBrowser", bundle: Bundle(for: FileListViewController.self)) self.edgesForExtendedLayout = UIRectEdge() // Set initial path self.initialPath = initialPath self.title = initialPath.lastPathComponent - + self.allowEditing = allowEditing + // Set search controller delegates searchController.searchResultsUpdater = self searchController.searchBar.delegate = self