marinofaggiana 5 years ago
parent
commit
11baf68a6b
2 changed files with 33 additions and 20 deletions
  1. 4 0
      iOSClient/Main/CCDetail.h
  2. 29 20
      iOSClient/Main/CCDetail.m

+ 4 - 0
iOSClient/Main/CCDetail.h

@@ -34,6 +34,7 @@
 @class tableMetadata;
 @class NCViewerImagemeter;
 @class NCViewerRichdocument;
+@class NCViewerNextcloudText;
 
 @interface CCDetail : UIViewController <MWPhotoBrowserDelegate, ReaderViewControllerDelegate>
 
@@ -66,6 +67,9 @@
 // RichDocument
 @property (nonatomic, strong) NCViewerRichdocument *richDocument;
 
+// NextcloudText
+@property (nonatomic, strong) NCViewerNextcloudText *nextcloudText;
+
 // IM
 @property (nonatomic, strong) NCViewerImagemeter *imagemeter;
 

+ 29 - 20
iOSClient/Main/CCDetail.m

@@ -221,31 +221,40 @@
             
             NSString *editor = [[NCUtility sharedInstance] isDirectEditing:self.metadataDetail];
             if ([editor.lowercaseString isEqualToString:@"nextcloud text"]) {
-                
-                [[NCUtility sharedInstance] startActivityIndicatorWithView:self.view bottom:0];
-                
-                NSString *fileNamePath = [CCUtility returnFileNamePathFromFileName:self.metadataDetail.fileName serverUrl:self.metadataDetail.serverUrl activeUrl:appDelegate.activeUrl];
-                [[NCCommunication sharedInstance] NCTextOpenFileWithUrlString:appDelegate.activeUrl fileNamePath:fileNamePath editor: @"text" account:self.metadataDetail.account completionHandler:^(NSString *account, NSString *url, NSInteger errorCode, NSString *errorMessage) {
+            
+                if([self.metadataDetail.url isEqualToString:@""]) {
                     
-                    if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
-                        
-                        
-                    } else {
+                    [[NCUtility sharedInstance] startActivityIndicatorWithView:self.view bottom:0];
+                    
+                    NSString *fileNamePath = [CCUtility returnFileNamePathFromFileName:self.metadataDetail.fileName serverUrl:self.metadataDetail.serverUrl activeUrl:appDelegate.activeUrl];
+                    [[NCCommunication sharedInstance] NCTextOpenFileWithUrlString:appDelegate.activeUrl fileNamePath:fileNamePath editor: @"text" account:self.metadataDetail.account completionHandler:^(NSString *account, NSString *url, NSInteger errorCode, NSString *errorMessage) {
                         
-                        if (errorCode != 0) {
-                            [appDelegate messageNotification:@"_error_" description:errorMessage visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
+                        if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
+                            
+                            self.nextcloudText = [[NCViewerNextcloudText alloc] initWithFrame:self.view.bounds configuration:[WKWebViewConfiguration new]];
+                            [self.view addSubview:self.nextcloudText];
+                            [self.nextcloudText viewNextcloudTextAt:url detail:self metadata:self.metadataDetail];
+                            
                         } else {
-                            NSLog(@"[LOG] It has been changed user during networking process, error.");
+                            
+                            if (errorCode != 0) {
+                                [appDelegate messageNotification:@"_error_" description:errorMessage visible:YES delay:k_dismissAfterSecond type:TWMessageBarMessageTypeError errorCode:errorCode];
+                            } else {
+                                NSLog(@"[LOG] It has been changed user during networking process, error.");
+                            }
+                            
+                            [self.navigationController popViewControllerAnimated:YES];
                         }
-                        
-                        [self.navigationController popViewControllerAnimated:YES];
-                    }
-                }];
-                
-            } else {
-                
-                
+                    }];
+                    
+                } else {
+                    
+                    self.nextcloudText = [[NCViewerNextcloudText alloc] initWithFrame:self.view.bounds configuration:[WKWebViewConfiguration new]];
+                    [self.view addSubview:self.nextcloudText];
+                    [self.nextcloudText viewNextcloudTextAt:self.metadataDetail.url detail:self metadata:self.metadataDetail];
+                }
             }
+            
             return;
         }