marinofaggiana 5 年之前
父节点
当前提交
9965d0ccde
共有 2 个文件被更改,包括 50 次插入1 次删除
  1. 49 1
      iOSClient/Main/CCMain.m
  2. 1 0
      iOSClient/Supporting Files/en.lproj/Localizable.strings

+ 49 - 1
iOSClient/Main/CCMain.m

@@ -133,6 +133,12 @@
     UILongPressGestureRecognizer* longPressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onLongPressTableView:)];
     [self.tableView addGestureRecognizer:longPressRecognizer];
     
+    // vewView Tap Action
+    UITapGestureRecognizer *webViewTapped = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(webViewTapAction:)];
+    webViewTapped.numberOfTapsRequired = 1;
+    webViewTapped.delegate = self;
+    [self.webView addGestureRecognizer:webViewTapped];
+    
     // Pull-to-Refresh
     [self createRefreshControl];
     
@@ -318,7 +324,16 @@
     // Nextcloud 18
     tableCapabilities *capabilities = [[NCManageDatabase sharedInstance] getCapabilitesWithAccount:appDelegate.activeAccount];
     if (capabilities.versionMajor >= k_nextcloud_version_18_0) {
-        self.viewSectionWebViewHeight.constant = CCUtility.getViewSectionWebViewHeight;
+        tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", appDelegate.activeAccount, self.serverUrl, @"readme.md"]];
+        if (metadata && [[NCUtility sharedInstance] isDirectEditing:metadata]) {
+            NSString *htmlString = metadata.richWorkspace;
+            [self.webView loadHTMLString:htmlString baseURL:NSBundle.mainBundle.bundleURL];
+            self.viewSectionWebViewHeight.constant = CCUtility.getViewSectionWebViewHeight;
+        } else {
+            NSString *htmlString = [NSString stringWithFormat:@"<h2><span style=\"color: #999999;\">%@</span></h2>", NSLocalizedString(@"_add_notes_readme_md_", nil)];
+            [self.webView loadHTMLString:htmlString baseURL:NSBundle.mainBundle.bundleURL];
+            self.viewSectionWebViewHeight.constant = CCUtility.getViewSectionWebViewHeight;
+        }
         [self.mainChangeHeightWebView setHidden:false];
     } else {
         self.viewSectionWebViewHeight.constant = 0;
@@ -1934,6 +1949,39 @@
     }
 }
 
+#pragma --------------------------------------------------------------------------------------------
+#pragma mark ===== Web view (NC 18) =====
+#pragma --------------------------------------------------------------------------------------------
+
+- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
+{
+    return YES;
+}
+
+- (void)webViewTapAction:(UITapGestureRecognizer *)tapGesture
+{
+    tableMetadata *metadata = [[NCManageDatabase sharedInstance] getMetadataWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@ AND fileNameView LIKE[c] %@", appDelegate.activeAccount, self.serverUrl, @"readme.md"]];
+    if (metadata && [[NCUtility sharedInstance] isDirectEditing:metadata]) {
+        if (appDelegate.reachability.isReachable) {
+            [self shouldPerformSegue:metadata selector:@""];
+        } else {
+            [[NCContentPresenter shared] messageNotification:@"_info_" description:@"_go_online_" delay:k_dismissAfterSecond type:messageTypeInfo errorCode:0];
+        }
+    } else if (metadata == nil) {
+        NSString *fileNamePath = [CCUtility returnFileNamePathFromFileName:@"Readme.md" serverUrl:self.serverUrl activeUrl:appDelegate.activeUrl];
+        [[NCCommunication sharedInstance] NCTextCreateFileWithUrlString:appDelegate.activeUrl fileNamePath:fileNamePath editor:@"text" templateId:@"" account:appDelegate.activeAccount completionHandler:^(NSString *account, NSString *url, NSInteger errorCode, NSString *errorMessage) {
+            if (errorCode == 0 && [account isEqualToString:appDelegate.activeAccount]) {
+                tableMetadata *metadata = [CCUtility createMetadataWithAccount:appDelegate.activeAccount date:[NSDate date] directory:false ocId:[CCUtility createRandomString:12] serverUrl:self.serverUrl fileName:@"Readme.md" etag:@"" size:0 status:k_metadataStatusNormal url:url contentType:@"text/markdown"];
+                [self shouldPerformSegue:metadata selector:@""];
+            } else if (errorCode != 0) {
+                [NCContentPresenter.shared  messageNotification:@"_error_" description:errorMessage delay:k_dismissAfterSecond type:messageTypeError errorCode:errorCode];
+            } else {
+                NSLog(@"[LOG] It has been changed user during networking process, error.");
+            }
+        }];
+    }
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Favorite =====
 #pragma --------------------------------------------------------------------------------------------

+ 1 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -115,6 +115,7 @@
 "_no_permission_delete_file_" = "You don't have permission to delete files";
 "_no_permission_modify_file_" = "You don't have permission to modify files";
 "_request_upload_new_ver_"  = "The file has been modified, do you want to upload the new version ?";
+"_add_notes_readme_md_"     = "Add notes, lists or links ...";
 
 // App