KMRepeatTrialAlertController.m 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. //
  2. // KMRepeatTrialAlertController.m
  3. // PDF Reader Pro Edition
  4. //
  5. // Created by Niehaoyu on 2023/9/13.
  6. //
  7. #import "KMRepeatTrialAlertController.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. @interface KMRepeatTrialAlertController ()
  15. @property (assign) IBOutlet NSView *contendView;
  16. @property (assign) IBOutlet NSImageView *iconImg;
  17. @property (assign) IBOutlet NSTextField *titleLbl;
  18. @property (assign) IBOutlet NSView *infoContendView;
  19. @property (assign) IBOutlet NSTextField *infoTitleLabel;
  20. @property (assign) IBOutlet NSTextField *infoSubTitleLabel;
  21. @property (assign) IBOutlet NSTextField *featureLbl;
  22. @property (assign) IBOutlet NSView *nTipView;
  23. @property (assign) IBOutlet NSTextField *nTipLabel;
  24. @property (assign) IBOutlet NSTextField *nInfoLabel;
  25. @property (assign) IBOutlet NSTextField *featureInfoLabel1;
  26. @property (assign) IBOutlet NSTextField *featureInfoLabel2;
  27. @property (assign) IBOutlet NSTextField *featureInfoLabel3;
  28. @property (assign) IBOutlet NSTextField *featureInfoLabel4;
  29. @property (assign) IBOutlet NSTextField *featureInfoLabel5;
  30. @property (assign) IBOutlet NSBox *freeTrialBox;
  31. @property (assign) IBOutlet KMButton *freeTrialButton;
  32. @property (assign) IBOutlet HyperLinkButton *learnMoreButton;
  33. @property (assign) IBOutlet HyperLinkButton *enterLicenseButton;
  34. @end
  35. @implementation KMRepeatTrialAlertController
  36. - (instancetype)init {
  37. if (self = [super initWithNibName:@"KMRepeatTrialAlertController" bundle:nil]) {
  38. }
  39. return self;
  40. }
  41. - (void)dealloc {
  42. [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
  43. }
  44. #pragma mark Setter Methods
  45. - (void)loadView {
  46. [super loadView];
  47. }
  48. - (void)viewDidLoad {
  49. [super viewDidLoad];
  50. // Do view setup here.
  51. self.contendView.wantsLayer = YES;
  52. [self refreshUI];
  53. }
  54. - (void)refreshUI {
  55. __weak typeof(self) weakSelf = self;
  56. self.titleLbl.stringValue = NSLocalizedString(@"Unlock All Features for Free", nil);
  57. self.infoTitleLabel.stringValue = [@"👋🏻 " stringByAppendingString:NSLocalizedString(@"7-day Free Trial", nil)];
  58. self.infoSubTitleLabel.stringValue = NSLocalizedString(@"PDF Reader Pro offers a 7-day free trial of the full functions.", nil);
  59. self.featureLbl.stringValue = NSLocalizedString(@"Key Features", nil);
  60. self.nTipLabel.stringValue = NSLocalizedString(@"New", nil);
  61. self.nInfoLabel.stringValue = NSLocalizedString(@"Digital signature", nil);
  62. self.featureInfoLabel1.stringValue = NSLocalizedString(@"Edit PDF", nil);
  63. self.featureInfoLabel2.stringValue = NSLocalizedString(@"Organize pages", nil);
  64. self.featureInfoLabel3.stringValue = NSLocalizedString(@"Convert PDF", nil);
  65. self.featureInfoLabel4.stringValue = NSLocalizedString(@"Create & fill form", nil);
  66. self.featureInfoLabel5.stringValue = NSLocalizedString(@"OCR", nil);
  67. self.freeTrialButton.title = NSLocalizedString(@"Free Trial", nil);
  68. self.learnMoreButton.title = NSLocalizedString(@"Buy Now", nil);
  69. self.enterLicenseButton.title = NSLocalizedString(@"Enter License", nil);
  70. self.nInfoLabel.toolTip = NSLocalizedString(@"Digital signature", nil);
  71. self.featureInfoLabel1.toolTip = NSLocalizedString(@"Edit PDF", nil);
  72. self.featureInfoLabel2.toolTip = NSLocalizedString(@"Organize pages", nil);
  73. self.featureInfoLabel3.toolTip = NSLocalizedString(@"Convert PDF", nil);
  74. self.featureInfoLabel4.toolTip = NSLocalizedString(@"Create & fill form", nil);
  75. self.featureInfoLabel5.toolTip = NSLocalizedString(@"OCR", nil);
  76. self.titleLbl.font = [NSFont UbuntuBoldFontWithSize:20];
  77. self.infoTitleLabel.font = [NSFont UbuntuBoldFontWithSize:26];
  78. self.infoSubTitleLabel.font = [NSFont SFProTextRegularFont:14];
  79. self.featureLbl.font = [NSFont SFProTextSemiboldFont:16.];
  80. self.nTipLabel.font = [NSFont SFProTextRegularFont:11];
  81. self.nInfoLabel.font = self.featureInfoLabel1.font = self.featureInfoLabel2.font = self.featureInfoLabel3.font = self.featureInfoLabel4.font = self.featureInfoLabel5.font = [NSFont SFProTextRegularFont:14.];
  82. self.titleLbl.textColor = [NSColor colorWithRed:68/255. green:66/255. blue:67/255. alpha:1];
  83. self.infoSubTitleLabel.textColor = [KMAppearance KMColor_Layout_H0];
  84. self.featureLbl.textColor = [KMAppearance KMColor_Layout_H0];
  85. self.nInfoLabel.textColor = [KMAppearance KMColor_Layout_H0];
  86. self.featureInfoLabel1.textColor = [KMAppearance KMColor_Layout_H0];
  87. self.featureInfoLabel2.textColor = [KMAppearance KMColor_Layout_H0];
  88. self.featureInfoLabel3.textColor = [KMAppearance KMColor_Layout_H0];
  89. self.featureInfoLabel4.textColor = [KMAppearance KMColor_Layout_H0];
  90. self.featureInfoLabel5.textColor = [KMAppearance KMColor_Layout_H0];
  91. self.infoContendView.wantsLayer = YES;
  92. self.infoContendView.layer.cornerRadius = 8;
  93. self.infoContendView.layer.masksToBounds = YES;
  94. self.nTipView.wantsLayer = YES;
  95. self.nTipView.layer.cornerRadius = 4;
  96. self.nTipView.layer.masksToBounds = YES;
  97. self.nTipView.layer.backgroundColor = [NSColor colorWithRed:0 green:207/255. blue:133/255. alpha:1.].CGColor;
  98. self.freeTrialBox.wantsLayer = YES;
  99. self.freeTrialBox.cornerRadius = CGRectGetHeight(self.freeTrialBox.frame)/2.;
  100. self.freeTrialButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  101. if ([KMAppearance isDarkMode]) {
  102. if (mouseEntered) {
  103. weakSelf.freeTrialBox.fillColor = [NSColor whiteColor];
  104. } else {
  105. weakSelf.freeTrialBox.fillColor = [NSColor colorWithRed:181/255. green:177/255. blue:239/255. alpha:1.];
  106. }
  107. } else {
  108. if (mouseEntered) {
  109. weakSelf.freeTrialBox.fillColor = [NSColor colorWithRed:0 green:207/255. blue:133/255. alpha:1.];
  110. } else {
  111. weakSelf.freeTrialBox.fillColor = [NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.];
  112. }
  113. }
  114. };
  115. self.learnMoreButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  116. if ([KMAppearance isDarkMode]) {
  117. if (mouseEntered) {
  118. [weakSelf.learnMoreButton setTitleColor:[NSColor whiteColor]];
  119. } else {
  120. [weakSelf.learnMoreButton setTitleColor:[NSColor colorWithRed:181/255. green:177/255. blue:239/255. alpha:1.]];
  121. }
  122. } else {
  123. if (mouseEntered) {
  124. [weakSelf.learnMoreButton setTitleColor:[NSColor colorWithRed:8/255. green:124/255. blue:255/255. alpha:1.]];
  125. } else {
  126. [weakSelf.learnMoreButton setTitleColor:[NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.]];
  127. }
  128. }
  129. };
  130. self.enterLicenseButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  131. if ([KMAppearance isDarkMode]) {
  132. if (mouseEntered) {
  133. [weakSelf.enterLicenseButton setTitleColor:[NSColor whiteColor]];
  134. } else {
  135. [weakSelf.enterLicenseButton setTitleColor:[NSColor colorWithRed:181/255. green:177/255. blue:239/255. alpha:1.]];
  136. }
  137. } else {
  138. if (mouseEntered) {
  139. [weakSelf.enterLicenseButton setTitleColor:[NSColor colorWithRed:8/255. green:124/255. blue:255/255. alpha:1.]];
  140. } else {
  141. [weakSelf.enterLicenseButton setTitleColor:[NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.]];
  142. }
  143. }
  144. };
  145. [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
  146. [self updateViewColor];
  147. }
  148. - (void)updateViewColor {
  149. if ([KMAppearance isDarkMode]) {
  150. self.infoContendView.layer.backgroundColor = [NSColor colorWithRed:24/255. green:22/255. blue:31/255. alpha:0.9].CGColor;
  151. self.freeTrialBox.fillColor = [NSColor colorWithRed:181/255. green:177/255. blue:239/255. alpha:1.];
  152. self.nTipLabel.textColor = [NSColor colorWithRed:47/255. green:45/255. blue:54/255. alpha:1.];
  153. [self.freeTrialButton setTitleColor:[NSColor colorWithRed:7/255. green:1/255. blue:34/255. alpha:1.]];
  154. [self.learnMoreButton setTitleColor:[NSColor colorWithRed:181/255. green:177/255. blue:239/255. alpha:1.]];
  155. [self.enterLicenseButton setTitleColor:[NSColor colorWithRed:181/255. green:177/255. blue:239/255. alpha:1.]];
  156. } else {
  157. self.infoContendView.layer.backgroundColor = [NSColor colorWithRed:248/255. green:249/255. blue:1 alpha:1].CGColor;
  158. self.freeTrialBox.fillColor = [NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.];
  159. self.nTipLabel.textColor = [NSColor whiteColor];
  160. [self.freeTrialButton setTitleColor:[NSColor whiteColor]];
  161. [self.learnMoreButton setTitleColor:[NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.]];
  162. [self.enterLicenseButton setTitleColor:[NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.]];
  163. }
  164. }
  165. - (IBAction)btnAction:(id)sender {
  166. if ([sender isEqual:self.freeTrialButton]) {
  167. if (self.callback) {
  168. self.callback(0, self);
  169. }
  170. // [[FMTrackEventManager manager] trackOnceEvent:@"PUW" withProperties:@{@"PUW_Btn":@"Btn_PUW_DigitalSignTrial_Start"}];
  171. } else if ([sender isEqual:self.learnMoreButton]) {
  172. if (self.callback) {
  173. self.callback(1, self);
  174. }
  175. // [[FMTrackEventManager manager] trackOnceEvent:@"PUW" withProperties:@{@"PUW_Btn":@"Btn_PUW_DigitalSignTrial_LearnMore"}];
  176. } else if ([sender isEqual:self.enterLicenseButton]) {
  177. if (self.callback) {
  178. self.callback(2, self);
  179. }
  180. }
  181. }
  182. #pragma mark - NSNotification
  183. - (void)themeChanged:(NSNotification *)notification {
  184. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  185. [self updateViewColor];
  186. });
  187. }
  188. @end