Browse Source

【综合】数据加载完善,兼容暗黑模式

niehaoyu 9 months ago
parent
commit
dd82028b29

+ 23 - 4
PDF Office/PDF Master/Class/GuideInfo/KMCouponDueWindowController.swift

@@ -29,7 +29,7 @@ class KMCouponDueWindowController: NSWindowController {
     var endUpAt: String = ""
     
     deinit {
-        print("KMCouponDueWindowController deInit")
+        NotificationCenter.default.removeObserver(self)
     }
     
     override func windowDidLoad() {
@@ -55,14 +55,16 @@ class KMCouponDueWindowController: NSWindowController {
         }
         self.buyButton.setTitleColor(NSColor.white)
         
+        NotificationCenter.default.addObserver(self, selector: #selector(recommondInfoUpdateNoti), name: NSNotification.Name("KMRecommondInfoUpdateNoti"), object: nil)
+
     }
     
     func refreshUI() {
         if KMAppearance.isDarkMode() {
             self.window?.contentView?.layer?.backgroundColor = NSColor(red: 24/255, green: 22/255, blue: 31/255, alpha: 1).cgColor
-            self.titleLabel.textColor = KMAppearance.KMColor_Layout_L0()
-            self.subTitleLabel.textColor = KMAppearance.KMColor_Layout_L0()
-            self.laterInfoLabel.textColor = KMAppearance.KMColor_Layout_L0()
+            self.titleLabel.textColor = NSColor(red: 252/255, green: 253/255, blue: 255/255, alpha: 1)
+            self.subTitleLabel.textColor = NSColor(red: 252/255, green: 253/255, blue: 255/255, alpha: 1)
+            self.laterInfoLabel.textColor = NSColor(red: 252/255, green: 253/255, blue: 255/255, alpha: 1)
             
         } else {
             self.window?.contentView?.layer?.backgroundColor = NSColor(red: 245/255, green: 249/255, blue: 255/255, alpha: 1).cgColor
@@ -105,4 +107,21 @@ class KMCouponDueWindowController: NSWindowController {
         FMTrackEventManager.defaultManager.trackEvent(event: "PUW", withProperties: ["PUW_Btn" : "Btn_PUW_TrialExpireOffer_Buy"])
     }
     
+    
+    @objc func recommondInfoUpdateNoti(_ notification: Notification) {
+        DispatchQueue.main.async {
+            guard let dict = notification.object as? NSDictionary else {
+                return
+            }
+            
+            guard let unique = dict["unique"] as? String else {
+                return
+            }
+            if unique == KMAdsInfoManager.shareInstance.couponInfo?.versionKey {
+                self.reloadData()
+            }
+            
+            
+        }
+    }
 }

+ 16 - 4
PDF Office/PDF Master/Class/Purchase/DMG/Verification/VerificationManager/KMAdsInfo.swift

@@ -146,10 +146,16 @@ import Cocoa
         get {
             
             let imageDict: [String: Any] = self.infoDict["image"] as! [String : Any]
-            let imageURLString = imageDict[KMAdsInfo().languageKey] as! NSString
+            var languageKey = KMAdsInfo().languageKey
+            if KMAppearance.isDarkMode() {
+                languageKey = "dark_" + KMAdsInfo().languageKey
+            }
+            guard let imageURLString = imageDict[languageKey] as? String else {
+                return NSImage(named: "cnLight")!
+            }
             
             var imageName = self.versionKey
-            imageName.append(String(format: "_%@.%@", KMAdsInfo().languageKey, imageURLString.lastPathComponent))
+            imageName.append(String(format: "_%@.%@", languageKey, imageURLString.lastPathComponent))
  
             let kImageCacheFilePath: String = NSTemporaryDirectory() + "Advertisement/ImageCache"
             let imgSavePath = kImageCacheFilePath + "/" + imageName
@@ -177,10 +183,16 @@ import Cocoa
         get {
             
             let imageDict: [String: Any] = self.infoDict["detailImage"] as! [String : Any]
-            let imageURLString = imageDict[KMAdsInfo().languageKey] as! NSString
+            var languageKey = KMAdsInfo().languageKey
+            if KMAppearance.isDarkMode() {
+                languageKey = "dark_" + KMAdsInfo().languageKey
+            }
+            guard let imageURLString = imageDict[languageKey] as? NSString else {
+                return NSImage(named: "detailCnDark")!
+            }
             
             var imageName = self.versionKey
-            imageName.append(String(format: "_%@.%@", KMAdsInfo().languageKey, imageURLString.lastPathComponent))
+            imageName.append(String(format: "_%@.%@", languageKey, imageURLString.lastPathComponent))
  
             let kImageCacheFilePath: String = NSTemporaryDirectory() + "Advertisement/ImageCache"
             let imgSavePath = kImageCacheFilePath + "/" + imageName