KMUnlockAlertViewController.m 5.9 KB

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