1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402 |
- //
- // KMPurchaseCompareWindowController.m
- // PDF Reader
- //
- // Created by wangshuai on 2017/5/8.
- // Copyright © 2017年 zhangjie. All rights reserved.
- //
- #import "KMPurchaseCompareWindowController.h"
- #import <PDF_Reader_Pro-Swift.h>
- //#import "WaitingView.h"
- //#import "NSButton+TitleColor.h"
- //#import "HyperLinkButton.h"
- //#import "IAPProductsManager.h"
- //#import "GAIManager.h"
- //#import "NSImage_SKExtensions.h"
- //
- //#import "KMButton.h"
- //#import "KMCustomButton.h"
- //#import "KMKdanRemoteConfig.h"
- //#import "VerificationManager.h"
- //#import "KMVerificationWindowController.h"
- //#import "SKInspectPublicTool.h"
- //#import "FMTrackEventManager.h"
- //#import "NSFont+Custom.h"
- //#if !VERSION_DMG
- //#import <StoreKit/StoreKit.h>
- //#endif
- #import "KMDiscountToSaveWindowController.h"
- static NSString *const KMPurchaseCompareEmptyCellIdentifier = @"KMPurchaseCompareEmptyCellIdentifier";
- static NSString *const KMPurchaseCompareHeaderCellIdentifier = @"KMPurchaseCompareHeaderCell";
- static NSString *const KMPurchaseCompareCellIdentifier = @"KMPurchaseCompareCell";
- #pragma mark - KMPurchaseCompareEmptyCell
- @interface KMPurchaseCompareEmptyCell : NSTableCellView
- @end
- @implementation KMPurchaseCompareEmptyCell
- - (void)dealloc {
- [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
-
- }
- - (void)awakeFromNib {
- [super awakeFromNib];
- self.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 {
- if ([KMAppearance isDarkMode]) {
- self.layer.backgroundColor = [NSColor colorWithRed:24/255.0 green:22/255.0 blue:31/255. alpha:1.].CGColor;
- } else {
- self.layer.backgroundColor = [NSColor colorWithRed:247/255.0 green:245/255.0 blue:1 alpha:1.].CGColor;
- }
- }
- @end
- @interface KMPurchaseCompareHeaderCell : NSTableCellView
- @property (nonatomic,assign) IBOutlet NSView *contentView;
- @end
- @implementation KMPurchaseCompareHeaderCell
- - (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 {
- if ([KMAppearance isDarkMode]) {
- self.contentView.layer.backgroundColor = [NSColor colorWithRed:40/255. green:38/255. blue:47/255. alpha:1].CGColor;
- } else {
- self.contentView.layer.backgroundColor = [NSColor colorWithRed:237/255. green:231/255. blue:255/255. alpha:1].CGColor;
- }
- self.textField.textColor = [KMAppearance KMColor_Layout_H0];
- self.textField.font = [NSFont boldSystemFontOfSize:14.0];
- }
- @end
- #pragma mark - KMPurchaseCompareCell
- @interface KMPurchaseCompareCell : NSTableCellView
- @property (nonatomic,assign) IBOutlet NSView *bgColorView;
- @property (nonatomic,assign) IBOutlet NSTextField *value1Label;
- @property (nonatomic,assign) IBOutlet NSTextField *value2Label;
- @property (nonatomic,assign) IBOutlet NSTextField *value3Label;
- @property (nonatomic,assign) IBOutlet NSTextField *value4Label;
- @property (nonatomic,assign) IBOutlet NSImageView *value1ImageView;
- @property (nonatomic,assign) IBOutlet NSImageView *value2ImageView;
- @property (nonatomic,assign) IBOutlet NSImageView *value3ImageView;
- @property (nonatomic,assign) IBOutlet NSImageView *value4ImageView;
- @property (nonatomic,assign) IBOutlet NSBox *lineBox;
- @property (assign) IBOutlet NSLayoutConstraint *boxBottomConst;
- @end
- @implementation KMPurchaseCompareCell
- - (void)dealloc
- {
- [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
-
- }
- - (void)awakeFromNib
- {
- [super awakeFromNib];
-
- self.bgColorView.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 {
-
- self.bgColorView.layer.backgroundColor = [NSColor colorWithRed:247/255.0 green:245/255.0 blue:1 alpha:1.].CGColor;
- NSColor *textColor = [NSColor colorWithRed:68.0/255.0 green:68.0/255.0 blue:68.0/255.0 alpha:1.0];
- NSColor *subtextColor = [NSColor colorWithRed:141.0/255.0 green:141.0/255.0 blue:141.0/255.0 alpha:1.0];
- NSColor *lineColor = [NSColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:0.4];
-
- if ([KMAppearance isDarkMode]) {
- self.bgColorView.layer.backgroundColor = [NSColor colorWithRed:24/255.0 green:22/255.0 blue:31/255. alpha:1.].CGColor;
- textColor = [NSColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.8];
- subtextColor = [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.15];
- }
-
- self.value1Label.textColor = subtextColor;
- self.value2Label.textColor = self.value3Label.textColor = self.value4Label.textColor = subtextColor;
- self.lineBox.fillColor = lineColor;
- self.textField.textColor = textColor;
- }
- @end
- #pragma mark - KMPurchaseCompareWindowController
- @interface KMPurchaseCompareWindowController ()<NSTableViewDelegate, NSTableViewDataSource>
- @property (nonatomic,assign) NSModalSession modalSession;
- @property (nonatomic,retain) NSArray *dataSource;
- @property (nonatomic,assign) IBOutlet NSTableView *tableView;
- @property (nonatomic,assign) IBOutlet NSTextField *titleLabel;
- @property (nonatomic,assign) IBOutlet NSTextField *switchLabel;
- @property (nonatomic,assign) IBOutlet NSButton *switchButton;
- @property (assign) IBOutlet NSView *freeInfoView;
- @property (assign) IBOutlet NSTextField *freeInfoLabel;
- @property (assign) IBOutlet NSView *value1InfoView;
- @property (assign) IBOutlet NSBox *value1InfoBox;
- @property (assign) IBOutlet NSBox *value1InfoTypeBox;
- @property (assign) IBOutlet NSTextField *sixMouthProLabel;
- @property (assign) IBOutlet NSTextField *oneYearProLabel;
- @property (assign) IBOutlet NSBox *switchBox;
- @property (assign) IBOutlet NSButton *switchBtn;
- @property (assign) IBOutlet NSView *switchCircleView;
- @property (assign) IBOutlet NSLayoutConstraint *switchCircleLeftConst;
- @property (assign) IBOutlet NSBox *saleBox;
- @property (assign) IBOutlet NSImageView *saleIv;
- @property (assign) IBOutlet NSTextField *saleLabel;
- @property (assign) IBOutlet NSTextField *value1InfoLabel;
- @property (nonatomic,assign) IBOutlet NSTextField *value1PurchaseLabel;
- @property (nonatomic,assign) IBOutlet NSTextField *value1PurchaseSubLabel;
- @property (nonatomic,assign) IBOutlet KMCustomButton *value1PurchaseButton;
- @property (assign) IBOutlet NSTextField *value1PurchaseBtnLbl;
- @property (assign) IBOutlet NSTextField *value1PurchaseOriPriceLbl;
- @property (assign) IBOutlet NSButton *value1PurchaseBtnLblBtn;
- @property (assign) IBOutlet NSView *value2InfoView;
- @property (assign) IBOutlet NSTextField *value2InfoLabel;
- @property (nonatomic,assign) IBOutlet NSTextField *value2PurchaseLabel;
- @property (nonatomic,assign) IBOutlet NSTextField *value2PurchaseSubLabel;
- @property (nonatomic,assign) IBOutlet KMButton *value2PurchaseButton;
- @property (assign) IBOutlet NSTextField *value2PurchaseLbl;
- @property (assign) IBOutlet KMButton *value2PurchaseLblBtn;
- @property (assign) IBOutlet NSView *value3InfoView;
- @property (assign) IBOutlet NSTextField *value3InfoLabel;
- @property (nonatomic,assign) IBOutlet NSTextField *value3PurchaseLabel;
- @property (nonatomic,assign) IBOutlet NSTextField *value3PurchaseSubLabel;
- @property (nonatomic,assign) IBOutlet KMButton *value3PurchaseButton;
- @property (strong) IBOutlet NSTextField *value3PurchaseBtnLbl;
- @property (nonatomic,assign) IBOutlet NSButton *aboutButton;
- @property (nonatomic,assign) IBOutlet HyperLinkButton *btnRestore;
- @property (assign) IBOutlet HyperLinkButton *privacyPolicyBtn;
- @property (assign) IBOutlet HyperLinkButton *termOfSerBtn;
- @property (nonatomic,assign) IBOutlet NSTextView *textView;
- @property (nonatomic,assign) IBOutlet NSView *specialView;
- @property (nonatomic,assign) IBOutlet NSImageView *specialImageView;
- @property (nonatomic,assign) IBOutlet NSTextField *specialLabel;
- @property (nonatomic,assign) IBOutlet NSView *specialView1;
- @property (nonatomic,assign) IBOutlet NSImageView *specialImageView1;
- @property (nonatomic,assign) IBOutlet NSTextField *specialLabel1;
- @property (nonatomic,assign) IBOutlet NSBox *box;
- @property (nonatomic,assign) IBOutlet NSBox *labelbox;
- @property (assign) IBOutlet NSLayoutConstraint *topButtonOffset;
- @property (nonatomic, retain) CALayer *value1Layer;
- @property (nonatomic, retain) KMDiscountToSaveWindowController *discountToSaveWinC;
- @property (nonatomic, assign) BOOL isPurchaseSwitch;
- @property (assign) IBOutlet NSLayoutConstraint *billedTopConst;
- @property (weak) IBOutlet NSImageView *discountYearly;
- @property (weak) IBOutlet NSImageView *discountPermanent;
- @property (weak) IBOutlet NSImageView *discountPremium;
- @end
- @implementation KMPurchaseCompareWindowController
- #pragma mark - Init Methods
- - (id)init {
- if (self = [super initWithWindowNibName:@"KMPurchaseCompareWindowController"]) {
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(IAPProductLoadedNotification:)
- name:KMIAPProductLoadedNotification
- object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(IAPSubscriptionLoadedNotification:)
- name:KMIAPSubscriptionLoadedNotification
- object:nil];
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(IAPProductPurchasedNotification:)
- name:KMIAPProductPurchasedNotification
- object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(IAPProductFailedNotification:)
- name:KMIAPProductFailedNotification
- object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(IAPProductRestoreFinishedNotification:)
- name:KMIAPProductRestoreFinishedNotification
- object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(IAPProductRestoreFailedNotification:)
- name:KMIAPProductRestoreFailedNotification
- object:nil];
-
- [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
-
- self.isPurchaseSwitch = false;
- }
- return self;
- }
- - (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)dealloc {
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- }
- + (NSWindowController *)sharedInstance {
- #if VERSION_DMG
- if (ActivityStatusNone == [VerificationManager manager].status) {
- static KMPurchaseFirstTrialWindowController *singleton = nil;
- static dispatch_once_t pred;
- dispatch_once(&pred, ^{
- singleton = [KMPurchaseCompareWindowController firstTrialWCCheck];
- });
- return singleton;
- } else {
- static KMPurchaseCompareDMGWindowController *singleton = nil;
- static dispatch_once_t pred;
- dispatch_once(&pred, ^{
- singleton = [[KMPurchaseCompareDMGWindowController alloc] init];
- });
- return singleton;
- }
- #else
- static KMPurchaseCompareWindowController *singleton = nil;
- static dispatch_once_t pred;
- dispatch_once(&pred, ^{
- singleton = [[KMPurchaseCompareWindowController alloc] init];
- });
- return singleton;
- #endif
- }
- + (NSWindowController *)DMGPurchaseInstance {
- static KMPurchaseCompareDMGWindowController *singleton = nil;
- static dispatch_once_t pred;
- dispatch_once(&pred, ^{
- singleton = [[KMPurchaseCompareDMGWindowController alloc] init];
- });
- return singleton;
- }
- #pragma mark - FirstTrial WC
- + (KMPurchaseFirstTrialWindowController *)firstTrialWCCheck {
- //弹出 试用弹窗UI优化-新用户试用路径 新UI 情况三 点到付费功能
- 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 ) {
- [[FMTrackEventManager defaultManager] trackEventWithEvent:@"Tbr" withProperties:@{@"Tbr_Btn":@"Btn_Tbr_SecondTrial"}];
- [[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) {
- #if VERSION_DMG
- 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];
- [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_UpgradeBuyNow"}];
- #endif
- } else if (btn.tag == 10003) {
- #if VERSION_DMG
- KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];//KMVerificationTypeActivate
- [vc showWindow:nil];
- [ftWC close];
- #endif
- }
- };
- return firstTrialWC;
- }
- #pragma mark - Window Methods
- - (void)windowDidLoad {
- [super windowDidLoad];
- // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
- self.window.backgroundColor = [KMAppearance KMColor_Upgrade_Vip_BG];
- self.window.movableByWindowBackground = YES;
- [self updateViewColor];
-
- self.value1InfoBox.fillColor = [NSColor colorWithRed:17/255. green:6/255. blue:143/255. alpha:1];
- self.freeInfoLabel.stringValue = NSLocalizedString(@"Free", nil);
- self.value1InfoLabel.stringValue = NSLocalizedString(@"6-Month Plan", nil);
- self.value2InfoLabel.stringValue = NSLocalizedString(@"Permanent Version", nil);
- self.value3InfoLabel.stringValue = NSLocalizedString(@"Premium Version", nil);
-
- self.freeInfoLabel.font = [NSFont UbuntuMediumFontWithSize:18];
- self.value1InfoLabel.font = [NSFont UbuntuMediumFontWithSize:16];
- self.value2InfoLabel.font = [NSFont UbuntuMediumFontWithSize:16];
- self.value3InfoLabel.font = [NSFont UbuntuMediumFontWithSize:16];
-
- self.value1InfoTypeBox.fillColor = [NSColor clearColor];
- self.value1InfoTypeBox.borderWidth = 0;
- self.sixMouthProLabel.stringValue = NSLocalizedString(@"6-Month Plan", @"");
- self.sixMouthProLabel.textColor = NSColor.whiteColor;
- self.sixMouthProLabel.font = [NSFont UbuntuMediumFontWithSize:14];
- self.sixMouthProLabel.lineBreakMode = NSLineBreakByTruncatingTail;
- self.sixMouthProLabel.toolTip = self.sixMouthProLabel.stringValue;
- self.sixMouthProLabel.alignment = NSTextAlignmentCenter;
-
- // #757780
- self.oneYearProLabel.stringValue = NSLocalizedString(@"1-year Plan", @"");
- self.oneYearProLabel.textColor = NSColor.whiteColor;
- self.oneYearProLabel.font = [NSFont UbuntuMediumFontWithSize:14];
- self.oneYearProLabel.lineBreakMode = NSLineBreakByTruncatingTail;
- self.oneYearProLabel.toolTip = self.oneYearProLabel.stringValue;
- self.oneYearProLabel.alignment = NSTextAlignmentCenter;
-
- self.switchBox.fillColor = [NSColor colorWithWhite:1 alpha:0.2];
- self.switchBox.cornerRadius = 12;
- self.switchBox.borderWidth = 1;
- self.switchBox.borderColor = [NSColor colorWithRed:235/255.0 green:236/255.0 blue:240/255.0 alpha:1.0];
- self.switchCircleView.wantsLayer = true;
- self.switchCircleView.layer.cornerRadius = 8;
- self.switchCircleView.layer.backgroundColor = [NSColor whiteColor].CGColor;
- self.switchBtn.title = @"";
- self.switchBtn.target = self;
- self.switchBtn.action = @selector(switchAction:);
-
- // self.saleLabel.stringValue = NSLocalizedString(@"30%\nOFF", @"");
- // self.saleLabel.textColor = NSColor.whiteColor;
- // self.saleLabel.wantsLayer = true;
- // self.saleLabel.layer.transform = CATransform3DMakeRotation(M_PI/4, 0, 1, 0);
- // self.saleLabel.layer.transform.m34 = 1/500.0;
- // self.saleLabel.layer.affineTransform = CGAffineTransformMakeRotation(M_PI/2);
- // self.saleLabel.superview.wantsLayer = true;
- // self.saleLabel.superview.layer.transform = CATransform3DMakeRotation(M_PI/4, 0, 0, 1);
- self.saleLabel.hidden = true;
- self.saleLabel.superview.hidden = true;
- self.saleBox.borderWidth = 0;
-
- self.value1PurchaseButton.wantsLayer = YES;
- self.value1PurchaseButton.layer.backgroundColor = [NSColor colorWithRed:1 green:94/255. blue:44/255. alpha:1].CGColor;
- self.value1PurchaseButton.layer.cornerRadius = CGRectGetHeight(self.value1PurchaseButton.frame) / 2.;
- self.value1PurchaseBtnLblBtn.wantsLayer = YES;
- self.value1PurchaseButton.mouseMoveCallback = ^(BOOL mouseEntered) {
- if (self.value1PurchaseBtnLblBtn.enabled) {
- if (mouseEntered) {
- self.value1PurchaseBtnLblBtn.layer.backgroundColor = [[NSColor blackColor] colorWithAlphaComponent:0.15].CGColor;
- } else {
- self.value1PurchaseBtnLblBtn.layer.backgroundColor = [NSColor clearColor].CGColor;
- }
- }
- };
- self.value1PurchaseBtnLblBtn.layer.cornerRadius = CGRectGetHeight(self.value1PurchaseBtnLblBtn.frame)/2.;
- self.value1PurchaseBtnLblBtn.layer.masksToBounds = YES;
-
- self.value2PurchaseButton.wantsLayer = YES;
- self.value2PurchaseButton.layer.cornerRadius = CGRectGetHeight(self.value2PurchaseButton.frame) / 2.;
- self.value2PurchaseButton.layer.backgroundColor = [NSColor whiteColor].CGColor;
- self.value2PurchaseLbl.stringValue = NSLocalizedString(@"Purchase", nil);
- self.value2PurchaseLbl.textColor = [NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0];
-
-
- self.value3PurchaseButton.title = NSLocalizedString(@"Purchase", nil);
- self.value3PurchaseBtnLbl.stringValue = NSLocalizedString(@"Purchase", nil);
- self.value3PurchaseButton.wantsLayer = YES;
- [self.value3PurchaseButton setTitleColor:[NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0]];
- self.value3PurchaseBtnLbl.textColor = [NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0];
- self.value3PurchaseButton.layer.backgroundColor = [NSColor whiteColor].CGColor;
- self.value3PurchaseButton.layer.cornerRadius = CGRectGetHeight(self.value3PurchaseButton.frame) / 2.;
-
- self.titleLabel.stringValue = NSLocalizedString(@"Subscribe to All Access Pack to enjoy more expanded features.", nil);
- self.switchLabel.stringValue = NSLocalizedString(@"Choose your favorite payment and enjoy flexible upgrades.", nil);
- self.switchLabel.textColor = [KMAppearance KMColor_Interactive_M0];
- self.switchButton.title = [NSString stringWithFormat:@"%@",NSLocalizedString(@"Pricing and Plans", nil)];
-
- self.box.wantsLayer = YES;
- self.box.shadow = [[NSShadow alloc] init];
- self.box.layer.shadowOpacity = 0.3;
- self.box.layer.shadowColor = [NSColor colorWithRed:0 green:0 blue:0 alpha:0.3].CGColor;
- self.box.layer.shadowOffset = NSMakeSize(0,3);
- self.box.layer.shadowRadius = 8;
- self.box.layer.masksToBounds = NO;
-
- NSButtonCell *cell = self.switchButton.cell;
- NSColor *txtColor = [NSColor colorWithRed:102.0/255.0 green:102.0/255.0 blue:102.0/255.0 alpha:1.0];
- NSAttributedString *attrStr1 = [cell attributedTitle];
- NSMutableAttributedString *myAttr = [[NSMutableAttributedString alloc] initWithAttributedString:attrStr1];
- [myAttr addAttribute:NSForegroundColorAttributeName value:txtColor range:NSMakeRange(0, myAttr.length)];
- [myAttr addAttribute:NSFontAttributeName value:[NSFont boldSystemFontOfSize:13.0] range:NSMakeRange(0, myAttr.length)];
- [cell setAttributedTitle:myAttr];
- [self.switchButton updateCell:cell];
- self.aboutButton.title = NSLocalizedString(@"About Subscriptions", nil);
- self.btnRestore.title = NSLocalizedString(@"Restore", nil);
- self.privacyPolicyBtn.title = NSLocalizedString(@"Privacy Policy", nil);
- self.termOfSerBtn.title = NSLocalizedString(@"Terms of Service", nil);
-
- self.btnRestore.toolTip = NSLocalizedString(@"Restore", nil);
- self.privacyPolicyBtn.toolTip = NSLocalizedString(@"Privacy Policy", nil);
- self.termOfSerBtn.toolTip = NSLocalizedString(@"Terms of Service", nil);
-
- [self.aboutButton setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.7]];
- [self.btnRestore setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
- [self.privacyPolicyBtn setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
- [self.termOfSerBtn setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
-
- self.btnRestore.mouseMoveCallback = ^(BOOL mouseEntered) {
- if (mouseEntered) {
- [self.btnRestore setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.7]];
- } else {
- [self.btnRestore setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
- }
- };
-
- self.privacyPolicyBtn.mouseMoveCallback = ^(BOOL mouseEntered) {
- if (mouseEntered) {
- [self.privacyPolicyBtn setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.7]];
- } else {
- [self.privacyPolicyBtn setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
- }
- };
-
- self.termOfSerBtn.mouseMoveCallback = ^(BOOL mouseEntered) {
- if (mouseEntered) {
- [self.termOfSerBtn setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.7]];
- } else {
- [self.termOfSerBtn setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
- }
- };
-
- self.aboutButton.hidden = YES;
- [self reloadData];
- [self reloadDataContent];
-
- [[IAPProductsManager defaultManager] loadProducts];
- __block typeof(self) blockSelf = self;
- self.value2PurchaseButton.mouseMoveCallback = ^(BOOL mouseEntered) {
- if (blockSelf.value2PurchaseButton.enabled) {
- if (mouseEntered) {
- [blockSelf.value2PurchaseLbl setTextColor:[NSColor whiteColor]];
- blockSelf.value2PurchaseButton.layer.backgroundColor = [NSColor colorWithRed:1 green:94/255.0 blue:44/255.0 alpha:1.0].CGColor;
- } else {
- [blockSelf.value2PurchaseLbl setTextColor:[NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0]];
- blockSelf.value2PurchaseButton.layer.backgroundColor = [NSColor whiteColor].CGColor;
- }
- }
- };
- self.value3PurchaseButton.mouseMoveCallback = ^(BOOL mouseEntered) {
- if (mouseEntered) {
- // [blockSelf.value3PurchaseButton setTitleColor:[NSColor whiteColor]];
- blockSelf.value3PurchaseBtnLbl.textColor = [NSColor whiteColor];
- blockSelf.value3PurchaseButton.layer.backgroundColor = [NSColor colorWithRed:1 green:94/255.0 blue:44/255.0 alpha:1.0].CGColor;
- } else {
- // [blockSelf.value3PurchaseButton setTitleColor:[NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0]];
- blockSelf.value3PurchaseBtnLbl.textColor = [NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0];
- blockSelf.value3PurchaseButton.layer.backgroundColor = [NSColor whiteColor].CGColor;
- }
- };
-
- self.textView.string = [NSString stringWithFormat:NSLocalizedString(@"Subscription plans:\nSubscriptions: %@\n\n- Subscriptions will be charged through your iTunes account at the confirmation of purchase.\n- Your subscriptions will automatically renew unless cancelled at least 24 hours before the end of current subscription period.\n- Your iTunes account will be charged for renewal within 24-hours prior to the end of the current period, for the same duration and at the current subscription price.\n- You may manage your subscriptions in your iTunes Account Settings after purchase.\n- No cancellation of the current subscription is allowed during an active subscription period.\n\n- Terms of service:\nhttps://www.pdfreaderpro.com/terms_of_service\n- Privacy Policy:\nhttps://www.pdfreaderpro.com/privacy-policy", @""), NSLocalizedString(@"USD $39.99/(6 months), USD$59.99/(12 months), USD $59.99/(one-time purchase)", @"")];
-
- [self showDiscount];
- }
- - (BOOL)windowShouldClose:(id)sender {
- [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_Upgrade_Cancel"}];
-
- if ([self isShowSale]) {
- [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_7OffUpgrade_Cancel"} platform:KMAnalyticsPlatformAppCenter];
- }
- [self endModal:sender];
- return YES;
- }
- - (void)close {
- [super close];
- [self endModal:nil];
- }
- - (IBAction)startModal:(id)sender {
-
- [NSApp stopModal];
-
- NSInteger modalCode;
- self.modalSession = [NSApp beginModalSessionForWindow:self.window];
- do {
- modalCode = [NSApp runModalSession:self.modalSession];
- } while (modalCode == NSModalResponseContinue);
- }
- - (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];
- [self buttonItemClicked_Restore:nil];
- }
- - (void)showWindow:(id)sender {
- [super showWindow:sender];
- [self reloadData];
-
- if ([self isShowSale]) {
- [self showDiscountToSaveWindow];
- }
- }
- #pragma mark - Private Methods
- - (void)reloadData {
- if (self.isPurchaseSwitch) {
- self.sixMouthProLabel.textColor = [NSColor colorWithRed:117/255.0 green:119/255.0 blue:128/255.0 alpha:1.0];
- self.oneYearProLabel.textColor = NSColor.whiteColor;
-
- self.switchCircleLeftConst.constant = 22;
-
- self.value1InfoLabel.stringValue = NSLocalizedString(@"1-year Plan", nil);
- } else {
- self.sixMouthProLabel.textColor = NSColor.whiteColor;
- self.oneYearProLabel.textColor = [NSColor colorWithRed:117/255.0 green:119/255.0 blue:128/255.0 alpha:1.0];
-
- self.switchCircleLeftConst.constant = 4;
-
- self.value1InfoLabel.stringValue = NSLocalizedString(@"6-Month Plan", nil);
- }
- self.saleBox.hidden = true;
- self.saleIv.hidden = true;
- if ([self isShowSale]) {
- KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.StoreUserRecovery.content.firstObject;
- NSURL *url = [NSURL URLWithString:[KMAdvertisementModelTransition transitionImagePathWithImage:info.saleImage highlight:true]];
- [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage * _Nonnull image) {
- if (image != nil) {
- self.saleIv.image = image;
- self.saleBox.hidden = false;
- self.saleIv.hidden = false;
-
- [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Exposure" : @"PUW_7OffUpgrade"} platform:KMAnalyticsPlatformAppCenter];
- }
- }];
- } else {
- self.saleBox.hidden = true;
- }
-
- if ([IAPProductsManager defaultManager].isAvailableAllFunction) {
- self.value1PurchaseButton.enabled = NO;
- self.value2PurchaseButton.enabled = NO;
- self.value2PurchaseLbl.textColor = [NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:0.5];
- } else {
- self.value1PurchaseButton.enabled = YES;
- self.value2PurchaseButton.enabled = YES;
- self.value2PurchaseLbl.textColor = [NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0];
- }
- self.value1PurchaseBtnLblBtn.enabled = self.value1PurchaseButton.enabled;
-
- self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
- if ([IAPProductsManager defaultManager].allAccessPackNew6months_lite.isTrialPeriod) {
- self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
- if ([IAPProductsManager defaultManager].allAccessPackNew6months_lite.isSubscribed) {
- self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribed", nil);
- }
- } else if ([IAPProductsManager defaultManager].allAccessPack12months_lite.isTrialPeriod) {
- self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
- if ([IAPProductsManager defaultManager].allAccessPack12months_lite.isSubscribed) {
- self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribed", nil);
- }
- } else {
- if ([IAPProductsManager defaultManager].allAccessPackNew6months_lite.isSubscribed) {
- self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribed", nil);
- } else if ([IAPProductsManager defaultManager].allAccessPack12months_lite.isSubscribed) {
- self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribed", nil);
- } else {
- self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Free Trial", nil);
- if (@available(macOS 10.13.2, *)) {
- #if !VERSION_DMG
- if (![IAPProductsManager defaultManager].allAccessPackNew6months_lite.product.introductoryPrice) {
- self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
- } else if (![IAPProductsManager defaultManager].allAccessPack12months_lite.product.introductoryPrice) {
- self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
- }
- #endif
- }
- }
- }
-
- if (self.value1PurchaseBtnLblBtn.enabled) {
- [self.value1PurchaseBtnLbl setTextColor:[NSColor whiteColor]];
- } else {
- [self.value1PurchaseBtnLbl setTextColor:[[NSColor whiteColor] colorWithAlphaComponent:0.5]];
- }
-
- self.value2PurchaseLblBtn.enabled = self.value2PurchaseButton.enabled;
-
- NSString *averageMonthPrice = nil;
- NSString *monthPrice = nil;
- NSString *averageMonthPrice_discount = nil;
- NSString *monthPrice_discount = nil;
- NSString *allPrice = nil;
- if ([IAPProductsManager defaultManager].allAccessPackNew6months_lite.isOffers) {
- self.specialView1.hidden = NO;
- averageMonthPrice = [IAPProductsManager defaultManager].allAccessPackNew6months_lite.offersAveragePrice;
- monthPrice = [IAPProductsManager defaultManager].allAccessPackNew6months_lite.offersPrice;
- averageMonthPrice_discount = [IAPProductsManager defaultManager].allAccessPackNew6months_lite.discountAveragePrice;
- monthPrice_discount = [IAPProductsManager defaultManager].allAccessPackNew6months_lite.discountPrice;
- self.topButtonOffset.constant = 20;
- } else if ([IAPProductsManager defaultManager].allAccessPack12months_lite.isOffers) {
- averageMonthPrice = [IAPProductsManager defaultManager].allAccessPack12months_lite.offersAveragePrice;
- monthPrice = [IAPProductsManager defaultManager].allAccessPack12months_lite.offersPrice;
- averageMonthPrice_discount = [IAPProductsManager defaultManager].allAccessPack12months_lite.discountAveragePrice;
- monthPrice_discount = [IAPProductsManager defaultManager].allAccessPack12months_lite.discountPrice;
- self.topButtonOffset.constant = 20;
- } else {
- self.specialView1.hidden = YES;
- if (self.isPurchaseSwitch == false) {
- averageMonthPrice = [IAPProductsManager defaultManager].allAccessPackNew6months_lite.averagePrice;
- monthPrice = [IAPProductsManager defaultManager].allAccessPackNew6months_lite.price;
- averageMonthPrice_discount = [IAPProductsManager defaultManager].allAccessPackNew6months_lite.discountAveragePrice;
- monthPrice_discount = [IAPProductsManager defaultManager].allAccessPackNew6months_lite.discountPrice;
- } else {
- averageMonthPrice = [IAPProductsManager defaultManager].allAccessPack12months_lite.averagePrice;
- monthPrice = [IAPProductsManager defaultManager].allAccessPack12months_lite.price;
- averageMonthPrice_discount = [IAPProductsManager defaultManager].allAccessPack12months_lite.discountAveragePrice;
- monthPrice_discount = [IAPProductsManager defaultManager].allAccessPack12months_lite.discountPrice;
- }
- self.topButtonOffset.constant = 10;
- }
-
- if ([IAPProductsManager defaultManager].allAccessPackPermanent_lite.isOffers) {
- self.topButtonOffset.constant = 20;
- self.specialView.hidden = NO;
- allPrice = [IAPProductsManager defaultManager].allAccessPackPermanent_lite.offersPrice;
- } else {
- self.topButtonOffset.constant = 10;
- self.specialView.hidden = YES;
- allPrice = [IAPProductsManager defaultManager].allAccessPackPermanent_lite.price;
- }
-
- CGFloat off = 1 -[IAPProductsManager defaultManager].allAccessPackPermanent_lite.offers;
- NSString *offString = [NSString stringWithFormat:@"%.f%%",off * 100];
- self.specialLabel.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@ off", @""),offString];
-
- if (self.isPurchaseSwitch) {
- off = 1 -[IAPProductsManager defaultManager].allAccessPack12months_lite.offers;
- } else {
- off = 1 -[IAPProductsManager defaultManager].allAccessPackNew6months_lite.offers;
- }
- offString = [NSString stringWithFormat:@"%.f%%",off * 100];
- self.specialLabel1.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@ off", @""),offString];
-
- NSImage *image = [NSImage imageNamed:@"KMImageNameCompareTagBG"];
-
- self.specialImageView.image = image;
- self.specialImageView1.image = image;
- BOOL isShowSale = [self isShowSale];
- if (KMKdanRemoteConfig.remoteConfig.showAPP_AveragePrice) {
- if (isShowSale) {
- self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", averageMonthPrice_discount, NSLocalizedString(@"mon", nil)];
- self.value1PurchaseOriPriceLbl.stringValue = [NSString stringWithFormat:@"%@/%@", averageMonthPrice, NSLocalizedString(@"mon", nil)];
- self.value1PurchaseOriPriceLbl.hidden = false;
- self.billedTopConst.constant = 16;
- } else {
- self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", averageMonthPrice, NSLocalizedString(@"mon", nil)];
- self.value1PurchaseOriPriceLbl.hidden = true;
- self.billedTopConst.constant = 0;
- }
- } else {
- if (self.isPurchaseSwitch) {
- if (isShowSale) {
- self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice_discount, NSLocalizedString(@"12 months", nil)];
- self.value1PurchaseOriPriceLbl.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice, NSLocalizedString(@"12 months", nil)];
- self.value1PurchaseOriPriceLbl.hidden = false;
- self.billedTopConst.constant = 16;
- } else {
- self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice, NSLocalizedString(@"12 months", nil)];
- self.value1PurchaseOriPriceLbl.hidden = true;
- self.billedTopConst.constant = 0;
- }
- } else {
- if (isShowSale) {
- self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice_discount, NSLocalizedString(@"6mon", nil)];
- self.value1PurchaseOriPriceLbl.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice, NSLocalizedString(@"6mon", nil)];
- self.value1PurchaseOriPriceLbl.hidden = false;
- self.billedTopConst.constant = 16;
- } else {
- self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice, NSLocalizedString(@"6mon", nil)];
- self.value1PurchaseOriPriceLbl.hidden = true;
- self.billedTopConst.constant = 0;
- }
- }
- }
- self.value1PurchaseLabel.textColor = [NSColor colorWithRed:1 green:231/255. blue:106/255. alpha:1.];
- self.value1PurchaseOriPriceLbl.textColor = [NSColor colorWithWhite:1 alpha:0.7];
-
- self.value1PurchaseOriPriceLbl.attributedStringValue = [[NSAttributedString alloc] initWithString:self.value1PurchaseOriPriceLbl.stringValue attributes:@{
- NSFontAttributeName : [NSFont SFProTextRegularFont:12],
- NSForegroundColorAttributeName: [NSColor colorWithWhite:1 alpha:0.7],
- NSStrikethroughStyleAttributeName : @(1)
- }];
-
- NSString *tTips = @"";
- if (isShowSale) {
- tTips = [NSString stringWithFormat:NSLocalizedString(@"%@ for the first 6-month subscription", nil), monthPrice_discount];
- } else {
- tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 6 months at %@", nil), monthPrice];
- }
- if ([self.value1PurchaseBtnLbl.stringValue isEqualToString:NSLocalizedString(@"Free Trial", nil)]) {
- tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 6 months at %@ after 7-day trial ends.", nil), monthPrice];
- #if !VERSION_DMG
- if (self.isPurchaseSwitch) {
- if ([IAPProductsManager defaultManager].allAccessPack12months_lite.product) {
- if (@available(macOS 10.13.2, *)) {
- tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 12 months at %@ after %@-day trial ends.", nil), monthPrice,@([IAPProductsManager defaultManager].allAccessPack12months_lite.product.introductoryPrice.subscriptionPeriod.numberOfUnits)];
- }
- }
- } else {
- if ([IAPProductsManager defaultManager].allAccessPackNew6months_lite.product) {
- if (@available(macOS 10.13.2, *)) {
- tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 6 months at %@ after %@-day trial ends.", nil), monthPrice,@([IAPProductsManager defaultManager].allAccessPackNew6months_lite.product.introductoryPrice.subscriptionPeriod.numberOfUnits)];
- }
- }
- }
- #endif
- }
- if (@available(macOS 10.13.2, *)) {
- #if !VERSION_DMG
- if (self.isPurchaseSwitch) {
- if (![IAPProductsManager defaultManager].allAccessPack12months_lite.product.introductoryPrice) {
- if (isShowSale) {
- tTips = [NSString stringWithFormat:NSLocalizedString(@"%@ for the first year's subscription", nil), monthPrice_discount];
- } else {
- tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 12 months at %@", nil), monthPrice];
- }
- }
- } else {
- if (![IAPProductsManager defaultManager].allAccessPackNew6months_lite.product.introductoryPrice) {
- if (isShowSale) {
- tTips = [NSString stringWithFormat:NSLocalizedString(@"%@ for the first 6-month subscription", nil), monthPrice_discount];
- } else {
- tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 6 months at %@", nil), monthPrice];
- }
- }
- }
- #endif
- }
- self.value1PurchaseSubLabel.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@", nil), tTips];
-
- self.value2PurchaseLabel.stringValue = allPrice?:@"";
- self.value2PurchaseLabel.textColor = [NSColor colorWithRed:1 green:231/255. blue:106/255. alpha:1.];
- self.value2PurchaseSubLabel.stringValue = NSLocalizedString(@"one-time purchase", nil);
-
- self.value3PurchaseLabel.stringValue = NSLocalizedString(@"USD $59.99", nil);
- self.value3PurchaseLabel.textColor = [NSColor colorWithRed:1 green:231/255. blue:106/255. alpha:1.];
- self.value3PurchaseSubLabel.stringValue = NSLocalizedString(@"one-time purchase", nil);
-
- self.value1PurchaseBtnLbl.font = [NSFont UbuntuBoldFontWithSize:16];
- self.value2PurchaseLbl.font = [NSFont UbuntuBoldFontWithSize:16];
- self.value3PurchaseBtnLbl.font = [NSFont UbuntuBoldFontWithSize:16];
-
- self.value1PurchaseLabel.font = [NSFont UbuntuBoldFontWithSize:22];
- self.value2PurchaseLabel.font = [NSFont UbuntuBoldFontWithSize:22];
- self.value3PurchaseLabel.font = [NSFont UbuntuBoldFontWithSize:22];
- self.value1PurchaseOriPriceLbl.font = [NSFont SFProTextRegularFont:12];
-
- }
- - (void)reloadDataContent {
- if (self.isPurchaseSwitch) {
- self.dataSource = @[@"PDF to Office",
- @[@"Convert PDFs to Word, HTML, TXT, JPEG or PNG files",@"Only first 10 pages",@"Advanced",@"Advanced",@"Standard"],
- @[@"Turn PDF to PPT, Excel, RTF, CSV, and more",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
- @[@"Convert PDF to TIFF, BMP, GIF or TGA files",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
- @"Edit PDF",
- @[@"Add and edit text in PDF",@"X",@"✓",@"✓",@"✓"],
- @[@"Edit, crop, replace image in PDF",@"X",@"✓",@"✓",@"✓"],
- @"OCR",
- @[@"Extract texts from image-based or scanned PDF",@"X",@"✓",@"✓",@"✓"],
- @"Organize Pages",
- @[@"Extract, rotate, rearrange, replace, add, delete pages",@"X",@"✓",@"✓",@"✓"],
- @[@"Split PDFs into multiple files",@"X",@"✓",@"✓",@"✓"],
- @"Advanced Editing Tools",
- @[@"Merge multiple documents into a new PDF",@"Up to 2 files or 20 MB",@"✓",@"∞",@"∞"],
- @[@"Add & edit watermark",@"X",@"✓",@"✓",@"✓"],
- @[@"Add header, footer, page numbers",@"X",@"✓",@"✓",@"✓"],
- @[@"Add Bates Number",@"X",@"✓",@"✓",@"✓"],
- @[@"Insert PDF page background by color or image",@"X",@"✓",@"✓",@"✓"],
- @[@"Create fattened copies",@"X",@"✓",@"✓",@"✓"],
- @[@"Extract Images",@"X",@"✓",@"✓",@"✓"],
- @[@"Extract tables",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
- @[@"Measuring Tools",@"X",@"✓",@"✓",@"✓"],
- @"Fill & Sign",
- @[@"Create digital signature",@"X",@"✓",@"✓",@"✓"],
- @[@"Create & Edit & Fill Adobe Fillable PDF Forms",@"X",@"✓",@"✓",@"✓"],
- @"Security",
- @[@"Batch encrypting PDF documents",@"X",@"✓",@"✓",@"✓"],
- @[@"PDF Password Remover",@"X",@"✓",@"✓",@"✓"],
- @[@"Redact sensitive information",@"X",@"✓",@"✓",@"✓"],
- @"Create PDF",
- @[@"Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs",@"1 file",@"✓",@"✓",@"✓"],
- @[@"Create PDFs from a scanner and iOS devices",@"X",@"✓",@"✓",@"✓"],
- @"Annotations",
- @[@"Customize PDF stamps",@"X",@"✓",@"✓",@"✓",@"✓"],
- @[@"Hyperlink",@"Page Number",@"Page Number, URL, Email",@"Page Number, URL, Email",@"Page Number, URL, Email"],
- @[@"Signature",@"Standard",@"Advanced",@"Advanced",@"Advanced"],
- @[@"Table",@"X",@"✓",@"✓",@"✓",@"✓"],
- @"View PDF",
- @[@"Multi-tab viewer",@"X",@"✓",@"✓",@"✓"],
- @[@"Various printing types: poster, booklet, multi-page printing",@"X",@"✓",@"✓",@"✓"],
- @[@"Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more",@"X",@"✓",@"✓",@"✓"],
- @[@"Split View to compare files",@"X",@"✓",@"✓",@"✓"],
- @"Subscription Based Solution",
- @[@"Access all premium features in app",@"X",@"12 months",@"∞",@"∞"],
- @[@"Priority customer support",@"X",@"✓",@"✓",@"✓"],
- @[@"Ad-free",@"X",@"✓",@"✓",@"✓"],
- @{}
- ];
- } else {
- self.dataSource = @[@"PDF to Office",
- @[@"Convert PDFs to Word, HTML, TXT, JPEG or PNG files",@"Only first 10 pages",@"Advanced",@"Advanced",@"Standard"],
- @[@"Turn PDF to PPT, Excel, RTF, CSV, and more",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
- @[@"Convert PDF to TIFF, BMP, GIF or TGA files",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
- @"Edit PDF",
- @[@"Add and edit text in PDF",@"X",@"✓",@"✓",@"✓"],
- @[@"Edit, crop, replace image in PDF",@"X",@"✓",@"✓",@"✓"],
- @"OCR",
- @[@"Extract texts from image-based or scanned PDF",@"X",@"✓",@"✓",@"✓"],
- @"Organize Pages",
- @[@"Extract, rotate, rearrange, replace, add, delete pages",@"X",@"✓",@"✓",@"✓"],
- @[@"Split PDFs into multiple files",@"X",@"✓",@"✓",@"✓"],
- @"Advanced Editing Tools",
- @[@"Merge multiple documents into a new PDF",@"Up to 2 files or 20 MB",@"✓",@"∞",@"∞"],
- @[@"Add & edit watermark",@"X",@"✓",@"✓",@"✓"],
- @[@"Add header, footer, page numbers",@"X",@"✓",@"✓",@"✓"],
- @[@"Add Bates Number",@"X",@"✓",@"✓",@"✓"],
- @[@"Insert PDF page background by color or image",@"X",@"✓",@"✓",@"✓"],
- @[@"Create fattened copies",@"X",@"✓",@"✓",@"✓"],
- @[@"Extract Images",@"X",@"✓",@"✓",@"✓"],
- @[@"Extract tables",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
- @[@"Measuring Tools",@"X",@"✓",@"✓",@"✓"],
- @"Fill & Sign",
- @[@"Create digital signature",@"X",@"✓",@"✓",@"✓"],
- @[@"Create & Edit & Fill Adobe Fillable PDF Forms",@"X",@"✓",@"✓",@"✓"],
- @"Security",
- @[@"Batch encrypting PDF documents",@"X",@"✓",@"✓",@"✓"],
- @[@"PDF Password Remover",@"X",@"✓",@"✓",@"✓"],
- @[@"Redact sensitive information",@"X",@"✓",@"✓",@"✓"],
- @"Create PDF",
- @[@"Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs",@"1 file",@"✓",@"✓",@"✓"],
- @[@"Create PDFs from a scanner and iOS devices",@"X",@"✓",@"✓",@"✓"],
- @"Annotations",
- @[@"Customize PDF stamps",@"X",@"✓",@"✓",@"✓",@"✓"],
- @[@"Hyperlink",@"Page Number",@"Page Number, URL, Email",@"Page Number, URL, Email",@"Page Number, URL, Email"],
- @[@"Signature",@"Standard",@"Advanced",@"Advanced",@"Advanced"],
- @[@"Table",@"X",@"✓",@"✓",@"✓",@"✓"],
- @"View PDF",
- @[@"Multi-tab viewer",@"X",@"✓",@"✓",@"✓"],
- @[@"Various printing types: poster, booklet, multi-page printing",@"X",@"✓",@"✓",@"✓"],
- @[@"Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more",@"X",@"✓",@"✓",@"✓"],
- @[@"Split View to compare files",@"X",@"✓",@"✓",@"✓"],
- @"Subscription Based Solution",
- @[@"Access all premium features in app",@"X",@"6 months",@"∞",@"∞"],
- @[@"Priority customer support",@"X",@"✓",@"✓",@"✓"],
- @[@"Ad-free",@"X",@"✓",@"✓",@"✓"],
- @{}
- ];
- }
- [self.tableView reloadData];
- }
- - (void)addWaingView:(NSView *)view {
- [self removeWaitingView:view];
- WaitingView *wView = [[WaitingView alloc] initWithFrame:view.bounds];
- [wView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
- [view addSubview:wView];
- [wView startAnimation];
- }
- - (void)removeWaitingView:(NSView *)view {
- for (id v in view.subviews) {
- if ([[v class] isSubclassOfClass:[WaitingView class]]) {
- [v removeFromSuperview];
- break;
- }
- }
- }
- - (void)updateViewColor {
-
- self.box.fillColor = [KMAppearance KMColor_Layout_L1];
- self.labelbox.fillColor = [NSColor clearColor];
- self.tableView.backgroundColor = [KMAppearance KMColor_Layout_L0];
- self.textView.backgroundColor = [NSColor clearColor];
- self.textView.textColor = [[NSColor whiteColor] colorWithAlphaComponent:0.5];
- self.value1PurchaseSubLabel.textColor = self.value2PurchaseSubLabel.textColor = self.value3PurchaseSubLabel.textColor = [KMAppearance KMColor_Layout_W0];
- }
- - (BOOL)isCancelAutoRenew {
- return [[IAPProductsManager defaultManager] isCancelAutoRenew];
- }
- - (BOOL)isShowSale {
- if (@available(macOS 10.14.4, *)) {
- if ([self isCancelAutoRenew]) {
- BOOL isSubscribed = [IAPProductsManager defaultManager].allAccessPackNew6months_lite.isSubscribed;
- if (isSubscribed) {
- return false;
- }
- isSubscribed = [IAPProductsManager defaultManager].allAccessPack12months_lite.isSubscribed;
- if (isSubscribed) {
- return false;
- }
- KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.StoreUserRecovery.content.firstObject;
- if ([info.show boolValue] == false) { // 活动结束
- return false;
- }
- return true;
- }
- }
- return false;
- }
- - (void)showDiscount {
- [self.discountYearly setHidden:YES];
- [self.discountPermanent setHidden:YES];
- [self.discountPremium setHidden:YES];
- if (KMAdvertisementManager.manager.info.StoreUserRecovery.content.count > 0) {
- for (int i = 0; i < KMAdvertisementManager.manager.info.StoreUserRecovery.content.count; i++) {
- if (i == 1) {
- KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.StoreUserRecovery.content[1];
- if ([KMAdvertisementManager checkAdvertisementValid:info]) {
- [self.discountYearly setHidden:NO];
- NSURL *url = [NSURL URLWithString:[KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight:NO]];
- self.discountYearly.image = [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage * _Nonnull image) {
- self.discountYearly.image = image;
- }];
- } else {
- [self.discountYearly setHidden:YES];
- }
- } else if (i == 2) {
- KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.StoreUserRecovery.content[2];
- if ([KMAdvertisementManager checkAdvertisementValid:info]) {
- [self.discountPermanent setHidden:NO];
- NSURL *url = [NSURL URLWithString:[KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight:NO]];
- self.discountPermanent.image = [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage * _Nonnull image) {
- self.discountPermanent.image = image;
- }];
- } else {
- [self.discountPermanent setHidden:YES];
- }
- } else if (i == 3) {
- KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.StoreUserRecovery.content[3];
- if ([KMAdvertisementManager checkAdvertisementValid:info]) {
- [self.discountPremium setHidden:NO];
- NSURL *url = [NSURL URLWithString:[KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight:NO]];
- self.discountPremium.image = [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage * _Nonnull image) {
- self.discountPremium.image = image;
- }];
- } else {
- [self.discountPremium setHidden:YES];
- }
- }
- }
- }
- }
- #pragma mark - Button Actions
- - (IBAction)buttonItemClicked_Subscribe:(id)sender {
- if (self.isPurchaseSwitch) {
- [[IAPProductsManager defaultManager] makeSubProduct:[IAPProductsManager defaultManager].allAccessPack12months_lite discount:[self isCancelAutoRenew]];
-
- } else {
- [[IAPProductsManager defaultManager] makeSubProduct:[IAPProductsManager defaultManager].allAccessPackNew6months_lite discount:[self isCancelAutoRenew]];
- }
- [self addWaingView:self.window.contentView];
- [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_Upgrade_6Mon"}];
- if ([self isShowSale]) {
- self.kEventTag = 1;
- if (self.isPurchaseSwitch) {
- [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_7OffUpgrade_12Mon"} platform:KMAnalyticsPlatformAppCenter];
- } else {
- [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_7OffUpgrade_6Mon"} platform:KMAnalyticsPlatformAppCenter];
- }
- }
- }
- - (void)showDiscountToSaveWindow {
- if ([KMDiscountToSaveWindowController needShow] == false) {
- return;
- }
-
- KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.StoreUserRecovery.content.firstObject;
- NSURL *url = [NSURL URLWithString: [KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight: YES]];
-
- __weak typeof(self) weakSelf = self;
- [self addWaingView:self.window.contentView];
- [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage *image) {
- [weakSelf removeWaitingView:weakSelf.window.contentView];
- if (image == nil) {
- return;
- }
-
- [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Exposure" : @"PUW_PromotionalOffer"} platform:KMAnalyticsPlatformAppCenter];
-
- KMDiscountToSaveWindowController *winC = [[KMDiscountToSaveWindowController alloc] initWithWindowNibName:@"KMDiscountToSaveWindowController"];
- weakSelf.discountToSaveWinC = winC;
- [weakSelf.window beginSheet:winC.window completionHandler:^(NSModalResponse returnCode) { }];
-
- winC.imgIv.image = image;
- winC.itemClick = ^(NSInteger idx) {
- [weakSelf.window endSheet:weakSelf.discountToSaveWinC.window];
- weakSelf.discountToSaveWinC = nil;
- if (idx == 2) { // 订阅
- //// NSLog(@"buttonItemClicked_Subscribe");
- [weakSelf trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_PromotionalOffer_Subscribe"} platform:KMAnalyticsPlatformAppCenter];
- } else if (idx == 1) {
- [weakSelf trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_PromotionalOffer_Cancel"} platform:KMAnalyticsPlatformAppCenter];
- }
- };
- }];
- }
- - (IBAction)buttonItemClicked_Restore:(id)sender {
- [[IAPProductsManager defaultManager] restoreSubscriptions];
- [self addWaingView:self.window.contentView];
- }
- - (IBAction)buttonItemClicked_Upgrade:(id)sender {
- [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"macappstore://apps.apple.com/app/id825459243?mt=12"]];
- [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_Upgrade_Premium"}];
- }
- - (IBAction)privacyPolicyAction:(NSButton *)sender {
- [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://www.pdfreaderpro.com/privacy-policy"]];
- }
- - (IBAction)termOfSerAction:(NSButton *)sender {
- [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://www.pdfreaderpro.com/terms_of_service"]];
- }
- - (IBAction)buttonItemClicked_LicenseUpgrade:(id)sender {
- [[IAPProductsManager defaultManager] makeProduct:[IAPProductsManager defaultManager].allAccessPackPermanent_lite];
- [self addWaingView:self.window.contentView];
- [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_Upgrade_Permanent"}];
- }
- - (IBAction)buttonItemClicked_AboutSubscriptions:(id)sender {
-
- NSString *tMessage = [NSString stringWithFormat:@"%@\n%@\n\n%@\n%@\n%@\n%@\n%@\n\n%@\n%@\n\n",
- @"Subscription plans: ",
- @"Subscriptions: USD $39.99/(6 months), USD $79.99/(one-time purchase) ",
- @"- Subscriptions will be charged through your iTunes account at the confirmation of purchase. ",
- @"- Your subscriptions will automatically renew unless cancelled at least 24 hours before the end of current subscription period. ",
- @"- Your iTunes account will be charged for renewal within 24-hours prior to the end of the current period, for the same duration and at the current subscription price. ",
- @"- You may manage your subscriptions in your iTunes Account Settings after purchase. ",
- @"- No cancellation of the current subscription is allowed during an active subscription period. ",
- @"- Terms of service: \nhttps://www.pdfreaderpro.com/terms_of_service ",
- @"- Privacy Policy: \nhttps://www.pdfreaderpro.com/privacy-policy "];
-
- NSAlert *alert = [[NSAlert alloc] init];
- [alert setAlertStyle:NSAlertStyleInformational];
- [alert setMessageText:NSLocalizedString(tMessage, nil)];
- [alert runModal];
- }
- - (IBAction)buttonItemClicked_CloseWindow:(id)sender {
- [self close];
- }
- - (void)switchAction:(NSButton *)sender {
- // NSControlStateValue state = self.switchBtn.state;
- BOOL isSwitch = self.isPurchaseSwitch;
- if (isSwitch) {
- // self.switchBtn.state = NSControlStateValueOff;
- self.isPurchaseSwitch = false;
-
- // self.switchCircleLeftConst.constant = 4;
- } else {
- // self.switchBtn.state = NSControlStateValueOn;
- self.isPurchaseSwitch = true;
-
- // self.switchCircleLeftConst.constant = 22;
- }
-
- // if (self.isPurchaseSwitch) { // 一年
- //
- // } else { // 半年
- //
- // }
- [self reloadDataContent];
- [self reloadData];
- }
- #pragma mark - NSTableViewDataSource Methods
- - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView {
- return self.dataSource.count;
- }
- - (id)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
- id object = [self.dataSource objectAtIndex:row];
- if ([object isKindOfClass:[NSString class]]) {
- KMPurchaseCompareHeaderCell *cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareHeaderCellIdentifier owner:self];
- cellView.textField.stringValue = NSLocalizedString(object, nil);
- return cellView;
- } else if ([object isKindOfClass:[NSArray class]]) {
- KMPurchaseCompareCell *cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareCellIdentifier owner:self];
- NSString *value = [(NSArray *)object count] > 0 ? object[0] : @"";
- NSString *value1 = [(NSArray *)object count] > 1 ? object[1] : @"";
- NSString *value2 = [(NSArray *)object count] > 2 ? object[2] : @"";
- NSString *value3 = [(NSArray *)object count] > 3 ? object[3] : @"";
- NSString *value4 = [(NSArray *)object count] > 4 ? object[4] : @"";
- cellView.textField.stringValue = NSLocalizedString(value, nil);
- cellView.lineBox.hidden = NO;
-
- if (row + 1 == (NSInteger)self.dataSource.count) {
- cellView.lineBox.hidden = YES;
- } else {
- id nextobject = [self.dataSource objectAtIndex:row+1];
- if ([nextobject isKindOfClass:[NSString class]]) {
- cellView.lineBox.hidden = YES;
- }
- }
-
- if (row + 2 == (NSInteger)self.dataSource.count) {
- cellView.boxBottomConst.constant = 0;
- } else {
- cellView.boxBottomConst.constant = -4;
- }
-
- if ([value1 isEqualToString:@"X"]) {
- cellView.value1Label.stringValue = @"";
- cellView.value1ImageView.image = [NSImage imageNamed:@"compare_nosupport"];
- } else if ([value1 isEqualToString:@"✓"]) {
- cellView.value1Label.stringValue = @"";
- cellView.value1ImageView.image = [NSImage imageNamed:@"compare_support"];
- } else if ([value1 isEqualToString:@"∞"]) {
- cellView.value1Label.stringValue = @"";
- cellView.value1ImageView.image = [NSImage imageNamed:@"compare_00"];
- } else {
- cellView.value1Label.stringValue = NSLocalizedString(value1, nil);
- cellView.value1ImageView.image = nil;
- }
-
- if ([value2 isEqualToString:@"X"]) {
- cellView.value2Label.stringValue = @"";
- cellView.value2ImageView.image = [NSImage imageNamed:@"compare_nosupport"];
- } else if ([value2 isEqualToString:@"✓"]) {
- cellView.value2Label.stringValue = @"";
- cellView.value2ImageView.image = [NSImage imageNamed:@"compare_support"];
- } else if ([value2 isEqualToString:@"∞"]) {
- cellView.value2Label.stringValue = @"";
- cellView.value2ImageView.image = [NSImage imageNamed:@"compare_00"];
- } else {
- cellView.value2Label.stringValue = NSLocalizedString(value2, nil);
- cellView.value2ImageView.image = nil;
- }
-
- if ([value3 isEqualToString:@"X"]) {
- cellView.value3Label.stringValue = @"";
- cellView.value3ImageView.image = [NSImage imageNamed:@"compare_nosupport"];
- } else if ([value3 isEqualToString:@"✓"]) {
- cellView.value3Label.stringValue = @"";
- cellView.value3ImageView.image = [NSImage imageNamed:@"compare_support"];
- } else if ([value3 isEqualToString:@"∞"]) {
- cellView.value3Label.stringValue = @"";
- cellView.value3ImageView.image = [NSImage imageNamed:@"compare_00"];
- } else {
- cellView.value3Label.stringValue = NSLocalizedString(value3, nil);
- cellView.value3ImageView.image = nil;
- }
-
- if ([value4 isEqualToString:@"X"]) {
- cellView.value4Label.stringValue = @"";
- cellView.value4ImageView.image = [NSImage imageNamed:@"compare_nosupport"];
- } else if ([value4 isEqualToString:@"✓"]) {
- cellView.value4Label.stringValue = @"";
- cellView.value4ImageView.image = [NSImage imageNamed:@"compare_support"];
- } else if ([value4 isEqualToString:@"∞"]) {
- cellView.value4Label.stringValue = @"";
- cellView.value4ImageView.image = [NSImage imageNamed:@"compare_00"];
- } else {
- cellView.value4Label.stringValue = NSLocalizedString(value4, nil);
- cellView.value4ImageView.image = nil;
- }
- return cellView;
- } else if ([object isKindOfClass:[NSDictionary class]]) {
- KMPurchaseCompareEmptyCell *cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareEmptyCellIdentifier owner:self];
- return cellView;
- }
- return nil;
- }
- - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row {
- NSTableCellView *cellView = nil;
- id object = [self.dataSource objectAtIndex:row];
- if ([object isKindOfClass:[NSString class]]) {
- cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareHeaderCellIdentifier owner:self];
- cellView.textField.stringValue = NSLocalizedString(object, nil);
- } else if ([object isKindOfClass:[NSArray class]]) {
- cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareCellIdentifier owner:self];
- cellView.textField.stringValue = NSLocalizedString(object[0], nil);
- } else if ([object isKindOfClass:[NSDictionary class]]) {
- return 40;
- }
- if (cellView) {
- [cellView layoutSubtreeIfNeeded];
- return cellView.frame.size.height;
- } else {
- return 0;
- }
- }
- #pragma mark - InAppPurchaseManager Notification
- - (void)IAPProductFailedNotification:(NSNotification*)notification {
- [self removeWaitingView:self.window.contentView];
- }
- - (void)IAPProductPurchasedNotification:(NSNotification*)notification {
- [self removeWaitingView:self.window.contentView];
- [self reloadData];
-
- if (IAPProductsManager.defaultManager.allAccessPackNew6months_lite.isSubscribed) {
- if (self.kEventTag == 1) {
- [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_7OffUpgrade_6MonthPaid"} platform:KMAnalyticsPlatformAppCenter];
- }
- } else if (IAPProductsManager.defaultManager.allAccessPack12months_lite.isSubscribed) {
- if (self.kEventTag == 1) {
- [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_7OffUpgrade_12MonthPaid"} platform:KMAnalyticsPlatformAppCenter];
- }
- }
- }
- - (void)IAPProductLoadedNotification:(NSNotification*)notification {
- [self reloadData];
- }
- - (void)IAPProductRestoreFinishedNotification:(NSNotification *)notification {
- [self removeWaitingView:self.window.contentView];
- [self reloadData];
- }
- - (void)IAPProductRestoreFailedNotification:(NSNotification *)notification {
- [self removeWaitingView:self.window.contentView];
- }
- - (void)IAPSubscriptionLoadedNotification:(NSNotification *)notification {
- [self removeWaitingView:self.window.contentView];
- [self reloadData];
- }
- @end
|