Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion FileBrowser/FileBrowser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion FileBrowser/FileListTableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
9 changes: 5 additions & 4 deletions FileBrowser/FileListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down