Marino Faggiana 6 years ago
parent
commit
1aabaad3c4

+ 9 - 17
iOSClient/Main/CCDetail.m

@@ -155,11 +155,6 @@
     }
 }
 
-- (void)backNavigationController
-{
-    [self.navigationController popViewControllerAnimated:YES];
-}
-
 - (void)changeToDisplayMode
 {
     if (_readerPDFViewController)
@@ -205,7 +200,6 @@
         
         fileNameExtension = [[self.metadataDetail.fileNameView pathExtension] uppercaseString];
         
-#if DEBUG
         // Richdocument editor
         NSString *mimeType = [CCUtility getMimeType:self.metadataDetail.fileNameView];
         NSArray *richdocumentsMimetypes = [[NCManageDatabase sharedInstance] getRichdocumentsMimetypes];
@@ -215,26 +209,24 @@
             NSString* mimeType = [NSString stringWithFormat:@"%@.%@",mimeTypeArray[mimeTypeArray.count-2], mimeTypeArray[mimeTypeArray.count-1]];
             for (NSString *richdocumentMimetype in richdocumentsMimetypes) {
                 if ([richdocumentMimetype containsString:mimeType]) {
-                    NSLog(@"Collabora");
                     
                     OCnetworking *ocNetworking = [[OCnetworking alloc] initWithDelegate:nil metadataNet:nil withUser:appDelegate.activeUser withUserID:appDelegate.activeUserID withPassword:appDelegate.activePassword withUrl:appDelegate.activeUrl];
                     
                     [ocNetworking createLinkRichdocumentsWithFileID:self.metadataDetail.fileID success:^(NSString *link) {
                         
+                        [appDelegate aspectNavigationControllerBar:self.navigationController.navigationBar online:[appDelegate.reachability isReachable] hidden:NO];
                         [[NCRichdocument sharedInstance] viewRichDocumentAt:link viewDetail:self];
-                        
+
                     } failure:^(NSString *message, NSInteger errorCode) {
                         
                         [appDelegate messageNotification:@"_error_" description:message visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
-                        [self backNavigationController];
+                        [self.navigationController popViewControllerAnimated:YES];
                         return;
                     }];
                 }
             }
-        }
-#endif
-
-        if ([fileNameExtension isEqualToString:@"PDF"]) {
+            
+        } else if ([fileNameExtension isEqualToString:@"PDF"]) {
             
             self.edgesForExtendedLayout = UIRectEdgeBottom;
             [self createToolbar];
@@ -313,7 +305,7 @@
     
     if ([CCUtility fileProviderStorageExists:self.metadataDetail.fileID fileNameView:self.metadataDetail.fileNameView] == NO) {
         
-        [self backNavigationController];
+        [self.navigationController popViewControllerAnimated:YES];
         return;
     }
     
@@ -847,7 +839,7 @@
     } else {
         [appDelegate messageNotification:@"_download_selected_files_" description:@"_error_download_photobrowser_" visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
         
-        [self backNavigationController];
+        [self.navigationController popViewControllerAnimated:YES];
     }
 }
 
@@ -1103,7 +1095,7 @@
             if ([self.metadataDetail.typeFile isEqualToString: k_metadataTypeFile_image] == NO) {
             
                 // exit
-                [self backNavigationController];
+                [self.navigationController popViewControllerAnimated:YES];
             
             } else {
                 
@@ -1119,7 +1111,7 @@
                         
                         // exit
                         if ([self.photoDataSource count] == 0) {
-                            [self backNavigationController];
+                            [self.navigationController popViewControllerAnimated:YES];
                         }
                     }
                 }

+ 2 - 2
iOSClient/Main/Main.storyboard

@@ -444,11 +444,11 @@
         <scene sceneID="zJM-E9-jgK">
             <objects>
                 <viewController storyboardIdentifier="CCDetailVC" extendedLayoutIncludesOpaqueBars="YES" id="zg6-hy-EbU" customClass="CCDetail" sceneMemberID="viewController">
-                    <view key="view" contentMode="scaleToFill" id="cUA-lB-tGG">
+                    <view key="view" tag="900" contentMode="scaleToFill" id="cUA-lB-tGG">
                         <rect key="frame" x="0.0" y="0.0" width="375" height="812"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" image="backgroundDetail" translatesAutoresizingMaskIntoConstraints="NO" id="zlU-MP-ZVs">
+                            <imageView userInteractionEnabled="NO" tag="999" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" image="backgroundDetail" translatesAutoresizingMaskIntoConstraints="NO" id="zlU-MP-ZVs">
                                 <rect key="frame" x="76" y="327.66666666666669" width="223" height="157"/>
                             </imageView>
                         </subviews>

+ 12 - 1
iOSClient/Richdocument/NCRichdocument.swift

@@ -31,6 +31,7 @@ class NCRichdocument: NSObject, WKNavigationDelegate, WKScriptMessageHandler {
     }()
     
     var viewDetail: CCDetail!
+    var webView: WKWebView!
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
 
     @objc func viewRichDocumentAt(_ link: String, viewDetail: CCDetail) {
@@ -42,7 +43,7 @@ class NCRichdocument: NSObject, WKNavigationDelegate, WKScriptMessageHandler {
         let configuration = WKWebViewConfiguration()
         configuration.userContentController = contentController
         
-        let webView = WKWebView(frame: viewDetail.view.bounds, configuration: configuration)
+        webView = WKWebView(frame: viewDetail.view.bounds, configuration: configuration)
         webView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
         webView.navigationDelegate = self
         
@@ -63,6 +64,16 @@ class NCRichdocument: NSObject, WKNavigationDelegate, WKScriptMessageHandler {
         if (message.name == "RichDocumentsMobileInterface") {
             if message.body as! String == "close" {
                 print("\(message.body)")
+                
+
+                for view in self.viewDetail.view.subviews{
+                    if view.tag < 900 {
+                        view.removeFromSuperview()
+                    }
+                }
+
+                self.viewDetail.navigationController?.popToRootViewController(animated: true)
+                
             }
         }
     }