marinofaggiana преди 5 години
родител
ревизия
d48492eb72
променени са 5 файла, в които са добавени 25 реда и са изтрити 46 реда
  1. 2 36
      iOSClient/Main/CCMain.m
  2. 18 4
      iOSClient/Main/NCRichWorkspace.swift
  3. 0 1
      iOSClient/Main/NCRichWorkspace.xib
  4. 2 2
      iOSClient/Utility/CCUtility.h
  5. 3 3
      iOSClient/Utility/CCUtility.m

+ 2 - 36
iOSClient/Main/CCMain.m

@@ -242,12 +242,6 @@
     [self closeAllMenu];
 }
 
-- (void)didReceiveMemoryWarning
-{
-    [super didReceiveMemoryWarning];
-    // Dispose of any resources that can be recreated.    
-}
-
 - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
 {
     [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
@@ -3872,8 +3866,6 @@
 
 - (void)setTableViewHeader
 {
-    NSString *htmlString;
-    
     // Nextcloud 18
     tableCapabilities *capabilities = [[NCManageDatabase sharedInstance] getCapabilitesWithAccount:appDelegate.activeAccount];
     if (capabilities.versionMajor < k_nextcloud_version_18_0) {
@@ -3882,37 +3874,11 @@
     }
     
     tableDirectory *directory = [[NCManageDatabase sharedInstance] getTableDirectoryWithPredicate:[NSPredicate predicateWithFormat:@"account == %@ AND serverUrl == %@", appDelegate.activeAccount, self.serverUrl]];
+    [self.viewRichWorkspace setRichWorkspaceText:directory.richWorkspace];
     [self.viewRichWorkspace setFrame:CGRectMake(0, 0, self.tableView.frame.size.width, CCUtility.getRichWorkspaceHeight)];
-    
-    if (directory.richWorkspace != nil && directory.richWorkspace.length > 0) {
-        htmlString = [NSString stringWithFormat:@"<h2><span style=\"color: #000000;\">%@</span></h2>", directory.richWorkspace];
-    } else {
-        htmlString = [NSString stringWithFormat:@"<h2><span style=\"color: #999999;\">%@</span></h2>", NSLocalizedString(@"_add_notes_readme_md_", nil)];
-    }
-    
-    [self.viewRichWorkspace.webView loadHTMLString:htmlString baseURL:NSBundle.mainBundle.bundleURL];
-    
     [self.tableView setTableHeaderView:self.viewRichWorkspace];
-
-    
-    /*
-    if (capabilities.versionMajor >= k_nextcloud_version_18_0) {
-        NSString *htmlString;
-        
-        if (richWorkspace != nil && richWorkspace.length > 0) {
-            htmlString = [NSString stringWithFormat:@"<h2><span style=\"color: #000000;\">%@</span></h2>", richWorkspace];
-        } else {
-            htmlString = [NSString stringWithFormat:@"<h2><span style=\"color: #999999;\">%@</span></h2>", NSLocalizedString(@"_add_notes_readme_md_", nil)];
-        }
-        [self.webViewRichWorkspace loadHTMLString:htmlString baseURL:NSBundle.mainBundle.bundleURL];
-        self.constraintHeightRichWorkspace.constant = CCUtility.getRichWorkspaceHeight;
-        [self.mainViewHeightRichWorkspace setHidden:false];
-    } else {
-        self.constraintHeightRichWorkspace.constant = 0;
-        [self.mainViewHeightRichWorkspace setHidden:true];
-    }
-    */
 }
+
 - (void)setTableViewFooter
 {
     UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 40)];

+ 18 - 4
iOSClient/Main/NCRichWorkspace.swift

@@ -11,7 +11,7 @@ import Foundation
 @objc class NCViewRichWorkspace: UIView {
     
     @IBOutlet weak var webView: WKWebView!
-    @IBOutlet weak var viewTouch: NCRichWorkspaceViewTouch!
+    var richWorkspace: String?
 
     required init?(coder: NSCoder) {
         super.init(coder: coder)
@@ -23,6 +23,20 @@ import Foundation
     @objc func changeTheming() {
         self.backgroundColor = NCBrandColor.sharedInstance.brand;
     }
+    
+    @objc func setRichWorkspaceText(_ richWorkspace: String?) {
+        
+        var html = ""
+        
+        if richWorkspace == self.richWorkspace { return }
+        if richWorkspace != nil || richWorkspace!.count > 0 {
+            html = "<h2><span style=\"color: #000000;\">" + richWorkspace! + "</span></h2>"
+        } else {
+            html = "<h2><span style=\"color: #000000;\">" + NSLocalizedString("_add_notes_readme_md_", comment: "") + "</span></h2>"
+        }
+        self.richWorkspace = richWorkspace
+        webView.loadHTMLString(html, baseURL: Bundle.main.bundleURL)
+    }
 }
 
 @objc class NCRichWorkspaceViewTouch: UIView {
@@ -62,11 +76,11 @@ import Foundation
         if let viewRichWorkspace = appDelegate.activeMain.tableView.tableHeaderView {
             let differenceHeight = viewRichWorkspace.frame.height + difference
             if differenceHeight <= minHeight {
-                CCUtility.setRichWorkspaceHeight(Int(minHeight))
+                CCUtility.setRichWorkspaceHeight(minHeight)
             } else if differenceHeight >= maxHeight {
-                CCUtility.setRichWorkspaceHeight(Int(maxHeight))
+                CCUtility.setRichWorkspaceHeight(maxHeight)
             } else {
-                CCUtility.setRichWorkspaceHeight(Int(differenceHeight))
+                CCUtility.setRichWorkspaceHeight(differenceHeight)
             }
             appDelegate.activeMain.setTableViewHeader()
         }

+ 0 - 1
iOSClient/Main/NCRichWorkspace.xib

@@ -56,7 +56,6 @@
             </constraints>
             <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
             <connections>
-                <outlet property="viewTouch" destination="C1O-Se-sSW" id="atg-iz-CXm"/>
                 <outlet property="webView" destination="XXz-cr-h4j" id="Sx0-bC-A3Q"/>
             </connections>
             <point key="canvasLocation" x="136" y="135"/>

+ 2 - 2
iOSClient/Utility/CCUtility.h

@@ -174,8 +174,8 @@
 + (BOOL)getDarkModeDetect;
 + (void)setDarkModeDetect:(BOOL)disable;
 
-+ (NSInteger)getRichWorkspaceHeight;
-+ (void)setRichWorkspaceHeight:(NSInteger)height;
++ (CGFloat)getRichWorkspaceHeight;
++ (void)setRichWorkspaceHeight:(CGFloat)height;
 
 // ===== Varius =====
 

+ 3 - 3
iOSClient/Utility/CCUtility.m

@@ -692,18 +692,18 @@
     [UICKeyChainStore setString:sDisable forKey:@"darkModeDetect" service:k_serviceShareKeyChain];
 }
 
-+ (NSInteger)getRichWorkspaceHeight
++ (CGFloat)getRichWorkspaceHeight
 {
     NSString *height = [UICKeyChainStore stringForKey:@"richWorkspaceHeight" service:k_serviceShareKeyChain];
     
     if (height == nil) {
         return UIScreen.mainScreen.bounds.size.height/5;
     } else {
-        return [height integerValue];
+        return [height floatValue];
     }
 }
 
-+ (void)setRichWorkspaceHeight:(NSInteger)height
++ (void)setRichWorkspaceHeight:(CGFloat)height
 {
     NSString *heightString = [@(height) stringValue];
     [UICKeyChainStore setString:heightString forKey:@"richWorkspaceHeight" service:k_serviceShareKeyChain];