KMPurchaseCompareWindowController.m 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993
  1. //
  2. // KMPurchaseCompareWindowController.m
  3. // PDF Reader
  4. //
  5. // Created by wangshuai on 2017/5/8.
  6. // Copyright © 2017年 zhangjie. All rights reserved.
  7. //
  8. #import "KMPurchaseCompareWindowController.h"
  9. #import <PDF_Reader_Pro-Swift.h>
  10. #import "KMPurchaseCompareDMGWindowController.h"
  11. //#import "WaitingView.h"
  12. //#import "NSButton+TitleColor.h"
  13. //#import "HyperLinkButton.h"
  14. //#import "IAPProductsManager.h"
  15. //#import "GAIManager.h"
  16. //#import "NSImage_SKExtensions.h"
  17. //
  18. //#import "KMButton.h"
  19. //#import "KMCustomButton.h"
  20. //#import "KMKdanRemoteConfig.h"
  21. //#import "VerificationManager.h"
  22. //#import "KMVerificationWindowController.h"
  23. //#import "SKInspectPublicTool.h"
  24. //#import "FMTrackEventManager.h"
  25. //#import "NSFont+Custom.h"
  26. //#if !VERSION_DMG
  27. //#import <StoreKit/StoreKit.h>
  28. //#endif
  29. static NSString *const KMPurchaseCompareEmptyCellIdentifier = @"KMPurchaseCompareEmptyCellIdentifier";
  30. static NSString *const KMPurchaseCompareHeaderCellIdentifier = @"KMPurchaseCompareHeaderCell";
  31. static NSString *const KMPurchaseCompareCellIdentifier = @"KMPurchaseCompareCell";
  32. #pragma mark - KMPurchaseCompareEmptyCell
  33. @interface KMPurchaseCompareEmptyCell : NSTableCellView
  34. @end
  35. @implementation KMPurchaseCompareEmptyCell
  36. - (void)dealloc {
  37. [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
  38. }
  39. - (void)awakeFromNib {
  40. [super awakeFromNib];
  41. self.wantsLayer = YES;
  42. [self updateViewColor];
  43. [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
  44. }
  45. - (void)themeChanged:(NSNotification *)notification {
  46. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  47. [self updateViewColor];
  48. });
  49. }
  50. - (void)updateViewColor {
  51. if ([KMAppearance isDarkMode]) {
  52. self.layer.backgroundColor = [NSColor colorWithRed:24/255.0 green:22/255.0 blue:31/255. alpha:1.].CGColor;
  53. } else {
  54. self.layer.backgroundColor = [NSColor colorWithRed:247/255.0 green:245/255.0 blue:1 alpha:1.].CGColor;
  55. }
  56. }
  57. @end
  58. @interface KMPurchaseCompareHeaderCell : NSTableCellView
  59. @property (nonatomic,assign) IBOutlet NSView *contentView;
  60. @end
  61. @implementation KMPurchaseCompareHeaderCell
  62. - (void)dealloc
  63. {
  64. [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
  65. }
  66. - (void)awakeFromNib
  67. {
  68. [super awakeFromNib];
  69. self.contentView.wantsLayer = YES;
  70. [self updateViewColor];
  71. [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
  72. }
  73. - (void)themeChanged:(NSNotification *)notification {
  74. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  75. [self updateViewColor];
  76. });
  77. }
  78. - (void)updateViewColor {
  79. if ([KMAppearance isDarkMode]) {
  80. self.contentView.layer.backgroundColor = [NSColor colorWithRed:40/255. green:38/255. blue:47/255. alpha:1].CGColor;
  81. } else {
  82. self.contentView.layer.backgroundColor = [NSColor colorWithRed:237/255. green:231/255. blue:255/255. alpha:1].CGColor;
  83. }
  84. self.textField.textColor = [KMAppearance KMColor_Layout_H0];
  85. self.textField.font = [NSFont boldSystemFontOfSize:14.0];
  86. }
  87. @end
  88. #pragma mark - KMPurchaseCompareCell
  89. @interface KMPurchaseCompareCell : NSTableCellView
  90. @property (nonatomic,assign) IBOutlet NSView *bgColorView;
  91. @property (nonatomic,assign) IBOutlet NSTextField *value1Label;
  92. @property (nonatomic,assign) IBOutlet NSTextField *value2Label;
  93. @property (nonatomic,assign) IBOutlet NSTextField *value3Label;
  94. @property (nonatomic,assign) IBOutlet NSTextField *value4Label;
  95. @property (nonatomic,assign) IBOutlet NSImageView *value1ImageView;
  96. @property (nonatomic,assign) IBOutlet NSImageView *value2ImageView;
  97. @property (nonatomic,assign) IBOutlet NSImageView *value3ImageView;
  98. @property (nonatomic,assign) IBOutlet NSImageView *value4ImageView;
  99. @property (nonatomic,assign) IBOutlet NSBox *lineBox;
  100. @property (assign) IBOutlet NSLayoutConstraint *boxBottomConst;
  101. @end
  102. @implementation KMPurchaseCompareCell
  103. - (void)dealloc
  104. {
  105. [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
  106. }
  107. - (void)awakeFromNib
  108. {
  109. [super awakeFromNib];
  110. self.bgColorView.wantsLayer = YES;
  111. [self updateViewColor];
  112. [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
  113. }
  114. - (void)themeChanged:(NSNotification *)notification {
  115. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  116. [self updateViewColor];
  117. });
  118. }
  119. - (void)updateViewColor {
  120. self.bgColorView.layer.backgroundColor = [NSColor colorWithRed:247/255.0 green:245/255.0 blue:1 alpha:1.].CGColor;
  121. NSColor *textColor = [NSColor colorWithRed:68.0/255.0 green:68.0/255.0 blue:68.0/255.0 alpha:1.0];
  122. NSColor *subtextColor = [NSColor colorWithRed:141.0/255.0 green:141.0/255.0 blue:141.0/255.0 alpha:1.0];
  123. NSColor *lineColor = [NSColor colorWithRed:204.0/255.0 green:204.0/255.0 blue:204.0/255.0 alpha:0.4];
  124. if ([KMAppearance isDarkMode]) {
  125. self.bgColorView.layer.backgroundColor = [NSColor colorWithRed:24/255.0 green:22/255.0 blue:31/255. alpha:1.].CGColor;
  126. textColor = [NSColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.8];
  127. subtextColor = [NSColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.6];
  128. lineColor = [NSColor colorWithRed:0.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:0.15];
  129. }
  130. self.value1Label.textColor = subtextColor;
  131. self.value2Label.textColor = self.value3Label.textColor = self.value4Label.textColor = subtextColor;
  132. self.lineBox.fillColor = lineColor;
  133. self.textField.textColor = textColor;
  134. }
  135. @end
  136. #pragma mark - KMPurchaseCompareWindowController
  137. static KMPurchaseCompareDMGWindowController *dmgSingleton = nil;
  138. static KMPurchaseFirstTrialWindowController *firstTrialSingleton = nil;
  139. @interface KMPurchaseCompareWindowController ()<NSTableViewDelegate, NSTableViewDataSource>
  140. @property (nonatomic,assign) NSModalSession modalSession;
  141. @property (nonatomic,retain) NSArray *dataSource;
  142. @property (nonatomic,assign) IBOutlet NSTableView *tableView;
  143. @property (nonatomic,assign) IBOutlet NSTextField *titleLabel;
  144. @property (nonatomic,assign) IBOutlet NSTextField *switchLabel;
  145. @property (nonatomic,assign) IBOutlet NSButton *switchButton;
  146. @property (assign) IBOutlet NSView *freeInfoView;
  147. @property (assign) IBOutlet NSTextField *freeInfoLabel;
  148. @property (assign) IBOutlet NSView *value1InfoView;
  149. @property (assign) IBOutlet NSBox *value1InfoBox;
  150. @property (assign) IBOutlet NSTextField *value1InfoLabel;
  151. @property (nonatomic,assign) IBOutlet NSTextField *value1PurchaseLabel;
  152. @property (nonatomic,assign) IBOutlet NSTextField *value1PurchaseSubLabel;
  153. @property (nonatomic,assign) IBOutlet KMButton *value1PurchaseButton;
  154. @property (assign) IBOutlet NSTextField *value1PurchaseBtnLbl;
  155. @property (assign) IBOutlet NSButton *value1PurchaseBtnLblBtn;
  156. @property (assign) IBOutlet NSView *value2InfoView;
  157. @property (assign) IBOutlet NSTextField *value2InfoLabel;
  158. @property (nonatomic,assign) IBOutlet NSTextField *value2PurchaseLabel;
  159. @property (nonatomic,assign) IBOutlet NSTextField *value2PurchaseSubLabel;
  160. @property (nonatomic,assign) IBOutlet KMButton *value2PurchaseButton;
  161. @property (assign) IBOutlet NSTextField *value2PurchaseLbl;
  162. @property (assign) IBOutlet KMButton *value2PurchaseLblBtn;
  163. @property (assign) IBOutlet NSView *value3InfoView;
  164. @property (assign) IBOutlet NSTextField *value3InfoLabel;
  165. @property (nonatomic,assign) IBOutlet NSTextField *value3PurchaseLabel;
  166. @property (nonatomic,assign) IBOutlet NSTextField *value3PurchaseSubLabel;
  167. @property (nonatomic,assign) IBOutlet KMButton *value3PurchaseButton;
  168. @property (strong) IBOutlet NSTextField *value3PurchaseBtnLbl;
  169. @property (nonatomic,assign) IBOutlet NSButton *aboutButton;
  170. @property (nonatomic,assign) IBOutlet KMButton *btnRestore;
  171. @property (assign) IBOutlet KMButton *privacyPolicyBtn;
  172. @property (assign) IBOutlet KMButton *termOfSerBtn;
  173. @property (nonatomic,assign) IBOutlet NSTextView *textView;
  174. @property (nonatomic,assign) IBOutlet NSView *specialView;
  175. @property (nonatomic,assign) IBOutlet NSImageView *specialImageView;
  176. @property (nonatomic,assign) IBOutlet NSTextField *specialLabel;
  177. @property (nonatomic,assign) IBOutlet NSView *specialView1;
  178. @property (nonatomic,assign) IBOutlet NSImageView *specialImageView1;
  179. @property (nonatomic,assign) IBOutlet NSTextField *specialLabel1;
  180. @property (nonatomic,assign) IBOutlet NSBox *box;
  181. @property (nonatomic,assign) IBOutlet NSBox *labelbox;
  182. @property (assign) IBOutlet NSLayoutConstraint *topButtonOffset;
  183. @property (nonatomic, retain) CALayer *value1Layer;
  184. @end
  185. @implementation KMPurchaseCompareWindowController
  186. #pragma mark - Init Methods
  187. - (id)init {
  188. if (self = [super initWithWindowNibName:@"KMPurchaseCompareWindowController"]) {
  189. [[NSNotificationCenter defaultCenter] addObserver:self
  190. selector:@selector(IAPProductLoadedNotification:)
  191. name:KMIAPProductLoadedNotification
  192. object:nil];
  193. [[NSNotificationCenter defaultCenter] addObserver:self
  194. selector:@selector(IAPSubscriptionLoadedNotification:)
  195. name:KMIAPSubscriptionLoadedNotification
  196. object:nil];
  197. [[NSNotificationCenter defaultCenter] addObserver:self
  198. selector:@selector(IAPProductPurchasedNotification:)
  199. name:KMIAPProductPurchasedNotification
  200. object:nil];
  201. [[NSNotificationCenter defaultCenter] addObserver:self
  202. selector:@selector(IAPProductFailedNotification:)
  203. name:KMIAPProductFailedNotification
  204. object:nil];
  205. [[NSNotificationCenter defaultCenter] addObserver:self
  206. selector:@selector(IAPProductRestoreFinishedNotification:)
  207. name:KMIAPProductRestoreFinishedNotification
  208. object:nil];
  209. [[NSNotificationCenter defaultCenter] addObserver:self
  210. selector:@selector(IAPProductRestoreFailedNotification:)
  211. name:KMIAPProductRestoreFailedNotification
  212. object:nil];
  213. [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
  214. }
  215. return self;
  216. }
  217. - (void)themeChanged:(NSNotification *)notification {
  218. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  219. [self updateViewColor];
  220. });
  221. }
  222. - (void)dealloc {
  223. [[NSNotificationCenter defaultCenter] removeObserver:self];
  224. }
  225. + (NSWindowController *)sharedInstance {
  226. #if VERSION_DMG
  227. if (ActivityStatusNone == [VerificationManager manager].status) {
  228. if (!firstTrialSingleton) {
  229. firstTrialSingleton = [KMPurchaseCompareWindowController firstTrialWCCheck];
  230. }
  231. return firstTrialSingleton;
  232. } else {
  233. if (!dmgSingleton) {
  234. dmgSingleton = [[KMPurchaseCompareDMGWindowController alloc] init];
  235. }
  236. return dmgSingleton;
  237. }
  238. #else
  239. static KMPurchaseCompareWindowController *singleton = nil;
  240. static dispatch_once_t pred;
  241. dispatch_once(&pred, ^{
  242. singleton = [[KMPurchaseCompareWindowController alloc] init];
  243. });
  244. return singleton;
  245. #endif
  246. }
  247. + (NSWindowController *)firstTrialInstance {
  248. if (!firstTrialSingleton) {
  249. firstTrialSingleton = [KMPurchaseCompareWindowController firstTrialWCCheck];
  250. }
  251. return firstTrialSingleton;
  252. }
  253. + (NSWindowController *)DMGPurchaseInstance {
  254. if (!dmgSingleton) {
  255. dmgSingleton = [[KMPurchaseCompareDMGWindowController alloc] init];
  256. }
  257. return dmgSingleton;
  258. }
  259. #pragma mark - FirstTrial WC
  260. + (KMPurchaseFirstTrialWindowController *)firstTrialWCCheck {
  261. //弹出 试用弹窗UI优化-新用户试用路径 新UI 情况三 点到付费功能
  262. KMPurchaseFirstTrialWindowController *firstTrialWC = [KMPurchaseFirstTrialWindowController currentFirstTrialWC];
  263. firstTrialWC.buttonActionBlock = ^(KMPurchaseFirstTrialWindowController * _Nonnull ftWC, KMButton * _Nonnull btn, NSString * _Nonnull email, NSString * _Nonnull name) {
  264. if (btn.tag == 10001) {
  265. if (ActivityStatusNone == [VerificationManager manager].status ||
  266. ActivityStatusTrialExpire == [VerificationManager manager].status ) {
  267. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"Tbr" withProperties:@{@"Tbr_Btn":@"Btn_Tbr_SecondTrial"}];
  268. [[VerificationManager manager] trialForDays:7
  269. email:email?:[VerificationManager manager].email
  270. name:name?:[VerificationManager manager].accountName
  271. complention:^(ActivityStatus status, NSDictionary *info, NSError *error) {
  272. if (error ||
  273. status != ActivityStatusTrial) {
  274. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
  275. defaultButton:NSLocalizedString(@"Try Again", nil)
  276. alternateButton:nil
  277. otherButton:nil
  278. informativeTextWithFormat:NSLocalizedString(@"Failed to sign up for the free trial. Please make sure your internet connection is available and try again later.", nil), nil];
  279. [alert runModal];
  280. } else {
  281. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeRepeatTrialSuccess];
  282. [vc showWindow:nil];
  283. }
  284. }];
  285. [ftWC close];
  286. } else {
  287. [ftWC close];
  288. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];
  289. vc.callback = ^{
  290. [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
  291. };
  292. [vc showWindow:nil];
  293. }
  294. } else if (btn.tag == 10002) {
  295. #if VERSION_DMG
  296. NSURL *url = [NSURL URLWithString:@"https://www.pdfreaderpro.com/store?utm_source=app_dmg&utm_medium=dmg_puw_free_trial"];
  297. if([SKInspectPublicTool currentisLanguageHans]) {
  298. url = [NSURL URLWithString:@"https://www.pdfreaderpro.com/zh-cn/store?utm_source=app_dmg&utm_medium=dmg_puw_free_trial"];
  299. }
  300. [[NSWorkspace sharedWorkspace] openURL:url];
  301. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_UpgradeBuyNow"}];
  302. #endif
  303. } else if (btn.tag == 10003) {
  304. #if VERSION_DMG
  305. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];//KMVerificationTypeActivate
  306. [vc showWindow:nil];
  307. [ftWC close];
  308. #endif
  309. }
  310. };
  311. return firstTrialWC;
  312. }
  313. #pragma mark - Window Methods
  314. - (void)windowDidLoad {
  315. [super windowDidLoad];
  316. // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
  317. self.window.backgroundColor = [KMAppearance KMColor_Upgrade_Vip_BG];
  318. self.window.movableByWindowBackground = YES;
  319. [self updateViewColor];
  320. self.value1InfoBox.fillColor = [NSColor colorWithRed:17/255. green:6/255. blue:143/255. alpha:1];
  321. self.freeInfoLabel.stringValue = NSLocalizedString(@"Free", nil);
  322. self.value1InfoLabel.stringValue = NSLocalizedString(@"6-Month Plan", nil);
  323. self.value2InfoLabel.stringValue = NSLocalizedString(@"Permanent Version", nil);
  324. self.value3InfoLabel.stringValue = NSLocalizedString(@"Premium Version", nil);
  325. self.freeInfoLabel.font = [NSFont UbuntuMediumFontWithSize:18];
  326. self.value1InfoLabel.font = [NSFont UbuntuMediumFontWithSize:16];
  327. self.value2InfoLabel.font = [NSFont UbuntuMediumFontWithSize:16];
  328. self.value3InfoLabel.font = [NSFont UbuntuMediumFontWithSize:16];
  329. self.value1PurchaseButton.wantsLayer = YES;
  330. self.value1PurchaseButton.layer.backgroundColor = [NSColor colorWithRed:1 green:94/255. blue:44/255. alpha:1].CGColor;
  331. self.value1PurchaseButton.layer.cornerRadius = CGRectGetHeight(self.value1PurchaseButton.frame) / 2.;
  332. self.value1PurchaseBtnLblBtn.wantsLayer = YES;
  333. self.value1PurchaseButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  334. if (self.value1PurchaseBtnLblBtn.enabled) {
  335. if (mouseEntered) {
  336. self.value1PurchaseBtnLblBtn.layer.backgroundColor = [[NSColor blackColor] colorWithAlphaComponent:0.15].CGColor;
  337. } else {
  338. self.value1PurchaseBtnLblBtn.layer.backgroundColor = [NSColor clearColor].CGColor;
  339. }
  340. }
  341. };
  342. self.value1PurchaseBtnLblBtn.layer.cornerRadius = CGRectGetHeight(self.value1PurchaseBtnLblBtn.frame)/2.;
  343. self.value1PurchaseBtnLblBtn.layer.masksToBounds = YES;
  344. self.value2PurchaseButton.wantsLayer = YES;
  345. self.value2PurchaseButton.layer.cornerRadius = CGRectGetHeight(self.value2PurchaseButton.frame) / 2.;
  346. self.value2PurchaseButton.layer.backgroundColor = [NSColor whiteColor].CGColor;
  347. self.value2PurchaseLbl.stringValue = NSLocalizedString(@"Purchase", nil);
  348. self.value2PurchaseLbl.textColor = [NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0];
  349. self.value3PurchaseButton.title = NSLocalizedString(@"", nil);
  350. self.value3PurchaseBtnLbl.stringValue = NSLocalizedString(@"Purchase", nil);
  351. self.value3PurchaseButton.wantsLayer = YES;
  352. [self.value3PurchaseButton setTitleColor:[NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0]];
  353. self.value3PurchaseBtnLbl.textColor = [NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0];
  354. self.value3PurchaseButton.layer.backgroundColor = [NSColor whiteColor].CGColor;
  355. self.value3PurchaseButton.layer.cornerRadius = CGRectGetHeight(self.value3PurchaseButton.frame) / 2.;
  356. self.titleLabel.stringValue = NSLocalizedString(@"Subscribe to All Access Pack to enjoy more expanded features.", nil);
  357. self.switchLabel.stringValue = NSLocalizedString(@"Choose your favorite payment and enjoy flexible upgrades.", nil);
  358. self.switchLabel.textColor = [KMAppearance KMColor_Interactive_M0];
  359. self.switchButton.title = [NSString stringWithFormat:@"%@",NSLocalizedString(@"Pricing and Plans", nil)];
  360. self.box.wantsLayer = YES;
  361. self.box.shadow = [[NSShadow alloc] init];
  362. self.box.layer.shadowOpacity = 0.3;
  363. self.box.layer.shadowColor = [NSColor colorWithRed:0 green:0 blue:0 alpha:0.3].CGColor;
  364. self.box.layer.shadowOffset = NSMakeSize(0,3);
  365. self.box.layer.shadowRadius = 8;
  366. self.box.layer.masksToBounds = NO;
  367. NSButtonCell *cell = self.switchButton.cell;
  368. NSColor *txtColor = [NSColor colorWithRed:102.0/255.0 green:102.0/255.0 blue:102.0/255.0 alpha:1.0];
  369. NSAttributedString *attrStr1 = [cell attributedTitle];
  370. NSMutableAttributedString *myAttr = [[NSMutableAttributedString alloc] initWithAttributedString:attrStr1];
  371. [myAttr addAttribute:NSForegroundColorAttributeName value:txtColor range:NSMakeRange(0, myAttr.length)];
  372. [myAttr addAttribute:NSFontAttributeName value:[NSFont boldSystemFontOfSize:13.0] range:NSMakeRange(0, myAttr.length)];
  373. [cell setAttributedTitle:myAttr];
  374. [self.switchButton updateCell:cell];
  375. self.aboutButton.title = NSLocalizedString(@"About Subscriptions", nil);
  376. self.btnRestore.title = NSLocalizedString(@"Restore", nil);
  377. self.privacyPolicyBtn.title = NSLocalizedString(@"Privacy Policy", nil);
  378. self.termOfSerBtn.title = NSLocalizedString(@"Terms of Service", nil);
  379. self.btnRestore.toolTip = NSLocalizedString(@"Restore", nil);
  380. self.privacyPolicyBtn.toolTip = NSLocalizedString(@"Privacy Policy", nil);
  381. self.termOfSerBtn.toolTip = NSLocalizedString(@"Terms of Service", nil);
  382. [self.aboutButton setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.7]];
  383. [self.btnRestore setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
  384. [self.privacyPolicyBtn setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
  385. [self.termOfSerBtn setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
  386. self.btnRestore.mouseMoveCallback = ^(BOOL mouseEntered) {
  387. if (mouseEntered) {
  388. [self.btnRestore setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.7]];
  389. } else {
  390. [self.btnRestore setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
  391. }
  392. };
  393. self.privacyPolicyBtn.mouseMoveCallback = ^(BOOL mouseEntered) {
  394. if (mouseEntered) {
  395. [self.privacyPolicyBtn setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.7]];
  396. } else {
  397. [self.privacyPolicyBtn setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
  398. }
  399. };
  400. self.termOfSerBtn.mouseMoveCallback = ^(BOOL mouseEntered) {
  401. if (mouseEntered) {
  402. [self.termOfSerBtn setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.7]];
  403. } else {
  404. [self.termOfSerBtn setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
  405. }
  406. };
  407. self.aboutButton.hidden = YES;
  408. [self reloadData];
  409. [self reloadDataContent];
  410. [[IAPProductsManager defaultManager] loadProducts];
  411. __block typeof(self) blockSelf = self;
  412. self.value2PurchaseButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  413. if (blockSelf.value2PurchaseButton.enabled) {
  414. if (mouseEntered) {
  415. [blockSelf.value2PurchaseLbl setTextColor:[NSColor whiteColor]];
  416. blockSelf.value2PurchaseButton.layer.backgroundColor = [NSColor colorWithRed:1 green:94/255.0 blue:44/255.0 alpha:1.0].CGColor;
  417. } else {
  418. [blockSelf.value2PurchaseLbl setTextColor:[NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0]];
  419. blockSelf.value2PurchaseButton.layer.backgroundColor = [NSColor whiteColor].CGColor;
  420. }
  421. }
  422. };
  423. self.value3PurchaseButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  424. if (mouseEntered) {
  425. // [blockSelf.value3PurchaseButton setTitleColor:[NSColor whiteColor]];
  426. blockSelf.value3PurchaseBtnLbl.textColor = [NSColor whiteColor];
  427. blockSelf.value3PurchaseButton.layer.backgroundColor = [NSColor colorWithRed:1 green:94/255.0 blue:44/255.0 alpha:1.0].CGColor;
  428. } else {
  429. // [blockSelf.value3PurchaseButton setTitleColor:[NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0]];
  430. blockSelf.value3PurchaseBtnLbl.textColor = [NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0];
  431. blockSelf.value3PurchaseButton.layer.backgroundColor = [NSColor whiteColor].CGColor;
  432. }
  433. };
  434. 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);
  435. }
  436. - (BOOL)windowShouldClose:(id)sender {
  437. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_Upgrade_Cancel"}];
  438. [self endModal:sender];
  439. return YES;
  440. }
  441. - (void)close {
  442. [super close];
  443. [self endModal:nil];
  444. }
  445. - (IBAction)startModal:(id)sender {
  446. [NSApp stopModal];
  447. NSInteger modalCode;
  448. self.modalSession = [NSApp beginModalSessionForWindow:self.window];
  449. do {
  450. modalCode = [NSApp runModalSession:self.modalSession];
  451. } while (modalCode == NSModalResponseContinue);
  452. }
  453. - (IBAction)endModal:(id)sender {
  454. if (self.modalSession) {
  455. [NSApp stopModal];
  456. [NSApp endModalSession:self.modalSession];
  457. [self.window orderOut:self];
  458. self.modalSession = nil;
  459. }
  460. }
  461. - (void)showWindowRestore:(id)sender {
  462. [self showWindow:sender];
  463. [self buttonItemClicked_Restore:nil];
  464. }
  465. - (void)showWindow:(id)sender {
  466. [super showWindow:sender];
  467. [self reloadData];
  468. }
  469. #pragma mark - Private Methods
  470. - (void)reloadData {
  471. if ([IAPProductsManager defaultManager].isAvailableAllFunction) {
  472. self.value1PurchaseButton.enabled = NO;
  473. self.value2PurchaseButton.enabled = NO;
  474. self.value2PurchaseLbl.textColor = [NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:0.5];
  475. } else {
  476. self.value1PurchaseButton.enabled = YES;
  477. self.value2PurchaseButton.enabled = YES;
  478. self.value2PurchaseLbl.textColor = [NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0];
  479. }
  480. self.value1PurchaseBtnLblBtn.enabled = self.value1PurchaseButton.enabled;
  481. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
  482. if ([IAPProductsManager defaultManager].newlyMonthProduct.isTrialPeriod) {
  483. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
  484. if ([IAPProductsManager defaultManager].newlyMonthProduct.isSubscribed) {
  485. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribed", nil);
  486. }
  487. } else {
  488. if ([IAPProductsManager defaultManager].newlyMonthProduct.isSubscribed) {
  489. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribed", nil);
  490. } else {
  491. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Free Trial", nil);
  492. if (@available(macOS 10.13.2, *)) {
  493. #if !VERSION_DMG
  494. if (![IAPProductsManager defaultManager].newlyMonthProduct.product.introductoryPrice) {
  495. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
  496. }
  497. #endif
  498. }
  499. }
  500. }
  501. if (self.value1PurchaseBtnLblBtn.enabled) {
  502. [self.value1PurchaseBtnLbl setTextColor:[NSColor whiteColor]];
  503. } else {
  504. [self.value1PurchaseBtnLbl setTextColor:[[NSColor whiteColor] colorWithAlphaComponent:0.5]];
  505. }
  506. self.value2PurchaseLblBtn.enabled = self.value2PurchaseButton.enabled;
  507. NSString *averageMonthPrice = nil;
  508. NSString *monthPrice = nil;
  509. NSString *allPrice = nil;
  510. if ([IAPProductsManager defaultManager].newlyMonthProduct.isOffers) {
  511. self.specialView1.hidden = NO;
  512. averageMonthPrice = [IAPProductsManager defaultManager].newlyMonthProduct.offersAveragePrice;
  513. monthPrice = [IAPProductsManager defaultManager].newlyMonthProduct.offersPrice;
  514. self.topButtonOffset.constant = 20;
  515. } else {
  516. self.specialView1.hidden = YES;
  517. averageMonthPrice = [IAPProductsManager defaultManager].newlyMonthProduct.averagePrice;
  518. monthPrice = [IAPProductsManager defaultManager].newlyMonthProduct.price;
  519. self.topButtonOffset.constant = 10;
  520. }
  521. if ([IAPProductsManager defaultManager].allAccessProduct.isOffers) {
  522. self.topButtonOffset.constant = 20;
  523. self.specialView.hidden = NO;
  524. allPrice = [IAPProductsManager defaultManager].allAccessProduct.offersPrice;
  525. } else {
  526. self.topButtonOffset.constant = 10;
  527. self.specialView.hidden = YES;
  528. allPrice = [IAPProductsManager defaultManager].allAccessProduct.price;
  529. }
  530. CGFloat off = 1 -[IAPProductsManager defaultManager].allAccessProduct.offers;
  531. NSString *offString = [NSString stringWithFormat:@"%.f%%",off * 100];
  532. self.specialLabel.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@ off", @""),offString];
  533. off = 1 -[IAPProductsManager defaultManager].newlyMonthProduct.offers;
  534. offString = [NSString stringWithFormat:@"%.f%%",off * 100];
  535. self.specialLabel1.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@ off", @""),offString];
  536. NSImage *image = [NSImage imageNamed:@"KMImageNameCompareTagBG"];
  537. self.specialImageView.image = image;
  538. self.specialImageView1.image = image;
  539. if (KMKdanRemoteConfig.remoteConfig.showAPP_AveragePrice) {
  540. self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", averageMonthPrice, NSLocalizedString(@"mon", nil)];
  541. } else {
  542. self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice, NSLocalizedString(@"6mon", nil)];
  543. }
  544. self.value1PurchaseLabel.textColor = [NSColor colorWithRed:1 green:231/255. blue:106/255. alpha:1.];
  545. NSString *tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 6 months at %@", nil), monthPrice];
  546. if ([self.value1PurchaseBtnLbl.stringValue isEqualToString:NSLocalizedString(@"Free Trial", nil)]) {
  547. tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 6 months at %@ after 7-day trial ends.", nil), monthPrice];
  548. #if !VERSION_DMG
  549. if ([IAPProductsManager defaultManager].newlyMonthProduct.product) {
  550. if (@available(macOS 10.13.2, *)) {
  551. tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 6 months at %@ after %@-day trial ends.", nil), monthPrice,@([IAPProductsManager defaultManager].newlyMonthProduct.product.introductoryPrice.subscriptionPeriod.numberOfUnits)];
  552. }
  553. }
  554. #endif
  555. }
  556. if (@available(macOS 10.13.2, *)) {
  557. #if !VERSION_DMG
  558. if (![IAPProductsManager defaultManager].newlyMonthProduct.product.introductoryPrice) {
  559. tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 6 months at %@", nil), monthPrice];
  560. }
  561. #endif
  562. }
  563. self.value1PurchaseSubLabel.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@", nil), tTips];
  564. self.value2PurchaseLabel.stringValue = allPrice?:@"";
  565. self.value2PurchaseLabel.textColor = [NSColor colorWithRed:1 green:231/255. blue:106/255. alpha:1.];
  566. self.value2PurchaseSubLabel.stringValue = NSLocalizedString(@"one-time purchase", nil);
  567. self.value3PurchaseLabel.stringValue = NSLocalizedString(@"USD $59.99", nil);
  568. self.value3PurchaseLabel.textColor = [NSColor colorWithRed:1 green:231/255. blue:106/255. alpha:1.];
  569. self.value3PurchaseSubLabel.stringValue = NSLocalizedString(@"one-time purchase", nil);
  570. self.value1PurchaseBtnLbl.font = [NSFont UbuntuBoldFontWithSize:16];
  571. self.value2PurchaseLbl.font = [NSFont UbuntuBoldFontWithSize:16];
  572. self.value3PurchaseBtnLbl.font = [NSFont UbuntuBoldFontWithSize:16];
  573. self.value1PurchaseLabel.font = [NSFont UbuntuBoldFontWithSize:22];
  574. self.value2PurchaseLabel.font = [NSFont UbuntuBoldFontWithSize:22];
  575. self.value3PurchaseLabel.font = [NSFont UbuntuBoldFontWithSize:22];
  576. }
  577. - (void)reloadDataContent {
  578. self.dataSource = @[@"PDF to Office",
  579. @[@"Convert PDFs to Word, HTML, TXT, JPEG or PNG files",@"Only first 10 pages",@"Advanced",@"Advanced",@"Standard"],
  580. @[@"Turn PDF to PPT, Excel, RTF, CSV, and more",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
  581. @[@"Convert PDF to TIFF, BMP, GIF or TGA files",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
  582. @"Edit PDF",
  583. @[@"Add and edit text in PDF",@"X",@"✓",@"✓",@"✓"],
  584. @[@"Edit, crop, replace image in PDF",@"X",@"✓",@"✓",@"✓"],
  585. @"OCR",
  586. @[@"Extract texts from image-based or scanned PDF",@"X",@"✓",@"✓",@"✓"],
  587. @"Organize Pages",
  588. @[@"Extract, rotate, rearrange, replace, add, delete pages",@"X",@"✓",@"✓",@"✓"],
  589. @[@"Split PDFs into multiple files",@"X",@"✓",@"✓",@"✓"],
  590. @"Advanced Editing Tools",
  591. @[@"Merge multiple documents into a new PDF",@"Up to 2 files or 20 MB",@"✓",@"∞",@"∞"],
  592. @[@"Add & edit watermark",@"X",@"✓",@"✓",@"✓"],
  593. @[@"Add header, footer, page numbers",@"X",@"✓",@"✓",@"✓"],
  594. @[@"Add Bates Number",@"X",@"✓",@"✓",@"✓"],
  595. @[@"Insert PDF page background by color or image",@"X",@"✓",@"✓",@"✓"],
  596. @[@"Create fattened copies",@"X",@"✓",@"✓",@"✓"],
  597. @[@"Extract Images",@"X",@"✓",@"✓",@"✓"],
  598. @[@"Extract tables",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
  599. @"Fill & Sign",
  600. @[@"Create digital signature",@"X",@"✓",@"✓",@"✓"],
  601. @[@"Create & Edit & Fill Adobe Fillable PDF Forms",@"X",@"✓",@"✓",@"✓"],
  602. @"Security",
  603. @[@"Batch encrypting PDF documents",@"X",@"✓",@"✓",@"✓"],
  604. @[@"PDF Password Remover",@"X",@"✓",@"✓",@"✓"],
  605. @[@"Redact sensitive information",@"X",@"✓",@"✓",@"✓"],
  606. @"Create PDF",
  607. @[@"Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs",@"1 file",@"✓",@"✓",@"✓"],
  608. @[@"Create PDFs from a scanner and iOS devices",@"X",@"✓",@"✓",@"✓"],
  609. @"Annotations",
  610. @[@"Customize PDF stamps",@"X",@"✓",@"✓",@"✓",@"✓"],
  611. @[@"Hyperlink",@"Page Number",@"Page Number, URL, Email",@"Page Number, URL, Email",@"Page Number, URL, Email"],
  612. @[@"Signature",@"Standard",@"Advanced",@"Advanced",@"Advanced"],
  613. @[@"Table",@"X",@"✓",@"✓",@"✓",@"✓"],
  614. @"View PDF",
  615. @[@"Multi-tab viewer",@"X",@"✓",@"✓",@"✓"],
  616. @[@"Various printing types: poster, booklet, multi-page printing",@"X",@"✓",@"✓",@"✓"],
  617. @[@"Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more",@"X",@"✓",@"✓",@"✓"],
  618. @[@"Split View to compare files",@"X",@"✓",@"✓",@"✓"],
  619. @"Subscription Based Solution",
  620. @[@"Access all premium features in app",@"X",@"6 months",@"∞",@"∞"],
  621. @[@"Priority customer support",@"X",@"✓",@"✓",@"✓"],
  622. @[@"Ad-free",@"X",@"✓",@"✓",@"✓"],
  623. @{}
  624. ];
  625. [self.tableView reloadData];
  626. }
  627. - (void)addWaingView:(NSView *)view {
  628. [self removeWaitingView:view];
  629. WaitingView *wView = [[WaitingView alloc] initWithFrame:view.bounds];
  630. [wView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
  631. [view addSubview:wView];
  632. [wView startAnimation];
  633. }
  634. - (void)removeWaitingView:(NSView *)view {
  635. for (id v in view.subviews) {
  636. if ([[v class] isSubclassOfClass:[WaitingView class]]) {
  637. [v removeFromSuperview];
  638. break;
  639. }
  640. }
  641. }
  642. - (void)updateViewColor {
  643. self.box.fillColor = [KMAppearance KMColor_Layout_L1];
  644. self.labelbox.fillColor = [NSColor clearColor];
  645. self.tableView.backgroundColor = [KMAppearance KMColor_Layout_L0];
  646. self.textView.backgroundColor = [NSColor clearColor];
  647. self.textView.textColor = [[NSColor whiteColor] colorWithAlphaComponent:0.5];
  648. self.value1PurchaseSubLabel.textColor = self.value2PurchaseSubLabel.textColor = self.value3PurchaseSubLabel.textColor = [KMAppearance KMColor_Layout_W0];
  649. }
  650. #pragma mark - Button Actions
  651. - (IBAction)buttonItemClicked_Subscribe:(id)sender {
  652. [[IAPProductsManager defaultManager] makeProduct:[IAPProductsManager defaultManager].newlyMonthProduct];
  653. [self addWaingView:self.window.contentView];
  654. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_Upgrade_6Mon"}];
  655. }
  656. - (IBAction)buttonItemClicked_Restore:(id)sender {
  657. [[IAPProductsManager defaultManager] restoreSubscriptions];
  658. [self addWaingView:self.window.contentView];
  659. }
  660. - (IBAction)buttonItemClicked_Upgrade:(id)sender {
  661. [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"macappstore://apps.apple.com/app/id825459243?mt=12"]];
  662. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_Upgrade_Premium"}];
  663. }
  664. - (IBAction)privacyPolicyAction:(NSButton *)sender {
  665. [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://www.pdfreaderpro.com/privacy-policy"]];
  666. }
  667. - (IBAction)termOfSerAction:(NSButton *)sender {
  668. [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://www.pdfreaderpro.com/terms_of_service"]];
  669. }
  670. - (IBAction)buttonItemClicked_LicenseUpgrade:(id)sender {
  671. [[IAPProductsManager defaultManager] makeProduct:[IAPProductsManager defaultManager].allAccessProduct];
  672. [self addWaingView:self.window.contentView];
  673. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_Upgrade_Permanent"}];
  674. }
  675. - (IBAction)buttonItemClicked_AboutSubscriptions:(id)sender {
  676. NSString *tMessage = [NSString stringWithFormat:@"%@\n%@\n\n%@\n%@\n%@\n%@\n%@\n\n%@\n%@\n\n",
  677. @"Subscription plans: ",
  678. @"Subscriptions: USD $39.99/(6 months), USD $79.99/(one-time purchase) ",
  679. @"- Subscriptions will be charged through your iTunes account at the confirmation of purchase. ",
  680. @"- Your subscriptions will automatically renew unless cancelled at least 24 hours before the end of current subscription period. ",
  681. @"- 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. ",
  682. @"- You may manage your subscriptions in your iTunes Account Settings after purchase. ",
  683. @"- No cancellation of the current subscription is allowed during an active subscription period. ",
  684. @"- Terms of service: \nhttps://www.pdfreaderpro.com/terms_of_service ",
  685. @"- Privacy Policy: \nhttps://www.pdfreaderpro.com/privacy-policy "];
  686. NSAlert *alert = [[NSAlert alloc] init];
  687. [alert setAlertStyle:NSAlertStyleInformational];
  688. [alert setMessageText:NSLocalizedString(tMessage, nil)];
  689. [alert runModal];
  690. }
  691. - (IBAction)buttonItemClicked_CloseWindow:(id)sender {
  692. [self close];
  693. }
  694. #pragma mark - NSTableViewDataSource Methods
  695. - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView {
  696. return self.dataSource.count;
  697. }
  698. - (id)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
  699. id object = [self.dataSource objectAtIndex:row];
  700. if ([object isKindOfClass:[NSString class]]) {
  701. KMPurchaseCompareHeaderCell *cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareHeaderCellIdentifier owner:self];
  702. cellView.textField.stringValue = NSLocalizedString(object, nil);
  703. return cellView;
  704. } else if ([object isKindOfClass:[NSArray class]]) {
  705. KMPurchaseCompareCell *cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareCellIdentifier owner:self];
  706. NSString *value = [(NSArray *)object count] > 0 ? object[0] : @"";
  707. NSString *value1 = [(NSArray *)object count] > 1 ? object[1] : @"";
  708. NSString *value2 = [(NSArray *)object count] > 2 ? object[2] : @"";
  709. NSString *value3 = [(NSArray *)object count] > 3 ? object[3] : @"";
  710. NSString *value4 = [(NSArray *)object count] > 4 ? object[4] : @"";
  711. cellView.textField.stringValue = NSLocalizedString(value, nil);
  712. cellView.lineBox.hidden = NO;
  713. if (row + 1 == (NSInteger)self.dataSource.count) {
  714. cellView.lineBox.hidden = YES;
  715. } else {
  716. id nextobject = [self.dataSource objectAtIndex:row+1];
  717. if ([nextobject isKindOfClass:[NSString class]]) {
  718. cellView.lineBox.hidden = YES;
  719. }
  720. }
  721. if (row + 2 == (NSInteger)self.dataSource.count) {
  722. cellView.boxBottomConst.constant = 0;
  723. } else {
  724. cellView.boxBottomConst.constant = -4;
  725. }
  726. if ([value1 isEqualToString:@"X"]) {
  727. cellView.value1Label.stringValue = @"";
  728. cellView.value1ImageView.image = [NSImage imageNamed:@"compare_nosupport"];
  729. } else if ([value1 isEqualToString:@"✓"]) {
  730. cellView.value1Label.stringValue = @"";
  731. cellView.value1ImageView.image = [NSImage imageNamed:@"compare_support"];
  732. } else if ([value1 isEqualToString:@"∞"]) {
  733. cellView.value1Label.stringValue = @"";
  734. cellView.value1ImageView.image = [NSImage imageNamed:@"compare_00"];
  735. } else {
  736. cellView.value1Label.stringValue = NSLocalizedString(value1, nil);
  737. cellView.value1ImageView.image = nil;
  738. }
  739. if ([value2 isEqualToString:@"X"]) {
  740. cellView.value2Label.stringValue = @"";
  741. cellView.value2ImageView.image = [NSImage imageNamed:@"compare_nosupport"];
  742. } else if ([value2 isEqualToString:@"✓"]) {
  743. cellView.value2Label.stringValue = @"";
  744. cellView.value2ImageView.image = [NSImage imageNamed:@"compare_support"];
  745. } else if ([value2 isEqualToString:@"∞"]) {
  746. cellView.value2Label.stringValue = @"";
  747. cellView.value2ImageView.image = [NSImage imageNamed:@"compare_00"];
  748. } else {
  749. cellView.value2Label.stringValue = NSLocalizedString(value2, nil);
  750. cellView.value2ImageView.image = nil;
  751. }
  752. if ([value3 isEqualToString:@"X"]) {
  753. cellView.value3Label.stringValue = @"";
  754. cellView.value3ImageView.image = [NSImage imageNamed:@"compare_nosupport"];
  755. } else if ([value3 isEqualToString:@"✓"]) {
  756. cellView.value3Label.stringValue = @"";
  757. cellView.value3ImageView.image = [NSImage imageNamed:@"compare_support"];
  758. } else if ([value3 isEqualToString:@"∞"]) {
  759. cellView.value3Label.stringValue = @"";
  760. cellView.value3ImageView.image = [NSImage imageNamed:@"compare_00"];
  761. } else {
  762. cellView.value3Label.stringValue = NSLocalizedString(value3, nil);
  763. cellView.value3ImageView.image = nil;
  764. }
  765. if ([value4 isEqualToString:@"X"]) {
  766. cellView.value4Label.stringValue = @"";
  767. cellView.value4ImageView.image = [NSImage imageNamed:@"compare_nosupport"];
  768. } else if ([value4 isEqualToString:@"✓"]) {
  769. cellView.value4Label.stringValue = @"";
  770. cellView.value4ImageView.image = [NSImage imageNamed:@"compare_support"];
  771. } else if ([value4 isEqualToString:@"∞"]) {
  772. cellView.value4Label.stringValue = @"";
  773. cellView.value4ImageView.image = [NSImage imageNamed:@"compare_00"];
  774. } else {
  775. cellView.value4Label.stringValue = NSLocalizedString(value4, nil);
  776. cellView.value4ImageView.image = nil;
  777. }
  778. return cellView;
  779. } else if ([object isKindOfClass:[NSDictionary class]]) {
  780. KMPurchaseCompareEmptyCell *cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareEmptyCellIdentifier owner:self];
  781. return cellView;
  782. }
  783. return nil;
  784. }
  785. - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row {
  786. NSTableCellView *cellView = nil;
  787. id object = [self.dataSource objectAtIndex:row];
  788. if ([object isKindOfClass:[NSString class]]) {
  789. cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareHeaderCellIdentifier owner:self];
  790. cellView.textField.stringValue = NSLocalizedString(object, nil);
  791. } else if ([object isKindOfClass:[NSArray class]]) {
  792. cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareCellIdentifier owner:self];
  793. cellView.textField.stringValue = NSLocalizedString(object[0], nil);
  794. } else if ([object isKindOfClass:[NSDictionary class]]) {
  795. return 40;
  796. }
  797. if (cellView) {
  798. [cellView layoutSubtreeIfNeeded];
  799. return cellView.frame.size.height;
  800. } else {
  801. return 0;
  802. }
  803. }
  804. #pragma mark - InAppPurchaseManager Notification
  805. - (void)IAPProductFailedNotification:(NSNotification*)notification {
  806. [self removeWaitingView:self.window.contentView];
  807. }
  808. - (void)IAPProductPurchasedNotification:(NSNotification*)notification {
  809. [self removeWaitingView:self.window.contentView];
  810. [self reloadData];
  811. }
  812. - (void)IAPProductLoadedNotification:(NSNotification*)notification {
  813. [self reloadData];
  814. }
  815. - (void)IAPProductRestoreFinishedNotification:(NSNotification *)notification {
  816. [self removeWaitingView:self.window.contentView];
  817. [self reloadData];
  818. }
  819. - (void)IAPProductRestoreFailedNotification:(NSNotification *)notification {
  820. [self removeWaitingView:self.window.contentView];
  821. }
  822. - (void)IAPSubscriptionLoadedNotification:(NSNotification *)notification {
  823. [self removeWaitingView:self.window.contentView];
  824. [self reloadData];
  825. }
  826. @end