123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- //
- // KMTrialSuccessController.swift
- // PDF Reader Pro Edition
- //
- // Created by Niehaoyu on 2023/12/7.
- //
- import Cocoa
- class KMTrialSuccessController: NSViewController {
- @IBOutlet weak var contendView: NSView!
- @IBOutlet weak var infoContendView: NSView!
- @IBOutlet weak var iconImg: NSImageView!
- @IBOutlet weak var titleLabel: NSTextField!
- @IBOutlet weak var subTitleLabel: NSTextField!
- @IBOutlet weak var getStartBox: KMBox!
- @IBOutlet weak var getStartLabel: NSTextField!
- @IBOutlet weak var getStartButton: KMButton!
-
-
- @objc var clickHandle: ((_ controller: KMTrialSuccessController)->Void)?
-
- convenience init() {
- self.init(nibName: "KMTrialSuccessController", bundle: nil)
-
- }
-
- deinit {
- DistributedNotificationCenter.default.removeObserver(self)
- }
-
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do view setup here.
-
- self.contendView.wantsLayer = true
- self.infoContendView.wantsLayer = true
- self.infoContendView.layer?.cornerRadius = 10
- self.infoContendView.layer?.masksToBounds = true
-
- self.getStartBox.wantsLayer = true
- self.getStartBox.layer?.masksToBounds = true
- self.getStartBox.layer?.cornerRadius = CGRectGetHeight(self.getStartBox.frame)/2
-
- self.titleLabel.stringValue = NSLocalizedString("Free Trial PDF Reader Pro for 7 Days!", comment: "")
- self.subTitleLabel.stringValue = NSLocalizedString("Congrats! You are eligible to enjoy all advanced features in PDF Reader Pro.", comment: "")
- self.getStartLabel.stringValue = NSLocalizedString("Start Now", comment: "")
-
- self.titleLabel.font = NSFont.UbuntuBoldFontWithSize(20)
- self.subTitleLabel.font = NSFont.SFProTextRegularFont(14)
- self.getStartLabel.font = NSFont.UbuntuMediumFontWithSize(14)
-
- self.getStartButton.wantsLayer = true
- self.getStartButton!.mouseMoveCallback = { [weak self] mouseEntered in
- if mouseEntered {
- self?.getStartButton?.layer?.backgroundColor = NSColor.black.withAlphaComponent(0.15).cgColor
- } else {
- self?.getStartButton?.layer?.backgroundColor = NSColor.clear.cgColor
- }
- }
-
- DistributedNotificationCenter.default().addObserver(self, selector: #selector(themeChange), name: NSNotification.Name(rawValue: "AppleInterfaceThemeChangedNotification"), object: nil)
- self.updateViewColor()
- }
-
- @objc func updateViewColor() {
- if KMAppearance.isDarkMode() {
- self.contendView.layer?.backgroundColor = NSColor(red: 57/255.0, green: 58/255.0, blue: 70/255.0, alpha: 1).cgColor
- self.infoContendView.layer?.backgroundColor = NSColor(red: 46/255, green: 44/255, blue: 54/255, alpha: 1).cgColor
- self.titleLabel.textColor = KMAppearance.KMColor_Layout_W0()
- self.subTitleLabel.textColor = KMAppearance.KMColor_Layout_W0()
- self.getStartBox.fillColor = NSColor(red: 181/255, green: 177/255, blue: 239/255, alpha: 1)
- self.getStartLabel.textColor = NSColor(red: 7/255, green: 1/255, blue: 34/255, alpha: 1)
- } else {
- self.contendView.layer?.backgroundColor = NSColor(red: 232/255.0, green: 233/255.0, blue: 1, alpha: 1).cgColor
- self.infoContendView.layer?.backgroundColor = NSColor(red: 248/255, green: 249/255, blue: 1, alpha: 1).cgColor
- self.titleLabel.textColor = NSColor(red: 0, green: 33/255, blue: 67/255, alpha: 1)
- self.subTitleLabel.textColor = KMAppearance.KMColor_Layout_H0()
- self.getStartBox.fillColor = NSColor(red: 39/255, green: 60/255, blue: 98/255, alpha: 1)
- self.getStartLabel.textColor = NSColor.white
- }
- }
-
- //MARK: IBAction
- @IBAction func getStartAction(_ sender: Any) {
- guard let callBack = self.clickHandle else {
- return
- }
- callBack(self)
- }
-
- @objc func themeChange() {
- DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.3) {
- self.updateViewColor()
- }
- }
-
-
-
- }
|