Browse Source

Merge branch 'develop_v1.2' of git.kdan.cc:Mac_PDF/PDF_Office into develop_v1.2

tangchao 1 year ago
parent
commit
e97537ee16

+ 26 - 63
PDF Office/PDF Master/Class/KMLightMember/Controller/ComparativeTable/View/KMComparativeView/KMComparativeView.swift

@@ -37,18 +37,19 @@ class KMComparativeView: KMBaseXibView {
         [
             "type": 0,
             "title": "Registered",
-            "subtitle": "Free",
+            "subtitle": "Free Plan",
+            "describe": "Simply log in and get benefits.",
             "content": [
-                ["title": "Basic functions like annotation and viewing",
-                 "state": true],
-                ["title": "Convert PDF to Office (Only first ten pages)",
-                 "state": true],
-                ["title": "Save without watermark",
-                 "state": false],
                 ["title": "AI translate, rewrite, correction",
-                 "state": false]
+                 "state": 0],
+                ["title": "Save without watermark",
+                 "state": 0],
+                ["title": "Convert with 10 pages per file",
+                 "state": 2],
+                ["title": "Basic functions like annotation and viewing",
+                 "state": 2]
             ],
-            "buttonTitle": "Sign up for Free"
+            "buttonTitle": "Free Trial"
         ],
         [
             "type": 1,
@@ -57,16 +58,16 @@ class KMComparativeView: KMBaseXibView {
             "describe": "Save 50%@ for the first year, auto-renew at %@. Billed yearly.",
             "productId": PRODUCT_1,
             "content": [
-                ["title": "Enjoy all premium features",
-                 "state": true],
-                ["title": "Convert PDF to Office without limitation",
-                 "state": true],
-                ["title": "Save without watermark",
-                 "state": true],
                 ["title": "AI translate, rewrite, correction",
-                 "state": true]
+                 "state": 1],
+                ["title": "Save without watermark",
+                 "state": 1],
+                ["title": "Convert PDF to Office without limitation",
+                 "state": 1],
+                ["title": "Unlock all premium features",
+                 "state": 1]
             ],
-            "buttonTitle": "Subscribe Now"
+            "buttonTitle": "Buy Now"
         ]
     ]
     
@@ -124,34 +125,8 @@ class KMComparativeView: KMBaseXibView {
     }
     
     override func updateLanguage() {
-//        + "  " + NSLocalizedString("Subscription", comment: ""
         self.restoreButton.title = NSLocalizedString("Restore Purchases", comment: "")
         self.titleLabel.stringValue = NSLocalizedString("Upgrade to Use All Features", comment: "")
-        
-//        let string = NSLocalizedString("""
-//Payment will be charged to your Apple ID account at the confirmation of purchase.
-//Subscription automatically renews unless it is canceled at least 24 hours before
-//the end of the current period. Your account will be charged for renewal within 24
-//hours prior to the end of the current period. You can manage and cancel your
-//subscriptions by going to your account settings on the App Store after purchase.
-//""", comment: "")
-//        let attributedString = NSMutableAttributedString.init(string: string)
-//        let paragraphStyle = NSMutableParagraphStyle()
-//        paragraphStyle.alignment = .left;
-//        paragraphStyle.lineHeightMultiple = 1.37
-//        attributedString.addAttributes([NSAttributedString.Key.font : NSFont.SFProTextRegular(11.0),
-//                                        NSAttributedString.Key.foregroundColor : NSColor(hex: "#94989C"),
-//                                        NSAttributedString.Key.paragraphStyle : paragraphStyle],
-//                                    range: NSRange(location: 0, length: string.count))
-//
-////        let range = string.range(of: NSLocalizedString("Subscription", comment: ""))
-////        attributedString.setAttributes([NSAttributedString.Key.font : NSFont.SFProTextRegular(12.0),
-////                                        NSAttributedString.Key.foregroundColor : NSColor(hex: "#1770F4"),
-////                                        NSAttributedString.Key.underlineColor : NSColor.clear,
-////                                        NSAttributedString.Key.link : "register://"],
-////                                       range: string.nsRange(from: range!)!)
-//
-//        self.textView.textStorage?.setAttributedString(attributedString)
     }
     
     override func reloadData() {
@@ -163,17 +138,6 @@ class KMComparativeView: KMBaseXibView {
     }
     
     @IBAction func infoButtonAction(_ sender: Any) {
-//        let contentViewController = NSViewController()
-//        contentViewController.view = NSView(frame: NSRect(x: 0, y: 0, width: 200, height: 100))
-//        contentViewController.view.wantsLayer = true
-//        contentViewController.view.layer?.backgroundColor = NSColor(hex:"#36383B").cgColor
-//        contentViewController.title =
-//
-//        let popover = NSPopover()
-//        popover.contentViewController = contentViewController
-//        popover.behavior = .transient
-//        popover.setValue(true, forKey: "shouldHideAnchor")
-//        popover.show(relativeTo: infoButton.bounds, of: infoButton, preferredEdge: .maxX)
         self.showPopover(sender)
     }
     
@@ -186,20 +150,18 @@ class KMComparativeView: KMBaseXibView {
     }
     
     func setupPopover() {
-        let string: NSString = NSLocalizedString("""
-            Payment will be charged to your Apple ID account at the confirmation of purchase.
-            Subscription automatically renews unless it is canceled at least 24 hours before
-            the end of the current period. Your account will be charged for renewal within 24
-            hours prior to the end of the current period. You can manage and cancel your
-            subscriptions by going to your account settings on the App Store after purchase.
-            """, comment: "") as NSString
+        let string: NSString = NSLocalizedString(
+"""
+Payment will be charged to your Apple ID account at the confirmation of purchase.\nSubscription automatically renews unless it is canceled at least 24 hours before the end of the current period. Your account will be charged for renewal within 24 hours prior to the end of the current period. You can manage and cancel your subscriptions by going to your account settings on the App Store after purchase.
+"""
+            , comment: "") as NSString
         
         let paragraphStyle = NSMutableParagraphStyle()
         paragraphStyle.lineHeightMultiple = 1.4
         paragraphStyle.alignment = .left
         let attributes = [NSAttributedString.Key.font : NSFont.SFProTextRegular(12), NSAttributedString.Key.paragraphStyle : paragraphStyle]
-        let size: NSSize = string.boundingRect(with: NSSize(width: 420, height: 400), options: NSString.DrawingOptions(rawValue: 3), attributes: attributes).size
-        
+        var size: NSSize = string.boundingRect(with: NSSize(width: 420, height: 600), options: NSString.DrawingOptions(rawValue: 3), attributes: attributes).size
+        size = CGSize(width: size.width, height: size.height + 30)
         
         popover.behavior = .transient
         popover.setValue(true, forKey: "shouldHideAnchor")
@@ -214,6 +176,7 @@ class KMComparativeView: KMBaseXibView {
         textField.drawsBackground = false
         textField.isEditable = false
         textField.isSelectable = false
+        textField.lineBreakMode = .byCharWrapping
         textField.textColor = NSColor(hex: "#FFFFFF")
         
         popover.contentViewController?.view.addSubview(textField)

+ 5 - 5
PDF Office/PDF Master/Class/KMLightMember/Controller/ComparativeTable/View/KMComparativeView/KMComparativeView.xib

@@ -173,16 +173,16 @@
                             </constraints>
                         </customView>
                         <customView translatesAutoresizingMaskIntoConstraints="NO" id="tuB-UO-PhU">
-                            <rect key="frame" x="0.0" y="56" width="807" height="505"/>
+                            <rect key="frame" x="0.0" y="76" width="807" height="485"/>
                             <subviews>
                                 <scrollView wantsLayer="YES" borderType="none" autohidesScrollers="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasVerticalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ScA-aL-r0P">
-                                    <rect key="frame" x="40" y="0.0" width="727" height="505"/>
+                                    <rect key="frame" x="40" y="0.0" width="727" height="485"/>
                                     <clipView key="contentView" drawsBackground="NO" id="O9C-OM-ue0">
-                                        <rect key="frame" x="0.0" y="0.0" width="727" height="505"/>
+                                        <rect key="frame" x="0.0" y="0.0" width="727" height="485"/>
                                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                         <subviews>
                                             <collectionView allowsEmptySelection="NO" id="tXY-fl-8XY">
-                                                <rect key="frame" x="0.0" y="0.0" width="727" height="505"/>
+                                                <rect key="frame" x="0.0" y="0.0" width="727" height="485"/>
                                                 <autoresizingMask key="autoresizingMask" heightSizable="YES"/>
                                                 <collectionViewFlowLayout key="collectionViewLayout" minimumInteritemSpacing="10" minimumLineSpacing="10" scrollDirection="horizontal" id="cPd-fj-JkJ">
                                                     <size key="itemSize" width="50" height="50"/>
@@ -203,6 +203,7 @@
                                 </scrollView>
                             </subviews>
                             <constraints>
+                                <constraint firstAttribute="height" constant="485" id="LRq-ib-ghz"/>
                                 <constraint firstAttribute="trailing" secondItem="ScA-aL-r0P" secondAttribute="trailing" constant="40" id="bke-OZ-98o"/>
                                 <constraint firstAttribute="bottom" secondItem="ScA-aL-r0P" secondAttribute="bottom" id="hcN-ec-kQR"/>
                                 <constraint firstItem="ScA-aL-r0P" firstAttribute="leading" secondItem="tuB-UO-PhU" secondAttribute="leading" constant="40" id="igv-8h-OSz"/>
@@ -212,7 +213,6 @@
                     </subviews>
                     <constraints>
                         <constraint firstAttribute="trailing" secondItem="nXE-h3-HLH" secondAttribute="trailing" id="4he-uf-tjb"/>
-                        <constraint firstItem="cMm-TO-WQD" firstAttribute="top" secondItem="tuB-UO-PhU" secondAttribute="bottom" constant="16" id="D9M-uh-Bn0"/>
                         <constraint firstItem="tuB-UO-PhU" firstAttribute="top" secondItem="nXE-h3-HLH" secondAttribute="bottom" constant="20" id="RR2-l8-5UO"/>
                         <constraint firstItem="cMm-TO-WQD" firstAttribute="leading" secondItem="yhM-ic-Qb1" secondAttribute="leading" constant="40" id="VTx-Ir-6RI"/>
                         <constraint firstItem="nXE-h3-HLH" firstAttribute="leading" secondItem="yhM-ic-Qb1" secondAttribute="leading" id="Xvu-rI-QaT"/>

+ 1 - 1
PDF Office/PDF Master/Class/KMLightMember/Controller/ComparativeTable/View/KMComparativeView/View/KMComparativeViewCollectionItem.swift

@@ -191,7 +191,7 @@ class KMComparativeViewCollectionItem: NSCollectionViewItem {
                 let describeString = NSString(format: describe as NSString, "%",priceString)
                 let attributedString = NSMutableAttributedString(string: describeString as String)
                 let range = (describeString as NSString).range(of: priceString)
-                attributedString.addAttribute(NSAttributedString.Key.strikethroughStyle, value: NSNumber(value: NSUnderlineStyle.single.rawValue), range: range)
+//                attributedString.addAttribute(NSAttributedString.Key.strikethroughStyle, value: NSNumber(value: NSUnderlineStyle.single.rawValue), range: range)
                 attributedString.addAttribute(NSAttributedString.Key.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: describeString.length))
                 self.describeLabel.attributedStringValue = attributedString
             }

+ 5 - 3
PDF Office/PDF Master/Class/KMLightMember/Controller/ComparativeTable/View/KMComparativeView/View/KMComparativeViewCollectionItemItem.swift

@@ -25,11 +25,13 @@ class KMComparativeViewCollectionItemItem: NSCollectionViewItem {
     
     func reloadData() {
         if data.count != 0 {
-            let state: Bool = data["state"] as? Bool ?? false
-            if state == false {
+            let state: Int = data["state"] as? Int ?? 0
+            if state == 2 {
                 self.iconImageView.image = NSImage(named: "icon_info")
-            } else {
+            } else if state == 1 {
                 self.iconImageView.image = NSImage(named: "tips")
+            } else if state == 0 {
+                self.iconImageView.image = NSImage(named: "tips 1")
             }
             
             let string = NSLocalizedString(data["title"] as! String, comment: "")

+ 11 - 16
PDF Office/PDF Master/Class/KMLightMember/Controller/SubscriptionView/WaterMark/View/KMSubscribeWaterMarkView.swift

@@ -128,11 +128,7 @@ class KMSubscribeWaterMarkView: KMBaseXibView {
         self.subscribeLabel.stringValue = NSLocalizedString("Subscribe", comment: "")
 //        + "  " + NSLocalizedString("Subscription", comment: ""
         let string = NSLocalizedString("""
-Payment will be charged to your Apple ID account at the confirmation of purchase.
-Subscription automatically renews unless it is canceled at least 24 hours before
-the end of the current period. Your account will be charged for renewal within 24
-hours prior to the end of the current period. You can manage and cancel your
-subscriptions by going to your account settings on the App Store after purchase.
+            Payment will be charged to your Apple ID account at the confirmation of purchase.Subscription automatically renews unless it is canceled at least 24 hours before the end of the current period. Your account will be charged for renewal within 24 hours prior to the end of the current period. You can manage and cancel your subscriptions by going to your account settings on the App Store after purchase.
 """, comment: "")
         let attributedString = NSMutableAttributedString.init(string: string)
         let paragraphStyle = NSMutableParagraphStyle()
@@ -240,20 +236,18 @@ extension KMSubscribeWaterMarkView {
     }
     
     func setupPopover() {
-        let string: NSString = NSLocalizedString("""
-            Payment will be charged to your Apple ID account at the confirmation of purchase.
-            Subscription automatically renews unless it is canceled at least 24 hours before
-            the end of the current period. Your account will be charged for renewal within 24
-            hours prior to the end of the current period. You can manage and cancel your
-            subscriptions by going to your account settings on the App Store after purchase.
-            """, comment: "") as NSString
+        let string: NSString = NSLocalizedString(
+"""
+Payment will be charged to your Apple ID account at the confirmation of purchase.\nSubscription automatically renews unless it is canceled at least 24 hours before the end of the current period. Your account will be charged for renewal within 24 hours prior to the end of the current period. You can manage and cancel your subscriptions by going to your account settings on the App Store after purchase.
+"""
+            , comment: "") as NSString
         
         let paragraphStyle = NSMutableParagraphStyle()
         paragraphStyle.lineHeightMultiple = 1.4
         paragraphStyle.alignment = .left
         let attributes = [NSAttributedString.Key.font : NSFont.SFProTextRegular(12), NSAttributedString.Key.paragraphStyle : paragraphStyle]
-        let size: NSSize = string.boundingRect(with: NSSize(width: 420, height: 400), options: NSString.DrawingOptions(rawValue: 3), attributes: attributes).size
-        
+        var size: NSSize = string.boundingRect(with: NSSize(width: 420, height: 600), options: NSString.DrawingOptions(rawValue: 3), attributes: attributes).size
+        size = CGSize(width: size.width, height: size.height + 30)
         
         popover.behavior = .transient
         popover.setValue(true, forKey: "shouldHideAnchor")
@@ -265,9 +259,10 @@ extension KMSubscribeWaterMarkView {
         let textField = NSTextField(frame: NSRect(x: 16, y: 8, width: size.width - 32, height: size.height - 16))
         textField.attributedStringValue = NSMutableAttributedString(string: NSLocalizedString(string as String, comment: ""), attributes: attributes)
         textField.backgroundColor(NSColor(hex: "#000000"))
+        textField.drawsBackground = false
         textField.isEditable = false
-        textField.isSelectable = true
-        textField.backgroundColor(NSColor.clear)
+        textField.isSelectable = false
+        textField.lineBreakMode = .byCharWrapping
         textField.textColor = NSColor(hex: "#FFFFFF")
         
         popover.contentViewController?.view.addSubview(textField)

+ 18 - 6
PDF Office/PDF Master/Class/KMLightMember/InAppPurchase/Appstore/KMInAppPurchaseManager.swift

@@ -213,9 +213,13 @@ extension KMInAppPurchaseManager: SKPaymentTransactionObserver {
     func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
         KMPrint("服务器返回数据")
         if transactions.count > 0 {
-            let transaction = transactions.first!
+            var resultTransaction = transactions.first!
+            var isExist = false
             for transaction in transactions {
                 if kPRODUCTS.contains(transaction.original?.payment.productIdentifier ?? PRODUCT_1) {
+                    isExist = true
+                    resultTransaction = transaction
+                    
                     // 检查购买的产品是否是订阅产品
                     switch transaction.transactionState {
                         case .purchased:
@@ -237,6 +241,11 @@ extension KMInAppPurchaseManager: SKPaymentTransactionObserver {
                     break
                 }
             }
+            if !isExist {
+                handleError(transaction: resultTransaction)
+            }
+        } else {
+            handleError(transaction: nil)
         }
     }
     
@@ -409,15 +418,18 @@ extension KMInAppPurchaseManager: SKPaymentTransactionObserver {
         return true
     }
     
-    func handleError(transaction: SKPaymentTransaction) {
+    func handleError(transaction: SKPaymentTransaction?) {
         // 处理购买失败的逻辑
-        SKPaymentQueue.default().finishTransaction(transaction)
-        if transaction.transactionState == .restored {
-            self.handleAction(state: .restoreFailed)
+        if let t = transaction {
+            SKPaymentQueue.default().finishTransaction(t)
+            if t.transactionState == .restored {
+                self.handleAction(state: .restoreFailed)
+            } else {
+                self.handleAction(state: .failed)
+            }
         } else {
             self.handleAction(state: .failed)
         }
-        // ...
     }
     
     func verifyPurchase(purchase: [String: Any]) -> KMPurchaseManagerState {

File diff suppressed because it is too large
+ 1 - 9
PDF Office/PDF Master/Strings/en.lproj/Localizable.strings