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. //
  57. self.titleLbl.stringValue = NSLocalizedString(@"Unlock All Features for Free", nil);
  58. self.infoTitleLabel.stringValue = [@"👋🏻 " stringByAppendingString:NSLocalizedString(@"7-day Free Trial", nil)];
  59. self.infoSubTitleLabel.stringValue = NSLocalizedString(@"PDF Reader Pro offers a 7-day free trial of the full functions.", nil);
  60. self.featureLbl.stringValue = NSLocalizedString(@"Key Features", nil);
  61. self.nTipLabel.stringValue = NSLocalizedString(@"New", nil);
  62. self.nInfoLabel.stringValue = NSLocalizedString(@"Digital signature", nil);
  63. self.featureInfoLabel1.stringValue = NSLocalizedString(@"Edit PDF", nil);
  64. self.featureInfoLabel2.stringValue = NSLocalizedString(@"Organize pages", nil);
  65. self.featureInfoLabel3.stringValue = NSLocalizedString(@"Convert PDF", nil);
  66. self.featureInfoLabel4.stringValue = NSLocalizedString(@"Create & fill form", nil);
  67. self.featureInfoLabel5.stringValue = NSLocalizedString(@"OCR", nil);
  68. self.freeTrialButton.title = NSLocalizedString(@"Free Trial", nil);
  69. self.learnMoreButton.title = NSLocalizedString(@"Buy Now", nil);
  70. self.enterLicenseButton.title = NSLocalizedString(@"Enter License", nil);
  71. self.nInfoLabel.toolTip = NSLocalizedString(@"Digital signature", nil);
  72. self.featureInfoLabel1.toolTip = NSLocalizedString(@"Edit PDF", nil);
  73. self.featureInfoLabel2.toolTip = NSLocalizedString(@"Organize pages", nil);
  74. self.featureInfoLabel3.toolTip = NSLocalizedString(@"Convert PDF", nil);
  75. self.featureInfoLabel4.toolTip = NSLocalizedString(@"Create & fill form", nil);
  76. self.featureInfoLabel5.toolTip = NSLocalizedString(@"OCR", nil);
  77. self.titleLbl.font = [NSFont UbuntuBoldFontWithSize:20];
  78. self.infoTitleLabel.font = [NSFont UbuntuBoldFontWithSize:26];
  79. self.infoSubTitleLabel.font = [NSFont SFProTextRegularFont:14];
  80. self.featureLbl.font = [NSFont SFProTextSemiboldFont:16.];
  81. self.nTipLabel.font = [NSFont SFProTextRegularFont:11];
  82. self.nInfoLabel.font = self.featureInfoLabel1.font = self.featureInfoLabel2.font = self.featureInfoLabel3.font = self.featureInfoLabel4.font = self.featureInfoLabel5.font = [NSFont SFProTextRegularFont:14.];
  83. self.titleLbl.textColor = [NSColor colorWithRed:68/255. green:66/255. blue:67/255. alpha:1];
  84. self.infoSubTitleLabel.textColor = [KMAppearance KMColor_Layout_H0];
  85. self.featureLbl.textColor = [KMAppearance KMColor_Layout_H0];
  86. self.nInfoLabel.textColor = [KMAppearance KMColor_Layout_H0];
  87. self.featureInfoLabel1.textColor = [KMAppearance KMColor_Layout_H0];
  88. self.featureInfoLabel2.textColor = [KMAppearance KMColor_Layout_H0];
  89. self.featureInfoLabel3.textColor = [KMAppearance KMColor_Layout_H0];
  90. self.featureInfoLabel4.textColor = [KMAppearance KMColor_Layout_H0];
  91. self.featureInfoLabel5.textColor = [KMAppearance KMColor_Layout_H0];
  92. self.infoContendView.wantsLayer = YES;
  93. self.infoContendView.layer.cornerRadius = 8;
  94. self.infoContendView.layer.masksToBounds = YES;
  95. self.nTipView.wantsLayer = YES;
  96. self.nTipView.layer.cornerRadius = 4;
  97. self.nTipView.layer.masksToBounds = YES;
  98. self.nTipView.layer.backgroundColor = [NSColor colorWithRed:0 green:207/255. blue:133/255. alpha:1.].CGColor;
  99. self.freeTrialBox.wantsLayer = YES;
  100. self.freeTrialBox.cornerRadius = CGRectGetHeight(self.freeTrialBox.frame)/2.;
  101. self.freeTrialButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  102. if ([KMAppearance isDarkMode]) {
  103. if (mouseEntered) {
  104. weakSelf.freeTrialBox.fillColor = [NSColor whiteColor];
  105. } else {
  106. weakSelf.freeTrialBox.fillColor = [NSColor colorWithRed:181/255. green:177/255. blue:239/255. alpha:1.];
  107. }
  108. } else {
  109. if (mouseEntered) {
  110. weakSelf.freeTrialBox.fillColor = [NSColor colorWithRed:0 green:207/255. blue:133/255. alpha:1.];
  111. } else {
  112. weakSelf.freeTrialBox.fillColor = [NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.];
  113. }
  114. }
  115. };
  116. self.learnMoreButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  117. if ([KMAppearance isDarkMode]) {
  118. if (mouseEntered) {
  119. [weakSelf.learnMoreButton setTitleColor:[NSColor whiteColor]];
  120. } else {
  121. [weakSelf.learnMoreButton setTitleColor:[NSColor colorWithRed:181/255. green:177/255. blue:239/255. alpha:1.]];
  122. }
  123. } else {
  124. if (mouseEntered) {
  125. [weakSelf.learnMoreButton setTitleColor:[NSColor colorWithRed:8/255. green:124/255. blue:255/255. alpha:1.]];
  126. } else {
  127. [weakSelf.learnMoreButton setTitleColor:[NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.]];
  128. }
  129. }
  130. };
  131. self.enterLicenseButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  132. if ([KMAppearance isDarkMode]) {
  133. if (mouseEntered) {
  134. [weakSelf.enterLicenseButton setTitleColor:[NSColor whiteColor]];
  135. } else {
  136. [weakSelf.enterLicenseButton setTitleColor:[NSColor colorWithRed:181/255. green:177/255. blue:239/255. alpha:1.]];
  137. }
  138. } else {
  139. if (mouseEntered) {
  140. [weakSelf.enterLicenseButton setTitleColor:[NSColor colorWithRed:8/255. green:124/255. blue:255/255. alpha:1.]];
  141. } else {
  142. [weakSelf.enterLicenseButton setTitleColor:[NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.]];
  143. }
  144. }
  145. };
  146. [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
  147. [self updateViewColor];
  148. }
  149. - (void)updateViewColor {
  150. if ([KMAppearance isDarkMode]) {
  151. self.infoContendView.layer.backgroundColor = [NSColor colorWithRed:24/255. green:22/255. blue:31/255. alpha:0.9].CGColor;
  152. self.freeTrialBox.fillColor = [NSColor colorWithRed:181/255. green:177/255. blue:239/255. alpha:1.];
  153. self.nTipLabel.textColor = [NSColor colorWithRed:47/255. green:45/255. blue:54/255. alpha:1.];
  154. [self.freeTrialButton setTitleColor:[NSColor colorWithRed:7/255. green:1/255. blue:34/255. alpha:1.]];
  155. [self.learnMoreButton setTitleColor:[NSColor colorWithRed:181/255. green:177/255. blue:239/255. alpha:1.]];
  156. [self.enterLicenseButton setTitleColor:[NSColor colorWithRed:181/255. green:177/255. blue:239/255. alpha:1.]];
  157. } else {
  158. self.infoContendView.layer.backgroundColor = [NSColor colorWithRed:248/255. green:249/255. blue:1 alpha:1].CGColor;
  159. self.freeTrialBox.fillColor = [NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.];
  160. self.nTipLabel.textColor = [NSColor whiteColor];
  161. [self.freeTrialButton setTitleColor:[NSColor whiteColor]];
  162. [self.learnMoreButton setTitleColor:[NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.]];
  163. [self.enterLicenseButton setTitleColor:[NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.]];
  164. }
  165. }
  166. - (IBAction)btnAction:(id)sender {
  167. if ([sender isEqual:self.freeTrialButton]) {
  168. if (self.callback) {
  169. self.callback(0, self);
  170. }
  171. // [[FMTrackEventManager manager] trackOnceEvent:@"PUW" withProperties:@{@"PUW_Btn":@"Btn_PUW_DigitalSignTrial_Start"}];
  172. } else if ([sender isEqual:self.learnMoreButton]) {
  173. if (self.callback) {
  174. self.callback(1, self);
  175. }
  176. // [[FMTrackEventManager manager] trackOnceEvent:@"PUW" withProperties:@{@"PUW_Btn":@"Btn_PUW_DigitalSignTrial_LearnMore"}];
  177. } else if ([sender isEqual:self.enterLicenseButton]) {
  178. if (self.callback) {
  179. self.callback(2, self);
  180. }
  181. }
  182. }
  183. #pragma mark - NSNotification
  184. - (void)themeChanged:(NSNotification *)notification {
  185. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  186. [self updateViewColor];
  187. });
  188. }
  189. @end