|
@@ -23,38 +23,21 @@
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
-class NCViewerNextcloudText: WKWebView, WKNavigationDelegate, WKScriptMessageHandler {
|
|
|
+class NCViewerNextcloudText: UIViewController, WKNavigationDelegate, WKScriptMessageHandler {
|
|
|
|
|
|
+ @IBOutlet weak var webView: WKWebView!
|
|
|
+
|
|
|
let appDelegate = UIApplication.shared.delegate as! AppDelegate
|
|
|
- var detail: CCDetail!
|
|
|
@objc var metadata: tableMetadata!
|
|
|
- var documentInteractionController: UIDocumentInteractionController!
|
|
|
-
|
|
|
- override init(frame: CGRect, configuration: WKWebViewConfiguration) {
|
|
|
- super.init(frame: frame, configuration: configuration)
|
|
|
+ @objc var link: String = ""
|
|
|
|
|
|
- let contentController = configuration.userContentController
|
|
|
- contentController.add(self, name: "DirectEditingMobileInterface")
|
|
|
-
|
|
|
- autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
|
- navigationDelegate = self
|
|
|
- }
|
|
|
-
|
|
|
- required init?(coder: NSCoder) {
|
|
|
- super.init(coder: coder)
|
|
|
- }
|
|
|
-
|
|
|
- @objc func viewerAt(_ link: String, detail: CCDetail, metadata: tableMetadata) {
|
|
|
-
|
|
|
- self.detail = detail
|
|
|
- self.metadata = metadata
|
|
|
+
|
|
|
+ override func viewDidLoad() {
|
|
|
+ super.viewDidLoad()
|
|
|
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(keyboardDidShow), name: UIResponder.keyboardDidShowNotification, object: nil)
|
|
|
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide), name: UIResponder.keyboardWillHideNotification, object: nil)
|
|
|
|
|
|
- if (UIDevice.current.userInterfaceIdiom == .phone) {
|
|
|
- detail.navigationController?.setNavigationBarHidden(true, animated: false)
|
|
|
- }
|
|
|
|
|
|
var request = URLRequest(url: URL(string: link)!)
|
|
|
request.addValue("true", forHTTPHeaderField: "OCS-APIRequest")
|
|
@@ -62,20 +45,22 @@ class NCViewerNextcloudText: WKWebView, WKNavigationDelegate, WKScriptMessageHan
|
|
|
request.addValue(language, forHTTPHeaderField: "Accept-Language")
|
|
|
|
|
|
let userAgent : String = CCUtility.getUserAgent()
|
|
|
- customUserAgent = userAgent
|
|
|
- load(request)
|
|
|
+ self.webView.customUserAgent = userAgent
|
|
|
+ self.webView.load(request)
|
|
|
}
|
|
|
|
|
|
@objc func keyboardDidShow(notification: Notification) {
|
|
|
+ /*
|
|
|
guard let info = notification.userInfo else { return }
|
|
|
guard let frameInfo = info[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue else { return }
|
|
|
let keyboardFrame = frameInfo.cgRectValue
|
|
|
//print("keyboardFrame: \(keyboardFrame)")
|
|
|
frame.size.height = detail.view.bounds.height - keyboardFrame.size.height
|
|
|
+ */
|
|
|
}
|
|
|
|
|
|
@objc func keyboardWillHide(notification: Notification) {
|
|
|
- frame = detail.view.bounds
|
|
|
+ //frame = detail.view.bounds
|
|
|
}
|
|
|
|
|
|
//MARK: -
|
|
@@ -86,17 +71,11 @@ class NCViewerNextcloudText: WKWebView, WKNavigationDelegate, WKScriptMessageHan
|
|
|
|
|
|
if message.body as? String == "close" {
|
|
|
|
|
|
- removeFromSuperview()
|
|
|
-
|
|
|
- detail.navigationController?.popViewController(animated: true)
|
|
|
- detail.navigationController?.navigationBar.topItem?.title = ""
|
|
|
-
|
|
|
- // REFRESH
|
|
|
appDelegate.activeMain.readFileReloadFolder()
|
|
|
}
|
|
|
|
|
|
if message.body as? String == "share" {
|
|
|
- NCMainCommon.sharedInstance.openShare(ViewController: detail, metadata: metadata, indexPage: 2)
|
|
|
+ NCMainCommon.sharedInstance.openShare(ViewController: self, metadata: metadata, indexPage: 2)
|
|
|
}
|
|
|
|
|
|
if message.body as? String == "loading" {
|