KMPurchaseCompareDMGWindowController.m 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  1. //
  2. // KMPurchaseCompareDMGWindowController.m
  3. // PDF Reader Pro Edition
  4. //
  5. // Created by 王帅 on 2018/5/8.
  6. //
  7. #import "KMPurchaseCompareDMGWindowController.h"
  8. #import <PDF_Reader_Pro-Swift.h>
  9. //#import "HyperLinkButton.h"
  10. #import "KMVerificationWindowController.h"
  11. //#import "KMPurchaseCompareWindowController.h"
  12. #import "VerificationManager.h"
  13. //#import "GAIManager.h"
  14. //#import "NSImage_SKExtensions.h"
  15. //#import "KMButton.h"
  16. //#import "KMBox.h"
  17. //#import "SKInspectPublicTool.h"
  18. //#import "FMTrackEventManager.h"
  19. //#import "NSFont+Custom.h"
  20. //#import "KMToolbarItemPopViewController.h"
  21. //#import "KMRecommondManager.h"
  22. static NSString *const KMPurchaseCompareDMGHeaderCellIdentifier = @"KMPurchaseCompareDMGHeaderCell";
  23. static NSString *const KMPurchaseCompareDMGCellIdentifier = @"KMPurchaseCompareDMGCell";
  24. #pragma mark - KMPurchaseCompareDMGHeaderCell
  25. @interface KMPurchaseCompareDMGHeaderCell : NSTableCellView
  26. @property (nonatomic,assign) IBOutlet NSView *contentView;
  27. @end
  28. @implementation KMPurchaseCompareDMGHeaderCell
  29. - (void)dealloc {
  30. [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
  31. }
  32. - (void)awakeFromNib {
  33. [super awakeFromNib];
  34. self.contentView.wantsLayer = YES;
  35. [self updateViewColor];
  36. [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
  37. }
  38. - (void)themeChanged:(NSNotification *)notification {
  39. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  40. [self updateViewColor];
  41. });
  42. }
  43. - (void)updateViewColor {
  44. NSColor *textColor = [NSColor colorWithDeviceRed:51.0/255.0 green:51.0/255.0 blue:51.0/255.0 alpha:1.0];
  45. NSColor *viewColor = [NSColor colorWithDeviceRed:55.0/255.0 green:57.0/255.0 blue:59.0/255.0 alpha:0.06];
  46. if (@available(macOS 10.14, *)) {
  47. NSAppearanceName appearanceName = [[NSApp effectiveAppearance] bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
  48. if ([appearanceName isEqualToString:NSAppearanceNameDarkAqua]) {
  49. textColor = [NSColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.87];
  50. viewColor = [NSColor colorWithRed:52.0/255.0 green:53.0/255.0 blue:56.0/255.0 alpha:1.0];
  51. }
  52. }
  53. self.contentView.layer.backgroundColor = viewColor.CGColor;
  54. self.textField.textColor = textColor;
  55. self.textField.font = [NSFont boldSystemFontOfSize:14.0];
  56. }
  57. @end
  58. #pragma mark - KMPurchaseCompareDMGCell
  59. @interface KMPurchaseCompareDMGCell : NSTableCellView
  60. @property (nonatomic,assign) IBOutlet NSTextField *value1Label;
  61. @property (nonatomic,assign) IBOutlet NSTextField *value2Label;
  62. @property (nonatomic,assign) IBOutlet NSImageView *value1ImageView;
  63. @property (nonatomic,assign) IBOutlet NSImageView *value2ImageView;
  64. @property (nonatomic,assign) IBOutlet NSBox *lineBox;
  65. @end
  66. @implementation KMPurchaseCompareDMGCell
  67. - (void)dealloc {
  68. [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
  69. }
  70. - (void)awakeFromNib {
  71. [super awakeFromNib];
  72. [self updateViewColor];
  73. [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
  74. }
  75. - (void)themeChanged:(NSNotification *)notification {
  76. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  77. [self updateViewColor];
  78. });
  79. }
  80. - (void)updateViewColor {
  81. NSColor *textColor = [NSColor colorWithRed:102.0/255.0 green:102.0/255.0 blue:102.0/255.0 alpha:0.85];
  82. NSColor *lineColor = [NSColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:0.4];
  83. if (@available(macOS 10.14, *)) {
  84. NSAppearanceName appearanceName = [[NSApp effectiveAppearance] bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
  85. if ([appearanceName isEqualToString:NSAppearanceNameDarkAqua]) {
  86. textColor = [NSColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.6];
  87. lineColor = [NSColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:0.4];
  88. }
  89. }
  90. self.value1Label.textColor = self.value2Label.textColor = textColor;
  91. self.lineBox.fillColor = lineColor;
  92. self.textField.textColor = textColor;
  93. }
  94. @end
  95. #pragma mark - KMPurchaseCompareDMGWindowController
  96. @interface KMPurchaseCompareDMGWindowController ()
  97. @property (nonatomic, assign) IBOutlet NSTextField *titleLabel;
  98. @property (assign) IBOutlet HyperLinkButton *enterLicenseButton;
  99. @property (assign) IBOutlet NSView *freeContendView;
  100. @property (assign) IBOutlet NSView *freeVersionBGView;
  101. @property (assign) IBOutlet NSTextField *freeVersionLbl;
  102. @property (assign) IBOutlet NSView *freeVersionLineView;
  103. @property (assign) IBOutlet NSTextField *freeVersionInfoLbl1;
  104. @property (assign) IBOutlet NSTextField *freeVersionInfoLbl2;
  105. @property (assign) IBOutlet NSTextField *freeVersionInfoLbl3;
  106. @property (assign) IBOutlet NSTextField *freeVersionInfoLbl4;
  107. @property (assign) IBOutlet NSTextField *freeVersionInfoLbl5;
  108. @property (assign) IBOutlet NSTextField *freeVersionInfoLbl6;
  109. @property (assign) IBOutlet NSTextField *freeVersionInfoLbl7;
  110. @property (assign) IBOutlet NSTextField *freeVersionInfoLbl8;
  111. @property (assign) IBOutlet NSTextField *freeVersionInfoLbl9;
  112. @property (assign) IBOutlet NSView *parmanentVerBGView;
  113. @property (assign) IBOutlet NSTextField *parmanentVerLbl;
  114. @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl1;
  115. @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl2;
  116. @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl3;
  117. @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl4;
  118. @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl5;
  119. @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl6;
  120. @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl7;
  121. @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl8;
  122. @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl9;
  123. @property (assign) IBOutlet KMButton *parmanentVerInfoBtn2;
  124. @property (assign) IBOutlet NSImageView *parmanentVerinfoimg2;
  125. @property (assign) IBOutlet NSView *parmanentInfoView;
  126. @property (assign) IBOutlet NSImageView *discountTipImage;
  127. @property (assign) IBOutlet NSTextField *oneTimeTipLbl;
  128. @property (assign) IBOutlet NSBox *freeTrialBox;
  129. @property (assign) IBOutlet KMButton *freeTrialButton;
  130. @property (assign) IBOutlet NSBox *buyNowBox;
  131. @property (assign) IBOutlet KMButton *buyNowButton;
  132. @property (assign) IBOutlet NSView *aiContendView;
  133. @property (assign) IBOutlet NSView *aiSepLineView;
  134. @property (assign) IBOutlet NSTextField *aiTitleLabel;
  135. @property (assign) IBOutlet NSTextField *aiInfoLbl1;
  136. @property (assign) IBOutlet NSTextField *aiInfoLbl2;
  137. @property (assign) IBOutlet NSTextField *aiInfoLbl3;
  138. @property (assign) IBOutlet NSTextField *aiInfoLbl4;
  139. @property (assign) IBOutlet NSTextField *aiPurchaseLabel;
  140. @property (assign) IBOutlet KMButton *aiPurchaseButton;
  141. @property (nonatomic, assign) NSModalSession modalSession;
  142. @property (nonatomic, retain) NSArray *dataSource;
  143. @property (nonatomic, retain) NSPopover *popOver;
  144. @end
  145. @implementation KMPurchaseCompareDMGWindowController
  146. #pragma mark Init Methods
  147. - (id)init {
  148. if (self = [super initWithWindowNibName:@"KMPurchaseCompareDMGWindowController"]) {
  149. }
  150. return self;
  151. }
  152. - (void)dealloc {
  153. [[NSNotificationCenter defaultCenter] removeObserver:self];
  154. [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
  155. }
  156. - (void)windowDidLoad {
  157. [super windowDidLoad];
  158. self.window.movableByWindowBackground = YES;
  159. self.window.backgroundColor = [NSColor whiteColor];
  160. __block typeof(self) blockSelf = self;
  161. [self.freeVersionInfoLbl2 setEnabled:YES];
  162. self.freeVersionLineView.wantsLayer = YES;
  163. self.freeVersionLbl.stringValue = NSLocalizedString(@"Free Version", nil);
  164. self.parmanentVerLbl.stringValue = NSLocalizedString(@"Permanent License", nil);
  165. self.freeVersionInfoLbl1.stringValue = self.parmanentVerInfoLbl1.stringValue = NSLocalizedString(@"View PDFs", nil);
  166. self.freeVersionInfoLbl2.stringValue = NSLocalizedString(@"Annotate PDFs (basic)", nil);
  167. self.parmanentVerInfoLbl2.stringValue = NSLocalizedString(@"Annotate PDFs (advanced)", nil);
  168. self.freeVersionInfoLbl3.stringValue = self.parmanentVerInfoLbl3.stringValue = NSLocalizedString(@"Unlimited file conversion", nil);
  169. self.freeVersionInfoLbl4.stringValue = self.parmanentVerInfoLbl4.stringValue = NSLocalizedString(@"Edit PDF text and images", nil);
  170. self.freeVersionInfoLbl5.stringValue = self.parmanentVerInfoLbl5.stringValue = NSLocalizedString(@"Digital signature", nil);
  171. self.freeVersionInfoLbl6.stringValue = self.parmanentVerInfoLbl6.stringValue = NSLocalizedString(@"Organize pages", nil);
  172. self.freeVersionInfoLbl7.stringValue = self.parmanentVerInfoLbl7.stringValue = NSLocalizedString(@"Batch process", nil);
  173. self.freeVersionInfoLbl8.stringValue = self.parmanentVerInfoLbl8.stringValue = NSLocalizedString(@"OCR PDFs", nil);
  174. self.freeVersionInfoLbl9.stringValue = self.parmanentVerInfoLbl9.stringValue = NSLocalizedString(@"Ad-free", nil);
  175. // self.parmanentVerinfoimg2.toolTip = NSLocalizedString(@"Support insert links and custom stamps", nil);
  176. self.parmanentVerInfoBtn2.mouseMoveCallback = ^(BOOL mouseEntered) {
  177. if (mouseEntered) {
  178. KMToolbarItemPopViewController *popViewController = [[KMToolbarItemPopViewController alloc] init];
  179. self.popOver = [[NSPopover alloc] init];
  180. self.popOver.contentViewController = popViewController;
  181. self.popOver.animates = NO;
  182. self.popOver.behavior = NSPopoverBehaviorSemitransient;
  183. self.popOver.contentSize = popViewController.view.frame.size;
  184. [popViewController updateWithHelpTipWithHelpTip:NSLocalizedString(@"Support insert links and custom stamps", nil)];
  185. [self.popOver showRelativeToRect:self.parmanentVerInfoBtn2.frame ofView:self.parmanentInfoView preferredEdge:NSRectEdgeMaxY];
  186. // self.parmanentVerinfoimg2.image = [NSImage imageNamed:@"ic_Tooltip_hover"];
  187. } else {
  188. [self.popOver close];
  189. // self.parmanentVerinfoimg2.image = [NSImage imageNamed:@"ic_Tooltip"];
  190. }
  191. };
  192. self.oneTimeTipLbl.stringValue = NSLocalizedString(@"one-time purchase", nil);
  193. self.enterLicenseButton.title = NSLocalizedString(@"Enter License", nil);
  194. [self.enterLicenseButton setTitleColor:[KMAppearance KMColor_Layout_W0]];
  195. self.enterLicenseButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  196. if (mouseEntered) {
  197. [blockSelf.enterLicenseButton setTitleColor:[KMAppearance KMColor_Layout_W70]];
  198. } else {
  199. [blockSelf.enterLicenseButton setTitleColor:[KMAppearance KMColor_Layout_W0]];
  200. }
  201. };
  202. self.titleLabel.font = [NSFont SFMediumFontWithSize:20];
  203. self.freeVersionLbl.font = [NSFont UbuntuBoldFontWithSize:24];
  204. self.parmanentVerLbl.font = [NSFont UbuntuBoldFontWithSize:24];
  205. self.freeVersionInfoLbl1.font = self.parmanentVerInfoLbl1.font = [NSFont SFProTextRegularFont:14.];
  206. self.freeVersionInfoLbl2.font = [NSFont SFProTextRegularFont:14.];
  207. self.parmanentVerInfoLbl2.font = [NSFont SFProTextRegularFont:14.];
  208. self.freeVersionInfoLbl3.font = self.parmanentVerInfoLbl3.font = [NSFont SFProTextRegularFont:14.];
  209. self.freeVersionInfoLbl4.font = self.parmanentVerInfoLbl4.font = [NSFont SFProTextRegularFont:14.];
  210. self.freeVersionInfoLbl5.font = self.parmanentVerInfoLbl5.font = [NSFont SFProTextRegularFont:14.];
  211. self.freeVersionInfoLbl6.font = self.parmanentVerInfoLbl6.font = [NSFont SFProTextRegularFont:14.];
  212. self.freeVersionInfoLbl7.font = self.parmanentVerInfoLbl7.font = [NSFont SFProTextRegularFont:14.];
  213. self.freeVersionInfoLbl8.font = self.parmanentVerInfoLbl8.font = [NSFont SFProTextRegularFont:14.];
  214. self.freeVersionInfoLbl9.font = self.parmanentVerInfoLbl9.font = [NSFont SFProTextRegularFont:14.];
  215. self.buyNowButton.font = [NSFont UbuntuMediumFontWithSize:16];
  216. self.freeTrialButton.font = [NSFont UbuntuMediumFontWithSize:16];
  217. self.freeContendView.wantsLayer = YES;
  218. self.freeContendView.layer.cornerRadius = 12;
  219. self.freeContendView.layer.masksToBounds = YES;
  220. self.parmanentVerBGView.wantsLayer = YES;
  221. self.parmanentVerBGView.layer.cornerRadius = 12;
  222. self.parmanentVerBGView.layer.masksToBounds = YES;
  223. self.buyNowBox.wantsLayer = YES;
  224. self.buyNowBox.fillColor = [NSColor colorWithRed:255/255. green:94/255. blue:44/255. alpha:1.];
  225. self.buyNowBox.cornerRadius = CGRectGetHeight(self.buyNowBox.frame)/2.;
  226. self.buyNowBox.layer.masksToBounds = YES;
  227. self.buyNowButton.wantsLayer = YES;
  228. self.buyNowButton.layer.cornerRadius = 1.0;
  229. self.buyNowButton.title = NSLocalizedString(@"Buy Now", nil);
  230. self.buyNowButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  231. if (mouseEntered) {
  232. blockSelf.buyNowButton.layer.backgroundColor = [[NSColor blackColor] colorWithAlphaComponent:0.15].CGColor;
  233. } else {
  234. blockSelf.buyNowButton.layer.backgroundColor = [NSColor clearColor].CGColor;
  235. }
  236. };
  237. self.freeTrialBox.cornerRadius = CGRectGetHeight(self.freeTrialBox.frame)/2.;
  238. self.freeTrialBox.borderWidth = 1.;
  239. self.freeTrialButton.target = self;
  240. self.freeTrialButton.action = @selector(buttonItemClicked_License:);
  241. self.freeTrialButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  242. if ([KMAppearance isDarkMode]) {
  243. if (mouseEntered) {
  244. blockSelf.freeTrialBox.fillColor = [NSColor colorWithRed:179/255. green:159/255. blue:1 alpha:0.2];
  245. } else {
  246. blockSelf.freeTrialBox.fillColor = [NSColor colorWithRed:179/255. green:159/255. blue:1 alpha:0.07];
  247. }
  248. } else {
  249. if (mouseEntered) {
  250. blockSelf.freeTrialBox.fillColor = [NSColor colorWithRed:85/255. green:40/255. blue:1 alpha:0.15];
  251. } else {
  252. blockSelf.freeTrialBox.fillColor = [NSColor colorWithRed:85/255. green:40/255. blue:1 alpha:0.07];
  253. }
  254. }
  255. };
  256. self.discountTipImage.hidden = YES;
  257. self.aiSepLineView.wantsLayer = YES;
  258. self.aiInfoLbl1.font = self.aiInfoLbl2.font = self.aiInfoLbl3.font = self.aiInfoLbl4.font = [NSFont SFProTextRegularFont:14];
  259. self.aiPurchaseLabel.font = [NSFont UbuntuMediumFontWithSize:16];
  260. self.aiTitleLabel.stringValue = NSLocalizedString(@"AI Tools", nil);
  261. self.aiInfoLbl1.stringValue = NSLocalizedString(@"AI Summarize", nil);
  262. self.aiInfoLbl2.stringValue = NSLocalizedString(@"AI Rewrite", nil);
  263. self.aiInfoLbl3.stringValue = NSLocalizedString(@"AI Proofread", nil);
  264. self.aiInfoLbl4.stringValue = NSLocalizedString(@"AI Translate", nil);
  265. self.aiPurchaseLabel.stringValue = NSLocalizedString(@"Buy Now", nil);
  266. self.aiPurchaseButton.wantsLayer = YES;
  267. self.aiPurchaseButton.layer.cornerRadius = CGRectGetHeight(self.aiPurchaseButton.frame)/2.;
  268. self.aiPurchaseButton.layer.masksToBounds = YES;
  269. self.aiPurchaseButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  270. if (mouseEntered) {
  271. self.aiPurchaseButton.layer.backgroundColor = [[NSColor whiteColor] colorWithAlphaComponent:0.2].CGColor;
  272. } else {
  273. self.aiPurchaseButton.layer.backgroundColor = [NSColor clearColor].CGColor;
  274. }
  275. };
  276. [self updateViewColor];
  277. [self updatePurchaseInformation];
  278. [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
  279. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recommondInfoUpdateNoti:) name:@"KMRecommondInfoUpdateNoti" object:nil];
  280. }
  281. #pragma mark - Private Methods
  282. - (void)updateViewColor {
  283. if ([KMAppearance isDarkMode]) {
  284. self.freeContendView.layer.backgroundColor = [[NSColor blackColor] colorWithAlphaComponent:0.3].CGColor;
  285. self.freeVersionLineView.layer.backgroundColor = [[NSColor whiteColor] colorWithAlphaComponent:0.1].CGColor;
  286. self.aiSepLineView.layer.backgroundColor = [[NSColor whiteColor] colorWithAlphaComponent:0.1].CGColor;
  287. self.freeVersionLbl.textColor = [[NSColor whiteColor] colorWithAlphaComponent:0.5];
  288. self.freeTrialBox.fillColor = [NSColor colorWithRed:179/255. green:159/255. blue:1 alpha:0.07];
  289. self.freeTrialBox.borderColor = [NSColor colorWithRed:207/255. green:146/255. blue:1 alpha:1];
  290. self.freeVersionInfoLbl1.textColor =
  291. self.freeVersionInfoLbl2.textColor =
  292. self.freeVersionInfoLbl3.textColor =
  293. self.freeVersionInfoLbl4.textColor =
  294. self.freeVersionInfoLbl5.textColor =
  295. self.freeVersionInfoLbl6.textColor =
  296. self.freeVersionInfoLbl7.textColor =
  297. self.freeVersionInfoLbl8.textColor =
  298. self.freeVersionInfoLbl9.textColor = [NSColor whiteColor];
  299. self.parmanentVerInfoLbl1.textColor =
  300. self.parmanentVerInfoLbl2.textColor =
  301. self.parmanentVerInfoLbl3.textColor =
  302. self.parmanentVerInfoLbl4.textColor =
  303. self.parmanentVerInfoLbl5.textColor =
  304. self.parmanentVerInfoLbl6.textColor =
  305. self.parmanentVerInfoLbl7.textColor =
  306. self.parmanentVerInfoLbl8.textColor =
  307. self.parmanentVerInfoLbl9.textColor = [NSColor whiteColor];
  308. self.aiInfoLbl1.textColor = self.aiInfoLbl2.textColor = self.aiInfoLbl3.textColor = self.aiInfoLbl4.textColor = [NSColor whiteColor];
  309. self.aiPurchaseLabel.textColor = [NSColor whiteColor];
  310. self.aiTitleLabel.textColor = [NSColor colorWithRed:239/255. green:235/255. blue:255/255. alpha:1];
  311. } else {
  312. self.freeContendView.layer.backgroundColor = [[NSColor whiteColor] colorWithAlphaComponent:0.7].CGColor;
  313. self.freeVersionLineView.layer.backgroundColor = [NSColor colorWithRed:0 green:33/255. blue:67/255. alpha:0.1].CGColor;
  314. self.aiSepLineView.layer.backgroundColor = [NSColor colorWithRed:0 green:33/255. blue:67/255. alpha:0.1].CGColor;
  315. self.freeVersionLbl.textColor = [NSColor colorWithRed:129/255. green:125/255. blue:178/255. alpha:1.];
  316. self.freeTrialBox.fillColor = [NSColor colorWithRed:85/255. green:40/255. blue:1 alpha:0.07];
  317. self.freeTrialBox.borderColor = [NSColor colorWithRed:160/255. green:40/255. blue:1 alpha:1];
  318. self.freeVersionInfoLbl1.textColor =
  319. self.freeVersionInfoLbl2.textColor =
  320. self.freeVersionInfoLbl3.textColor =
  321. self.freeVersionInfoLbl4.textColor =
  322. self.freeVersionInfoLbl5.textColor =
  323. self.freeVersionInfoLbl6.textColor =
  324. self.freeVersionInfoLbl7.textColor =
  325. self.freeVersionInfoLbl8.textColor =
  326. self.freeVersionInfoLbl9.textColor = [NSColor colorWithRed:20/255.0 green:0/255.0 blue:102/255.0 alpha:1];
  327. self.parmanentVerInfoLbl1.textColor =
  328. self.parmanentVerInfoLbl2.textColor =
  329. self.parmanentVerInfoLbl3.textColor =
  330. self.parmanentVerInfoLbl4.textColor =
  331. self.parmanentVerInfoLbl5.textColor =
  332. self.parmanentVerInfoLbl6.textColor =
  333. self.parmanentVerInfoLbl7.textColor =
  334. self.parmanentVerInfoLbl8.textColor =
  335. self.parmanentVerInfoLbl9.textColor = [NSColor whiteColor];
  336. self.aiInfoLbl1.textColor = self.aiInfoLbl2.textColor = self.aiInfoLbl3.textColor = self.aiInfoLbl4.textColor = [NSColor colorWithRed:20/255. green:0 blue:102/255. alpha:1];
  337. self.aiPurchaseLabel.textColor = [NSColor whiteColor];
  338. self.aiTitleLabel.textColor = [NSColor colorWithRed:20/255. green:0 blue:102/255. alpha:1];
  339. }
  340. self.parmanentVerLbl.textColor = [NSColor colorWithRed:255/255. green:94/255. blue:44/255. alpha:1.];
  341. self.oneTimeTipLbl.textColor = [NSColor colorWithRed:255/255. green:231/255. blue:106/255. alpha:1.];
  342. if ([KMAppearance isDarkMode]) {
  343. [self.freeTrialButton setTitleColor:[NSColor colorWithRed:178/255. green:165/255. blue:1 alpha:1]];
  344. } else {
  345. [self.freeTrialButton setTitleColor:[NSColor colorWithRed:160/255. green:40/255. blue:1 alpha:1]];
  346. }
  347. }
  348. - (void)updatePurchaseInformation {
  349. self.freeTrialBox.hidden = NO;
  350. self.titleLabel.stringValue = NSLocalizedString(@"Upgrade to Pro Version", nil);
  351. self.titleLabel.textColor = [NSColor whiteColor];
  352. [self.freeTrialButton setTitle:NSLocalizedString(@"7-day Free Trial", nil)];
  353. if (ActivityStatusVerification == [VerificationManager manager].status) {
  354. self.freeTrialBox.hidden = YES;
  355. } else if (ActivityStatusNone == [VerificationManager manager].status) {
  356. } else if (ActivityStatusTrialExpire == [VerificationManager manager].status) {
  357. self.freeTrialBox.hidden = YES;
  358. if ([VerificationManager manager].secondTrialEnabled) {
  359. self.freeTrialBox.hidden = NO;
  360. }
  361. } else {
  362. self.freeTrialBox.hidden = YES;
  363. }
  364. if ([KMAppearance isDarkMode]) {
  365. [self.freeTrialButton setTitleColor:[NSColor colorWithRed:178/255. green:165/255. blue:1 alpha:1]];
  366. } else {
  367. [self.freeTrialButton setTitleColor:[NSColor colorWithRed:160/255. green:40/255. blue:1 alpha:1]];
  368. }
  369. [self.buyNowButton setTitleColor:[NSColor whiteColor]];
  370. if (KMAdvertisementManager.manager.info.discountContent.content.count > 0) {
  371. KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.discountContent.content.firstObject;
  372. if ([KMAdvertisementManager checkAdvertisementValid:info]) {
  373. self.discountTipImage.hidden = NO;
  374. NSURL *url = [NSURL URLWithString:[KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight:NO]];
  375. self.discountTipImage.image = [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage * _Nonnull image) {
  376. self.discountTipImage.image = image;
  377. }];
  378. } else {
  379. self.discountTipImage.hidden = YES;
  380. }
  381. }
  382. }
  383. #pragma mark - Window Method
  384. - (void)showWindow:(id)sender {
  385. [super showWindow:nil];
  386. [self.window center];
  387. [self.window orderFront:nil];
  388. [self updatePurchaseInformation];
  389. }
  390. - (BOOL)windowShouldClose:(id)sender {
  391. [self endModal:sender];
  392. return YES;
  393. }
  394. - (void)close {
  395. [super close];
  396. [self endModal:nil];
  397. }
  398. - (void)updateTitle:(NSString *)title andColor:(NSColor *)titleColor {
  399. self.titleLabel.stringValue = title ?:@"";
  400. self.titleLabel.textColor = titleColor ?:[NSColor labelColor];
  401. }
  402. #pragma mark - IBAction
  403. - (IBAction)startModal:(id)sender {
  404. [NSApp stopModal];
  405. NSInteger modalCode;
  406. self.modalSession = [NSApp beginModalSessionForWindow:self.window];
  407. do {
  408. modalCode = [NSApp runModalSession:self.modalSession];
  409. } while (modalCode == NSRunContinuesResponse);
  410. }
  411. - (IBAction)endModal:(id)sender {
  412. if (self.modalSession) {
  413. [NSApp stopModal];
  414. [NSApp endModalSession:self.modalSession];
  415. [self.window orderOut:self];
  416. self.modalSession = nil;
  417. }
  418. }
  419. - (void)showWindowRestore:(id)sender {
  420. [self showWindow:sender];
  421. }
  422. - (IBAction)enterLicenseAction:(id)sender {
  423. // if (ActivityStatusNone == [VerificationManager manager].status) {
  424. // [self close];
  425. // KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];
  426. // vc.callback = ^{
  427. // [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
  428. // };
  429. // [vc showWindow:nil];
  430. // } else if (ActivityStatusTrialExpire == [VerificationManager manager].status) {
  431. // if ([VerificationManager manager].secondTrialEnabled) {
  432. // [[FMTrackEventManager manager] trackEvent:@"Tbr" withProperties:@{@"Tbr_Btn":@"Btn_Tbr_SecondTrial"}];
  433. // [[VerificationManager manager] trialForDays:7
  434. // email:[VerificationManager manager].email
  435. // name:[VerificationManager manager].accountName
  436. // complention:^(ActivityStatus status, NSDictionary *info, NSError *error) {
  437. // if (error ||
  438. // status != ActivityStatusTrial) {
  439. // NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
  440. // defaultButton:NSLocalizedString(@"Try Again", nil)
  441. // alternateButton:nil
  442. // otherButton:nil
  443. // informativeTextWithFormat:NSLocalizedString(@"Failed to sign up for the free trial. Please make sure your internet connection is available and try again later.", nil), nil];
  444. // [alert runModal];
  445. // } else {
  446. // KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeRepeatTrialSuccess];
  447. // [vc showWindow:nil];
  448. // }
  449. // }];
  450. // [self close];
  451. // } else {
  452. // [self close];
  453. // KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];
  454. // vc.callback = ^{
  455. // [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
  456. // };
  457. // [vc showWindow:nil];
  458. // }
  459. // } else {
  460. [self close];
  461. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];
  462. vc.callback = ^{
  463. [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
  464. };
  465. [vc showWindow:nil];
  466. // }
  467. }
  468. - (IBAction)buttonItemClicked_Buy:(id)sender {
  469. #if VERSION_DMG
  470. NSURL *url = [NSURL URLWithString:@"https://www.pdfreaderpro.com/store?utm_source=app_dmg&utm_medium=dmg_puw_comparison"];
  471. if([SKInspectPublicTool currentisLanguageHans]) {
  472. url = [NSURL URLWithString:@"https://www.pdfreaderpro.com/zh-cn/store?utm_source=app_dmg&utm_medium=dmg_puw_comparison"];
  473. }
  474. [[NSWorkspace sharedWorkspace] openURL:url];
  475. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_UpgradeBuyNow"}];
  476. #endif
  477. }
  478. - (IBAction)buttonItemClicked_CloseWindow:(id)sender {
  479. [self close];
  480. }
  481. - (void)buttonItemClicked_License:(id)sender {
  482. // if (ActivityStatusNone == [VerificationManager manager].status) {
  483. // [self close];
  484. //
  485. // KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeTrial];
  486. // [vc showWindow:nil];
  487. // } else if (ActivityStatusTrialExpire == [VerificationManager manager].status) {
  488. if ([VerificationManager manager].secondTrialEnabled) {
  489. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"Tbr" withProperties:@{@"Tbr_Btn":@"Btn_Tbr_SecondTrial"}];
  490. [[VerificationManager manager] trialForDays:7
  491. email:[VerificationManager manager].email
  492. name:[VerificationManager manager].accountName
  493. complention:^(ActivityStatus status, NSDictionary *info, NSError *error) {
  494. if (error ||
  495. status != ActivityStatusTrial) {
  496. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
  497. defaultButton:NSLocalizedString(@"Try Again", nil)
  498. alternateButton:nil
  499. otherButton:nil
  500. informativeTextWithFormat:NSLocalizedString(@"Failed to sign up for the free trial. Please make sure your internet connection is available and try again later.", nil), nil];
  501. [alert runModal];
  502. } else {
  503. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeRepeatTrialSuccess];
  504. [vc showWindow:nil];
  505. }
  506. }];
  507. [self close];
  508. } else {
  509. [self close];
  510. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeTrial];
  511. vc.callback = ^{
  512. [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
  513. };
  514. [vc showWindow:nil];
  515. }
  516. // } else {
  517. // [self close];
  518. // KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];
  519. // vc.callback = ^{
  520. // [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
  521. // };
  522. // [vc showWindow:nil];
  523. // }
  524. }
  525. - (IBAction)aiPurchaseButtonClick:(NSButton *)sender {
  526. NSURL *url = [NSURL URLWithString:kAIStoreServerLink];
  527. [[NSWorkspace sharedWorkspace] openURL:url];
  528. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_BuyAITools"}];
  529. }
  530. #pragma mark - Noti
  531. - (void)themeChanged:(NSNotification *)notification {
  532. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  533. [self updateViewColor];
  534. });
  535. }
  536. - (void)recommondInfoUpdateNoti:(NSNotification *)noti {
  537. dispatch_async(dispatch_get_main_queue(), ^{
  538. if (KMAdvertisementManager.manager.info.discountContent.content.count > 0) {
  539. KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.discountContent.content.firstObject;
  540. if ([KMAdvertisementManager checkAdvertisementValid:info]) {
  541. self.discountTipImage.hidden = NO;
  542. self.discountTipImage.image = info.image;
  543. } else {
  544. self.discountTipImage.hidden = YES;
  545. }
  546. }
  547. });
  548. }
  549. @end