marinofaggiana 5 years ago
parent
commit
d163d83891

+ 3 - 1
iOSClient/Main/CCMain.m

@@ -3889,6 +3889,8 @@
 
 - (void)setTableViewHeader
 {
+    CGFloat height = UIScreen.mainScreen.bounds.size.height/5;
+    
     // Nextcloud 18
     tableCapabilities *capabilities = [[NCManageDatabase sharedInstance] getCapabilitesWithAccount:appDelegate.activeAccount];
     if (capabilities.versionMajor < k_nextcloud_version_18_0) {
@@ -3906,7 +3908,7 @@
         } else {
             
             [self.viewRichWorkspace setRichWorkspaceText:directory.richWorkspace];
-            [self.viewRichWorkspace setFrame:CGRectMake(0, 0, self.tableView.frame.size.width, CCUtility.getRichWorkspaceHeight)];
+            [self.viewRichWorkspace setFrame:CGRectMake(0, 0, self.tableView.frame.size.width, height)];
             [self.tableView setTableHeaderView:self.viewRichWorkspace];
         }
     }

+ 22 - 52
iOSClient/RichWorkspace/NCRichWorkspace.swift

@@ -16,66 +16,36 @@ import Foundation
         super.init(coder: coder)
         
         NotificationCenter.default.addObserver(self, selector: #selector(self.changeTheming), name: NSNotification.Name(rawValue: "changeTheming"), object: nil)
-        self.backgroundColor = NCBrandColor.sharedInstance.brand;
+        self.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
     }
     
     @objc func changeTheming() {
-        self.backgroundColor = NCBrandColor.sharedInstance.brand;
+        self.backgroundColor = NCBrandColor.sharedInstance.backgroundView;
     }
     
-    @objc func setRichWorkspaceText(_ richWorkspace: String?) {
+    @objc func setRichWorkspaceText(_ richWorkspace: String) {
         
-        let html = "<h2><span style=\"color: #000000;\">" + richWorkspace! + "</span></h2>"
-        
-        webView.loadHTMLString(html, baseURL: Bundle.main.bundleURL)
-        webView.isUserInteractionEnabled = false
-    }
-}
-
-@objc class NCRichWorkspaceViewTouch: UIView {
-
-    let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    var startPosition: CGPoint?
-    var originalHeight: CGFloat = 0
-    let minHeight: CGFloat = 0
-    let maxHeight: CGFloat = UIScreen.main.bounds.size.height/3
-
-    required init?(coder: NSCoder) {
-        super.init(coder: coder)
-        
-        self.backgroundColor = NCBrandColor.sharedInstance.separator
-    }
-    
-    /*
-    override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
-        return false
-    }
-    
-    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
-        let touch = touches.first
-        startPosition = touch?.location(in: self)
-        originalHeight = self.frame.height
-    }
-    
-    override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
-        let touch = touches.first
-        let endPosition = touch?.location(in: self)
-        let difference = endPosition!.y - startPosition!.y
-        if let viewRichWorkspace = appDelegate.activeMain.tableView.tableHeaderView {
-            let differenceHeight = viewRichWorkspace.frame.height + difference
-            if differenceHeight <= minHeight {
-                CCUtility.setRichWorkspaceHeight(minHeight)
-            } else if differenceHeight >= maxHeight {
-                CCUtility.setRichWorkspaceHeight(maxHeight)
+        var richWorkspaceHtml = ""
+        let richWorkspaceArray = richWorkspace.components(separatedBy: "\n")
+        for string in richWorkspaceArray {
+            if string.hasPrefix("# ") {
+                richWorkspaceHtml = richWorkspaceHtml + "<h1><span style=\"color: #000000;\">" + string.replacingOccurrences(of: "# ", with: "") + "</span></h1>"
+            } else if string.hasPrefix("## ") {
+                richWorkspaceHtml = richWorkspaceHtml + "<h2><span style=\"color: #000000;\">" + string.replacingOccurrences(of: "## ", with: "") + "</span></h2>"
+            } else if string.hasPrefix("### ") {
+                richWorkspaceHtml = richWorkspaceHtml + "<h3><span style=\"color: #000000;\">" + string.replacingOccurrences(of: "### ", with: "") + "</span></h3>"
+            } else if string.hasPrefix("#### ") {
+                richWorkspaceHtml = richWorkspaceHtml + "<h4><span style=\"color: #000000;\">" + string.replacingOccurrences(of: "#### ", with: "") + "</span></h4>"
+            } else if string.hasPrefix("##### ") {
+                richWorkspaceHtml = richWorkspaceHtml + "<h5><span style=\"color: #000000;\">" + string.replacingOccurrences(of: "##### ", with: "") + "</span></h5>"
+            } else if string.hasPrefix("###### ") {
+                richWorkspaceHtml = richWorkspaceHtml + "<h6><span style=\"color: #000000;\">" + string.replacingOccurrences(of: "###### ", with: "") + "</span></h6>"
             } else {
-                CCUtility.setRichWorkspaceHeight(differenceHeight)
+                richWorkspaceHtml = richWorkspaceHtml + "<span style=\"color: #000000;\">" + string + "</span>"
             }
-            appDelegate.activeMain.setTableViewHeader()
+            richWorkspaceHtml = richWorkspaceHtml + "<br>"
         }
+        
+        webView.loadHTMLString(richWorkspaceHtml, baseURL: Bundle.main.bundleURL)
     }
-    
-    override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
-//        appDelegate.activeMain.tableView.reloadData()
-    }
-    */
 }

+ 6 - 16
iOSClient/RichWorkspace/NCRichWorkspace.xib

@@ -15,36 +15,26 @@
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <subviews>
                 <wkWebView contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XXz-cr-h4j">
-                    <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
+                    <rect key="frame" x="5" y="5" width="310" height="470"/>
                     <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                     <wkWebViewConfiguration key="configuration">
                         <audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
                         <wkPreferences key="preferences"/>
                     </wkWebViewConfiguration>
                 </wkWebView>
-                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="C1O-Se-sSW" customClass="NCRichWorkspaceViewTouch" customModule="Nextcloud" customModuleProvider="target">
-                    <rect key="frame" x="0.0" y="480" width="320" height="0.0"/>
-                    <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-                    <constraints>
-                        <constraint firstAttribute="height" id="xy3-eG-rRi"/>
-                    </constraints>
-                </view>
             </subviews>
             <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
             <constraints>
-                <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="C1O-Se-sSW" secondAttribute="trailing" id="CHl-hJ-Qnx"/>
-                <constraint firstItem="XXz-cr-h4j" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="DCK-aY-jxF"/>
-                <constraint firstItem="XXz-cr-h4j" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" id="FBk-U6-oyG"/>
-                <constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="C1O-Se-sSW" secondAttribute="bottom" id="Zk1-rb-wAc"/>
-                <constraint firstItem="C1O-Se-sSW" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" id="fLO-Ez-t2Z"/>
-                <constraint firstItem="C1O-Se-sSW" firstAttribute="top" secondItem="XXz-cr-h4j" secondAttribute="bottom" id="oxW-bj-bTB"/>
-                <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="XXz-cr-h4j" secondAttribute="trailing" id="sSB-Ux-4JO"/>
+                <constraint firstItem="vUN-kp-3ea" firstAttribute="bottom" secondItem="XXz-cr-h4j" secondAttribute="bottom" constant="5" id="0tw-2O-jd5"/>
+                <constraint firstItem="XXz-cr-h4j" firstAttribute="leading" secondItem="vUN-kp-3ea" secondAttribute="leading" constant="5" id="DCK-aY-jxF"/>
+                <constraint firstItem="XXz-cr-h4j" firstAttribute="top" secondItem="vUN-kp-3ea" secondAttribute="top" constant="5" id="FBk-U6-oyG"/>
+                <constraint firstItem="vUN-kp-3ea" firstAttribute="trailing" secondItem="XXz-cr-h4j" secondAttribute="trailing" constant="5" id="sSB-Ux-4JO"/>
             </constraints>
             <viewLayoutGuide key="safeArea" id="vUN-kp-3ea"/>
             <connections>
                 <outlet property="webView" destination="XXz-cr-h4j" id="Sx0-bC-A3Q"/>
             </connections>
-            <point key="canvasLocation" x="136" y="135"/>
+            <point key="canvasLocation" x="136.875" y="88.75"/>
         </view>
     </objects>
 </document>

+ 0 - 3
iOSClient/Utility/CCUtility.h

@@ -174,9 +174,6 @@
 + (BOOL)getDarkModeDetect;
 + (void)setDarkModeDetect:(BOOL)disable;
 
-+ (CGFloat)getRichWorkspaceHeight;
-+ (void)setRichWorkspaceHeight:(CGFloat)height;
-
 // ===== Varius =====
 
 + (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL;

+ 0 - 17
iOSClient/Utility/CCUtility.m

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