mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-04-17 22:53:52 +08:00
Add PDF support (#1596)
* Add string extension for searching pdf files (#1552) * Create RepositoryWebViewController (#1552) * Initial presenting of the pdf files (#1552) * refactor: Rename String+Resource -> String+BinaryFile (#1552) * Build destination URL (#1552) * Configure title (#1552) * Encode file path * Use EmptyView for errors * Replace UIWebView with WKWebView * Review fixes * refactor: Make binarySuffix computed property * Unify if-else path * Group guard statements
This commit is contained in:
@@ -130,23 +130,50 @@ ListSingleSectionControllerDelegate {
|
||||
|
||||
func didSelect(_ sectionController: ListSingleSectionController, with object: Any) {
|
||||
guard let file = object as? RepositoryFile else { return }
|
||||
let next = path.appending(file.name)
|
||||
let controller: UIViewController
|
||||
let nextPath = path.appending(file.name)
|
||||
|
||||
if file.isDirectory {
|
||||
controller = RepositoryCodeDirectoryViewController(
|
||||
client: client,
|
||||
showDirectory(at: nextPath)
|
||||
} else {
|
||||
showFile(at: nextPath)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - RepositoryCodeDirectoryViewController (Navigation) -
|
||||
|
||||
extension RepositoryCodeDirectoryViewController {
|
||||
|
||||
private func showDirectory(at path: FilePath) {
|
||||
let controller = RepositoryCodeDirectoryViewController(
|
||||
client: client,
|
||||
repo: repo,
|
||||
branch: branch,
|
||||
path: path
|
||||
)
|
||||
|
||||
navigationController?.pushViewController(controller, animated: trueUnlessReduceMotionEnabled)
|
||||
}
|
||||
|
||||
private func showFile(at path: FilePath) {
|
||||
let controller: UIViewController
|
||||
|
||||
if path.hasBinarySuffix {
|
||||
controller = RepositoryWebViewController(
|
||||
repo: repo,
|
||||
branch: branch,
|
||||
path: next
|
||||
path: path
|
||||
)
|
||||
} else {
|
||||
controller = RepositoryCodeBlobViewController(
|
||||
client: client,
|
||||
repo: repo,
|
||||
branch: branch,
|
||||
path: next
|
||||
path: path
|
||||
)
|
||||
}
|
||||
|
||||
navigationController?.pushViewController(controller, animated: trueUnlessReduceMotionEnabled)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user