KMRepeatTrialAlertController.m 9.8 KB

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