KMPurchaseCompareDMGWindowController.m 29 KB

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