12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- //
- // KMRateWindowController.swift
- // PDF Master
- //
- // Created by liujiajie on 2024/1/12.
- //
- import Cocoa
- typealias rateCloseBlock = (_ wc: KMRateWindowController) -> ()
- class KMRateWindow: NSWindow{
- override func close() {
- super.close()
- self.orderOut(self.windowController)
- }
- }
- class KMRateWindowController: NSWindowController, NSWindowDelegate{
- @IBOutlet var imageView: NSImageView!
- @IBOutlet var rateUsButton: NSButton!
- @IBOutlet var feedBackButton: NSButton!
- @IBOutlet var introduceLabel: NSTextField!
-
- var closeBlock: rateCloseBlock?
-
- convenience init() {
- self.init(windowNibName: "KMRateWindowController")
- }
-
- override func windowDidLoad() {
- super.windowDidLoad()
- self.window?.title = NSLocalizedString("Rate Us", comment: "")
-
- self.introduceLabel.stringValue = NSLocalizedString("We would appreciate your input! \nPlease take one minute to give us a great review on the App Store to help other people make a right decision.", comment: "")
-
- #if VERSION_FREE
- self.imageView.image = NSImage(named: "rate_pic_free")
- #else
- self.imageView.image = NSImage(named: "rate_pic_pro")
- #endif
-
- //Title Color
- let ps = NSMutableParagraphStyle()
- ps.alignment = NSTextAlignment.center
- let color = NSColor.white
- let color1 = NSColor(red: 26/255.0, green: 136/255.0, blue: 255/255.0, alpha: 1)
- let textDictionary: [NSAttributedString.Key: Any] = [NSAttributedString.Key.foregroundColor: color, NSAttributedString.Key.paragraphStyle: ps, NSAttributedString.Key.font: NSFont.systemFont(ofSize: 13)]
- let textDictionary1: [NSAttributedString.Key: Any] = [NSAttributedString.Key.foregroundColor: color1, NSAttributedString.Key.paragraphStyle: ps, NSAttributedString.Key.font: NSFont.systemFont(ofSize: 13)]
- let rateUsButtonString = NSMutableAttributedString(string: NSLocalizedString("Give a 5-Star", comment: ""), attributes: textDictionary)
- self.rateUsButton.attributedTitle = rateUsButtonString
- let feedBackButtonString = NSMutableAttributedString(string: NSLocalizedString("Give a suggestion", comment: ""), attributes: textDictionary1)
- self.feedBackButton.attributedTitle = feedBackButtonString
-
- self.rateUsButton.wantsLayer = true
- self.rateUsButton.layer?.backgroundColor = color1.cgColor
- self.feedBackButton.wantsLayer = true
- self.feedBackButton.layer?.backgroundColor = NSColor(red: 235/255.0, green: 245/255.0, blue: 255/255.0, alpha: 1).cgColor
-
- self.rateUsButton.layer?.cornerRadius = 4
- self.feedBackButton.layer?.cornerRadius = 4
-
- iRate.sharedInstance().lastReminded = Date()
- }
- func windowShouldClose(_ sender: NSWindow) -> Bool {
- iRate.sharedInstance().remindMeLater()
- return true
- }
- @IBAction func rateUsAction(_ sender: Any) {
- iRate.sharedInstance().ratedThisVersion = true
- iRate.sharedInstance().openRatingsPageInAppStore()
- close()
- }
-
- @IBAction func feedBackAction(_ sender: Any) {
- iRate.sharedInstance().remindMeLater()
- close()
- }
-
- override func close() {
- super.close()
- if (self.closeBlock != nil) {
- closeBlock!(self)
- }
- }
- }
|