123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989 |
- //
- // 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
- 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 NSTextField *value1InfoLabel;
- @property (nonatomic,assign) IBOutlet NSTextField *value1PurchaseLabel;
- @property (nonatomic,assign) IBOutlet NSTextField *value1PurchaseSubLabel;
- @property (nonatomic,assign) IBOutlet KMButton *value1PurchaseButton;
- @property (assign) IBOutlet NSTextField *value1PurchaseBtnLbl;
- @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 KMButton *btnRestore;
- @property (assign) IBOutlet KMButton *privacyPolicyBtn;
- @property (assign) IBOutlet KMButton *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;
- @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];
- }
- 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:@"https://www.pdfreaderpro.com/store?utm_source=app_dmg&utm_medium=dmg_puw_free_trial"];
- if([SKInspectPublicTool currentisLanguageHans]) {
- url = [NSURL URLWithString:@"https://www.pdfreaderpro.com/zh-cn/store?utm_source=app_dmg&utm_medium=dmg_puw_free_trial"];
- }
- [[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.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(@"", 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 = NSLocalizedString(@"Subscription plans:\nSubscriptions: USD $39.99/(6 months), USD $79.99/(one-time purchase)\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", nil);
- }
- - (BOOL)windowShouldClose:(id)sender {
- [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_Upgrade_Cancel"}];
- [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];
- }
- #pragma mark - Private Methods
- - (void)reloadData {
- 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].newlyMonthProduct.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);
- }
- #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 *allPrice = nil;
- if ([IAPProductsManager defaultManager].newlyMonthProduct.isOffers) {
- self.specialView1.hidden = NO;
- averageMonthPrice = [IAPProductsManager defaultManager].newlyMonthProduct.offersAveragePrice;
- monthPrice = [IAPProductsManager defaultManager].newlyMonthProduct.offersPrice;
- self.topButtonOffset.constant = 20;
- } else {
- self.specialView1.hidden = YES;
- averageMonthPrice = [IAPProductsManager defaultManager].newlyMonthProduct.averagePrice;
- monthPrice = [IAPProductsManager defaultManager].newlyMonthProduct.price;
- 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];
-
- 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;
-
- if (KMKdanRemoteConfig.remoteConfig.showAPP_AveragePrice) {
- self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", averageMonthPrice, NSLocalizedString(@"mon", nil)];
- } else {
- self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice, NSLocalizedString(@"6mon", nil)];
- }
- self.value1PurchaseLabel.textColor = [NSColor colorWithRed:1 green:231/255. blue:106/255. alpha:1.];
-
- NSString *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 ([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 (![IAPProductsManager defaultManager].newlyMonthProduct.product.introductoryPrice) {
- 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];
-
- }
- - (void)reloadDataContent {
- 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"],
- @"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];
- }
- #pragma mark - Button Actions
- - (IBAction)buttonItemClicked_Subscribe:(id)sender {
- [[IAPProductsManager defaultManager] makeProduct:[IAPProductsManager defaultManager].newlyMonthProduct];
- [self addWaingView:self.window.contentView];
- [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_Upgrade_6Mon"}];
- }
- - (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];
- }
- #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];
- }
- - (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
|