Skip to content

Commit

Permalink
update root folder
Browse files Browse the repository at this point in the history
  • Loading branch information
DamonHu committed Jul 11, 2023
1 parent 609ba4c commit d70a39f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ ZXFileBrowser.shared.start()
ZXFileBrowser.shared.getFileType(filePath: path)
```

#### 指定预览的根目录

默认根目录是app的根目录,如果有特殊需求,比如只让用户查看某个目录,则可以设置根目录即可

```
ZXFileBrowser.shared.rootDirectoryPath = ZXKitUtil.shared.getFileDirectory(type: .caches)
```

## 预览


Expand Down
2 changes: 1 addition & 1 deletion ZXFileBrowser.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = 'ZXFileBrowser'
s.swift_version = '5.0'
s.version = '2.0.2'
s.version = '2.0.3'
s.license= { :type => "MIT", :file => "LICENSE" }
s.summary = 'iOS Sandbox file browser, iOS沙盒文件浏览器'
s.homepage = 'https://github.com/DamonHu/ZXFileBrowser'
Expand Down
Binary file not shown.
1 change: 1 addition & 0 deletions example/ZXFileBrowserDemo/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class ViewController: UIViewController {
}

@objc func _openBrowser() {
// ZXFileBrowser.shared.rootDirectoryPath = ZXKitUtil.shared.getFileDirectory(type: .caches)
ZXFileBrowser.shared.start()
}

Expand Down
2 changes: 1 addition & 1 deletion pod/ZXFileBrowser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ open class ZXFileBrowser: NSObject {
open class var shared: ZXFileBrowser {
return instance
}

public var rootDirectoryPath = ZXKitUtil.shared.getFileDirectory(type: .home)
//MARK: UI
lazy var mNavigationController: UINavigationController = {
let rootViewController = ZXFileBrowserVC()
Expand Down
18 changes: 17 additions & 1 deletion pod/vc/ZXFileBrowserVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class ZXFileBrowserVC: UIViewController {
var extensionDirectoryPath = "" //选择的相对路径
var operateFilePath: URL? //操作的文件路径,例如复制、粘贴等
var currentDirectoryPath: URL { //当前的文件夹
return ZXKitUtil.shared.getFileDirectory(type: .home).appendingPathComponent(self.extensionDirectoryPath, isDirectory: true)
print(ZXFileBrowser.shared.rootDirectoryPath)
return ZXFileBrowser.shared.rootDirectoryPath.appendingPathComponent(self.extensionDirectoryPath, isDirectory: true)
}


Expand Down Expand Up @@ -72,6 +73,15 @@ class ZXFileBrowserVC: UIViewController {
tTableView.register(ZXFileTableViewCell.self, forCellReuseIdentifier: "ZXFileTableViewCell")
return tTableView
}()

lazy var mEmptyLabel: UILabel = {
let label = UILabel()
label.isHidden = true
label.text = "This folder is empty~"
label.textColor = UIColor.zx.color(hexValue: 0x666666)
label.font = .systemFont(ofSize: 16, weight: .medium)
return label
}()
}

private extension ZXFileBrowserVC {
Expand All @@ -81,6 +91,11 @@ private extension ZXFileBrowserVC {
mTableView.snp.makeConstraints {
$0.edges.equalToSuperview()
}

self.view.addSubview(mEmptyLabel)
mEmptyLabel.snp.makeConstraints {
$0.center.equalToSuperview()
}
}

func _loadData() {
Expand Down Expand Up @@ -114,6 +129,7 @@ private extension ZXFileBrowserVC {
}
}
}
self.mEmptyLabel.isHidden = !mTableViewList.isEmpty
mTableView.reloadData()
}

Expand Down

0 comments on commit d70a39f

Please sign in to comment.