12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403 |
- //
- // 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 "KMPurchaseCompareDMGWindowController.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].newlyMonthProduct.isTrialPeriod) {
- self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
- if ([IAPProductsManager defaultManager].newlyMonthProduct.isSubscribed) {
- self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribed", nil);
- }
- } else if ([IAPProductsManager defaultManager].yearProduct.isTrialPeriod) {
- self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
- if ([IAPProductsManager defaultManager].yearProduct.isSubscribed) {
- self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribed", nil);
- }
- } else {
- if ([IAPProductsManager defaultManager].newlyMonthProduct.isSubscribed) {
- self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribed", nil);
- } else if ([IAPProductsManager defaultManager].yearProduct.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].newlyMonthProduct.product.introductoryPrice) {
- self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
- } else if (![IAPProductsManager defaultManager].yearProduct.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].newlyMonthProduct.isOffers) {
- self.specialView1.hidden = NO;
- averageMonthPrice = [IAPProductsManager defaultManager].newlyMonthProduct.offersAveragePrice;
- monthPrice = [IAPProductsManager defaultManager].newlyMonthProduct.offersPrice;
- averageMonthPrice_discount = [IAPProductsManager defaultManager].newlyMonthProduct.discountAveragePrice;
- monthPrice_discount = [IAPProductsManager defaultManager].newlyMonthProduct.discountPrice;
- self.topButtonOffset.constant = 20;
- } else if ([IAPProductsManager defaultManager].yearProduct.isOffers) {
- averageMonthPrice = [IAPProductsManager defaultManager].yearProduct.offersAveragePrice;
- monthPrice = [IAPProductsManager defaultManager].yearProduct.offersPrice;
- averageMonthPrice_discount = [IAPProductsManager defaultManager].yearProduct.discountAveragePrice;
- monthPrice_discount = [IAPProductsManager defaultManager].yearProduct.discountPrice;
- self.topButtonOffset.constant = 20;
- } else {
- self.specialView1.hidden = YES;
- if (self.isPurchaseSwitch == false) {
- averageMonthPrice = [IAPProductsManager defaultManager].newlyMonthProduct.averagePrice;
- monthPrice = [IAPProductsManager defaultManager].newlyMonthProduct.price;
- averageMonthPrice_discount = [IAPProductsManager defaultManager].newlyMonthProduct.discountAveragePrice;
- monthPrice_discount = [IAPProductsManager defaultManager].newlyMonthProduct.discountPrice;
- } else {
- averageMonthPrice = [IAPProductsManager defaultManager].yearProduct.averagePrice;
- monthPrice = [IAPProductsManager defaultManager].yearProduct.price;
- averageMonthPrice_discount = [IAPProductsManager defaultManager].yearProduct.discountAveragePrice;
- monthPrice_discount = [IAPProductsManager defaultManager].yearProduct.discountPrice;
- }
- self.topButtonOffset.constant = 10;
- }
-
- if ([IAPProductsManager defaultManager].allAccessProduct.isOffers) {
- self.topButtonOffset.constant = 20;
- self.specialView.hidden = NO;
- allPrice = [IAPProductsManager defaultManager].allAccessProduct.offersPrice;
- } else {
- self.topButtonOffset.constant = 10;
- self.specialView.hidden = YES;
- allPrice = [IAPProductsManager defaultManager].allAccessProduct.price;
- }
-
- CGFloat off = 1 -[IAPProductsManager defaultManager].allAccessProduct.offers;
- NSString *offString = [NSString stringWithFormat:@"%.f%%",off * 100];
- self.specialLabel.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@ off", @""),offString];
-
- if (self.isPurchaseSwitch) {
- off = 1 -[IAPProductsManager defaultManager].yearProduct.offers;
- } else {
- off = 1 -[IAPProductsManager defaultManager].newlyMonthProduct.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].yearProduct.product) {
- if (@available(macOS 10.13.2, *)) {
- tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 12 months at %@ after %@-day trial ends.", nil), monthPrice,@([IAPProductsManager defaultManager].yearProduct.product.introductoryPrice.subscriptionPeriod.numberOfUnits)];
- }
- }
- } else {
- if ([IAPProductsManager defaultManager].newlyMonthProduct.product) {
- if (@available(macOS 10.13.2, *)) {
- tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 6 months at %@ after %@-day trial ends.", nil), monthPrice,@([IAPProductsManager defaultManager].newlyMonthProduct.product.introductoryPrice.subscriptionPeriod.numberOfUnits)];
- }
- }
- }
- #endif
- }
- if (@available(macOS 10.13.2, *)) {
- #if !VERSION_DMG
- if (self.isPurchaseSwitch) {
- if (![IAPProductsManager defaultManager].yearProduct.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].newlyMonthProduct.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].newlyMonthProduct.isSubscribed;
- if (isSubscribed) {
- return false;
- }
- isSubscribed = [IAPProductsManager defaultManager].yearProduct.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].yearProduct discount:[self isCancelAutoRenew]];
-
- } else {
- [[IAPProductsManager defaultManager] makeSubProduct:[IAPProductsManager defaultManager].newlyMonthProduct 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].allAccessProduct];
- [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.newlyMonthProduct.isSubscribed) {
- if (self.kEventTag == 1) {
- [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_7OffUpgrade_6MonthPaid"} platform:KMAnalyticsPlatformAppCenter];
- }
- } else if (IAPProductsManager.defaultManager.yearProduct.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
|