KMPurchaseCompareDMGWindowController.m 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858
  1. //
  2. // KMPurchaseCompareDMGWindowController.m
  3. // EaseUS PDF Editor
  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 "NSFont+Custom.h"
  19. //#import "KMToolbarItemPopViewController.h"
  20. //#import "KMRecommondManager.h"
  21. static NSString *const KMPurchaseCompareDMGHeaderCellIdentifier = @"KMPurchaseCompareDMGHeaderCell";
  22. static NSString *const KMPurchaseCompareDMGCellIdentifier = @"KMPurchaseCompareDMGCell";
  23. #pragma mark - KMPurchaseCompareDMGHeaderCell
  24. @interface KMPurchaseCompareDMGHeaderCell : NSTableCellView
  25. @property (nonatomic,assign) IBOutlet NSView *contentView;
  26. @end
  27. @implementation KMPurchaseCompareDMGHeaderCell
  28. - (void)dealloc {
  29. [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
  30. }
  31. - (void)awakeFromNib {
  32. [super awakeFromNib];
  33. self.contentView.wantsLayer = YES;
  34. [self updateViewColor];
  35. [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
  36. }
  37. - (void)themeChanged:(NSNotification *)notification {
  38. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  39. [self updateViewColor];
  40. });
  41. }
  42. - (void)updateViewColor {
  43. NSColor *textColor = [NSColor colorWithDeviceRed:51.0/255.0 green:51.0/255.0 blue:51.0/255.0 alpha:1.0];
  44. NSColor *viewColor = [NSColor colorWithDeviceRed:55.0/255.0 green:57.0/255.0 blue:59.0/255.0 alpha:0.06];
  45. if (@available(macOS 10.14, *)) {
  46. NSAppearanceName appearanceName = [[NSApp effectiveAppearance] bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
  47. if ([appearanceName isEqualToString:NSAppearanceNameDarkAqua]) {
  48. textColor = [NSColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.87];
  49. viewColor = [NSColor colorWithRed:52.0/255.0 green:53.0/255.0 blue:56.0/255.0 alpha:1.0];
  50. }
  51. }
  52. self.contentView.layer.backgroundColor = viewColor.CGColor;
  53. self.textField.textColor = textColor;
  54. self.textField.font = [NSFont boldSystemFontOfSize:14.0];
  55. }
  56. @end
  57. #pragma mark - KMPurchaseCompareDMGCell
  58. @interface KMPurchaseCompareDMGCell : NSTableCellView
  59. @property (nonatomic,assign) IBOutlet NSTextField *value1Label;
  60. @property (nonatomic,assign) IBOutlet NSTextField *value2Label;
  61. @property (nonatomic,assign) IBOutlet NSImageView *value1ImageView;
  62. @property (nonatomic,assign) IBOutlet NSImageView *value2ImageView;
  63. @property (nonatomic,assign) IBOutlet NSBox *lineBox;
  64. @end
  65. @implementation KMPurchaseCompareDMGCell
  66. - (void)dealloc {
  67. [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
  68. }
  69. - (void)awakeFromNib {
  70. [super awakeFromNib];
  71. [self updateViewColor];
  72. [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
  73. }
  74. - (void)themeChanged:(NSNotification *)notification {
  75. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  76. [self updateViewColor];
  77. });
  78. }
  79. - (void)updateViewColor {
  80. NSColor *textColor = [NSColor colorWithRed:102.0/255.0 green:102.0/255.0 blue:102.0/255.0 alpha:0.85];
  81. NSColor *lineColor = [NSColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:0.4];
  82. if (@available(macOS 10.14, *)) {
  83. NSAppearanceName appearanceName = [[NSApp effectiveAppearance] bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
  84. if ([appearanceName isEqualToString:NSAppearanceNameDarkAqua]) {
  85. textColor = [NSColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.6];
  86. lineColor = [NSColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:0.4];
  87. }
  88. }
  89. self.value1Label.textColor = self.value2Label.textColor = textColor;
  90. self.lineBox.fillColor = lineColor;
  91. self.textField.textColor = textColor;
  92. }
  93. @end
  94. #pragma mark - KMPurchaseCompareDMGWindowController
  95. @interface KMPurchaseCompareDMGWindowController ()
  96. @property (nonatomic, assign) IBOutlet NSTextField *titleLabel;
  97. @property (assign) IBOutlet HyperLinkButton *enterLicenseButton;
  98. @property (assign) IBOutlet NSView *freeContendView;
  99. @property (assign) IBOutlet NSView *freeVersionBGView;
  100. @property (assign) IBOutlet NSTextField *freeVersionLbl;
  101. @property (assign) IBOutlet NSView *freeVersionLineView;
  102. @property (assign) IBOutlet NSTextField *freeVersionInfoLbl1;
  103. @property (assign) IBOutlet NSTextField *freeVersionInfoLbl2;
  104. @property (assign) IBOutlet NSTextField *freeVersionInfoLbl3;
  105. @property (assign) IBOutlet NSTextField *freeVersionInfoLbl4;
  106. @property (assign) IBOutlet NSTextField *freeVersionInfoLbl5;
  107. @property (assign) IBOutlet NSTextField *freeVersionInfoLbl6;
  108. @property (assign) IBOutlet NSTextField *freeVersionInfoLbl7;
  109. @property (assign) IBOutlet NSTextField *freeVersionInfoLbl8;
  110. @property (assign) IBOutlet NSTextField *freeVersionInfoLbl9;
  111. @property (weak) IBOutlet NSTextField *freeVersionInfoLbl10;
  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 (weak) IBOutlet NSImageView *parmanentVerInfoImage1;
  124. @property (weak) IBOutlet NSTextField *parmanentVerInfoLbl10;
  125. @property (assign) IBOutlet KMButton *parmanentVerInfoBtn2;
  126. @property (assign) IBOutlet NSImageView *parmanentVerinfoimg2;
  127. @property (assign) IBOutlet NSView *parmanentInfoView;
  128. @property (assign) IBOutlet NSTextField *oneTimeTipLbl;
  129. @property (assign) IBOutlet NSBox *freeTrialBox;
  130. @property (assign) IBOutlet KMButton *freeTrialButton;
  131. @property (assign) IBOutlet NSBox *buyNowBox;
  132. @property (assign) IBOutlet KMButton *buyNowButton;
  133. @property (nonatomic, assign) NSModalSession modalSession;
  134. @property (nonatomic, retain) NSArray *dataSource;
  135. @property (nonatomic, retain) NSPopover *popOver;
  136. - (NSString *)_buyNowEventToPaidEventName;
  137. - (NSDictionary *)_getPaidEventParamsWith:(NSString *)eventN;
  138. @end
  139. @implementation KMPurchaseCompareDMGWindowController
  140. #pragma mark Init Methods
  141. - (id)init {
  142. if (self = [super initWithWindowNibName:@"KMPurchaseCompareDMGWindowController"]) {
  143. }
  144. return self;
  145. }
  146. - (void)dealloc {
  147. [[NSNotificationCenter defaultCenter] removeObserver:self];
  148. [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
  149. }
  150. - (void)windowDidLoad {
  151. [super windowDidLoad];
  152. self.window.movableByWindowBackground = YES;
  153. self.window.backgroundColor = [NSColor whiteColor];
  154. __block typeof(self) blockSelf = self;
  155. [self.freeVersionInfoLbl2 setEnabled:YES];
  156. self.freeVersionLineView.wantsLayer = YES;
  157. self.freeVersionLbl.stringValue = NSLocalizedString(@"Free Version", nil);
  158. self.parmanentVerLbl.stringValue = NSLocalizedString(@"Permanent License", nil);
  159. self.freeVersionInfoLbl1.stringValue = self.parmanentVerInfoLbl1.stringValue = NSLocalizedString(@"View PDFs", nil);
  160. self.freeVersionInfoLbl2.stringValue = NSLocalizedString(@"Annotate PDFs (basic)", nil);
  161. self.parmanentVerInfoLbl2.stringValue = NSLocalizedString(@"Annotate PDFs (advanced)", nil);
  162. self.freeVersionInfoLbl3.stringValue = self.parmanentVerInfoLbl3.stringValue = NSLocalizedString(@"Unlimited file conversion", nil);
  163. self.freeVersionInfoLbl4.stringValue = self.parmanentVerInfoLbl4.stringValue = NSLocalizedString(@"Edit PDF text and images", nil);
  164. self.freeVersionInfoLbl5.stringValue = self.parmanentVerInfoLbl5.stringValue = NSLocalizedString(@"Digital signature", nil);
  165. self.freeVersionInfoLbl6.stringValue = self.parmanentVerInfoLbl6.stringValue = NSLocalizedString(@"Organize pages", nil);
  166. self.freeVersionInfoLbl7.stringValue = self.parmanentVerInfoLbl7.stringValue = NSLocalizedString(@"Batch process", nil);
  167. self.freeVersionInfoLbl8.stringValue = self.parmanentVerInfoLbl8.stringValue = NSLocalizedString(@"OCR PDFs", nil);
  168. self.freeVersionInfoLbl9.stringValue = self.parmanentVerInfoLbl9.stringValue = NSLocalizedString(@"Measuring Tools", nil);
  169. self.freeVersionInfoLbl10.stringValue = self.parmanentVerInfoLbl10.stringValue = NSLocalizedString(@"Ad-free", nil);
  170. [self refreshParmanentVerInfo];
  171. // self.parmanentVerinfoimg2.toolTip = NSLocalizedString(@"Support insert links and custom stamps", nil);
  172. self.parmanentVerInfoBtn2.mouseMoveCallback = ^(BOOL mouseEntered) {
  173. if (mouseEntered) {
  174. KMToolbarItemPopViewController *popViewController = [[KMToolbarItemPopViewController alloc] init];
  175. self.popOver = [[NSPopover alloc] init];
  176. self.popOver.contentViewController = popViewController;
  177. self.popOver.animates = NO;
  178. self.popOver.behavior = NSPopoverBehaviorSemitransient;
  179. self.popOver.contentSize = popViewController.view.frame.size;
  180. [popViewController updateWithHelpTipWithHelpTip:NSLocalizedString(@"Support insert links and custom stamps", nil)];
  181. [self.popOver showRelativeToRect:self.parmanentVerInfoBtn2.frame ofView:self.parmanentInfoView preferredEdge:NSRectEdgeMaxY];
  182. // self.parmanentVerinfoimg2.image = [NSImage imageNamed:@"ic_Tooltip_hover"];
  183. } else {
  184. [self.popOver close];
  185. // self.parmanentVerinfoimg2.image = [NSImage imageNamed:@"ic_Tooltip"];
  186. }
  187. };
  188. self.oneTimeTipLbl.stringValue = NSLocalizedString(@"one-time purchase", nil);
  189. self.enterLicenseButton.title = NSLocalizedString(@"Enter License", nil);
  190. [self.enterLicenseButton setTitleColor:[KMAppearance KMColor_Layout_W0]];
  191. self.enterLicenseButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  192. if (mouseEntered) {
  193. [blockSelf.enterLicenseButton setTitleColor:[KMAppearance KMColor_Layout_W70]];
  194. } else {
  195. [blockSelf.enterLicenseButton setTitleColor:[KMAppearance KMColor_Layout_W0]];
  196. }
  197. };
  198. self.titleLabel.font = [NSFont SFMediumFontWithSize:20];
  199. self.freeVersionLbl.font = [NSFont UbuntuBoldFontWithSize:24];
  200. self.parmanentVerLbl.font = [NSFont UbuntuBoldFontWithSize:24];
  201. self.freeVersionInfoLbl1.font = self.parmanentVerInfoLbl1.font = [NSFont SFProTextRegularFont:14.];
  202. self.freeVersionInfoLbl2.font = [NSFont SFProTextRegularFont:14.];
  203. self.parmanentVerInfoLbl2.font = [NSFont SFProTextRegularFont:14.];
  204. self.freeVersionInfoLbl3.font = self.parmanentVerInfoLbl3.font = [NSFont SFProTextRegularFont:14.];
  205. self.freeVersionInfoLbl4.font = self.parmanentVerInfoLbl4.font = [NSFont SFProTextRegularFont:14.];
  206. self.freeVersionInfoLbl5.font = self.parmanentVerInfoLbl5.font = [NSFont SFProTextRegularFont:14.];
  207. self.freeVersionInfoLbl6.font = self.parmanentVerInfoLbl6.font = [NSFont SFProTextRegularFont:14.];
  208. self.freeVersionInfoLbl7.font = self.parmanentVerInfoLbl7.font = [NSFont SFProTextRegularFont:14.];
  209. self.freeVersionInfoLbl8.font = self.parmanentVerInfoLbl8.font = [NSFont SFProTextRegularFont:14.];
  210. self.freeVersionInfoLbl9.font = self.parmanentVerInfoLbl9.font = [NSFont SFProTextRegularFont:14.];
  211. self.freeVersionInfoLbl10.font = self.parmanentVerInfoLbl10.font = [NSFont SFProTextRegularFont:14.];
  212. self.buyNowButton.font = [NSFont UbuntuMediumFontWithSize:16];
  213. self.freeTrialButton.font = [NSFont UbuntuMediumFontWithSize:16];
  214. self.freeContendView.wantsLayer = YES;
  215. self.freeContendView.layer.cornerRadius = 12;
  216. self.freeContendView.layer.masksToBounds = YES;
  217. self.parmanentVerBGView.wantsLayer = YES;
  218. self.parmanentVerBGView.layer.cornerRadius = 12;
  219. self.parmanentVerBGView.layer.masksToBounds = YES;
  220. self.buyNowBox.wantsLayer = YES;
  221. self.buyNowBox.fillColor = [NSColor colorWithRed:255/255. green:94/255. blue:44/255. alpha:1.];
  222. self.buyNowBox.cornerRadius = CGRectGetHeight(self.buyNowBox.frame)/2.;
  223. self.buyNowBox.layer.masksToBounds = YES;
  224. self.buyNowButton.wantsLayer = YES;
  225. self.buyNowButton.layer.cornerRadius = 1.0;
  226. self.buyNowButton.title = NSLocalizedString(@"Buy Now", nil);
  227. self.buyNowButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  228. if (mouseEntered) {
  229. blockSelf.buyNowButton.layer.backgroundColor = [[NSColor blackColor] colorWithAlphaComponent:0.15].CGColor;
  230. } else {
  231. blockSelf.buyNowButton.layer.backgroundColor = [NSColor clearColor].CGColor;
  232. }
  233. };
  234. self.freeTrialBox.cornerRadius = CGRectGetHeight(self.freeTrialBox.frame)/2.;
  235. self.freeTrialBox.borderWidth = 1.;
  236. self.freeTrialButton.target = self;
  237. self.freeTrialButton.action = @selector(buttonItemClicked_License:);
  238. self.freeTrialButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  239. if ([KMAppearance isDarkMode]) {
  240. if (mouseEntered) {
  241. blockSelf.freeTrialBox.fillColor = [NSColor colorWithRed:179/255. green:159/255. blue:1 alpha:0.2];
  242. } else {
  243. blockSelf.freeTrialBox.fillColor = [NSColor colorWithRed:179/255. green:159/255. blue:1 alpha:0.07];
  244. }
  245. } else {
  246. if (mouseEntered) {
  247. blockSelf.freeTrialBox.fillColor = [NSColor colorWithRed:85/255. green:40/255. blue:1 alpha:0.15];
  248. } else {
  249. blockSelf.freeTrialBox.fillColor = [NSColor colorWithRed:85/255. green:40/255. blue:1 alpha:0.07];
  250. }
  251. }
  252. };
  253. [self updatePriceLabel];
  254. [self updateViewColor];
  255. [self updatePurchaseInformation];
  256. [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
  257. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recommondInfoUpdateNoti:) name:@"KMRecommondInfoUpdateNoti" object:nil];
  258. }
  259. #pragma mark - Private Methods
  260. - (void)updateViewColor {
  261. if ([KMAppearance isDarkMode]) {
  262. self.freeContendView.layer.backgroundColor = [[NSColor blackColor] colorWithAlphaComponent:0.3].CGColor;
  263. self.freeVersionLineView.layer.backgroundColor = [[NSColor whiteColor] colorWithAlphaComponent:0.1].CGColor;
  264. self.freeVersionLbl.textColor = [[NSColor whiteColor] colorWithAlphaComponent:0.5];
  265. self.freeTrialBox.fillColor = [NSColor colorWithRed:179/255. green:159/255. blue:1 alpha:0.07];
  266. self.freeTrialBox.borderColor = [NSColor colorWithRed:207/255. green:146/255. blue:1 alpha:1];
  267. self.freeVersionInfoLbl1.textColor =
  268. self.freeVersionInfoLbl2.textColor =
  269. self.freeVersionInfoLbl3.textColor =
  270. self.freeVersionInfoLbl4.textColor =
  271. self.freeVersionInfoLbl5.textColor =
  272. self.freeVersionInfoLbl6.textColor =
  273. self.freeVersionInfoLbl7.textColor =
  274. self.freeVersionInfoLbl8.textColor =
  275. self.freeVersionInfoLbl9.textColor =
  276. self.freeVersionInfoLbl10.textColor = [NSColor whiteColor];
  277. self.parmanentVerInfoLbl1.textColor =
  278. self.parmanentVerInfoLbl2.textColor =
  279. self.parmanentVerInfoLbl3.textColor =
  280. self.parmanentVerInfoLbl4.textColor =
  281. self.parmanentVerInfoLbl5.textColor =
  282. self.parmanentVerInfoLbl6.textColor =
  283. self.parmanentVerInfoLbl7.textColor =
  284. self.parmanentVerInfoLbl8.textColor =
  285. self.parmanentVerInfoLbl9.textColor =
  286. self.parmanentVerInfoLbl10.textColor = [NSColor whiteColor];
  287. } else {
  288. self.freeContendView.layer.backgroundColor = [[NSColor whiteColor] colorWithAlphaComponent:0.7].CGColor;
  289. self.freeVersionLineView.layer.backgroundColor = [NSColor colorWithRed:0 green:33/255. blue:67/255. alpha:0.1].CGColor;
  290. self.freeVersionLbl.textColor = [NSColor colorWithRed:129/255. green:125/255. blue:178/255. alpha:1.];
  291. self.freeTrialBox.fillColor = [NSColor colorWithRed:85/255. green:40/255. blue:1 alpha:0.07];
  292. self.freeTrialBox.borderColor = [NSColor colorWithRed:160/255. green:40/255. blue:1 alpha:1];
  293. self.freeVersionInfoLbl1.textColor =
  294. self.freeVersionInfoLbl2.textColor =
  295. self.freeVersionInfoLbl3.textColor =
  296. self.freeVersionInfoLbl4.textColor =
  297. self.freeVersionInfoLbl5.textColor =
  298. self.freeVersionInfoLbl6.textColor =
  299. self.freeVersionInfoLbl7.textColor =
  300. self.freeVersionInfoLbl8.textColor =
  301. self.freeVersionInfoLbl9.textColor =
  302. self.freeVersionInfoLbl10.textColor = [NSColor colorWithRed:20/255.0 green:0/255.0 blue:102/255.0 alpha:1];
  303. self.parmanentVerInfoLbl1.textColor =
  304. self.parmanentVerInfoLbl2.textColor =
  305. self.parmanentVerInfoLbl3.textColor =
  306. self.parmanentVerInfoLbl4.textColor =
  307. self.parmanentVerInfoLbl5.textColor =
  308. self.parmanentVerInfoLbl6.textColor =
  309. self.parmanentVerInfoLbl7.textColor =
  310. self.parmanentVerInfoLbl8.textColor =
  311. self.parmanentVerInfoLbl9.textColor =
  312. self.parmanentVerInfoLbl10.textColor = [NSColor whiteColor];
  313. }
  314. self.parmanentVerLbl.textColor = [NSColor colorWithRed:252/255. green:253/255. blue:255/255. alpha:1.];
  315. self.oneTimeTipLbl.textColor = [NSColor colorWithRed:255/255. green:231/255. blue:106/255. alpha:1.];
  316. if ([KMAppearance isDarkMode]) {
  317. [self.freeTrialButton setTitleColor:[NSColor colorWithRed:178/255. green:165/255. blue:1 alpha:1]];
  318. } else {
  319. [self.freeTrialButton setTitleColor:[NSColor colorWithRed:160/255. green:40/255. blue:1 alpha:1]];
  320. }
  321. }
  322. - (void)updatePurchaseInformation {
  323. self.freeTrialBox.hidden = NO;
  324. self.titleLabel.stringValue = NSLocalizedString(@"Upgrade to Pro Version", nil);
  325. self.titleLabel.textColor = [NSColor whiteColor];
  326. [self.freeTrialButton setTitle:NSLocalizedString(@"1-day Free Trial", nil)];
  327. if (ActivityStatusVerification == [VerificationManager manager].status) {
  328. self.freeTrialBox.hidden = YES;
  329. } else if (ActivityStatusNone == [VerificationManager manager].status) {
  330. } else if (ActivityStatusTrialExpire == [VerificationManager manager].status) {
  331. self.freeTrialBox.hidden = YES;
  332. if ([VerificationManager manager].secondTrialEnabled) {
  333. self.freeTrialBox.hidden = NO;
  334. }
  335. } else {
  336. self.freeTrialBox.hidden = YES;
  337. }
  338. if ([KMAppearance isDarkMode]) {
  339. [self.freeTrialButton setTitleColor:[NSColor colorWithRed:178/255. green:165/255. blue:1 alpha:1]];
  340. } else {
  341. [self.freeTrialButton setTitleColor:[NSColor colorWithRed:160/255. green:40/255. blue:1 alpha:1]];
  342. }
  343. [self.buyNowButton setTitleColor:[NSColor whiteColor]];
  344. [self updatePriceLabel];
  345. }
  346. - (void)updatePriceLabel {
  347. #if VERSION_DMG
  348. NSString *abbreviation = @"$";
  349. if ([@"CNY" isEqualToString:NSLocalizedString(@"USD", nil)]) {
  350. abbreviation = @"¥";
  351. }
  352. #endif
  353. }
  354. //- (void)updatePriceLabel {
  355. // NSString *originalText = @"";
  356. // NSString *discountText = @"";
  357. // if ([@"USD" isEqualToString:NSLocalizedString(@"USD", nil)]) {
  358. //#if VERSION_DMG
  359. // if ([self.buySwitch state]) {
  360. // originalText = [NSString stringWithFormat:@"$%@", [[KMDMGProductsManager shareInstance] getPrice:@"com.brother.pdfreaderpro.mac.product_3"]];
  361. // discountText = [NSString stringWithFormat:@"$%@", [[KMDMGProductsManager shareInstance] getActivityPrice:@"com.brother.pdfreaderpro.mac.product_3"]];
  362. // } else {
  363. // originalText = [NSString stringWithFormat:@"$%@", [[KMDMGProductsManager shareInstance] getPrice:@"com.brother.pdfreaderpro.mac.product_1"]];
  364. // discountText = [NSString stringWithFormat:@"$%@", [[KMDMGProductsManager shareInstance] getActivityPrice:@"com.brother.pdfreaderpro.mac.product_1"]];
  365. // }
  366. //#endif
  367. // } else {
  368. //#if VERSION_DMG
  369. // if ([self.buySwitch state]) {
  370. // originalText = [NSString stringWithFormat:@"¥%@", [[KMDMGProductsManager shareInstance] getPriceCNY:@"com.brother.pdfreaderpro.mac.product_3"]];
  371. // discountText = [NSString stringWithFormat:@"¥%@", [[KMDMGProductsManager shareInstance] getActivityPriceCNY:@"com.brother.pdfreaderpro.mac.product_3"]];
  372. // } else {
  373. // originalText = [NSString stringWithFormat:@"¥%@", [[KMDMGProductsManager shareInstance] getPriceCNY:@"com.brother.pdfreaderpro.mac.product_1"]];
  374. // discountText = [NSString stringWithFormat:@"¥%@", [[KMDMGProductsManager shareInstance] getActivityPriceCNY:@"com.brother.pdfreaderpro.mac.product_1"]];
  375. // }
  376. //#endif
  377. // }
  378. // NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:originalText];
  379. // [attributedText addAttribute:NSStrikethroughStyleAttributeName
  380. // value:@(NSUnderlineStyleSingle)
  381. // range:NSMakeRange(0, originalText.length)];
  382. // self.originalPriceLabel.attributedStringValue = attributedText;
  383. // self.discountPriceLabel.stringValue = discountText;
  384. //
  385. // if ([originalText isEqualToString:discountText]) {
  386. // [self.originalPriceLabel setHidden:YES];
  387. // } else {
  388. // [self.originalPriceLabel setHidden:NO];
  389. // }
  390. //}
  391. - (void)refreshParmanentVerInfo {
  392. }
  393. #pragma mark - Window Method
  394. - (void)showWindow:(id)sender {
  395. [super showWindow:nil];
  396. [self.window center];
  397. [self.window orderFront:nil];
  398. [self updatePriceLabel];
  399. [self updatePurchaseInformation];
  400. }
  401. - (BOOL)windowShouldClose:(id)sender {
  402. [self endModal:sender];
  403. return YES;
  404. }
  405. - (void)close {
  406. [super close];
  407. // 清空埋点的数据
  408. [self endModal:nil];
  409. }
  410. - (void)updateTitle:(NSString *)title andColor:(NSColor *)titleColor {
  411. self.titleLabel.stringValue = title ?:@"";
  412. self.titleLabel.textColor = titleColor ?:[NSColor labelColor];
  413. }
  414. #pragma mark - IBAction
  415. - (IBAction)startModal:(id)sender {
  416. [NSApp stopModal];
  417. NSInteger modalCode;
  418. self.modalSession = [NSApp beginModalSessionForWindow:self.window];
  419. do {
  420. modalCode = [NSApp runModalSession:self.modalSession];
  421. } while (modalCode == NSRunContinuesResponse);
  422. }
  423. - (IBAction)endModal:(id)sender {
  424. if (self.modalSession) {
  425. [NSApp stopModal];
  426. [NSApp endModalSession:self.modalSession];
  427. [self.window orderOut:self];
  428. self.modalSession = nil;
  429. }
  430. }
  431. - (void)showWindowRestore:(id)sender {
  432. [self showWindow:sender];
  433. }
  434. - (IBAction)enterLicenseAction:(id)sender {
  435. // if (ActivityStatusNone == [VerificationManager manager].status) {
  436. // [self close];
  437. // KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];
  438. // vc.callback = ^{
  439. // [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
  440. // };
  441. // [vc showWindow:nil];
  442. // } else if (ActivityStatusTrialExpire == [VerificationManager manager].status) {
  443. // if ([VerificationManager manager].secondTrialEnabled) {
  444. // [[VerificationManager manager] trialForDays:7
  445. // email:[VerificationManager manager].email
  446. // name:[VerificationManager manager].accountName
  447. // complention:^(ActivityStatus status, NSDictionary *info, NSError *error) {
  448. // if (error ||
  449. // status != ActivityStatusTrial) {
  450. // NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
  451. // defaultButton:NSLocalizedString(@"Try Again", nil)
  452. // alternateButton:nil
  453. // otherButton:nil
  454. // informativeTextWithFormat:NSLocalizedString(@"Failed to sign up for the free trial. Please make sure your internet connection is available and try again later.", nil), nil];
  455. // [alert runModal];
  456. // } else {
  457. // KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeRepeatTrialSuccess];
  458. // [vc showWindow:nil];
  459. // }
  460. // }];
  461. // [self close];
  462. // } else {
  463. // [self close];
  464. // KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];
  465. // vc.callback = ^{
  466. // [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
  467. // };
  468. // [vc showWindow:nil];
  469. // }
  470. // } else {
  471. [self close];
  472. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];
  473. vc.callback = ^{
  474. [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
  475. };
  476. [vc showWindow:nil];
  477. // }
  478. }
  479. - (IBAction)buttonItemClicked_Buy:(id)sender {
  480. //#if VERSION_DMG
  481. // NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?utm_source=app_dmg&utm_medium=dmg_puw_comparison", Swift_oc_Tool.Store_Link_OC]];
  482. // [[NSWorkspace sharedWorkspace] openURL:url];
  483. //#endif
  484. #if VERSION_DMG
  485. [self trackEvent_buyNow];
  486. NSString *paidEventName = [self _buyNowEventToPaidEventName];
  487. NSDictionary *paidEventParams = [self _getPaidEventParamsWith:paidEventName];
  488. NSString *thePaidEventName = paidEventParams.allKeys.firstObject;
  489. NSDictionary *thePaidEventParams = nil;
  490. if (paidEventName != nil && paidEventParams.allValues.firstObject != nil) {
  491. thePaidEventParams = @{paidEventParams.allValues.firstObject : paidEventName};
  492. }
  493. [self close];
  494. NSString *productID = @"";
  495. NSURL *url = [NSURL URLWithString:@"https://www.easeus-software.com/pdf-editor/buy-pdf-mac.html"];
  496. [[NSWorkspace sharedWorkspace] openURL:url];
  497. #endif
  498. }
  499. - (IBAction)buttonItemClicked_CloseWindow:(id)sender {
  500. [self close];
  501. }
  502. - (void)buttonItemClicked_License:(id)sender {
  503. KMPurchaseFirstTrialWindowController *firstTrialWC = [KMPurchaseFirstTrialWindowController currentFirstTrialWC];
  504. firstTrialWC.buttonActionBlock = ^(KMPurchaseFirstTrialWindowController * _Nonnull ftWC, KMButton * _Nonnull btn, NSString * _Nonnull email, NSString * _Nonnull name) {
  505. if (btn.tag == 10001) {
  506. if (ActivityStatusNone == [VerificationManager manager].status ||
  507. ActivityStatusTrialExpire == [VerificationManager manager].status) {
  508. [[VerificationManager manager] trialForDays:7
  509. email:email?:[VerificationManager manager].email
  510. name:name?:[VerificationManager manager].accountName
  511. complention:^(ActivityStatus status, NSDictionary *info, NSError *error) {
  512. if (error ||
  513. status != ActivityStatusTrial) {
  514. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
  515. defaultButton:NSLocalizedString(@"Try Again", nil)
  516. alternateButton:nil
  517. otherButton:nil
  518. informativeTextWithFormat:NSLocalizedString(@"Failed to sign up for the free trial. Please make sure your internet connection is available and try again later.", nil), nil];
  519. [alert runModal];
  520. } else {
  521. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeRepeatTrialSuccess];
  522. [vc showWindow:nil];
  523. }
  524. }];
  525. [ftWC close];
  526. } else {
  527. [ftWC close];
  528. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];
  529. vc.callback = ^{
  530. [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
  531. };
  532. [vc showWindow:nil];
  533. }
  534. } else if (btn.tag == 10002) {
  535. NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?utm_source=app_dmg&utm_medium=dmg_puw_free_trial", Swift_oc_Tool.Store_Link_OC]];
  536. [[NSWorkspace sharedWorkspace] openURL:url];
  537. } else if (btn.tag == 10003) {
  538. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];//KMVerificationTypeActivate
  539. [vc showWindow:nil];
  540. [ftWC close];
  541. }
  542. };
  543. [firstTrialWC.window center];
  544. [firstTrialWC showWindow:nil];
  545. }
  546. - (IBAction)aiPurchaseButtonClick:(NSButton *)sender {
  547. // NSURL *url = [NSURL URLWithString:Swift_oc_Tool.AIProduct_Link_OC];
  548. // [[NSWorkspace sharedWorkspace] openURL:url];
  549. //
  550. [self trackEvent_buyNow];
  551. NSString *paidEventName = [self _buyNowEventToPaidEventName];
  552. NSDictionary *paidEventParams = [self _getPaidEventParamsWith:paidEventName];
  553. NSString *thePaidEventName = paidEventParams.allKeys.firstObject;
  554. NSDictionary *thePaidEventParams = nil;
  555. if (paidEventName != nil && paidEventParams.allValues.firstObject != nil) {
  556. thePaidEventParams = @{paidEventParams.allValues.firstObject : paidEventName};
  557. }
  558. [self close];
  559. #if VERSION_DMG
  560. NSURL *url = [NSURL URLWithString:@"https://www.easeus-software.com/pdf-editor/buy-pdf-mac.html"];
  561. [[NSWorkspace sharedWorkspace] openURL:url];
  562. #endif
  563. }
  564. - (IBAction)buySwitchAction:(NSSwitch *)sender {
  565. [self refreshParmanentVerInfo];
  566. [self updatePriceLabel];
  567. }
  568. #pragma mark - Noti
  569. - (void)themeChanged:(NSNotification *)notification {
  570. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  571. [self updateViewColor];
  572. });
  573. }
  574. - (void)recommondInfoUpdateNoti:(NSNotification *)noti {
  575. dispatch_async(dispatch_get_main_queue(), ^{
  576. [self updatePriceLabel];
  577. });
  578. }
  579. @end
  580. @implementation KMPurchaseCompareDMGWindowController (KMAnalytic)
  581. - (void)trackEvent_buyNow {
  582. NSDictionary *params = [self _getBuyNowEventParams];
  583. NSString *theEventName = params.allKeys.firstObject;
  584. NSDictionary *theParams = nil;
  585. }
  586. - (NSDictionary *)_getBuyNowEventParams {
  587. return nil;
  588. }
  589. - (NSString *)_buyNowEventToPaidEventName {
  590. return nil;
  591. }
  592. - (NSDictionary *)_getPaidEventParamsWith:(NSString *)eventN {
  593. NSString *eveN = eventN;
  594. if (eveN == nil || eveN.length == 0) {
  595. return nil;
  596. }
  597. // Paid_Tools SubTbr_Tools
  598. if ([eveN isEqual:@"Reading_WebsiteLink_Paid"] ||
  599. [eveN isEqual:@"Reading_EmailLink_Paid"] ||
  600. [eveN isEqual:@"Reading_DynamicStamp_Paid"] ||
  601. [eveN isEqual:@"Reading_CustomStamp_Paid"] ||
  602. [eveN isEqual:@"Reading_Signature_Paid"] ||
  603. [eveN isEqual:@"Reading_Table_Paid"]) {
  604. return @{@"Paid_Tools" : @"SubTbr_Tools"};
  605. }
  606. // Paid_PageEdit SubTbr_PageEdit
  607. else if ([eveN isEqual:@"Reading_InsertBlankPage_Paid"] ||
  608. [eveN isEqual:@"Reading_InsertPDF_Paid"] ||
  609. [eveN isEqual:@"Reading_InsertSacnner_Paid"] ||
  610. [eveN isEqual:@"Reading_InsertImage_Paid"] ||
  611. [eveN isEqual:@"Reading_InsertClipboard_Paid"] ||
  612. [eveN isEqual:@"Reading_Replace_Paid"] ||
  613. [eveN isEqual:@"Reading_Extract_Paid"] ||
  614. [eveN isEqual:@"Reading_Split_Paid"] ||
  615. [eveN isEqual:@"Reading_Rotate_Paid"] ||
  616. [eveN isEqual:@"Reading_Reverse_Paid"] ||
  617. [eveN isEqual:@"Reading_Copy_Paid"] ||
  618. [eveN isEqual:@"Reading_Delete_Paid"] ||
  619. [eveN isEqual:@"Reading_Merge_Paid"]) {
  620. return @{@"Paid_PageEdit" : @"SubTbr_PageEdit"};
  621. }
  622. // Paid_PageEdit Home_PageEdit
  623. else if ([eveN isEqual:@"Onbrd_EditPage_Paid"] ||
  624. [eveN isEqual:@"Onbrd_Merge_Paid"]) {
  625. return @{@"Paid_PageEdit" : @"Home_PageEdit"};
  626. }
  627. // Paid_Editor SubTbr_Editor
  628. else if ([eveN isEqual:@"Reading_RemoveSecurity_Paid"] ||
  629. [eveN isEqual:@"Reading_Compare_Paid"] ||
  630. [eveN isEqual:@"Reading_AddWatermark_Paid"] ||
  631. [eveN isEqual:@"Reading_RemoveWatermark_Paid"] ||
  632. [eveN isEqual:@"Reading_AddBackground_Paid"] ||
  633. [eveN isEqual:@"Reading_RemoveBackground_Paid"] ||
  634. [eveN isEqual:@"Reading_AddHeaderFooter_Paid"] ||
  635. [eveN isEqual:@"Reading_RemoveHeaderFooter_Paid"] ||
  636. [eveN isEqual:@"Reading_AddBates_Paid"] ||
  637. [eveN isEqual:@"Reading_RemoveBates_Paid"] ||
  638. [eveN isEqual:@"Reading_Measure_Paid"]) {
  639. return @{@"" : @""};
  640. }
  641. // Paid_Editor Home_Editor
  642. else if ([eveN isEqual:@"Onbrd_Compare_Paid"] ||
  643. [eveN isEqual:@"Onbrd_Background_Paid"] ||
  644. [eveN isEqual:@"Onbrd_Watermard_Paid"] ||
  645. [eveN isEqual:@"Onbrd_HeaderFooter_Paid"] ||
  646. [eveN isEqual:@"Onbrd_Bates_Paid"] ||
  647. [eveN isEqual:@"Onbrd_Security_Paid"]) {
  648. return @{@"Paid_Editor" : @"Home_Editor"};
  649. }
  650. // Paid_Converter SubTbr_Converter
  651. else if ([eveN isEqual:@"Reading_PDFtoWord_Paid"] ||
  652. [eveN isEqual:@"Reading_PDFtoExcel_Paid"] ||
  653. [eveN isEqual:@"Reading_PDFtoPPT_Paid"] ||
  654. [eveN isEqual:@"Reading_PDFtoRTF_Paid"] ||
  655. [eveN isEqual:@"Reading_PDFtoCSV_Paid"] ||
  656. [eveN isEqual:@"Reading_PDFtoText_Paid"] ||
  657. [eveN isEqual:@"Reading_PDFtoImage_Paid"] ||
  658. [eveN isEqual:@"Reading_ExtractImage_Paid"]) {
  659. return @{@"Paid_Converter" : @"SubTbr_Converter"};
  660. }
  661. // Paid_Converter Home_Converter
  662. else if ([eveN isEqual:@"Onbrd_ConvertPDF_Paid"] ||
  663. [eveN isEqual:@"Onbrd_PDFtoWord_Paid"] ||
  664. [eveN isEqual:@"Onbrd_PDFtoExcel_Paid"] ||
  665. [eveN isEqual:@"Onbrd_PDFtoPPT_Paid"] ||
  666. [eveN isEqual:@"Onbrd_ImagetoPDF_Paid"]) {
  667. return @{@"Paid_Converter" : @"Home_Converter"};
  668. }
  669. // Paid_Form SubTbr_Forms
  670. else if ([eveN isEqual:@"Reading_TextField_Paid"] ||
  671. [eveN isEqual:@"Reading_CheckBox_Paid"] ||
  672. [eveN isEqual:@"Reading_RadioButton_Paid"] ||
  673. [eveN isEqual:@"Reading_ListBox_Paid"] ||
  674. [eveN isEqual:@"Reading_ComboBox_Paid"] ||
  675. [eveN isEqual:@"Reading_Button_Paid"]) {
  676. return @{@"Paid_Form" : @"SubTbr_Forms"};
  677. }
  678. // Paid_Sign SunTbr_Signature
  679. else if ([eveN isEqual:@"Reading_FillSign_Signature_Paid"] ||
  680. [eveN isEqual:@"Reading_DigitalSign_Paid"] ||
  681. [eveN isEqual:@"Reading_ElectronicSign_Paid"]) {
  682. return @{@"Paid_Sign" : @"SunTbr_Signature"};
  683. }
  684. // Paid_EditPDF Tbr_Edit PDF
  685. else if ([eveN isEqual:@"Reading_EditPDF_Paid"] ||
  686. [eveN isEqual:@"Reading_ReplaceText_Paid"]) {
  687. return @{@"Paid_EditPDF" : @"Tbr_Edit PDF"};
  688. }
  689. // Paid_Redact Tbr_Redact
  690. else if ([eveN isEqual:@"Reading_Redact_Paid"]) {
  691. return @{@"Paid_Redact" : @"Tbr_Redact"};
  692. }
  693. // Paid_OCR SubTbr_OCR
  694. else if ([eveN isEqual:@"Reading_OCR_Paid"] ||
  695. [eveN isEqual:@"Reading_Convert_OCR_Paid"] ||
  696. [eveN isEqual:@"Onbrd_OCR_Paid"]) {
  697. return @{@"Paid_OCR" : @"SubTbr_OCR"};
  698. }
  699. // Paid_PageDisplay SubTbr_Page Display
  700. else if ([eveN isEqual:@"Reading_SplitView_Paid"] ||
  701. [eveN isEqual:@"Reading_Rotate_Paid"] ||
  702. [eveN isEqual:@"Reading_Theme_Paid"] ||
  703. [eveN isEqual:@"Reading_MultiTab_Paid"]) {
  704. return @{@"Paid_PageDisplay" : @"SubTbr_Page Display"};
  705. }
  706. // Home_Others
  707. else if ([eveN isEqual:@"Onbrd_PrintPoster_Paid"] ||
  708. [eveN isEqual:@"Onbrd_PrintMultiple_Paid"] ||
  709. [eveN isEqual:@"Onbrd_PrintBooklet_Paid"]) {
  710. return @{@"Paid_Others" : @"Home_Others"};
  711. }
  712. // Paid_Others SubTbr_Others
  713. else if ([eveN isEqual:@"Reading_Flatten_Paid"]) {
  714. return @{@"Paid_Others" : @"SubTbr_Others"};
  715. }
  716. // Paid_Others MenuBar_Others
  717. else if ([eveN isEqual:@"MenuBar_PrintPoster_Paid"] ||
  718. [eveN isEqual:@"MenuBar_PrintMultiple_Paid"] ||
  719. [eveN isEqual:@"MenuBar_PrintBooklet_Paid"]) {
  720. return @{@"Paid_Others" : @"MenuBar_Others"};
  721. }
  722. return nil;
  723. }
  724. @end