123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858 |
- //
- // KMPurchaseCompareDMGWindowController.m
- // EaseUS PDF Editor
- //
- // Created by 王帅 on 2018/5/8.
- //
- #import "KMPurchaseCompareDMGWindowController.h"
- #import <PDF_Reader_Pro-Swift.h>
- //#import "HyperLinkButton.h"
- #import "KMVerificationWindowController.h"
- //#import "KMPurchaseCompareWindowController.h"
- #import "VerificationManager.h"
- //#import "GAIManager.h"
- //#import "NSImage_SKExtensions.h"
- //#import "KMButton.h"
- //#import "KMBox.h"
- //#import "SKInspectPublicTool.h"
- //#import "NSFont+Custom.h"
- //#import "KMToolbarItemPopViewController.h"
- //#import "KMRecommondManager.h"
- static NSString *const KMPurchaseCompareDMGHeaderCellIdentifier = @"KMPurchaseCompareDMGHeaderCell";
- static NSString *const KMPurchaseCompareDMGCellIdentifier = @"KMPurchaseCompareDMGCell";
- #pragma mark - KMPurchaseCompareDMGHeaderCell
- @interface KMPurchaseCompareDMGHeaderCell : NSTableCellView
- @property (nonatomic,assign) IBOutlet NSView *contentView;
- @end
- @implementation KMPurchaseCompareDMGHeaderCell
- - (void)dealloc {
- [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
- }
- - (void)awakeFromNib {
- [super awakeFromNib];
-
- self.contentView.wantsLayer = YES;
- [self updateViewColor];
- [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
- }
- - (void)themeChanged:(NSNotification *)notification {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self updateViewColor];
- });
- }
- - (void)updateViewColor {
- NSColor *textColor = [NSColor colorWithDeviceRed:51.0/255.0 green:51.0/255.0 blue:51.0/255.0 alpha:1.0];
- NSColor *viewColor = [NSColor colorWithDeviceRed:55.0/255.0 green:57.0/255.0 blue:59.0/255.0 alpha:0.06];
-
- if (@available(macOS 10.14, *)) {
- NSAppearanceName appearanceName = [[NSApp effectiveAppearance] bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
- if ([appearanceName isEqualToString:NSAppearanceNameDarkAqua]) {
- textColor = [NSColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.87];
- viewColor = [NSColor colorWithRed:52.0/255.0 green:53.0/255.0 blue:56.0/255.0 alpha:1.0];
- }
- }
-
- self.contentView.layer.backgroundColor = viewColor.CGColor;
- self.textField.textColor = textColor;
- self.textField.font = [NSFont boldSystemFontOfSize:14.0];
- }
- @end
- #pragma mark - KMPurchaseCompareDMGCell
- @interface KMPurchaseCompareDMGCell : NSTableCellView
- @property (nonatomic,assign) IBOutlet NSTextField *value1Label;
- @property (nonatomic,assign) IBOutlet NSTextField *value2Label;
- @property (nonatomic,assign) IBOutlet NSImageView *value1ImageView;
- @property (nonatomic,assign) IBOutlet NSImageView *value2ImageView;
- @property (nonatomic,assign) IBOutlet NSBox *lineBox;
- @end
- @implementation KMPurchaseCompareDMGCell
- - (void)dealloc {
- [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
- }
- - (void)awakeFromNib {
- [super awakeFromNib];
- [self updateViewColor];
- [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
- }
- - (void)themeChanged:(NSNotification *)notification {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self updateViewColor];
- });
- }
- - (void)updateViewColor {
- NSColor *textColor = [NSColor colorWithRed:102.0/255.0 green:102.0/255.0 blue:102.0/255.0 alpha:0.85];
- NSColor *lineColor = [NSColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:0.4];
-
- if (@available(macOS 10.14, *)) {
- NSAppearanceName appearanceName = [[NSApp effectiveAppearance] bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
- if ([appearanceName isEqualToString:NSAppearanceNameDarkAqua]) {
- textColor = [NSColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.6];
- lineColor = [NSColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:0.4];
- }
- }
- self.value1Label.textColor = self.value2Label.textColor = textColor;
- self.lineBox.fillColor = lineColor;
- self.textField.textColor = textColor;
- }
- @end
- #pragma mark - KMPurchaseCompareDMGWindowController
- @interface KMPurchaseCompareDMGWindowController ()
- @property (nonatomic, assign) IBOutlet NSTextField *titleLabel;
- @property (assign) IBOutlet HyperLinkButton *enterLicenseButton;
- @property (assign) IBOutlet NSView *freeContendView;
- @property (assign) IBOutlet NSView *freeVersionBGView;
- @property (assign) IBOutlet NSTextField *freeVersionLbl;
- @property (assign) IBOutlet NSView *freeVersionLineView;
- @property (assign) IBOutlet NSTextField *freeVersionInfoLbl1;
- @property (assign) IBOutlet NSTextField *freeVersionInfoLbl2;
- @property (assign) IBOutlet NSTextField *freeVersionInfoLbl3;
- @property (assign) IBOutlet NSTextField *freeVersionInfoLbl4;
- @property (assign) IBOutlet NSTextField *freeVersionInfoLbl5;
- @property (assign) IBOutlet NSTextField *freeVersionInfoLbl6;
- @property (assign) IBOutlet NSTextField *freeVersionInfoLbl7;
- @property (assign) IBOutlet NSTextField *freeVersionInfoLbl8;
- @property (assign) IBOutlet NSTextField *freeVersionInfoLbl9;
- @property (weak) IBOutlet NSTextField *freeVersionInfoLbl10;
- @property (assign) IBOutlet NSView *parmanentVerBGView;
- @property (assign) IBOutlet NSTextField *parmanentVerLbl;
- @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl1;
- @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl2;
- @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl3;
- @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl4;
- @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl5;
- @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl6;
- @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl7;
- @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl8;
- @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl9;
- @property (weak) IBOutlet NSImageView *parmanentVerInfoImage1;
- @property (weak) IBOutlet NSTextField *parmanentVerInfoLbl10;
- @property (assign) IBOutlet KMButton *parmanentVerInfoBtn2;
- @property (assign) IBOutlet NSImageView *parmanentVerinfoimg2;
- @property (assign) IBOutlet NSView *parmanentInfoView;
- @property (assign) IBOutlet NSTextField *oneTimeTipLbl;
- @property (assign) IBOutlet NSBox *freeTrialBox;
- @property (assign) IBOutlet KMButton *freeTrialButton;
- @property (assign) IBOutlet NSBox *buyNowBox;
- @property (assign) IBOutlet KMButton *buyNowButton;
- @property (nonatomic, assign) NSModalSession modalSession;
- @property (nonatomic, retain) NSArray *dataSource;
- @property (nonatomic, retain) NSPopover *popOver;
- - (NSString *)_buyNowEventToPaidEventName;
- - (NSDictionary *)_getPaidEventParamsWith:(NSString *)eventN;
- @end
- @implementation KMPurchaseCompareDMGWindowController
- #pragma mark Init Methods
- - (id)init {
- if (self = [super initWithWindowNibName:@"KMPurchaseCompareDMGWindowController"]) {
- }
- return self;
- }
- - (void)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
-
- }
- - (void)windowDidLoad {
- [super windowDidLoad];
-
- self.window.movableByWindowBackground = YES;
- self.window.backgroundColor = [NSColor whiteColor];
-
- __block typeof(self) blockSelf = self;
-
- [self.freeVersionInfoLbl2 setEnabled:YES];
-
- self.freeVersionLineView.wantsLayer = YES;
- self.freeVersionLbl.stringValue = NSLocalizedString(@"Free Version", nil);
- self.parmanentVerLbl.stringValue = NSLocalizedString(@"Permanent License", nil);
-
- self.freeVersionInfoLbl1.stringValue = self.parmanentVerInfoLbl1.stringValue = NSLocalizedString(@"View PDFs", nil);
- self.freeVersionInfoLbl2.stringValue = NSLocalizedString(@"Annotate PDFs (basic)", nil);
- self.parmanentVerInfoLbl2.stringValue = NSLocalizedString(@"Annotate PDFs (advanced)", nil);
- self.freeVersionInfoLbl3.stringValue = self.parmanentVerInfoLbl3.stringValue = NSLocalizedString(@"Unlimited file conversion", nil);
- self.freeVersionInfoLbl4.stringValue = self.parmanentVerInfoLbl4.stringValue = NSLocalizedString(@"Edit PDF text and images", nil);
- self.freeVersionInfoLbl5.stringValue = self.parmanentVerInfoLbl5.stringValue = NSLocalizedString(@"Digital signature", nil);
- self.freeVersionInfoLbl6.stringValue = self.parmanentVerInfoLbl6.stringValue = NSLocalizedString(@"Organize pages", nil);
- self.freeVersionInfoLbl7.stringValue = self.parmanentVerInfoLbl7.stringValue = NSLocalizedString(@"Batch process", nil);
- self.freeVersionInfoLbl8.stringValue = self.parmanentVerInfoLbl8.stringValue = NSLocalizedString(@"OCR PDFs", nil);
- self.freeVersionInfoLbl9.stringValue = self.parmanentVerInfoLbl9.stringValue = NSLocalizedString(@"Measuring Tools", nil);
- self.freeVersionInfoLbl10.stringValue = self.parmanentVerInfoLbl10.stringValue = NSLocalizedString(@"Ad-free", nil);
- [self refreshParmanentVerInfo];
- // self.parmanentVerinfoimg2.toolTip = NSLocalizedString(@"Support insert links and custom stamps", nil);
- self.parmanentVerInfoBtn2.mouseMoveCallback = ^(BOOL mouseEntered) {
- if (mouseEntered) {
- KMToolbarItemPopViewController *popViewController = [[KMToolbarItemPopViewController alloc] init];
- self.popOver = [[NSPopover alloc] init];
- self.popOver.contentViewController = popViewController;
- self.popOver.animates = NO;
- self.popOver.behavior = NSPopoverBehaviorSemitransient;
-
- self.popOver.contentSize = popViewController.view.frame.size;
- [popViewController updateWithHelpTipWithHelpTip:NSLocalizedString(@"Support insert links and custom stamps", nil)];
- [self.popOver showRelativeToRect:self.parmanentVerInfoBtn2.frame ofView:self.parmanentInfoView preferredEdge:NSRectEdgeMaxY];
- // self.parmanentVerinfoimg2.image = [NSImage imageNamed:@"ic_Tooltip_hover"];
- } else {
- [self.popOver close];
- // self.parmanentVerinfoimg2.image = [NSImage imageNamed:@"ic_Tooltip"];
- }
- };
-
-
-
- self.oneTimeTipLbl.stringValue = NSLocalizedString(@"one-time purchase", nil);
- self.enterLicenseButton.title = NSLocalizedString(@"Enter License", nil);
- [self.enterLicenseButton setTitleColor:[KMAppearance KMColor_Layout_W0]];
- self.enterLicenseButton.mouseMoveCallback = ^(BOOL mouseEntered) {
- if (mouseEntered) {
- [blockSelf.enterLicenseButton setTitleColor:[KMAppearance KMColor_Layout_W70]];
- } else {
- [blockSelf.enterLicenseButton setTitleColor:[KMAppearance KMColor_Layout_W0]];
- }
- };
-
- self.titleLabel.font = [NSFont SFMediumFontWithSize:20];
- self.freeVersionLbl.font = [NSFont UbuntuBoldFontWithSize:24];
- self.parmanentVerLbl.font = [NSFont UbuntuBoldFontWithSize:24];
- self.freeVersionInfoLbl1.font = self.parmanentVerInfoLbl1.font = [NSFont SFProTextRegularFont:14.];
- self.freeVersionInfoLbl2.font = [NSFont SFProTextRegularFont:14.];
- self.parmanentVerInfoLbl2.font = [NSFont SFProTextRegularFont:14.];
- self.freeVersionInfoLbl3.font = self.parmanentVerInfoLbl3.font = [NSFont SFProTextRegularFont:14.];
- self.freeVersionInfoLbl4.font = self.parmanentVerInfoLbl4.font = [NSFont SFProTextRegularFont:14.];
- self.freeVersionInfoLbl5.font = self.parmanentVerInfoLbl5.font = [NSFont SFProTextRegularFont:14.];
- self.freeVersionInfoLbl6.font = self.parmanentVerInfoLbl6.font = [NSFont SFProTextRegularFont:14.];
- self.freeVersionInfoLbl7.font = self.parmanentVerInfoLbl7.font = [NSFont SFProTextRegularFont:14.];
- self.freeVersionInfoLbl8.font = self.parmanentVerInfoLbl8.font = [NSFont SFProTextRegularFont:14.];
- self.freeVersionInfoLbl9.font = self.parmanentVerInfoLbl9.font = [NSFont SFProTextRegularFont:14.];
- self.freeVersionInfoLbl10.font = self.parmanentVerInfoLbl10.font = [NSFont SFProTextRegularFont:14.];
- self.buyNowButton.font = [NSFont UbuntuMediumFontWithSize:16];
- self.freeTrialButton.font = [NSFont UbuntuMediumFontWithSize:16];
-
-
- self.freeContendView.wantsLayer = YES;
- self.freeContendView.layer.cornerRadius = 12;
- self.freeContendView.layer.masksToBounds = YES;
-
- self.parmanentVerBGView.wantsLayer = YES;
- self.parmanentVerBGView.layer.cornerRadius = 12;
- self.parmanentVerBGView.layer.masksToBounds = YES;
-
- self.buyNowBox.wantsLayer = YES;
- self.buyNowBox.fillColor = [NSColor colorWithRed:255/255. green:94/255. blue:44/255. alpha:1.];
- self.buyNowBox.cornerRadius = CGRectGetHeight(self.buyNowBox.frame)/2.;
- self.buyNowBox.layer.masksToBounds = YES;
-
- self.buyNowButton.wantsLayer = YES;
- self.buyNowButton.layer.cornerRadius = 1.0;
- self.buyNowButton.title = NSLocalizedString(@"Buy Now", nil);
- self.buyNowButton.mouseMoveCallback = ^(BOOL mouseEntered) {
- if (mouseEntered) {
- blockSelf.buyNowButton.layer.backgroundColor = [[NSColor blackColor] colorWithAlphaComponent:0.15].CGColor;
- } else {
- blockSelf.buyNowButton.layer.backgroundColor = [NSColor clearColor].CGColor;
- }
- };
-
- self.freeTrialBox.cornerRadius = CGRectGetHeight(self.freeTrialBox.frame)/2.;
- self.freeTrialBox.borderWidth = 1.;
-
- self.freeTrialButton.target = self;
- self.freeTrialButton.action = @selector(buttonItemClicked_License:);
- self.freeTrialButton.mouseMoveCallback = ^(BOOL mouseEntered) {
- if ([KMAppearance isDarkMode]) {
- if (mouseEntered) {
- blockSelf.freeTrialBox.fillColor = [NSColor colorWithRed:179/255. green:159/255. blue:1 alpha:0.2];
- } else {
- blockSelf.freeTrialBox.fillColor = [NSColor colorWithRed:179/255. green:159/255. blue:1 alpha:0.07];
- }
- } else {
- if (mouseEntered) {
- blockSelf.freeTrialBox.fillColor = [NSColor colorWithRed:85/255. green:40/255. blue:1 alpha:0.15];
- } else {
- blockSelf.freeTrialBox.fillColor = [NSColor colorWithRed:85/255. green:40/255. blue:1 alpha:0.07];
- }
- }
- };
- [self updatePriceLabel];
-
- [self updateViewColor];
-
- [self updatePurchaseInformation];
-
- [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recommondInfoUpdateNoti:) name:@"KMRecommondInfoUpdateNoti" object:nil];
- }
- #pragma mark - Private Methods
- - (void)updateViewColor {
-
- if ([KMAppearance isDarkMode]) {
- self.freeContendView.layer.backgroundColor = [[NSColor blackColor] colorWithAlphaComponent:0.3].CGColor;
- self.freeVersionLineView.layer.backgroundColor = [[NSColor whiteColor] colorWithAlphaComponent:0.1].CGColor;
- self.freeVersionLbl.textColor = [[NSColor whiteColor] colorWithAlphaComponent:0.5];
- self.freeTrialBox.fillColor = [NSColor colorWithRed:179/255. green:159/255. blue:1 alpha:0.07];
- self.freeTrialBox.borderColor = [NSColor colorWithRed:207/255. green:146/255. blue:1 alpha:1];
-
- self.freeVersionInfoLbl1.textColor =
- self.freeVersionInfoLbl2.textColor =
- self.freeVersionInfoLbl3.textColor =
- self.freeVersionInfoLbl4.textColor =
- self.freeVersionInfoLbl5.textColor =
- self.freeVersionInfoLbl6.textColor =
- self.freeVersionInfoLbl7.textColor =
- self.freeVersionInfoLbl8.textColor =
- self.freeVersionInfoLbl9.textColor =
- self.freeVersionInfoLbl10.textColor = [NSColor whiteColor];
-
- self.parmanentVerInfoLbl1.textColor =
- self.parmanentVerInfoLbl2.textColor =
- self.parmanentVerInfoLbl3.textColor =
- self.parmanentVerInfoLbl4.textColor =
- self.parmanentVerInfoLbl5.textColor =
- self.parmanentVerInfoLbl6.textColor =
- self.parmanentVerInfoLbl7.textColor =
- self.parmanentVerInfoLbl8.textColor =
- self.parmanentVerInfoLbl9.textColor =
- self.parmanentVerInfoLbl10.textColor = [NSColor whiteColor];
- } else {
- self.freeContendView.layer.backgroundColor = [[NSColor whiteColor] colorWithAlphaComponent:0.7].CGColor;
- self.freeVersionLineView.layer.backgroundColor = [NSColor colorWithRed:0 green:33/255. blue:67/255. alpha:0.1].CGColor;
- self.freeVersionLbl.textColor = [NSColor colorWithRed:129/255. green:125/255. blue:178/255. alpha:1.];
- self.freeTrialBox.fillColor = [NSColor colorWithRed:85/255. green:40/255. blue:1 alpha:0.07];
- self.freeTrialBox.borderColor = [NSColor colorWithRed:160/255. green:40/255. blue:1 alpha:1];
-
- self.freeVersionInfoLbl1.textColor =
- self.freeVersionInfoLbl2.textColor =
- self.freeVersionInfoLbl3.textColor =
- self.freeVersionInfoLbl4.textColor =
- self.freeVersionInfoLbl5.textColor =
- self.freeVersionInfoLbl6.textColor =
- self.freeVersionInfoLbl7.textColor =
- self.freeVersionInfoLbl8.textColor =
- self.freeVersionInfoLbl9.textColor =
- self.freeVersionInfoLbl10.textColor = [NSColor colorWithRed:20/255.0 green:0/255.0 blue:102/255.0 alpha:1];
-
- self.parmanentVerInfoLbl1.textColor =
- self.parmanentVerInfoLbl2.textColor =
- self.parmanentVerInfoLbl3.textColor =
- self.parmanentVerInfoLbl4.textColor =
- self.parmanentVerInfoLbl5.textColor =
- self.parmanentVerInfoLbl6.textColor =
- self.parmanentVerInfoLbl7.textColor =
- self.parmanentVerInfoLbl8.textColor =
- self.parmanentVerInfoLbl9.textColor =
- self.parmanentVerInfoLbl10.textColor = [NSColor whiteColor];
- }
-
- self.parmanentVerLbl.textColor = [NSColor colorWithRed:252/255. green:253/255. blue:255/255. alpha:1.];
- self.oneTimeTipLbl.textColor = [NSColor colorWithRed:255/255. green:231/255. blue:106/255. alpha:1.];
-
- if ([KMAppearance isDarkMode]) {
- [self.freeTrialButton setTitleColor:[NSColor colorWithRed:178/255. green:165/255. blue:1 alpha:1]];
- } else {
- [self.freeTrialButton setTitleColor:[NSColor colorWithRed:160/255. green:40/255. blue:1 alpha:1]];
- }
- }
- - (void)updatePurchaseInformation {
- self.freeTrialBox.hidden = NO;
- self.titleLabel.stringValue = NSLocalizedString(@"Upgrade to Pro Version", nil);
- self.titleLabel.textColor = [NSColor whiteColor];
-
- [self.freeTrialButton setTitle:NSLocalizedString(@"1-day Free Trial", nil)];
- if (ActivityStatusVerification == [VerificationManager manager].status) {
- self.freeTrialBox.hidden = YES;
- } else if (ActivityStatusNone == [VerificationManager manager].status) {
-
- } else if (ActivityStatusTrialExpire == [VerificationManager manager].status) {
- self.freeTrialBox.hidden = YES;
- if ([VerificationManager manager].secondTrialEnabled) {
- self.freeTrialBox.hidden = NO;
- }
- } else {
- self.freeTrialBox.hidden = YES;
- }
- if ([KMAppearance isDarkMode]) {
- [self.freeTrialButton setTitleColor:[NSColor colorWithRed:178/255. green:165/255. blue:1 alpha:1]];
- } else {
- [self.freeTrialButton setTitleColor:[NSColor colorWithRed:160/255. green:40/255. blue:1 alpha:1]];
- }
- [self.buyNowButton setTitleColor:[NSColor whiteColor]];
-
- [self updatePriceLabel];
- }
- - (void)updatePriceLabel {
- #if VERSION_DMG
- NSString *abbreviation = @"$";
- if ([@"CNY" isEqualToString:NSLocalizedString(@"USD", nil)]) {
- abbreviation = @"¥";
- }
- #endif
- }
- //- (void)updatePriceLabel {
- // NSString *originalText = @"";
- // NSString *discountText = @"";
- // if ([@"USD" isEqualToString:NSLocalizedString(@"USD", nil)]) {
- //#if VERSION_DMG
- // if ([self.buySwitch state]) {
- // originalText = [NSString stringWithFormat:@"$%@", [[KMDMGProductsManager shareInstance] getPrice:@"com.brother.pdfreaderpro.mac.product_3"]];
- // discountText = [NSString stringWithFormat:@"$%@", [[KMDMGProductsManager shareInstance] getActivityPrice:@"com.brother.pdfreaderpro.mac.product_3"]];
- // } else {
- // originalText = [NSString stringWithFormat:@"$%@", [[KMDMGProductsManager shareInstance] getPrice:@"com.brother.pdfreaderpro.mac.product_1"]];
- // discountText = [NSString stringWithFormat:@"$%@", [[KMDMGProductsManager shareInstance] getActivityPrice:@"com.brother.pdfreaderpro.mac.product_1"]];
- // }
- //#endif
- // } else {
- //#if VERSION_DMG
- // if ([self.buySwitch state]) {
- // originalText = [NSString stringWithFormat:@"¥%@", [[KMDMGProductsManager shareInstance] getPriceCNY:@"com.brother.pdfreaderpro.mac.product_3"]];
- // discountText = [NSString stringWithFormat:@"¥%@", [[KMDMGProductsManager shareInstance] getActivityPriceCNY:@"com.brother.pdfreaderpro.mac.product_3"]];
- // } else {
- // originalText = [NSString stringWithFormat:@"¥%@", [[KMDMGProductsManager shareInstance] getPriceCNY:@"com.brother.pdfreaderpro.mac.product_1"]];
- // discountText = [NSString stringWithFormat:@"¥%@", [[KMDMGProductsManager shareInstance] getActivityPriceCNY:@"com.brother.pdfreaderpro.mac.product_1"]];
- // }
- //#endif
- // }
- // NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc] initWithString:originalText];
- // [attributedText addAttribute:NSStrikethroughStyleAttributeName
- // value:@(NSUnderlineStyleSingle)
- // range:NSMakeRange(0, originalText.length)];
- // self.originalPriceLabel.attributedStringValue = attributedText;
- // self.discountPriceLabel.stringValue = discountText;
- //
- // if ([originalText isEqualToString:discountText]) {
- // [self.originalPriceLabel setHidden:YES];
- // } else {
- // [self.originalPriceLabel setHidden:NO];
- // }
- //}
- - (void)refreshParmanentVerInfo {
- }
- #pragma mark - Window Method
- - (void)showWindow:(id)sender {
- [super showWindow:nil];
-
- [self.window center];
- [self.window orderFront:nil];
-
- [self updatePriceLabel];
- [self updatePurchaseInformation];
- }
- - (BOOL)windowShouldClose:(id)sender {
- [self endModal:sender];
- return YES;
- }
- - (void)close {
- [super close];
-
- // 清空埋点的数据
-
- [self endModal:nil];
- }
- - (void)updateTitle:(NSString *)title andColor:(NSColor *)titleColor {
- self.titleLabel.stringValue = title ?:@"";
- self.titleLabel.textColor = titleColor ?:[NSColor labelColor];
-
- }
- #pragma mark - IBAction
- - (IBAction)startModal:(id)sender {
-
- [NSApp stopModal];
-
- NSInteger modalCode;
- self.modalSession = [NSApp beginModalSessionForWindow:self.window];
- do {
- modalCode = [NSApp runModalSession:self.modalSession];
- } while (modalCode == NSRunContinuesResponse);
- }
- - (IBAction)endModal:(id)sender {
- if (self.modalSession) {
- [NSApp stopModal];
- [NSApp endModalSession:self.modalSession];
- [self.window orderOut:self];
-
- self.modalSession = nil;
- }
- }
- - (void)showWindowRestore:(id)sender {
- [self showWindow:sender];
- }
- - (IBAction)enterLicenseAction:(id)sender {
- // if (ActivityStatusNone == [VerificationManager manager].status) {
- // [self close];
- // KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];
- // vc.callback = ^{
- // [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
- // };
- // [vc showWindow:nil];
- // } else if (ActivityStatusTrialExpire == [VerificationManager manager].status) {
- // if ([VerificationManager manager].secondTrialEnabled) {
- // [[VerificationManager manager] trialForDays:7
- // email:[VerificationManager manager].email
- // name:[VerificationManager manager].accountName
- // complention:^(ActivityStatus status, NSDictionary *info, NSError *error) {
- // if (error ||
- // status != ActivityStatusTrial) {
- // NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
- // defaultButton:NSLocalizedString(@"Try Again", nil)
- // alternateButton:nil
- // otherButton:nil
- // informativeTextWithFormat:NSLocalizedString(@"Failed to sign up for the free trial. Please make sure your internet connection is available and try again later.", nil), nil];
- // [alert runModal];
- // } else {
- // KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeRepeatTrialSuccess];
- // [vc showWindow:nil];
- // }
- // }];
- // [self close];
- // } else {
- // [self close];
- // KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];
- // vc.callback = ^{
- // [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
- // };
- // [vc showWindow:nil];
- // }
- // } else {
- [self close];
- KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];
- vc.callback = ^{
- [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
- };
- [vc showWindow:nil];
- // }
- }
- - (IBAction)buttonItemClicked_Buy:(id)sender {
- //#if VERSION_DMG
- // NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?utm_source=app_dmg&utm_medium=dmg_puw_comparison", Swift_oc_Tool.Store_Link_OC]];
- // [[NSWorkspace sharedWorkspace] openURL:url];
- //#endif
-
- #if VERSION_DMG
- [self trackEvent_buyNow];
- NSString *paidEventName = [self _buyNowEventToPaidEventName];
- NSDictionary *paidEventParams = [self _getPaidEventParamsWith:paidEventName];
-
- NSString *thePaidEventName = paidEventParams.allKeys.firstObject;
- NSDictionary *thePaidEventParams = nil;
- if (paidEventName != nil && paidEventParams.allValues.firstObject != nil) {
- thePaidEventParams = @{paidEventParams.allValues.firstObject : paidEventName};
- }
-
- [self close];
-
- NSString *productID = @"";
- NSURL *url = [NSURL URLWithString:@"https://www.easeus-software.com/pdf-editor/buy-pdf-mac.html"];
- [[NSWorkspace sharedWorkspace] openURL:url];
- #endif
- }
- - (IBAction)buttonItemClicked_CloseWindow:(id)sender {
- [self close];
- }
- - (void)buttonItemClicked_License:(id)sender {
- KMPurchaseFirstTrialWindowController *firstTrialWC = [KMPurchaseFirstTrialWindowController currentFirstTrialWC];
- firstTrialWC.buttonActionBlock = ^(KMPurchaseFirstTrialWindowController * _Nonnull ftWC, KMButton * _Nonnull btn, NSString * _Nonnull email, NSString * _Nonnull name) {
- if (btn.tag == 10001) {
- if (ActivityStatusNone == [VerificationManager manager].status ||
- ActivityStatusTrialExpire == [VerificationManager manager].status) {
- [[VerificationManager manager] trialForDays:7
- email:email?:[VerificationManager manager].email
- name:name?:[VerificationManager manager].accountName
- complention:^(ActivityStatus status, NSDictionary *info, NSError *error) {
- if (error ||
- status != ActivityStatusTrial) {
- NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
- defaultButton:NSLocalizedString(@"Try Again", nil)
- alternateButton:nil
- otherButton:nil
- informativeTextWithFormat:NSLocalizedString(@"Failed to sign up for the free trial. Please make sure your internet connection is available and try again later.", nil), nil];
- [alert runModal];
- } else {
- KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeRepeatTrialSuccess];
- [vc showWindow:nil];
- }
- }];
- [ftWC close];
- } else {
- [ftWC close];
- KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];
- vc.callback = ^{
- [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
- };
- [vc showWindow:nil];
- }
- } else if (btn.tag == 10002) {
- NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?utm_source=app_dmg&utm_medium=dmg_puw_free_trial", Swift_oc_Tool.Store_Link_OC]];
- [[NSWorkspace sharedWorkspace] openURL:url];
- } else if (btn.tag == 10003) {
- KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];//KMVerificationTypeActivate
- [vc showWindow:nil];
- [ftWC close];
- }
- };
- [firstTrialWC.window center];
- [firstTrialWC showWindow:nil];
- }
- - (IBAction)aiPurchaseButtonClick:(NSButton *)sender {
- // NSURL *url = [NSURL URLWithString:Swift_oc_Tool.AIProduct_Link_OC];
- // [[NSWorkspace sharedWorkspace] openURL:url];
- //
- [self trackEvent_buyNow];
- NSString *paidEventName = [self _buyNowEventToPaidEventName];
- NSDictionary *paidEventParams = [self _getPaidEventParamsWith:paidEventName];
- NSString *thePaidEventName = paidEventParams.allKeys.firstObject;
- NSDictionary *thePaidEventParams = nil;
- if (paidEventName != nil && paidEventParams.allValues.firstObject != nil) {
- thePaidEventParams = @{paidEventParams.allValues.firstObject : paidEventName};
- }
-
- [self close];
- #if VERSION_DMG
- NSURL *url = [NSURL URLWithString:@"https://www.easeus-software.com/pdf-editor/buy-pdf-mac.html"];
- [[NSWorkspace sharedWorkspace] openURL:url];
- #endif
- }
- - (IBAction)buySwitchAction:(NSSwitch *)sender {
- [self refreshParmanentVerInfo];
- [self updatePriceLabel];
- }
- #pragma mark - Noti
- - (void)themeChanged:(NSNotification *)notification {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
- [self updateViewColor];
- });
- }
- - (void)recommondInfoUpdateNoti:(NSNotification *)noti {
- dispatch_async(dispatch_get_main_queue(), ^{
- [self updatePriceLabel];
- });
- }
- @end
- @implementation KMPurchaseCompareDMGWindowController (KMAnalytic)
- - (void)trackEvent_buyNow {
- NSDictionary *params = [self _getBuyNowEventParams];
- NSString *theEventName = params.allKeys.firstObject;
- NSDictionary *theParams = nil;
- }
- - (NSDictionary *)_getBuyNowEventParams {
- return nil;
- }
- - (NSString *)_buyNowEventToPaidEventName {
- return nil;
- }
- - (NSDictionary *)_getPaidEventParamsWith:(NSString *)eventN {
- NSString *eveN = eventN;
- if (eveN == nil || eveN.length == 0) {
- return nil;
- }
-
- // Paid_Tools SubTbr_Tools
- if ([eveN isEqual:@"Reading_WebsiteLink_Paid"] ||
- [eveN isEqual:@"Reading_EmailLink_Paid"] ||
- [eveN isEqual:@"Reading_DynamicStamp_Paid"] ||
- [eveN isEqual:@"Reading_CustomStamp_Paid"] ||
- [eveN isEqual:@"Reading_Signature_Paid"] ||
- [eveN isEqual:@"Reading_Table_Paid"]) {
- return @{@"Paid_Tools" : @"SubTbr_Tools"};
- }
- // Paid_PageEdit SubTbr_PageEdit
- else if ([eveN isEqual:@"Reading_InsertBlankPage_Paid"] ||
- [eveN isEqual:@"Reading_InsertPDF_Paid"] ||
- [eveN isEqual:@"Reading_InsertSacnner_Paid"] ||
- [eveN isEqual:@"Reading_InsertImage_Paid"] ||
- [eveN isEqual:@"Reading_InsertClipboard_Paid"] ||
- [eveN isEqual:@"Reading_Replace_Paid"] ||
- [eveN isEqual:@"Reading_Extract_Paid"] ||
- [eveN isEqual:@"Reading_Split_Paid"] ||
- [eveN isEqual:@"Reading_Rotate_Paid"] ||
- [eveN isEqual:@"Reading_Reverse_Paid"] ||
- [eveN isEqual:@"Reading_Copy_Paid"] ||
- [eveN isEqual:@"Reading_Delete_Paid"] ||
- [eveN isEqual:@"Reading_Merge_Paid"]) {
- return @{@"Paid_PageEdit" : @"SubTbr_PageEdit"};
- }
- // Paid_PageEdit Home_PageEdit
- else if ([eveN isEqual:@"Onbrd_EditPage_Paid"] ||
- [eveN isEqual:@"Onbrd_Merge_Paid"]) {
- return @{@"Paid_PageEdit" : @"Home_PageEdit"};
- }
- // Paid_Editor SubTbr_Editor
- else if ([eveN isEqual:@"Reading_RemoveSecurity_Paid"] ||
- [eveN isEqual:@"Reading_Compare_Paid"] ||
- [eveN isEqual:@"Reading_AddWatermark_Paid"] ||
- [eveN isEqual:@"Reading_RemoveWatermark_Paid"] ||
- [eveN isEqual:@"Reading_AddBackground_Paid"] ||
- [eveN isEqual:@"Reading_RemoveBackground_Paid"] ||
- [eveN isEqual:@"Reading_AddHeaderFooter_Paid"] ||
- [eveN isEqual:@"Reading_RemoveHeaderFooter_Paid"] ||
- [eveN isEqual:@"Reading_AddBates_Paid"] ||
- [eveN isEqual:@"Reading_RemoveBates_Paid"] ||
- [eveN isEqual:@"Reading_Measure_Paid"]) {
- return @{@"" : @""};
- }
- // Paid_Editor Home_Editor
- else if ([eveN isEqual:@"Onbrd_Compare_Paid"] ||
- [eveN isEqual:@"Onbrd_Background_Paid"] ||
- [eveN isEqual:@"Onbrd_Watermard_Paid"] ||
- [eveN isEqual:@"Onbrd_HeaderFooter_Paid"] ||
- [eveN isEqual:@"Onbrd_Bates_Paid"] ||
- [eveN isEqual:@"Onbrd_Security_Paid"]) {
- return @{@"Paid_Editor" : @"Home_Editor"};
- }
- // Paid_Converter SubTbr_Converter
- else if ([eveN isEqual:@"Reading_PDFtoWord_Paid"] ||
- [eveN isEqual:@"Reading_PDFtoExcel_Paid"] ||
- [eveN isEqual:@"Reading_PDFtoPPT_Paid"] ||
- [eveN isEqual:@"Reading_PDFtoRTF_Paid"] ||
- [eveN isEqual:@"Reading_PDFtoCSV_Paid"] ||
- [eveN isEqual:@"Reading_PDFtoText_Paid"] ||
- [eveN isEqual:@"Reading_PDFtoImage_Paid"] ||
- [eveN isEqual:@"Reading_ExtractImage_Paid"]) {
- return @{@"Paid_Converter" : @"SubTbr_Converter"};
- }
- // Paid_Converter Home_Converter
- else if ([eveN isEqual:@"Onbrd_ConvertPDF_Paid"] ||
- [eveN isEqual:@"Onbrd_PDFtoWord_Paid"] ||
- [eveN isEqual:@"Onbrd_PDFtoExcel_Paid"] ||
- [eveN isEqual:@"Onbrd_PDFtoPPT_Paid"] ||
- [eveN isEqual:@"Onbrd_ImagetoPDF_Paid"]) {
- return @{@"Paid_Converter" : @"Home_Converter"};
- }
- // Paid_Form SubTbr_Forms
- else if ([eveN isEqual:@"Reading_TextField_Paid"] ||
- [eveN isEqual:@"Reading_CheckBox_Paid"] ||
- [eveN isEqual:@"Reading_RadioButton_Paid"] ||
- [eveN isEqual:@"Reading_ListBox_Paid"] ||
- [eveN isEqual:@"Reading_ComboBox_Paid"] ||
- [eveN isEqual:@"Reading_Button_Paid"]) {
- return @{@"Paid_Form" : @"SubTbr_Forms"};
- }
- // Paid_Sign SunTbr_Signature
- else if ([eveN isEqual:@"Reading_FillSign_Signature_Paid"] ||
- [eveN isEqual:@"Reading_DigitalSign_Paid"] ||
- [eveN isEqual:@"Reading_ElectronicSign_Paid"]) {
- return @{@"Paid_Sign" : @"SunTbr_Signature"};
- }
- // Paid_EditPDF Tbr_Edit PDF
- else if ([eveN isEqual:@"Reading_EditPDF_Paid"] ||
- [eveN isEqual:@"Reading_ReplaceText_Paid"]) {
- return @{@"Paid_EditPDF" : @"Tbr_Edit PDF"};
- }
- // Paid_Redact Tbr_Redact
- else if ([eveN isEqual:@"Reading_Redact_Paid"]) {
- return @{@"Paid_Redact" : @"Tbr_Redact"};
- }
- // Paid_OCR SubTbr_OCR
- else if ([eveN isEqual:@"Reading_OCR_Paid"] ||
- [eveN isEqual:@"Reading_Convert_OCR_Paid"] ||
- [eveN isEqual:@"Onbrd_OCR_Paid"]) {
- return @{@"Paid_OCR" : @"SubTbr_OCR"};
- }
- // Paid_PageDisplay SubTbr_Page Display
- else if ([eveN isEqual:@"Reading_SplitView_Paid"] ||
- [eveN isEqual:@"Reading_Rotate_Paid"] ||
- [eveN isEqual:@"Reading_Theme_Paid"] ||
- [eveN isEqual:@"Reading_MultiTab_Paid"]) {
- return @{@"Paid_PageDisplay" : @"SubTbr_Page Display"};
- }
- // Home_Others
- else if ([eveN isEqual:@"Onbrd_PrintPoster_Paid"] ||
- [eveN isEqual:@"Onbrd_PrintMultiple_Paid"] ||
- [eveN isEqual:@"Onbrd_PrintBooklet_Paid"]) {
- return @{@"Paid_Others" : @"Home_Others"};
- }
- // Paid_Others SubTbr_Others
- else if ([eveN isEqual:@"Reading_Flatten_Paid"]) {
- return @{@"Paid_Others" : @"SubTbr_Others"};
- }
- // Paid_Others MenuBar_Others
- else if ([eveN isEqual:@"MenuBar_PrintPoster_Paid"] ||
- [eveN isEqual:@"MenuBar_PrintMultiple_Paid"] ||
- [eveN isEqual:@"MenuBar_PrintBooklet_Paid"]) {
- return @{@"Paid_Others" : @"MenuBar_Others"};
- }
- return nil;
- }
- @end
|