KMPurchaseCompareWindowController.m 47 KB

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