Ver código fonte

【订阅】权益界面逻辑完善

lizhe 1 ano atrás
pai
commit
2f961973f1

+ 18 - 1
PDF Office/PDF Master/Class/KMLightMember/Controller/SubscriptionView/WaterMark/KMSubscribeWaterMarkWindowController.swift

@@ -12,15 +12,18 @@ var subscribeWaterMarkMainWindow: NSWindow?
 typealias KMSubscribeWaterMarkWindowControllerCloseAction = (_ controller: KMSubscribeWaterMarkWindowController) -> Void
 typealias KMSubscribeWaterMarkWindowControllerWatermarkExportAction = (_ controller: KMSubscribeWaterMarkWindowController) -> Void
 typealias KMSubscribeWaterMarkWindowControllerSubscribeAction = (_ controller: KMSubscribeWaterMarkWindowController) -> Void
+typealias KMSubscribeWaterMarkWindowControllerRestoreAction = (_ controller: KMSubscribeWaterMarkWindowController) -> Void
+
 class KMSubscribeWaterMarkWindowController: NSWindowController {
 
     @IBOutlet weak var waterMarkView: KMSubscribeWaterMarkView!
     var closeAction: KMSubscribeWaterMarkWindowControllerCloseAction?
     var subscribeAction: KMSubscribeWaterMarkWindowControllerSubscribeAction?
     var watermarkExportAction: KMSubscribeWaterMarkWindowControllerWatermarkExportAction?
+    var restoreAction: KMSubscribeWaterMarkWindowControllerRestoreAction?
     
     deinit {
-        print("KMCancellationWindowController 释放")
+        print("KMSubscribeWaterMarkWindowController 释放")
     }
     
     override func windowDidLoad() {
@@ -73,6 +76,11 @@ class KMSubscribeWaterMarkWindowController: NSWindowController {
             }
         }
         
+        subscribeWaterMarkWindowController.restoreAction = { controller in
+            print("restore")
+            KMPurchaseManager.manager.restorePurchases()
+        }
+        
         subscribeWaterMarkController = subscribeWaterMarkWindowController
         subscribeWaterMarkMainWindow = window
         return subscribeWaterMarkWindowController
@@ -82,16 +90,25 @@ class KMSubscribeWaterMarkWindowController: NSWindowController {
         self.window?.contentView?.backgroundColor(NSColor(hex: "#FFFFFF"))
         self.waterMarkView.closeAction = { [weak self] view in
             guard let callBack = self?.closeAction else { return }
+            
             callBack((self!))
         }
         
         self.waterMarkView.waterMarkExportAction = { [weak self] view in
             guard let callBack = self?.watermarkExportAction else { return }
+            
             callBack((self!))
         }
         
         self.waterMarkView.subscribeAction = { [weak self] view in
             guard let callBack = self?.subscribeAction else { return }
+            
+            callBack((self!))
+        }
+        
+        self.waterMarkView.restoreAction = { [weak self] view in
+            guard let callBack = self?.restoreAction else { return }
+            
             callBack((self!))
         }
     }

+ 9 - 1
PDF Office/PDF Master/Class/KMLightMember/Controller/SubscriptionView/WaterMark/View/KMSubscribeWaterMarkCollectionItem.swift

@@ -39,7 +39,15 @@ class KMSubscribeWaterMarkCollectionItem: NSCollectionViewItem {
             let titleString: String = data["title"] as? String ?? ""
             let subtitleString: String = data["subtitle"] as? String ?? ""
             self.titleLabel.stringValue = NSLocalizedString(titleString, comment: "")
-            self.titleLabel.stringValue = NSLocalizedString(subtitleString, comment: "")
+            self.subtitleLabel.stringValue = NSLocalizedString(subtitleString, comment: "")
+            self.iconImageView.image = NSImage(named: data["image"] as! NSImage.Name)
+            
+            let paragraphStyle = NSMutableParagraphStyle()
+            paragraphStyle.lineHeightMultiple = 1.32
+            paragraphStyle.alignment = .left
+            self.titleLabel.attributedStringValue = NSMutableAttributedString(string: NSLocalizedString(titleString, comment: ""), attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
+            
+            self.subtitleLabel.attributedStringValue = NSMutableAttributedString(string: NSLocalizedString(subtitleString, comment: ""), attributes: [NSAttributedString.Key.paragraphStyle: paragraphStyle])
         }
     }
 }

+ 2 - 2
PDF Office/PDF Master/Class/KMLightMember/Controller/SubscriptionView/WaterMark/View/KMSubscribeWaterMarkCollectionItem.xib

@@ -17,7 +17,7 @@
         <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
         <customObject id="-3" userLabel="Application" customClass="NSObject"/>
         <customView id="Hz6-mo-xeY">
-            <rect key="frame" x="0.0" y="0.0" width="400" height="66"/>
+            <rect key="frame" x="0.0" y="0.0" width="448" height="66"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
             <subviews>
                 <imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="UN8-s9-tdC">
@@ -33,7 +33,7 @@
                     <constraints>
                         <constraint firstAttribute="width" constant="356" id="Qfq-qo-48g"/>
                     </constraints>
-                    <textFieldCell key="cell" lineBreakMode="clipping" title="Using the AI function" id="WM5-O9-VQg">
+                    <textFieldCell key="cell" title="Using the AI function" id="WM5-O9-VQg">
                         <font key="font" metaFont="system"/>
                         <color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>

+ 9 - 14
PDF Office/PDF Master/Class/KMLightMember/Controller/SubscriptionView/WaterMark/View/KMSubscribeWaterMarkView.swift

@@ -65,7 +65,7 @@ class KMSubscribeWaterMarkView: KMBaseXibView {
         self.titleLabel.font = NSFont.SFProTextSemibold(20)
         
         self.waterExportButton.backgroundColor(NSColor(hex: "#EDEEF0"))
-        self.waterExportButton.border(NSColor(hex: "#DFE1E5"), 0, 20)
+        self.waterExportButton.border(NSColor(hex: "#DFE1E5"), 1, 20)
         self.waterExportButton.contentTintColor = NSColor(hex: "#252629")
         self.waterExportButton.font = NSFont.SFProTextRegular(16)
         
@@ -131,26 +131,19 @@ extension KMSubscribeWaterMarkView {
     }
 }
 
-extension KMSubscribeWaterMarkView {
-    @IBAction func doneAction(_ sender: Any) {
-//        guard let callBack = doneAction else { return }
-//
-//        callBack(self, data)
-    }
-}
-
 extension KMSubscribeWaterMarkView: NSCollectionViewDataSource {
 public func numberOfSections(in collectionView: NSCollectionView) -> Int {
-        return 1
+    return dataArray.count
     }
 
     public func collectionView(_ collectionView: NSCollectionView, numberOfItemsInSection section: Int) -> Int {
-        return dataArray.count
+        return 1
     }
 
     //返回对应的item自定义个体
     public func collectionView(_ collectionView: NSCollectionView, itemForRepresentedObjectAt indexPath: IndexPath) -> NSCollectionViewItem {
         let view = collectionView.makeItem(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "KMSubscribeWaterMarkCollectionItem"), for: indexPath) as! KMSubscribeWaterMarkCollectionItem
+        view.data = self.dataArray[indexPath.section]
         return view
     }
 }
@@ -172,19 +165,21 @@ extension KMSubscribeWaterMarkView: NSCollectionViewDelegateFlowLayout {
     public func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> NSSize {
         let data = self.dataArray[indexPath.section]
         let string: NSString = data["title"]! as NSString
+        let subtitleString: NSString = data["subtitle"]! as NSString
 
         let paragraphStyle = NSMutableParagraphStyle()
         paragraphStyle.lineHeightMultiple = 1.32
         paragraphStyle.alignment = .left
-        let size: NSSize = string.boundingRect(with: NSSize(width: 232, height: 100), options: NSString.DrawingOptions(rawValue: 3), attributes: [NSAttributedString.Key.font : NSFont.SFProTextRegular(12), NSAttributedString.Key.paragraphStyle : paragraphStyle]).size
-        return NSSize(width: 279, height: max(20, size.height))
+        let size: NSSize = string.boundingRect(with: NSSize(width: 356, height: 100), options: NSString.DrawingOptions(rawValue: 3), attributes: [NSAttributedString.Key.font : NSFont.SFProTextSemibold(14), NSAttributedString.Key.paragraphStyle : paragraphStyle]).size
+        let subtitleSize: NSSize = subtitleString.boundingRect(with: NSSize(width: 356, height: 100), options: NSString.DrawingOptions(rawValue: 3), attributes: [NSAttributedString.Key.font : NSFont.SFProTextRegular(12), NSAttributedString.Key.paragraphStyle : paragraphStyle]).size
+        return NSSize(width: 400, height: max(66, size.height + subtitleSize.height + 4))
     }
 
     public func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, insetForSectionAt section: Int) -> NSEdgeInsets {
         if section == self.dataArray.count - 1 {
             return NSEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
         } else {
-            return NSEdgeInsets(top: 0, left: 0, bottom: 12, right: 0)
+            return NSEdgeInsets(top: 0, left: 0, bottom: 20, right: 0)
         }
     }
 }

+ 2 - 2
PDF Office/PDF Master/Class/KMLightMember/Controller/SubscriptionView/WaterMark/View/KMSubscribeWaterMarkView.xib

@@ -114,14 +114,14 @@
                 <customView translatesAutoresizingMaskIntoConstraints="NO" id="MG4-H3-ZA1">
                     <rect key="frame" x="24" y="189" width="400" height="238"/>
                     <subviews>
-                        <scrollView wantsLayer="YES" borderType="none" autohidesScrollers="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" hasVerticalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iQs-EU-LBJ">
+                        <scrollView wantsLayer="YES" borderType="none" autohidesScrollers="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iQs-EU-LBJ">
                             <rect key="frame" x="0.0" y="0.0" width="400" height="238"/>
                             <clipView key="contentView" drawsBackground="NO" id="k4V-l0-a8F">
                                 <rect key="frame" x="0.0" y="0.0" width="400" height="238"/>
                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                 <subviews>
                                     <collectionView id="G8e-lU-M2R">
-                                        <rect key="frame" x="0.0" y="0.0" width="400" height="158"/>
+                                        <rect key="frame" x="0.0" y="0.0" width="400" height="238"/>
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES"/>
                                         <collectionViewFlowLayout key="collectionViewLayout" minimumInteritemSpacing="10" minimumLineSpacing="10" id="1Gk-3q-zuH">
                                             <size key="itemSize" width="50" height="50"/>