marinofaggiana 4 年之前
父节点
当前提交
697c4c5ec8

+ 25 - 72
iOSClient/Main/Collection/NCCollectionViewCommon.swift

@@ -52,9 +52,8 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
     private var listLayout: NCListLayout!
     private var listLayout: NCListLayout!
     private var gridLayout: NCGridLayout!
     private var gridLayout: NCGridLayout!
             
             
-    private let headerMenuHeight: CGFloat = 50
+    private let headerHeight: CGFloat = 50
     private var headerRichWorkspaceHeight: CGFloat = 0
     private var headerRichWorkspaceHeight: CGFloat = 0
-    private let sectionHeaderHeight: CGFloat = 20
     private let footerHeight: CGFloat = 50
     private let footerHeight: CGFloat = 50
     
     
     private var timerInputSearch: Timer?
     private var timerInputSearch: Timer?
@@ -674,71 +673,34 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
 
 
     func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
     func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
         
         
-        if (indexPath.section == 0) {
+        if kind == UICollectionView.elementKindSectionHeader {
             
             
-            if kind == UICollectionView.elementKindSectionHeader {
-                
-                let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as! NCSectionHeaderMenu
-                
-                if collectionView.collectionViewLayout == gridLayout {
-                    header.buttonSwitch.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "switchList"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), for: .normal)
-                } else {
-                    header.buttonSwitch.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "switchGrid"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), for: .normal)
-                }
-                
-                header.delegate = self
-                header.backgroundColor = NCBrandColor.sharedInstance.backgroundView
-                header.separator.backgroundColor = NCBrandColor.sharedInstance.separator
-                header.setStatusButton(count: dataSource?.metadatas.count ?? 0)
-                header.setTitleSorted(datasourceTitleButton: titleButton)
-                header.labelSectionHeightConstraint.constant = headerRichWorkspaceHeight
-
-                if groupBy == "none" {
-                    header.labelSection.isHidden = true
-                    header.labelSectionHeightConstraint.constant = 0
-                } else {
-                    header.labelSection.isHidden = false
-                    header.setTitleLabel(title: "")
-                    header.labelSectionHeightConstraint.constant = sectionHeaderHeight
-                }
-                
-                if metadataFolder?.richWorkspace?.count ?? 0 == 0 {
-                    header.labelSection.isHidden = true
-                } else {
-                    header.labelSection.isHidden = false
-                }
-                
-                return header
-                
+            let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as! NCSectionHeaderMenu
+            
+            if collectionView.collectionViewLayout == gridLayout {
+                header.buttonSwitch.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "switchList"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), for: .normal)
             } else {
             } else {
-                
-                let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
-                
-                let info = dataSource?.getFilesInformation()
-                footer.setTitleLabel(directories: info?.directories ?? 0, files: info?.files ?? 0, size: info?.size ?? 0)
-                
-                return footer
+                header.buttonSwitch.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "switchGrid"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), for: .normal)
             }
             }
             
             
+            header.delegate = self
+            header.backgroundColor = NCBrandColor.sharedInstance.backgroundView
+            header.separator.backgroundColor = NCBrandColor.sharedInstance.separator
+            header.setStatusButton(count: dataSource?.metadatas.count ?? 0)
+            header.setTitleSorted(datasourceTitleButton: titleButton)
+            header.viewRichWorkspaceHeightConstraint.constant = headerRichWorkspaceHeight
+            header.setRichWorkspaceText(richWorkspaceText: metadataFolder?.richWorkspace)
+
+            return header
+            
         } else {
         } else {
             
             
-            if kind == UICollectionView.elementKindSectionHeader {
-                
-                let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) as! NCSectionHeader
-                
-                header.setTitleLabel(title: "")
-                
-                return header
-                
-            } else {
-                
-                let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
-                
-                let info = dataSource?.getFilesInformation()
-                footer.setTitleLabel(directories: info?.directories ?? 0, files: info?.files ?? 0, size: info?.size ?? 0)
-                
-                return footer
-            }
+            let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
+            
+            let info = dataSource?.getFilesInformation()
+            footer.setTitleLabel(directories: info?.directories ?? 0, files: info?.files ?? 0, size: info?.size ?? 0)
+            
+            return footer
         }
         }
     }
     }
     
     
@@ -778,19 +740,10 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
 extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout {
 extension NCCollectionViewCommon: UICollectionViewDelegateFlowLayout {
 
 
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
-        if section == 0 {
-            return CGSize(width: collectionView.frame.width, height: headerMenuHeight + sectionHeaderHeight + headerRichWorkspaceHeight)
-        } else {
-            return CGSize(width: collectionView.frame.width, height: sectionHeaderHeight)
-        }
+        return CGSize(width: collectionView.frame.width, height: headerHeight + headerRichWorkspaceHeight)
     }
     }
     
     
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
-        let sections = 1
-        if (section == sections - 1) {
-            return CGSize(width: collectionView.frame.width, height: footerHeight)
-        } else {
-            return CGSize(width: collectionView.frame.width, height: 0)
-        }
+        return CGSize(width: collectionView.frame.width, height: footerHeight)
     }
     }
 }
 }

+ 10 - 27
iOSClient/Main/Section/NCSectionHeaderFooter.swift

@@ -22,6 +22,7 @@
 //
 //
 
 
 import Foundation
 import Foundation
+import MarkdownKit
 
 
 class NCSectionHeaderMenu: UICollectionReusableView {
 class NCSectionHeaderMenu: UICollectionReusableView {
     
     
@@ -29,12 +30,13 @@ class NCSectionHeaderMenu: UICollectionReusableView {
     @IBOutlet weak var buttonSwitch: UIButton!
     @IBOutlet weak var buttonSwitch: UIButton!
     @IBOutlet weak var buttonOrder: UIButton!
     @IBOutlet weak var buttonOrder: UIButton!
     @IBOutlet weak var buttonOrderWidthConstraint: NSLayoutConstraint!
     @IBOutlet weak var buttonOrderWidthConstraint: NSLayoutConstraint!
-    @IBOutlet weak var viewLabelSection: UIView!
-    @IBOutlet weak var labelSection: UILabel!
-    @IBOutlet weak var labelSectionHeightConstraint: NSLayoutConstraint!
+    @IBOutlet weak var viewRichWorkspace: UIView!
+    @IBOutlet weak var viewRichWorkspaceHeightConstraint: NSLayoutConstraint!
+    @IBOutlet weak var textViewRichWorkspace: UITextView!
     @IBOutlet weak var separator: UIView!
     @IBOutlet weak var separator: UIView!
     
     
     var delegate: NCSectionHeaderMenuDelegate?
     var delegate: NCSectionHeaderMenuDelegate?
+    private var markdownParser = MarkdownParser()
     
     
     override func awakeFromNib() {
     override func awakeFromNib() {
         super.awakeFromNib()
         super.awakeFromNib()
@@ -46,7 +48,6 @@ class NCSectionHeaderMenu: UICollectionReusableView {
         
         
         buttonMore.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "more"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon), for: .normal)
         buttonMore.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "more"), width: 50, height: 50, color: NCBrandColor.sharedInstance.icon), for: .normal)
         
         
-        viewLabelSection.backgroundColor = NCBrandColor.sharedInstance.select
         separator.backgroundColor = NCBrandColor.sharedInstance.separator
         separator.backgroundColor = NCBrandColor.sharedInstance.separator
         self.backgroundColor = NCBrandColor.sharedInstance.backgroundView
         self.backgroundColor = NCBrandColor.sharedInstance.backgroundView
     }
     }
@@ -60,29 +61,6 @@ class NCSectionHeaderMenu: UICollectionReusableView {
         buttonOrderWidthConstraint.constant = size.width + 5
         buttonOrderWidthConstraint.constant = size.width + 5
     }
     }
     
     
-    func setTitleLabel(title: String) {
-        
-        /*
-        var title = ""
-        
-        if sectionDatasource.sections.object(at: section) is String {
-            title = sectionDatasource.sections.object(at: section) as! String
-        }
-        if sectionDatasource.sections.object(at: section) is Date {
-            let titleDate = sectionDatasource.sections.object(at: section) as! Date
-            title = CCUtility.getTitleSectionDate(titleDate)
-        }
-        */
-        
-        if title.contains("download") {
-            labelSection.text = NSLocalizedString("_title_section_download_", comment: "")
-        } else if title.contains("upload") {
-            labelSection.text = NSLocalizedString("_title_section_upload_", comment: "")
-        } else {
-            labelSection.text = NSLocalizedString(title, comment: "")
-        }
-    }
-    
     func setStatusButton(count: Int) {
     func setStatusButton(count: Int) {
         
         
         if count == 0 {
         if count == 0 {
@@ -96,6 +74,11 @@ class NCSectionHeaderMenu: UICollectionReusableView {
         }
         }
     }
     }
     
     
+    func setRichWorkspaceText(richWorkspaceText: String?) {
+        guard let richWorkspaceText = richWorkspaceText else { return }
+        textViewRichWorkspace.attributedText = markdownParser.parse(richWorkspaceText)
+    }
+    
     @IBAction func touchUpInsideMore(_ sender: Any) {
     @IBAction func touchUpInsideMore(_ sender: Any) {
         delegate?.tapMoreHeader(sender: sender)
         delegate?.tapMoreHeader(sender: sender)
     }
     }

+ 18 - 19
iOSClient/Main/Section/NCSectionHeaderMenu.xib

@@ -1,11 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
-    <device id="retina4_7" orientation="portrait">
-        <adaptation id="fullscreen"/>
-    </device>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16097.3" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait" appearance="light"/>
     <dependencies>
     <dependencies>
         <deployment identifier="iOS"/>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     </dependencies>
@@ -75,22 +73,23 @@
                         <constraint firstItem="0bo-yl-t5k" firstAttribute="leading" secondItem="1LD-cd-zhc" secondAttribute="trailing" constant="18" id="tBF-23-TJ4"/>
                         <constraint firstItem="0bo-yl-t5k" firstAttribute="leading" secondItem="1LD-cd-zhc" secondAttribute="trailing" constant="18" id="tBF-23-TJ4"/>
                     </constraints>
                     </constraints>
                 </view>
                 </view>
-                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="NC1-5C-E5z">
+                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="NC1-5C-E5z" userLabel="ViewRichWorkspace">
                     <rect key="frame" x="0.0" y="113" width="375" height="50"/>
                     <rect key="frame" x="0.0" y="113" width="375" height="50"/>
                     <subviews>
                     <subviews>
-                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="PVg-rp-dMy">
-                            <rect key="frame" x="10" y="18" width="355" height="14.5"/>
-                            <fontDescription key="fontDescription" type="system" pointSize="12"/>
-                            <nil key="textColor"/>
-                            <nil key="highlightedColor"/>
-                        </label>
+                        <textView clipsSubviews="YES" multipleTouchEnabled="YES" userInteractionEnabled="NO" contentMode="scaleToFill" editable="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="pYo-pF-MGv">
+                            <rect key="frame" x="5" y="0.0" width="365" height="50"/>
+                            <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                            <color key="textColor" systemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>
+                            <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                            <textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
+                        </textView>
                     </subviews>
                     </subviews>
-                    <color key="backgroundColor" red="1" green="0.5" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                     <constraints>
                     <constraints>
-                        <constraint firstAttribute="trailing" secondItem="PVg-rp-dMy" secondAttribute="trailing" constant="10" id="Rup-Kj-YB9"/>
-                        <constraint firstItem="PVg-rp-dMy" firstAttribute="leading" secondItem="NC1-5C-E5z" secondAttribute="leading" constant="10" id="VT2-KQ-3Rs"/>
+                        <constraint firstItem="pYo-pF-MGv" firstAttribute="top" secondItem="NC1-5C-E5z" secondAttribute="top" id="PgU-fC-vEG"/>
                         <constraint firstAttribute="height" constant="50" id="eT3-4m-mJ6"/>
                         <constraint firstAttribute="height" constant="50" id="eT3-4m-mJ6"/>
-                        <constraint firstItem="PVg-rp-dMy" firstAttribute="centerY" secondItem="NC1-5C-E5z" secondAttribute="centerY" id="kJS-Jt-w50"/>
+                        <constraint firstAttribute="trailing" secondItem="pYo-pF-MGv" secondAttribute="trailing" constant="5" id="nSk-Jr-ufp"/>
+                        <constraint firstItem="pYo-pF-MGv" firstAttribute="leading" secondItem="NC1-5C-E5z" secondAttribute="leading" constant="5" id="qoB-Sw-ipc"/>
+                        <constraint firstAttribute="bottom" secondItem="pYo-pF-MGv" secondAttribute="bottom" id="t4r-dA-VyW"/>
                     </constraints>
                     </constraints>
                 </view>
                 </view>
             </subviews>
             </subviews>
@@ -109,10 +108,10 @@
                 <outlet property="buttonOrder" destination="0bo-yl-t5k" id="Kbw-BG-73C"/>
                 <outlet property="buttonOrder" destination="0bo-yl-t5k" id="Kbw-BG-73C"/>
                 <outlet property="buttonOrderWidthConstraint" destination="jvv-Ug-l3I" id="E6N-z6-2VC"/>
                 <outlet property="buttonOrderWidthConstraint" destination="jvv-Ug-l3I" id="E6N-z6-2VC"/>
                 <outlet property="buttonSwitch" destination="1LD-cd-zhc" id="Ec2-cM-CoY"/>
                 <outlet property="buttonSwitch" destination="1LD-cd-zhc" id="Ec2-cM-CoY"/>
-                <outlet property="labelSection" destination="PVg-rp-dMy" id="wrp-Tl-oBd"/>
-                <outlet property="labelSectionHeightConstraint" destination="eT3-4m-mJ6" id="e31-Et-7U1"/>
                 <outlet property="separator" destination="LZu-Te-clJ" id="EwO-za-LxT"/>
                 <outlet property="separator" destination="LZu-Te-clJ" id="EwO-za-LxT"/>
-                <outlet property="viewLabelSection" destination="NC1-5C-E5z" id="FXG-Lp-IGJ"/>
+                <outlet property="textViewRichWorkspace" destination="pYo-pF-MGv" id="2h4-LP-T1z"/>
+                <outlet property="viewRichWorkspace" destination="NC1-5C-E5z" id="NyN-tr-sJl"/>
+                <outlet property="viewRichWorkspaceHeightConstraint" destination="eT3-4m-mJ6" id="agb-tE-jhw"/>
             </connections>
             </connections>
             <point key="canvasLocation" x="138.40000000000001" y="194.75262368815595"/>
             <point key="canvasLocation" x="138.40000000000001" y="194.75262368815595"/>
         </collectionReusableView>
         </collectionReusableView>

+ 0 - 9
iOSClient/Select/NCSelect.swift

@@ -412,15 +412,6 @@ extension NCSelect: UICollectionViewDataSource {
                 header.setStatusButton(count: dataSource?.metadatas.count ?? 0)
                 header.setStatusButton(count: dataSource?.metadatas.count ?? 0)
                 header.setTitleSorted(datasourceTitleButton: titleButton)
                 header.setTitleSorted(datasourceTitleButton: titleButton)
                 
                 
-                if groupBy == "none" {
-                    header.labelSection.isHidden = true
-                    header.labelSectionHeightConstraint.constant = 0
-                } else {
-                    header.labelSection.isHidden = false
-                    header.setTitleLabel(title: "")
-                    header.labelSectionHeightConstraint.constant = sectionHeaderHeight
-                }
-                
                 return header
                 return header
                 
                 
             } else {
             } else {