KMUnlockAlertViewController.m 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. //
  2. // KMUnlockAlertViewController.m
  3. // PDF Reader Pro Edition
  4. //
  5. // Created by Niehaoyu on 2023/4/3.
  6. //
  7. #import "KMUnlockAlertViewController.h"
  8. #import <PDF_Reader_Pro-Swift.h>
  9. #import "VerificationManager.h"
  10. @interface KMUnlockAlertViewController ()
  11. @property (assign) IBOutlet NSTextField *titleLbl;
  12. @property (assign) IBOutlet NSTextField *subTitleLbl;
  13. @property (assign) IBOutlet NSView *desView1;
  14. @property (assign) IBOutlet NSImageView *desImg1;
  15. @property (assign) IBOutlet NSTextField *deslbl1;
  16. @property (assign) IBOutlet NSImageView *desImg2;
  17. @property (assign) IBOutlet NSTextField *desLbl2;
  18. @property (assign) IBOutlet NSImageView *desImg3;
  19. @property (assign) IBOutlet NSTextField *desLbl3;
  20. @property (assign) IBOutlet NSImageView *desImg4;
  21. @property (assign) IBOutlet NSTextField *desLbl4;
  22. @property (assign) IBOutlet NSImageView *desImg5;
  23. @property (assign) IBOutlet NSTextField *desLbl5;
  24. @property (assign) IBOutlet HyperLinkButton *continueButton;
  25. @property (assign) IBOutlet NSBox *buyNowBox;
  26. @property (assign) IBOutlet KMCustomButton *buyNowButton;
  27. @property (nonatomic, retain) NSTrackingArea *trackingArea;
  28. @end
  29. @implementation KMUnlockAlertViewController
  30. - (void)dealloc {
  31. if (self.trackingArea) {
  32. [self.view removeTrackingArea:self.trackingArea];
  33. }
  34. }
  35. - (void)viewDidLoad {
  36. [super viewDidLoad];
  37. // Do view setup here.
  38. self.titleLbl.font = [NSFont boldSystemFontOfSize:18.];
  39. self.subTitleLbl.font = [NSFont systemFontOfSize:11.];
  40. self.deslbl1.font = self.desLbl2.font = self.desLbl3.font = self.desLbl4.font = self.desLbl5.font = [NSFont systemFontOfSize:13.];
  41. self.titleLbl.stringValue = NSLocalizedString(@"Unlock All Advanced Features", nil);
  42. self.deslbl1.stringValue = NSLocalizedString(@"Convert PDF from/to Word/Excel/PPT/HTML/Image, etc.", nil);
  43. self.desLbl2.stringValue = NSLocalizedString(@"Edit and Modify Texts in PDFs", nil);
  44. self.desLbl3.stringValue = NSLocalizedString(@"Organize pages", nil);
  45. self.desLbl4.stringValue = NSLocalizedString(@"Optical Character Recognition (OCR)", nil);
  46. self.desLbl5.stringValue = NSLocalizedString(@"Create&Fill Forms, digital sign PDFs", nil);
  47. __block typeof(self) blockSelf = self;
  48. self.buyNowBox.wantsLayer = YES;
  49. self.buyNowBox.layer.cornerRadius = CGRectGetHeight(self.buyNowBox.frame)/2.0;
  50. self.buyNowBox.layer.masksToBounds = YES;
  51. self.buyNowButton.wantsLayer = YES;
  52. self.buyNowButton.title = NSLocalizedString(@"Buy Now", nil);
  53. [self.buyNowButton setTitleColor:[NSColor whiteColor]];
  54. self.buyNowButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  55. if (mouseEntered) {
  56. blockSelf.buyNowButton.layer.backgroundColor = [NSColor colorWithRed:0 green:0 blue:0 alpha:0.15].CGColor;
  57. } else {
  58. blockSelf.buyNowButton.layer.backgroundColor = [NSColor clearColor].CGColor;
  59. }
  60. };
  61. self.continueButton.wantsLayer = YES;
  62. self.continueButton.layer.masksToBounds = YES;
  63. self.continueButton.layer.cornerRadius = 1.0;
  64. self.continueButton.title = NSLocalizedString(@"Enter License", nil);
  65. [self.continueButton setTitleColor:[NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1]];
  66. if ([KMAppearance isDarkMode]) {
  67. [self.continueButton setTitleColor:[NSColor whiteColor]];
  68. }
  69. self.continueButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  70. if ([KMAppearance isDarkMode]) {
  71. if (mouseEntered) {
  72. [blockSelf.continueButton setTitleColor:[NSColor whiteColor]];
  73. } else {
  74. [blockSelf.continueButton setTitleColor:[NSColor whiteColor]];
  75. }
  76. } else {
  77. if (mouseEntered) {
  78. [blockSelf.continueButton setTitleColor:[NSColor colorWithRed:8/255. green:124/255. blue:255/255. alpha:1.]];
  79. } else {
  80. [blockSelf.continueButton setTitleColor:[NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.]];
  81. }
  82. }
  83. };
  84. self.subTitleLbl.stringValue = NSLocalizedString(@"Upgrade PDF Reader Pro to enjoy the full functions.", nil);
  85. if ([KMAppearance isDarkMode]) {
  86. self.subTitleLbl.textColor = [KMAppearance KMColor_Layout_W70];
  87. } else {
  88. self.subTitleLbl.textColor = [KMAppearance KMColor_Layout_H2];
  89. }
  90. if (ActivityStatusTrialExpire == [VerificationManager manager].status &&
  91. [VerificationManager manager].secondTrialEnabled == false) {
  92. self.subTitleLbl.stringValue = NSLocalizedString(@"Free trial expired. Upgrade PDF Reader Pro to enjoy the full functions.", nil);
  93. self.subTitleLbl.textColor = [KMAppearance KMColor_Status_Err];
  94. }
  95. self.titleLbl.textColor = [KMAppearance KMColor_Layout_H0];
  96. self.deslbl1.textColor = self.desLbl2.textColor = self.desLbl3.textColor = self.desLbl4.textColor = self.desLbl5.textColor = [KMAppearance KMColor_Layout_H0];
  97. }
  98. - (void)addtrackingAreaInfo {
  99. if (!self.trackingArea) {
  100. self.trackingArea = [[NSTrackingArea alloc] initWithRect:self.view.bounds options:NSTrackingMouseEnteredAndExited | NSTrackingInVisibleRect | NSTrackingActiveAlways owner:self userInfo:nil];
  101. }
  102. [self.view addTrackingArea:self.trackingArea];
  103. }
  104. - (void)removeTrackingAreaInfo {
  105. if (self.trackingArea) {
  106. [self.view removeTrackingArea:self.trackingArea];
  107. }
  108. }
  109. #pragma mark - IBAction
  110. - (IBAction)continueAction:(id)sender {
  111. if (self.callback) {
  112. self.callback(1);
  113. }
  114. }
  115. - (IBAction)buynowAction:(id)sender {
  116. if (self.callback) {
  117. self.callback(2);
  118. }
  119. }
  120. - (void)mouseEntered:(NSEvent *)event {
  121. [super mouseEntered:event];
  122. if (self.mouseEventCall) {
  123. self.mouseEventCall(YES);
  124. }
  125. }
  126. - (void)mouseExited:(NSEvent *)event {
  127. [super mouseExited:event];
  128. if (self.mouseEventCall) {
  129. self.mouseEventCall(NO);
  130. }
  131. }
  132. @end