marinofaggiana 5 anos atrás
pai
commit
bd43103845

+ 3 - 3
Nextcloud.xcodeproj/project.pbxproj

@@ -2233,9 +2233,6 @@
 			isa = PBXGroup;
 			children = (
 				F790110D21415BF600D7B136 /* NCViewerRichdocument.swift */,
-				F78A18B523CDD07D00F681F3 /* NCViewerNextcloudText.swift */,
-				F78A18B723CDE2B300F681F3 /* NCViewerRichWorkspace.swift */,
-				F7D1611F23CF19E30039EBBF /* NCViewerRichWorkspace.storyboard */,
 				F7FB1D3D215E191D00D669EA /* NCViewerDocumentWeb.swift */,
 				F79630ED215527D40015EEA5 /* NCViewerMedia.swift */,
 			);
@@ -2506,6 +2503,9 @@
 		F7CADB3D23CCDDA1000EEC78 /* RichWorkspace */ = {
 			isa = PBXGroup;
 			children = (
+				F78A18B723CDE2B300F681F3 /* NCViewerRichWorkspace.swift */,
+				F7D1611F23CF19E30039EBBF /* NCViewerRichWorkspace.storyboard */,
+				F78A18B523CDD07D00F681F3 /* NCViewerNextcloudText.swift */,
 				F7F4B1D723C74B3E00D82A6E /* NCRichWorkspace.swift */,
 				F722814223C8C34500C41898 /* NCRichWorkspace.xib */,
 			);

+ 3 - 0
iOSClient/Main/CCDetail.m

@@ -216,6 +216,7 @@
             return;
         }
         
+        /*
         // Nextcloud Text - RichWorkspace
         if ([[NCUtility sharedInstance] isDirectEditing:self.metadataDetail] != nil && appDelegate.reachability.isReachable) {
             
@@ -257,6 +258,8 @@
             
             return;
         }
+        */
+        
         
         // RichDocument
         if ([[NCUtility sharedInstance] isRichDocument:self.metadataDetail] && appDelegate.reachability.isReachable) {

+ 13 - 34
iOSClient/Viewer/NCViewerNextcloudText.swift → iOSClient/RichWorkspace/NCViewerNextcloudText.swift

@@ -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" {

+ 35 - 1
iOSClient/Viewer/NCViewerRichWorkspace.storyboard → iOSClient/RichWorkspace/NCViewerRichWorkspace.storyboard

@@ -2,7 +2,7 @@
 <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="eDT-g5-qb3">
     <device id="retina6_1" orientation="portrait" appearance="light"/>
     <dependencies>
-        <deployment identifier="iOS"/>
+        <deployment version="4352" identifier="iOS"/>
         <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
@@ -72,6 +72,40 @@
             </objects>
             <point key="canvasLocation" x="1013.0434782608696" y="23.4375"/>
         </scene>
+        <!--Viewer Nextcloud Text-->
+        <scene sceneID="FAF-zB-yaq">
+            <objects>
+                <viewController id="Ces-GG-tAv" customClass="NCViewerNextcloudText" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
+                    <view key="view" contentMode="scaleToFill" id="T4r-I1-FJU">
+                        <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <wkWebView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hsc-I0-5ib">
+                                <rect key="frame" x="0.0" y="44" width="414" height="818"/>
+                                <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                <wkWebViewConfiguration key="configuration">
+                                    <audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
+                                    <wkPreferences key="preferences"/>
+                                </wkWebViewConfiguration>
+                            </wkWebView>
+                        </subviews>
+                        <color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
+                        <constraints>
+                            <constraint firstItem="2i0-Vr-dr1" firstAttribute="trailing" secondItem="hsc-I0-5ib" secondAttribute="trailing" id="5Os-LM-5Yz"/>
+                            <constraint firstItem="2i0-Vr-dr1" firstAttribute="bottom" secondItem="hsc-I0-5ib" secondAttribute="bottom" id="Hsc-5E-1br"/>
+                            <constraint firstItem="hsc-I0-5ib" firstAttribute="top" secondItem="2i0-Vr-dr1" secondAttribute="top" id="h4D-CW-VTS"/>
+                            <constraint firstItem="hsc-I0-5ib" firstAttribute="leading" secondItem="2i0-Vr-dr1" secondAttribute="leading" id="rtd-Ru-0UY"/>
+                        </constraints>
+                        <viewLayoutGuide key="safeArea" id="2i0-Vr-dr1"/>
+                    </view>
+                    <connections>
+                        <outlet property="webView" destination="hsc-I0-5ib" id="xu8-Ll-srm"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="o3L-2f-s1m" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="1943" y="22"/>
+        </scene>
         <!--Navigation Controller-->
         <scene sceneID="yfZ-KI-HLn">
             <objects>

+ 1 - 1
iOSClient/Viewer/NCViewerRichWorkspace.swift → iOSClient/RichWorkspace/NCViewerRichWorkspace.swift

@@ -59,7 +59,7 @@ import Foundation
         if let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", appDelegate.activeAccount, serverUrl, k_fileNameRichWorkspace.lowercased())) {
             
             dismiss(animated: false) {
-                self.appDelegate.activeMain.shouldPerformSegue(metadata, selector: "")
+                //self.appDelegate.activeMain.shouldPerformSegue(metadata, selector: "")
             }
         }
     }