marinofaggiana 4 年之前
父节点
当前提交
afc3e179a3
共有 2 个文件被更改,包括 34 次插入2 次删除
  1. 34 1
      iOSClient/Main/Section/NCSectionHeaderFooter.swift
  2. 0 1
      iOSClient/RichWorkspace/NCRichWorkspace.swift

+ 34 - 1
iOSClient/Main/Section/NCSectionHeaderFooter.swift

@@ -36,7 +36,11 @@ class NCSectionHeaderMenu: UICollectionReusableView {
     @IBOutlet weak var separator: UIView!
     
     var delegate: NCSectionHeaderMenuDelegate?
+    
     private var markdownParser = MarkdownParser()
+    private var richWorkspaceText: String?
+    private var textViewColor: UIColor?
+    private let gradient : CAGradientLayer = CAGradientLayer()
     
     override func awakeFromNib() {
         super.awakeFromNib()
@@ -50,6 +54,32 @@ class NCSectionHeaderMenu: UICollectionReusableView {
         
         separator.backgroundColor = NCBrandColor.sharedInstance.separator
         self.backgroundColor = NCBrandColor.sharedInstance.backgroundView
+        
+        // Gradient
+        gradient.startPoint = CGPoint(x: 0, y: 0.60)
+        gradient.endPoint = CGPoint(x: 0, y: 1)
+        viewRichWorkspace.layer.addSublayer(gradient)
+        
+        NotificationCenter.default.addObserver(self, selector: #selector(changeTheming), name: NSNotification.Name(rawValue: k_notificationCenter_changeTheming), object: nil)
+        changeTheming()
+    }
+    
+    @objc func changeTheming() {
+        if textViewColor != NCBrandColor.sharedInstance.textView {
+            markdownParser = MarkdownParser(font: UIFont.systemFont(ofSize: 15), color: NCBrandColor.sharedInstance.textView)
+            markdownParser.header.font = UIFont.systemFont(ofSize: 25)
+            if let richWorkspaceText = richWorkspaceText {
+                textViewRichWorkspace.attributedText = markdownParser.parse(richWorkspaceText)
+            }
+            textViewColor = NCBrandColor.sharedInstance.textView
+            
+            if CCUtility.getDarkMode() {
+                gradient.colors = [UIColor.init(white: 0, alpha: 0).cgColor, UIColor.black.cgColor]
+            } else {
+                gradient.colors = [UIColor.init(white: 1, alpha: 0).cgColor, UIColor.white.cgColor]
+            }
+            
+        }
     }
     
     func setTitleSorted(datasourceTitleButton: String) {
@@ -76,7 +106,10 @@ class NCSectionHeaderMenu: UICollectionReusableView {
     
     func setRichWorkspaceText(richWorkspaceText: String?) {
         guard let richWorkspaceText = richWorkspaceText else { return }
-        textViewRichWorkspace.attributedText = markdownParser.parse(richWorkspaceText)
+        if richWorkspaceText != self.richWorkspaceText {
+            textViewRichWorkspace.attributedText = markdownParser.parse(richWorkspaceText)
+            self.richWorkspaceText = richWorkspaceText
+        }
     }
     
     @IBAction func touchUpInsideMore(_ sender: Any) {

+ 0 - 1
iOSClient/RichWorkspace/NCRichWorkspace.swift

@@ -65,7 +65,6 @@ import MarkdownKit
             } else {
                 gradient.colors = [UIColor.init(white: 1, alpha: 0).cgColor, UIColor.white.cgColor]
             }
-            
         }
     }