|
@@ -59,10 +59,12 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
@IBOutlet weak var applyButton: NSButton!
|
|
|
@IBOutlet weak var lastPriceLabel: NSTextField!
|
|
|
@IBOutlet weak var lastPriceLabel1: NSTextField!
|
|
|
+ @IBOutlet weak var discountView: NSView!
|
|
|
@IBOutlet weak var discountLabel: NSTextField!
|
|
|
@IBOutlet weak var discountLabel1: NSTextField!
|
|
|
@IBOutlet weak var paySumLabel: NSTextField!
|
|
|
@IBOutlet weak var paySumLabel1: NSTextField!
|
|
|
+ @IBOutlet weak var discountLayoutConstraint: NSLayoutConstraint!
|
|
|
|
|
|
@IBOutlet weak var privacyLabel: NSTextField!
|
|
|
|
|
@@ -255,7 +257,7 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
oneLicenseLabel.stringValue = NSLocalizedString("Manually renew at USD 14.99", comment: "")
|
|
|
}
|
|
|
} else {
|
|
|
- pdfReaderProLabel.stringValue = NSLocalizedString("PDF Reader Pro for Mac", comment: "")
|
|
|
+ pdfReaderProLabel.stringValue = NSLocalizedString("I have a coupon ?", comment: "")
|
|
|
prmiumLabel.stringValue = NSLocalizedString("Premium and PDF to Office Converter", comment: "")
|
|
|
oneLicenseLabel.stringValue = NSLocalizedString("One License for One Mac. One Time Purchase.", comment: "")
|
|
|
|
|
@@ -319,22 +321,33 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
paySumLabel1.textColor = NSColor(named: "KMPurchaseCouponColor")
|
|
|
paySumLabel1.font = NSFont.SFProTextBoldFont(24.0)
|
|
|
|
|
|
+ privacyLabel.isEditable = false
|
|
|
+ privacyLabel.isSelectable = true
|
|
|
+ privacyLabel.allowsEditingTextAttributes = true
|
|
|
privacyLabel.textColor = NSColor.black
|
|
|
+ privacyLabel.font = NSFont.SFProTextRegularFont(16.0)
|
|
|
let tipsString = NSLocalizedString("Are you a student or a professor? %@ / Want a volume purchase? Please %@.", comment: "")
|
|
|
let specialOffer = NSLocalizedString("Get Special Offer", comment: "")
|
|
|
let contactsUs = NSLocalizedString("Contact Us", comment: "")
|
|
|
let fullString = String(format: tipsString, specialOffer, contactsUs)
|
|
|
let attributedString = NSMutableAttributedString(string: fullString)
|
|
|
+ // 定义链接的范围
|
|
|
let specialOfferRange = (fullString as NSString).range(of: specialOffer)
|
|
|
let contactsUsRange = (fullString as NSString).range(of: contactsUs)
|
|
|
- attributedString.addAttribute(.foregroundColor, value: NSColor(red: 73/255.0, green: 130/255.0, blue: 230/255.0, alpha: 1.0), range: specialOfferRange)
|
|
|
- attributedString.addAttribute(.link, value: "GetSpecialOffer://", range: specialOfferRange)
|
|
|
- attributedString.addAttribute(.foregroundColor, value: NSColor(red: 73/255.0, green: 130/255.0, blue: 230/255.0, alpha: 1.0), range: contactsUsRange)
|
|
|
- attributedString.addAttribute(.link, value: "www.baidu.com", range: contactsUsRange)
|
|
|
-// attributedString.addAttributes([.link : "www.baidu.com"], range: contactsUsRange)
|
|
|
+ let linkColor = NSColor(red: 73/255.0, green: 130/255.0, blue: 230/255.0, alpha: 1.0)
|
|
|
+ let font = NSFont.SFProTextRegularFont(16.0) // 与普通文本相同的字体
|
|
|
+ attributedString.addAttributes([
|
|
|
+ .foregroundColor: linkColor,
|
|
|
+ .link: NSLocalizedString("https://www.pdfreaderpro.com/store?mode=edu", comment: ""),
|
|
|
+ .font: font
|
|
|
+ ], range: specialOfferRange)
|
|
|
+ attributedString.addAttributes([
|
|
|
+ .foregroundColor: linkColor,
|
|
|
+ .link: NSLocalizedString("https://www.pdfreaderpro.com/vpp-purchase-program", comment: ""),
|
|
|
+ .font: font
|
|
|
+ ], range: contactsUsRange)
|
|
|
+ attributedString.addAttribute(.font, value: font, range: (fullString as NSString).range(of: fullString))
|
|
|
privacyLabel.attributedStringValue = attributedString
|
|
|
- privacyLabel.font = NSFont.SFProTextRegularFont(16.0)
|
|
|
- privacyLabel.delegate = self
|
|
|
|
|
|
billInformationLabel.stringValue = NSLocalizedString("Bill Information", comment: "")
|
|
|
billInformationLabel.textColor = NSColor(named: "KMPurchaseTitleColor1")
|
|
@@ -356,23 +369,33 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
paymentMethodLabel.textColor = NSColor(named: "KMPurchaseTitleColor1")
|
|
|
paymentMethodLabel.font = NSFont.SFProTextRegularFont(14.0)
|
|
|
wechatPayButton2.isHidden = true
|
|
|
-
|
|
|
+
|
|
|
+ payExplainLabel.isEditable = false
|
|
|
+ payExplainLabel.isSelectable = true
|
|
|
+ payExplainLabel.allowsEditingTextAttributes = true
|
|
|
payExplainLabel.textColor = NSColor.black
|
|
|
+ payExplainLabel.font = NSFont.SFProTextRegularFont(11.0)
|
|
|
let localizedString = NSLocalizedString("By submitting this order, I agree to the %@ and %@ for subscription products", comment: "")
|
|
|
let privacyPolicy = NSLocalizedString("Privacy Policy", comment: "")
|
|
|
let termsOfService = NSLocalizedString("Terms of Service", comment: "")
|
|
|
let fullString1 = String(format: localizedString, privacyPolicy, termsOfService)
|
|
|
let attributedString1 = NSMutableAttributedString(string: fullString1)
|
|
|
- let privacyPolicyRange = (fullString as NSString).range(of: privacyPolicy)
|
|
|
- let termsOfServiceRange = (fullString as NSString).range(of: termsOfService)
|
|
|
- attributedString1.addAttribute(.foregroundColor, value: NSColor(red: 73/255.0, green: 130/255.0, blue: 230/255.0, alpha: 1.0), range: privacyPolicyRange)
|
|
|
- attributedString1.addAttribute(.link, value: "PrivacyPolicy://", range: privacyPolicyRange)
|
|
|
- attributedString1.addAttribute(.foregroundColor, value: NSColor(red: 73/255.0, green: 130/255.0, blue: 230/255.0, alpha: 1.0), range: termsOfServiceRange)
|
|
|
-// attributedString1.addAttribute(.link, value: "TermsofService://", range: termsOfServiceRange)
|
|
|
- attributedString1.addAttributes([.link : "www.baidu.com"], range: termsOfServiceRange)
|
|
|
- payExplainLabel.attributedStringValue = attributedString
|
|
|
- payExplainLabel.font = NSFont.SFProTextRegularFont(11.0)
|
|
|
- payExplainLabel.delegate = self
|
|
|
+ let privacyPolicyRange = (fullString1 as NSString).range(of: privacyPolicy)
|
|
|
+ let termsOfServiceRange = (fullString1 as NSString).range(of: termsOfService)
|
|
|
+ let linkColor1 = NSColor(red: 73/255.0, green: 130/255.0, blue: 230/255.0, alpha: 1.0)
|
|
|
+ let font1 = NSFont.SFProTextRegularFont(11.0) // 与普通文本相同的字体
|
|
|
+ attributedString1.addAttributes([
|
|
|
+ .foregroundColor: linkColor1,
|
|
|
+ .link: NSLocalizedString("https://www.pdfreaderpro.com/privacy-policy", comment: ""),
|
|
|
+ .font: font1
|
|
|
+ ], range: privacyPolicyRange)
|
|
|
+ attributedString1.addAttributes([
|
|
|
+ .foregroundColor: linkColor1,
|
|
|
+ .link: NSLocalizedString("https://www.pdfreaderpro.com/terms_of_service", comment: ""),
|
|
|
+ .font: font1
|
|
|
+ ], range: termsOfServiceRange)
|
|
|
+ attributedString1.addAttribute(.font, value: font1, range: (fullString1 as NSString).range(of: fullString1))
|
|
|
+ payExplainLabel.attributedStringValue = attributedString1
|
|
|
|
|
|
paypalBuyNowLabel.stringValue = NSLocalizedString("Buy Now", comment: "")
|
|
|
paypalBuyNowLabel.textColor = NSColor.white
|
|
@@ -651,6 +674,11 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
lastPriceLabel1.stringValue = String(format: "%@ %@", abbreviation, originalTotalPrice)
|
|
|
discountLabel1.stringValue = String(format: "%@ %@", abbreviation, discountAmount1)
|
|
|
paySumLabel1.stringValue = String(format: "%@ %@", abbreviation, discountTotalPrice)
|
|
|
+
|
|
|
+ if Float(discountAmount1) == 0 {
|
|
|
+ discountView.isHidden = true
|
|
|
+ discountLayoutConstraint.constant = discountView.isHidden ? -CGRectGetHeight(discountView.bounds) : 8
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// MARK: Active
|
|
@@ -663,7 +691,9 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
}
|
|
|
}
|
|
|
if sender.tag == 1 {
|
|
|
- pdfCount += 1
|
|
|
+ if pdfCount < 9999 {
|
|
|
+ pdfCount += 1
|
|
|
+ }
|
|
|
}
|
|
|
if pdfCount > 1 {
|
|
|
removeButton1.isEnabled = true
|
|
@@ -1424,16 +1454,22 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
// }
|
|
|
// self.handler = handler
|
|
|
// }
|
|
|
-
|
|
|
- // MARK: - Notification
|
|
|
-
|
|
|
+}
|
|
|
+
|
|
|
+extension KMPurchaseEmbeddedWindowController: NSTextFieldDelegate {
|
|
|
func controlTextDidEndEditing(_ obj: Notification) {
|
|
|
let textField = obj.object as? NSTextField
|
|
|
if textField == amountTextField1 {
|
|
|
if !isNumeric(textField!.stringValue) {
|
|
|
if textField == amountTextField1 { textField?.stringValue = String(pdfCount) }
|
|
|
} else {
|
|
|
- if textField == amountTextField1 { pdfCount = Int(textField!.stringValue) ?? 1 }
|
|
|
+ if textField == amountTextField1 {
|
|
|
+ pdfCount = Int(textField!.stringValue) ?? 1
|
|
|
+ if Int(textField!.stringValue)! > 9999 {
|
|
|
+ pdfCount = 9999
|
|
|
+ textField?.stringValue = String(pdfCount)
|
|
|
+ }
|
|
|
+ }
|
|
|
if pdfCount > 100 {
|
|
|
wechatPayButton2.isHidden = false
|
|
|
cardButton.isHidden = true
|
|
@@ -1453,31 +1489,6 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
-extension KMPurchaseEmbeddedWindowController: NSTextFieldDelegate {
|
|
|
- func textView(_ textView: NSTextView, clickedOnLink link: Any, at charIndex: Int) -> Bool {
|
|
|
- if let url = link as? String {
|
|
|
- switch url {
|
|
|
- case "GetSpecialOffer://":
|
|
|
- NSWorkspace.shared.open(URL(string: NSLocalizedString("https://www.pdfreaderpro.com/store?mode=edu", comment: ""))!)
|
|
|
- break
|
|
|
- case "ContactUs://":
|
|
|
- NSWorkspace.shared.open(URL(string: NSLocalizedString("https://www.pdfreaderpro.com/vpp-purchase-program", comment: ""))!)
|
|
|
- break
|
|
|
- case "PrivacyPolicy://":
|
|
|
- NSWorkspace.shared.open(URL(string: "https://www.pdfreaderpro.com/privacy-policy")!)
|
|
|
- break
|
|
|
- case "TermsofService://":
|
|
|
- NSWorkspace.shared.open(URL(string: "https://www.pdfreaderpro.com/terms_of_service")!)
|
|
|
- break
|
|
|
- default:
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- return true
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
extension KMPurchaseEmbeddedWindowController: NSWindowDelegate {
|