KMPurchaseCompareWindowController.m 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402
  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 "WaitingView.h"
  11. //#import "NSButton+TitleColor.h"
  12. //#import "HyperLinkButton.h"
  13. //#import "IAPProductsManager.h"
  14. //#import "GAIManager.h"
  15. //#import "NSImage_SKExtensions.h"
  16. //
  17. //#import "KMButton.h"
  18. //#import "KMCustomButton.h"
  19. //#import "KMKdanRemoteConfig.h"
  20. //#import "VerificationManager.h"
  21. //#import "KMVerificationWindowController.h"
  22. //#import "SKInspectPublicTool.h"
  23. //#import "FMTrackEventManager.h"
  24. //#import "NSFont+Custom.h"
  25. //#if !VERSION_DMG
  26. //#import <StoreKit/StoreKit.h>
  27. //#endif
  28. #import "KMDiscountToSaveWindowController.h"
  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 NSBox *value1InfoTypeBox;
  149. @property (assign) IBOutlet NSTextField *sixMouthProLabel;
  150. @property (assign) IBOutlet NSTextField *oneYearProLabel;
  151. @property (assign) IBOutlet NSBox *switchBox;
  152. @property (assign) IBOutlet NSButton *switchBtn;
  153. @property (assign) IBOutlet NSView *switchCircleView;
  154. @property (assign) IBOutlet NSLayoutConstraint *switchCircleLeftConst;
  155. @property (assign) IBOutlet NSBox *saleBox;
  156. @property (assign) IBOutlet NSImageView *saleIv;
  157. @property (assign) IBOutlet NSTextField *saleLabel;
  158. @property (assign) IBOutlet NSTextField *value1InfoLabel;
  159. @property (nonatomic,assign) IBOutlet NSTextField *value1PurchaseLabel;
  160. @property (nonatomic,assign) IBOutlet NSTextField *value1PurchaseSubLabel;
  161. @property (nonatomic,assign) IBOutlet KMCustomButton *value1PurchaseButton;
  162. @property (assign) IBOutlet NSTextField *value1PurchaseBtnLbl;
  163. @property (assign) IBOutlet NSTextField *value1PurchaseOriPriceLbl;
  164. @property (assign) IBOutlet NSButton *value1PurchaseBtnLblBtn;
  165. @property (assign) IBOutlet NSView *value2InfoView;
  166. @property (assign) IBOutlet NSTextField *value2InfoLabel;
  167. @property (nonatomic,assign) IBOutlet NSTextField *value2PurchaseLabel;
  168. @property (nonatomic,assign) IBOutlet NSTextField *value2PurchaseSubLabel;
  169. @property (nonatomic,assign) IBOutlet KMButton *value2PurchaseButton;
  170. @property (assign) IBOutlet NSTextField *value2PurchaseLbl;
  171. @property (assign) IBOutlet KMButton *value2PurchaseLblBtn;
  172. @property (assign) IBOutlet NSView *value3InfoView;
  173. @property (assign) IBOutlet NSTextField *value3InfoLabel;
  174. @property (nonatomic,assign) IBOutlet NSTextField *value3PurchaseLabel;
  175. @property (nonatomic,assign) IBOutlet NSTextField *value3PurchaseSubLabel;
  176. @property (nonatomic,assign) IBOutlet KMButton *value3PurchaseButton;
  177. @property (strong) IBOutlet NSTextField *value3PurchaseBtnLbl;
  178. @property (nonatomic,assign) IBOutlet NSButton *aboutButton;
  179. @property (nonatomic,assign) IBOutlet HyperLinkButton *btnRestore;
  180. @property (assign) IBOutlet HyperLinkButton *privacyPolicyBtn;
  181. @property (assign) IBOutlet HyperLinkButton *termOfSerBtn;
  182. @property (nonatomic,assign) IBOutlet NSTextView *textView;
  183. @property (nonatomic,assign) IBOutlet NSView *specialView;
  184. @property (nonatomic,assign) IBOutlet NSImageView *specialImageView;
  185. @property (nonatomic,assign) IBOutlet NSTextField *specialLabel;
  186. @property (nonatomic,assign) IBOutlet NSView *specialView1;
  187. @property (nonatomic,assign) IBOutlet NSImageView *specialImageView1;
  188. @property (nonatomic,assign) IBOutlet NSTextField *specialLabel1;
  189. @property (nonatomic,assign) IBOutlet NSBox *box;
  190. @property (nonatomic,assign) IBOutlet NSBox *labelbox;
  191. @property (assign) IBOutlet NSLayoutConstraint *topButtonOffset;
  192. @property (nonatomic, retain) CALayer *value1Layer;
  193. @property (nonatomic, retain) KMDiscountToSaveWindowController *discountToSaveWinC;
  194. @property (nonatomic, assign) BOOL isPurchaseSwitch;
  195. @property (assign) IBOutlet NSLayoutConstraint *billedTopConst;
  196. @property (weak) IBOutlet NSImageView *discountYearly;
  197. @property (weak) IBOutlet NSImageView *discountPermanent;
  198. @property (weak) IBOutlet NSImageView *discountPremium;
  199. @end
  200. @implementation KMPurchaseCompareWindowController
  201. #pragma mark - Init Methods
  202. - (id)init {
  203. if (self = [super initWithWindowNibName:@"KMPurchaseCompareWindowController"]) {
  204. [[NSNotificationCenter defaultCenter] addObserver:self
  205. selector:@selector(IAPProductLoadedNotification:)
  206. name:KMIAPProductLoadedNotification
  207. object:nil];
  208. [[NSNotificationCenter defaultCenter] addObserver:self
  209. selector:@selector(IAPSubscriptionLoadedNotification:)
  210. name:KMIAPSubscriptionLoadedNotification
  211. object:nil];
  212. [[NSNotificationCenter defaultCenter] addObserver:self
  213. selector:@selector(IAPProductPurchasedNotification:)
  214. name:KMIAPProductPurchasedNotification
  215. object:nil];
  216. [[NSNotificationCenter defaultCenter] addObserver:self
  217. selector:@selector(IAPProductFailedNotification:)
  218. name:KMIAPProductFailedNotification
  219. object:nil];
  220. [[NSNotificationCenter defaultCenter] addObserver:self
  221. selector:@selector(IAPProductRestoreFinishedNotification:)
  222. name:KMIAPProductRestoreFinishedNotification
  223. object:nil];
  224. [[NSNotificationCenter defaultCenter] addObserver:self
  225. selector:@selector(IAPProductRestoreFailedNotification:)
  226. name:KMIAPProductRestoreFailedNotification
  227. object:nil];
  228. [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
  229. self.isPurchaseSwitch = false;
  230. }
  231. return self;
  232. }
  233. - (void)themeChanged:(NSNotification *)notification {
  234. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  235. [self updateViewColor];
  236. });
  237. }
  238. - (void)dealloc {
  239. [[NSNotificationCenter defaultCenter] removeObserver:self];
  240. }
  241. + (NSWindowController *)sharedInstance {
  242. #if VERSION_DMG
  243. if (ActivityStatusNone == [VerificationManager manager].status) {
  244. static KMPurchaseFirstTrialWindowController *singleton = nil;
  245. static dispatch_once_t pred;
  246. dispatch_once(&pred, ^{
  247. singleton = [KMPurchaseCompareWindowController firstTrialWCCheck];
  248. });
  249. return singleton;
  250. } else {
  251. static KMPurchaseCompareDMGWindowController *singleton = nil;
  252. static dispatch_once_t pred;
  253. dispatch_once(&pred, ^{
  254. singleton = [[KMPurchaseCompareDMGWindowController alloc] init];
  255. });
  256. return singleton;
  257. }
  258. #else
  259. static KMPurchaseCompareWindowController *singleton = nil;
  260. static dispatch_once_t pred;
  261. dispatch_once(&pred, ^{
  262. singleton = [[KMPurchaseCompareWindowController alloc] init];
  263. });
  264. return singleton;
  265. #endif
  266. }
  267. + (NSWindowController *)DMGPurchaseInstance {
  268. static KMPurchaseCompareDMGWindowController *singleton = nil;
  269. static dispatch_once_t pred;
  270. dispatch_once(&pred, ^{
  271. singleton = [[KMPurchaseCompareDMGWindowController alloc] init];
  272. });
  273. return singleton;
  274. }
  275. #pragma mark - FirstTrial WC
  276. + (KMPurchaseFirstTrialWindowController *)firstTrialWCCheck {
  277. //弹出 试用弹窗UI优化-新用户试用路径 新UI 情况三 点到付费功能
  278. KMPurchaseFirstTrialWindowController *firstTrialWC = [KMPurchaseFirstTrialWindowController currentFirstTrialWC];
  279. firstTrialWC.buttonActionBlock = ^(KMPurchaseFirstTrialWindowController * _Nonnull ftWC, KMButton * _Nonnull btn, NSString * _Nonnull email, NSString * _Nonnull name) {
  280. if (btn.tag == 10001) {
  281. if (ActivityStatusNone == [VerificationManager manager].status ||
  282. ActivityStatusTrialExpire == [VerificationManager manager].status ) {
  283. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"Tbr" withProperties:@{@"Tbr_Btn":@"Btn_Tbr_SecondTrial"}];
  284. [[VerificationManager manager] trialForDays:7
  285. email:email?:[VerificationManager manager].email
  286. name:name?:[VerificationManager manager].accountName
  287. complention:^(ActivityStatus status, NSDictionary *info, NSError *error) {
  288. if (error ||
  289. status != ActivityStatusTrial) {
  290. NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Activation Error", nil)
  291. defaultButton:NSLocalizedString(@"Try Again", nil)
  292. alternateButton:nil
  293. otherButton:nil
  294. informativeTextWithFormat:NSLocalizedString(@"Failed to sign up for the free trial. Please make sure your internet connection is available and try again later.", nil), nil];
  295. [alert runModal];
  296. } else {
  297. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeRepeatTrialSuccess];
  298. [vc showWindow:nil];
  299. }
  300. }];
  301. [ftWC close];
  302. } else {
  303. [ftWC close];
  304. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];
  305. vc.callback = ^{
  306. [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
  307. };
  308. [vc showWindow:nil];
  309. }
  310. } else if (btn.tag == 10002) {
  311. #if VERSION_DMG
  312. NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?utm_source=app_dmg&utm_medium=dmg_puw_free_trial", Swift_oc_Tool.Store_Link_OC]];
  313. [[NSWorkspace sharedWorkspace] openURL:url];
  314. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_UpgradeBuyNow"}];
  315. #endif
  316. } else if (btn.tag == 10003) {
  317. #if VERSION_DMG
  318. KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeActivate];//KMVerificationTypeActivate
  319. [vc showWindow:nil];
  320. [ftWC close];
  321. #endif
  322. }
  323. };
  324. return firstTrialWC;
  325. }
  326. #pragma mark - Window Methods
  327. - (void)windowDidLoad {
  328. [super windowDidLoad];
  329. // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
  330. self.window.backgroundColor = [KMAppearance KMColor_Upgrade_Vip_BG];
  331. self.window.movableByWindowBackground = YES;
  332. [self updateViewColor];
  333. self.value1InfoBox.fillColor = [NSColor colorWithRed:17/255. green:6/255. blue:143/255. alpha:1];
  334. self.freeInfoLabel.stringValue = NSLocalizedString(@"Free", nil);
  335. self.value1InfoLabel.stringValue = NSLocalizedString(@"6-Month Plan", nil);
  336. self.value2InfoLabel.stringValue = NSLocalizedString(@"Permanent Version", nil);
  337. self.value3InfoLabel.stringValue = NSLocalizedString(@"Premium Version", nil);
  338. self.freeInfoLabel.font = [NSFont UbuntuMediumFontWithSize:18];
  339. self.value1InfoLabel.font = [NSFont UbuntuMediumFontWithSize:16];
  340. self.value2InfoLabel.font = [NSFont UbuntuMediumFontWithSize:16];
  341. self.value3InfoLabel.font = [NSFont UbuntuMediumFontWithSize:16];
  342. self.value1InfoTypeBox.fillColor = [NSColor clearColor];
  343. self.value1InfoTypeBox.borderWidth = 0;
  344. self.sixMouthProLabel.stringValue = NSLocalizedString(@"6-Month Plan", @"");
  345. self.sixMouthProLabel.textColor = NSColor.whiteColor;
  346. self.sixMouthProLabel.font = [NSFont UbuntuMediumFontWithSize:14];
  347. self.sixMouthProLabel.lineBreakMode = NSLineBreakByTruncatingTail;
  348. self.sixMouthProLabel.toolTip = self.sixMouthProLabel.stringValue;
  349. self.sixMouthProLabel.alignment = NSTextAlignmentCenter;
  350. // #757780
  351. self.oneYearProLabel.stringValue = NSLocalizedString(@"1-year Plan", @"");
  352. self.oneYearProLabel.textColor = NSColor.whiteColor;
  353. self.oneYearProLabel.font = [NSFont UbuntuMediumFontWithSize:14];
  354. self.oneYearProLabel.lineBreakMode = NSLineBreakByTruncatingTail;
  355. self.oneYearProLabel.toolTip = self.oneYearProLabel.stringValue;
  356. self.oneYearProLabel.alignment = NSTextAlignmentCenter;
  357. self.switchBox.fillColor = [NSColor colorWithWhite:1 alpha:0.2];
  358. self.switchBox.cornerRadius = 12;
  359. self.switchBox.borderWidth = 1;
  360. self.switchBox.borderColor = [NSColor colorWithRed:235/255.0 green:236/255.0 blue:240/255.0 alpha:1.0];
  361. self.switchCircleView.wantsLayer = true;
  362. self.switchCircleView.layer.cornerRadius = 8;
  363. self.switchCircleView.layer.backgroundColor = [NSColor whiteColor].CGColor;
  364. self.switchBtn.title = @"";
  365. self.switchBtn.target = self;
  366. self.switchBtn.action = @selector(switchAction:);
  367. // self.saleLabel.stringValue = NSLocalizedString(@"30%\nOFF", @"");
  368. // self.saleLabel.textColor = NSColor.whiteColor;
  369. // self.saleLabel.wantsLayer = true;
  370. // self.saleLabel.layer.transform = CATransform3DMakeRotation(M_PI/4, 0, 1, 0);
  371. // self.saleLabel.layer.transform.m34 = 1/500.0;
  372. // self.saleLabel.layer.affineTransform = CGAffineTransformMakeRotation(M_PI/2);
  373. // self.saleLabel.superview.wantsLayer = true;
  374. // self.saleLabel.superview.layer.transform = CATransform3DMakeRotation(M_PI/4, 0, 0, 1);
  375. self.saleLabel.hidden = true;
  376. self.saleLabel.superview.hidden = true;
  377. self.saleBox.borderWidth = 0;
  378. self.value1PurchaseButton.wantsLayer = YES;
  379. self.value1PurchaseButton.layer.backgroundColor = [NSColor colorWithRed:1 green:94/255. blue:44/255. alpha:1].CGColor;
  380. self.value1PurchaseButton.layer.cornerRadius = CGRectGetHeight(self.value1PurchaseButton.frame) / 2.;
  381. self.value1PurchaseBtnLblBtn.wantsLayer = YES;
  382. self.value1PurchaseButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  383. if (self.value1PurchaseBtnLblBtn.enabled) {
  384. if (mouseEntered) {
  385. self.value1PurchaseBtnLblBtn.layer.backgroundColor = [[NSColor blackColor] colorWithAlphaComponent:0.15].CGColor;
  386. } else {
  387. self.value1PurchaseBtnLblBtn.layer.backgroundColor = [NSColor clearColor].CGColor;
  388. }
  389. }
  390. };
  391. self.value1PurchaseBtnLblBtn.layer.cornerRadius = CGRectGetHeight(self.value1PurchaseBtnLblBtn.frame)/2.;
  392. self.value1PurchaseBtnLblBtn.layer.masksToBounds = YES;
  393. self.value2PurchaseButton.wantsLayer = YES;
  394. self.value2PurchaseButton.layer.cornerRadius = CGRectGetHeight(self.value2PurchaseButton.frame) / 2.;
  395. self.value2PurchaseButton.layer.backgroundColor = [NSColor whiteColor].CGColor;
  396. self.value2PurchaseLbl.stringValue = NSLocalizedString(@"Purchase", nil);
  397. self.value2PurchaseLbl.textColor = [NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0];
  398. self.value3PurchaseButton.title = NSLocalizedString(@"Purchase", nil);
  399. self.value3PurchaseBtnLbl.stringValue = NSLocalizedString(@"Purchase", nil);
  400. self.value3PurchaseButton.wantsLayer = YES;
  401. [self.value3PurchaseButton setTitleColor:[NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0]];
  402. self.value3PurchaseBtnLbl.textColor = [NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0];
  403. self.value3PurchaseButton.layer.backgroundColor = [NSColor whiteColor].CGColor;
  404. self.value3PurchaseButton.layer.cornerRadius = CGRectGetHeight(self.value3PurchaseButton.frame) / 2.;
  405. self.titleLabel.stringValue = NSLocalizedString(@"Subscribe to All Access Pack to enjoy more expanded features.", nil);
  406. self.switchLabel.stringValue = NSLocalizedString(@"Choose your favorite payment and enjoy flexible upgrades.", nil);
  407. self.switchLabel.textColor = [KMAppearance KMColor_Interactive_M0];
  408. self.switchButton.title = [NSString stringWithFormat:@"%@",NSLocalizedString(@"Pricing and Plans", nil)];
  409. self.box.wantsLayer = YES;
  410. self.box.shadow = [[NSShadow alloc] init];
  411. self.box.layer.shadowOpacity = 0.3;
  412. self.box.layer.shadowColor = [NSColor colorWithRed:0 green:0 blue:0 alpha:0.3].CGColor;
  413. self.box.layer.shadowOffset = NSMakeSize(0,3);
  414. self.box.layer.shadowRadius = 8;
  415. self.box.layer.masksToBounds = NO;
  416. NSButtonCell *cell = self.switchButton.cell;
  417. NSColor *txtColor = [NSColor colorWithRed:102.0/255.0 green:102.0/255.0 blue:102.0/255.0 alpha:1.0];
  418. NSAttributedString *attrStr1 = [cell attributedTitle];
  419. NSMutableAttributedString *myAttr = [[NSMutableAttributedString alloc] initWithAttributedString:attrStr1];
  420. [myAttr addAttribute:NSForegroundColorAttributeName value:txtColor range:NSMakeRange(0, myAttr.length)];
  421. [myAttr addAttribute:NSFontAttributeName value:[NSFont boldSystemFontOfSize:13.0] range:NSMakeRange(0, myAttr.length)];
  422. [cell setAttributedTitle:myAttr];
  423. [self.switchButton updateCell:cell];
  424. self.aboutButton.title = NSLocalizedString(@"About Subscriptions", nil);
  425. self.btnRestore.title = NSLocalizedString(@"Restore", nil);
  426. self.privacyPolicyBtn.title = NSLocalizedString(@"Privacy Policy", nil);
  427. self.termOfSerBtn.title = NSLocalizedString(@"Terms of Service", nil);
  428. self.btnRestore.toolTip = NSLocalizedString(@"Restore", nil);
  429. self.privacyPolicyBtn.toolTip = NSLocalizedString(@"Privacy Policy", nil);
  430. self.termOfSerBtn.toolTip = NSLocalizedString(@"Terms of Service", nil);
  431. [self.aboutButton setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.7]];
  432. [self.btnRestore setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
  433. [self.privacyPolicyBtn setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
  434. [self.termOfSerBtn setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
  435. self.btnRestore.mouseMoveCallback = ^(BOOL mouseEntered) {
  436. if (mouseEntered) {
  437. [self.btnRestore setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.7]];
  438. } else {
  439. [self.btnRestore setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
  440. }
  441. };
  442. self.privacyPolicyBtn.mouseMoveCallback = ^(BOOL mouseEntered) {
  443. if (mouseEntered) {
  444. [self.privacyPolicyBtn setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.7]];
  445. } else {
  446. [self.privacyPolicyBtn setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
  447. }
  448. };
  449. self.termOfSerBtn.mouseMoveCallback = ^(BOOL mouseEntered) {
  450. if (mouseEntered) {
  451. [self.termOfSerBtn setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.7]];
  452. } else {
  453. [self.termOfSerBtn setTitleColor:[NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1]];
  454. }
  455. };
  456. self.aboutButton.hidden = YES;
  457. [self reloadData];
  458. [self reloadDataContent];
  459. [[IAPProductsManager defaultManager] loadProducts];
  460. __block typeof(self) blockSelf = self;
  461. self.value2PurchaseButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  462. if (blockSelf.value2PurchaseButton.enabled) {
  463. if (mouseEntered) {
  464. [blockSelf.value2PurchaseLbl setTextColor:[NSColor whiteColor]];
  465. blockSelf.value2PurchaseButton.layer.backgroundColor = [NSColor colorWithRed:1 green:94/255.0 blue:44/255.0 alpha:1.0].CGColor;
  466. } else {
  467. [blockSelf.value2PurchaseLbl setTextColor:[NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0]];
  468. blockSelf.value2PurchaseButton.layer.backgroundColor = [NSColor whiteColor].CGColor;
  469. }
  470. }
  471. };
  472. self.value3PurchaseButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  473. if (mouseEntered) {
  474. // [blockSelf.value3PurchaseButton setTitleColor:[NSColor whiteColor]];
  475. blockSelf.value3PurchaseBtnLbl.textColor = [NSColor whiteColor];
  476. blockSelf.value3PurchaseButton.layer.backgroundColor = [NSColor colorWithRed:1 green:94/255.0 blue:44/255.0 alpha:1.0].CGColor;
  477. } else {
  478. // [blockSelf.value3PurchaseButton setTitleColor:[NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0]];
  479. blockSelf.value3PurchaseBtnLbl.textColor = [NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0];
  480. blockSelf.value3PurchaseButton.layer.backgroundColor = [NSColor whiteColor].CGColor;
  481. }
  482. };
  483. self.textView.string = [NSString stringWithFormat:NSLocalizedString(@"Subscription plans:\nSubscriptions: %@\n\n- Subscriptions will be charged through your iTunes account at the confirmation of purchase.\n- Your subscriptions will automatically renew unless cancelled at least 24 hours before the end of current subscription period.\n- Your iTunes account will be charged for renewal within 24-hours prior to the end of the current period, for the same duration and at the current subscription price.\n- You may manage your subscriptions in your iTunes Account Settings after purchase.\n- No cancellation of the current subscription is allowed during an active subscription period.\n\n- Terms of service:\nhttps://www.pdfreaderpro.com/terms_of_service\n- Privacy Policy:\nhttps://www.pdfreaderpro.com/privacy-policy", @""), NSLocalizedString(@"USD $39.99/(6 months), USD$59.99/(12 months), USD $59.99/(one-time purchase)", @"")];
  484. [self showDiscount];
  485. }
  486. - (BOOL)windowShouldClose:(id)sender {
  487. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_Upgrade_Cancel"}];
  488. if ([self isShowSale]) {
  489. [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_7OffUpgrade_Cancel"} platform:KMAnalyticsPlatformAppCenter];
  490. }
  491. [self endModal:sender];
  492. return YES;
  493. }
  494. - (void)close {
  495. [super close];
  496. [self endModal:nil];
  497. }
  498. - (IBAction)startModal:(id)sender {
  499. [NSApp stopModal];
  500. NSInteger modalCode;
  501. self.modalSession = [NSApp beginModalSessionForWindow:self.window];
  502. do {
  503. modalCode = [NSApp runModalSession:self.modalSession];
  504. } while (modalCode == NSModalResponseContinue);
  505. }
  506. - (IBAction)endModal:(id)sender {
  507. if (self.modalSession) {
  508. [NSApp stopModal];
  509. [NSApp endModalSession:self.modalSession];
  510. [self.window orderOut:self];
  511. self.modalSession = nil;
  512. }
  513. }
  514. - (void)showWindowRestore:(id)sender {
  515. [self showWindow:sender];
  516. [self buttonItemClicked_Restore:nil];
  517. }
  518. - (void)showWindow:(id)sender {
  519. [super showWindow:sender];
  520. [self reloadData];
  521. if ([self isShowSale]) {
  522. [self showDiscountToSaveWindow];
  523. }
  524. }
  525. #pragma mark - Private Methods
  526. - (void)reloadData {
  527. if (self.isPurchaseSwitch) {
  528. self.sixMouthProLabel.textColor = [NSColor colorWithRed:117/255.0 green:119/255.0 blue:128/255.0 alpha:1.0];
  529. self.oneYearProLabel.textColor = NSColor.whiteColor;
  530. self.switchCircleLeftConst.constant = 22;
  531. self.value1InfoLabel.stringValue = NSLocalizedString(@"1-year Plan", nil);
  532. } else {
  533. self.sixMouthProLabel.textColor = NSColor.whiteColor;
  534. self.oneYearProLabel.textColor = [NSColor colorWithRed:117/255.0 green:119/255.0 blue:128/255.0 alpha:1.0];
  535. self.switchCircleLeftConst.constant = 4;
  536. self.value1InfoLabel.stringValue = NSLocalizedString(@"6-Month Plan", nil);
  537. }
  538. self.saleBox.hidden = true;
  539. self.saleIv.hidden = true;
  540. if ([self isShowSale]) {
  541. KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.StoreUserRecovery.content.firstObject;
  542. NSURL *url = [NSURL URLWithString:[KMAdvertisementModelTransition transitionImagePathWithImage:info.saleImage highlight:true]];
  543. [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage * _Nonnull image) {
  544. if (image != nil) {
  545. self.saleIv.image = image;
  546. self.saleBox.hidden = false;
  547. self.saleIv.hidden = false;
  548. [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Exposure" : @"PUW_7OffUpgrade"} platform:KMAnalyticsPlatformAppCenter];
  549. }
  550. }];
  551. } else {
  552. self.saleBox.hidden = true;
  553. }
  554. if ([IAPProductsManager defaultManager].isAvailableAllFunction) {
  555. self.value1PurchaseButton.enabled = NO;
  556. self.value2PurchaseButton.enabled = NO;
  557. self.value2PurchaseLbl.textColor = [NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:0.5];
  558. } else {
  559. self.value1PurchaseButton.enabled = YES;
  560. self.value2PurchaseButton.enabled = YES;
  561. self.value2PurchaseLbl.textColor = [NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0];
  562. }
  563. self.value1PurchaseBtnLblBtn.enabled = self.value1PurchaseButton.enabled;
  564. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
  565. if ([IAPProductsManager defaultManager].allAccessPackNew6months_lite.isTrialPeriod) {
  566. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
  567. if ([IAPProductsManager defaultManager].allAccessPackNew6months_lite.isSubscribed) {
  568. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribed", nil);
  569. }
  570. } else if ([IAPProductsManager defaultManager].allAccessPack12months_lite.isTrialPeriod) {
  571. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
  572. if ([IAPProductsManager defaultManager].allAccessPack12months_lite.isSubscribed) {
  573. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribed", nil);
  574. }
  575. } else {
  576. if ([IAPProductsManager defaultManager].allAccessPackNew6months_lite.isSubscribed) {
  577. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribed", nil);
  578. } else if ([IAPProductsManager defaultManager].allAccessPack12months_lite.isSubscribed) {
  579. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribed", nil);
  580. } else {
  581. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Free Trial", nil);
  582. if (@available(macOS 10.13.2, *)) {
  583. #if !VERSION_DMG
  584. if (![IAPProductsManager defaultManager].allAccessPackNew6months_lite.product.introductoryPrice) {
  585. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
  586. } else if (![IAPProductsManager defaultManager].allAccessPack12months_lite.product.introductoryPrice) {
  587. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
  588. }
  589. #endif
  590. }
  591. }
  592. }
  593. if (self.value1PurchaseBtnLblBtn.enabled) {
  594. [self.value1PurchaseBtnLbl setTextColor:[NSColor whiteColor]];
  595. } else {
  596. [self.value1PurchaseBtnLbl setTextColor:[[NSColor whiteColor] colorWithAlphaComponent:0.5]];
  597. }
  598. self.value2PurchaseLblBtn.enabled = self.value2PurchaseButton.enabled;
  599. NSString *averageMonthPrice = nil;
  600. NSString *monthPrice = nil;
  601. NSString *averageMonthPrice_discount = nil;
  602. NSString *monthPrice_discount = nil;
  603. NSString *allPrice = nil;
  604. if ([IAPProductsManager defaultManager].allAccessPackNew6months_lite.isOffers) {
  605. self.specialView1.hidden = NO;
  606. averageMonthPrice = [IAPProductsManager defaultManager].allAccessPackNew6months_lite.offersAveragePrice;
  607. monthPrice = [IAPProductsManager defaultManager].allAccessPackNew6months_lite.offersPrice;
  608. averageMonthPrice_discount = [IAPProductsManager defaultManager].allAccessPackNew6months_lite.discountAveragePrice;
  609. monthPrice_discount = [IAPProductsManager defaultManager].allAccessPackNew6months_lite.discountPrice;
  610. self.topButtonOffset.constant = 20;
  611. } else if ([IAPProductsManager defaultManager].allAccessPack12months_lite.isOffers) {
  612. averageMonthPrice = [IAPProductsManager defaultManager].allAccessPack12months_lite.offersAveragePrice;
  613. monthPrice = [IAPProductsManager defaultManager].allAccessPack12months_lite.offersPrice;
  614. averageMonthPrice_discount = [IAPProductsManager defaultManager].allAccessPack12months_lite.discountAveragePrice;
  615. monthPrice_discount = [IAPProductsManager defaultManager].allAccessPack12months_lite.discountPrice;
  616. self.topButtonOffset.constant = 20;
  617. } else {
  618. self.specialView1.hidden = YES;
  619. if (self.isPurchaseSwitch == false) {
  620. averageMonthPrice = [IAPProductsManager defaultManager].allAccessPackNew6months_lite.averagePrice;
  621. monthPrice = [IAPProductsManager defaultManager].allAccessPackNew6months_lite.price;
  622. averageMonthPrice_discount = [IAPProductsManager defaultManager].allAccessPackNew6months_lite.discountAveragePrice;
  623. monthPrice_discount = [IAPProductsManager defaultManager].allAccessPackNew6months_lite.discountPrice;
  624. } else {
  625. averageMonthPrice = [IAPProductsManager defaultManager].allAccessPack12months_lite.averagePrice;
  626. monthPrice = [IAPProductsManager defaultManager].allAccessPack12months_lite.price;
  627. averageMonthPrice_discount = [IAPProductsManager defaultManager].allAccessPack12months_lite.discountAveragePrice;
  628. monthPrice_discount = [IAPProductsManager defaultManager].allAccessPack12months_lite.discountPrice;
  629. }
  630. self.topButtonOffset.constant = 10;
  631. }
  632. if ([IAPProductsManager defaultManager].allAccessPackPermanent_lite.isOffers) {
  633. self.topButtonOffset.constant = 20;
  634. self.specialView.hidden = NO;
  635. allPrice = [IAPProductsManager defaultManager].allAccessPackPermanent_lite.offersPrice;
  636. } else {
  637. self.topButtonOffset.constant = 10;
  638. self.specialView.hidden = YES;
  639. allPrice = [IAPProductsManager defaultManager].allAccessPackPermanent_lite.price;
  640. }
  641. CGFloat off = 1 -[IAPProductsManager defaultManager].allAccessPackPermanent_lite.offers;
  642. NSString *offString = [NSString stringWithFormat:@"%.f%%",off * 100];
  643. self.specialLabel.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@ off", @""),offString];
  644. if (self.isPurchaseSwitch) {
  645. off = 1 -[IAPProductsManager defaultManager].allAccessPack12months_lite.offers;
  646. } else {
  647. off = 1 -[IAPProductsManager defaultManager].allAccessPackNew6months_lite.offers;
  648. }
  649. offString = [NSString stringWithFormat:@"%.f%%",off * 100];
  650. self.specialLabel1.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@ off", @""),offString];
  651. NSImage *image = [NSImage imageNamed:@"KMImageNameCompareTagBG"];
  652. self.specialImageView.image = image;
  653. self.specialImageView1.image = image;
  654. BOOL isShowSale = [self isShowSale];
  655. if (KMKdanRemoteConfig.remoteConfig.showAPP_AveragePrice) {
  656. if (isShowSale) {
  657. self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", averageMonthPrice_discount, NSLocalizedString(@"mon", nil)];
  658. self.value1PurchaseOriPriceLbl.stringValue = [NSString stringWithFormat:@"%@/%@", averageMonthPrice, NSLocalizedString(@"mon", nil)];
  659. self.value1PurchaseOriPriceLbl.hidden = false;
  660. self.billedTopConst.constant = 16;
  661. } else {
  662. self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", averageMonthPrice, NSLocalizedString(@"mon", nil)];
  663. self.value1PurchaseOriPriceLbl.hidden = true;
  664. self.billedTopConst.constant = 0;
  665. }
  666. } else {
  667. if (self.isPurchaseSwitch) {
  668. if (isShowSale) {
  669. self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice_discount, NSLocalizedString(@"12 months", nil)];
  670. self.value1PurchaseOriPriceLbl.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice, NSLocalizedString(@"12 months", nil)];
  671. self.value1PurchaseOriPriceLbl.hidden = false;
  672. self.billedTopConst.constant = 16;
  673. } else {
  674. self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice, NSLocalizedString(@"12 months", nil)];
  675. self.value1PurchaseOriPriceLbl.hidden = true;
  676. self.billedTopConst.constant = 0;
  677. }
  678. } else {
  679. if (isShowSale) {
  680. self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice_discount, NSLocalizedString(@"6mon", nil)];
  681. self.value1PurchaseOriPriceLbl.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice, NSLocalizedString(@"6mon", nil)];
  682. self.value1PurchaseOriPriceLbl.hidden = false;
  683. self.billedTopConst.constant = 16;
  684. } else {
  685. self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice, NSLocalizedString(@"6mon", nil)];
  686. self.value1PurchaseOriPriceLbl.hidden = true;
  687. self.billedTopConst.constant = 0;
  688. }
  689. }
  690. }
  691. self.value1PurchaseLabel.textColor = [NSColor colorWithRed:1 green:231/255. blue:106/255. alpha:1.];
  692. self.value1PurchaseOriPriceLbl.textColor = [NSColor colorWithWhite:1 alpha:0.7];
  693. self.value1PurchaseOriPriceLbl.attributedStringValue = [[NSAttributedString alloc] initWithString:self.value1PurchaseOriPriceLbl.stringValue attributes:@{
  694. NSFontAttributeName : [NSFont SFProTextRegularFont:12],
  695. NSForegroundColorAttributeName: [NSColor colorWithWhite:1 alpha:0.7],
  696. NSStrikethroughStyleAttributeName : @(1)
  697. }];
  698. NSString *tTips = @"";
  699. if (isShowSale) {
  700. tTips = [NSString stringWithFormat:NSLocalizedString(@"%@ for the first 6-month subscription", nil), monthPrice_discount];
  701. } else {
  702. tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 6 months at %@", nil), monthPrice];
  703. }
  704. if ([self.value1PurchaseBtnLbl.stringValue isEqualToString:NSLocalizedString(@"Free Trial", nil)]) {
  705. tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 6 months at %@ after 7-day trial ends.", nil), monthPrice];
  706. #if !VERSION_DMG
  707. if (self.isPurchaseSwitch) {
  708. if ([IAPProductsManager defaultManager].allAccessPack12months_lite.product) {
  709. if (@available(macOS 10.13.2, *)) {
  710. tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 12 months at %@ after %@-day trial ends.", nil), monthPrice,@([IAPProductsManager defaultManager].allAccessPack12months_lite.product.introductoryPrice.subscriptionPeriod.numberOfUnits)];
  711. }
  712. }
  713. } else {
  714. if ([IAPProductsManager defaultManager].allAccessPackNew6months_lite.product) {
  715. if (@available(macOS 10.13.2, *)) {
  716. tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 6 months at %@ after %@-day trial ends.", nil), monthPrice,@([IAPProductsManager defaultManager].allAccessPackNew6months_lite.product.introductoryPrice.subscriptionPeriod.numberOfUnits)];
  717. }
  718. }
  719. }
  720. #endif
  721. }
  722. if (@available(macOS 10.13.2, *)) {
  723. #if !VERSION_DMG
  724. if (self.isPurchaseSwitch) {
  725. if (![IAPProductsManager defaultManager].allAccessPack12months_lite.product.introductoryPrice) {
  726. if (isShowSale) {
  727. tTips = [NSString stringWithFormat:NSLocalizedString(@"%@ for the first year's subscription", nil), monthPrice_discount];
  728. } else {
  729. tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 12 months at %@", nil), monthPrice];
  730. }
  731. }
  732. } else {
  733. if (![IAPProductsManager defaultManager].allAccessPackNew6months_lite.product.introductoryPrice) {
  734. if (isShowSale) {
  735. tTips = [NSString stringWithFormat:NSLocalizedString(@"%@ for the first 6-month subscription", nil), monthPrice_discount];
  736. } else {
  737. tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 6 months at %@", nil), monthPrice];
  738. }
  739. }
  740. }
  741. #endif
  742. }
  743. self.value1PurchaseSubLabel.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@", nil), tTips];
  744. self.value2PurchaseLabel.stringValue = allPrice?:@"";
  745. self.value2PurchaseLabel.textColor = [NSColor colorWithRed:1 green:231/255. blue:106/255. alpha:1.];
  746. self.value2PurchaseSubLabel.stringValue = NSLocalizedString(@"one-time purchase", nil);
  747. self.value3PurchaseLabel.stringValue = NSLocalizedString(@"USD $59.99", nil);
  748. self.value3PurchaseLabel.textColor = [NSColor colorWithRed:1 green:231/255. blue:106/255. alpha:1.];
  749. self.value3PurchaseSubLabel.stringValue = NSLocalizedString(@"one-time purchase", nil);
  750. self.value1PurchaseBtnLbl.font = [NSFont UbuntuBoldFontWithSize:16];
  751. self.value2PurchaseLbl.font = [NSFont UbuntuBoldFontWithSize:16];
  752. self.value3PurchaseBtnLbl.font = [NSFont UbuntuBoldFontWithSize:16];
  753. self.value1PurchaseLabel.font = [NSFont UbuntuBoldFontWithSize:22];
  754. self.value2PurchaseLabel.font = [NSFont UbuntuBoldFontWithSize:22];
  755. self.value3PurchaseLabel.font = [NSFont UbuntuBoldFontWithSize:22];
  756. self.value1PurchaseOriPriceLbl.font = [NSFont SFProTextRegularFont:12];
  757. }
  758. - (void)reloadDataContent {
  759. if (self.isPurchaseSwitch) {
  760. self.dataSource = @[@"PDF to Office",
  761. @[@"Convert PDFs to Word, HTML, TXT, JPEG or PNG files",@"Only first 10 pages",@"Advanced",@"Advanced",@"Standard"],
  762. @[@"Turn PDF to PPT, Excel, RTF, CSV, and more",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
  763. @[@"Convert PDF to TIFF, BMP, GIF or TGA files",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
  764. @"Edit PDF",
  765. @[@"Add and edit text in PDF",@"X",@"✓",@"✓",@"✓"],
  766. @[@"Edit, crop, replace image in PDF",@"X",@"✓",@"✓",@"✓"],
  767. @"OCR",
  768. @[@"Extract texts from image-based or scanned PDF",@"X",@"✓",@"✓",@"✓"],
  769. @"Organize Pages",
  770. @[@"Extract, rotate, rearrange, replace, add, delete pages",@"X",@"✓",@"✓",@"✓"],
  771. @[@"Split PDFs into multiple files",@"X",@"✓",@"✓",@"✓"],
  772. @"Advanced Editing Tools",
  773. @[@"Merge multiple documents into a new PDF",@"Up to 2 files or 20 MB",@"✓",@"∞",@"∞"],
  774. @[@"Add & edit watermark",@"X",@"✓",@"✓",@"✓"],
  775. @[@"Add header, footer, page numbers",@"X",@"✓",@"✓",@"✓"],
  776. @[@"Add Bates Number",@"X",@"✓",@"✓",@"✓"],
  777. @[@"Insert PDF page background by color or image",@"X",@"✓",@"✓",@"✓"],
  778. @[@"Create fattened copies",@"X",@"✓",@"✓",@"✓"],
  779. @[@"Extract Images",@"X",@"✓",@"✓",@"✓"],
  780. @[@"Extract tables",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
  781. @[@"Measuring Tools",@"X",@"✓",@"✓",@"✓"],
  782. @"Fill & Sign",
  783. @[@"Create digital signature",@"X",@"✓",@"✓",@"✓"],
  784. @[@"Create & Edit & Fill Adobe Fillable PDF Forms",@"X",@"✓",@"✓",@"✓"],
  785. @"Security",
  786. @[@"Batch encrypting PDF documents",@"X",@"✓",@"✓",@"✓"],
  787. @[@"PDF Password Remover",@"X",@"✓",@"✓",@"✓"],
  788. @[@"Redact sensitive information",@"X",@"✓",@"✓",@"✓"],
  789. @"Create PDF",
  790. @[@"Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs",@"1 file",@"✓",@"✓",@"✓"],
  791. @[@"Create PDFs from a scanner and iOS devices",@"X",@"✓",@"✓",@"✓"],
  792. @"Annotations",
  793. @[@"Customize PDF stamps",@"X",@"✓",@"✓",@"✓",@"✓"],
  794. @[@"Hyperlink",@"Page Number",@"Page Number, URL, Email",@"Page Number, URL, Email",@"Page Number, URL, Email"],
  795. @[@"Signature",@"Standard",@"Advanced",@"Advanced",@"Advanced"],
  796. @[@"Table",@"X",@"✓",@"✓",@"✓",@"✓"],
  797. @"View PDF",
  798. @[@"Multi-tab viewer",@"X",@"✓",@"✓",@"✓"],
  799. @[@"Various printing types: poster, booklet, multi-page printing",@"X",@"✓",@"✓",@"✓"],
  800. @[@"Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more",@"X",@"✓",@"✓",@"✓"],
  801. @[@"Split View to compare files",@"X",@"✓",@"✓",@"✓"],
  802. @"Subscription Based Solution",
  803. @[@"Access all premium features in app",@"X",@"12 months",@"∞",@"∞"],
  804. @[@"Priority customer support",@"X",@"✓",@"✓",@"✓"],
  805. @[@"Ad-free",@"X",@"✓",@"✓",@"✓"],
  806. @{}
  807. ];
  808. } else {
  809. self.dataSource = @[@"PDF to Office",
  810. @[@"Convert PDFs to Word, HTML, TXT, JPEG or PNG files",@"Only first 10 pages",@"Advanced",@"Advanced",@"Standard"],
  811. @[@"Turn PDF to PPT, Excel, RTF, CSV, and more",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
  812. @[@"Convert PDF to TIFF, BMP, GIF or TGA files",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
  813. @"Edit PDF",
  814. @[@"Add and edit text in PDF",@"X",@"✓",@"✓",@"✓"],
  815. @[@"Edit, crop, replace image in PDF",@"X",@"✓",@"✓",@"✓"],
  816. @"OCR",
  817. @[@"Extract texts from image-based or scanned PDF",@"X",@"✓",@"✓",@"✓"],
  818. @"Organize Pages",
  819. @[@"Extract, rotate, rearrange, replace, add, delete pages",@"X",@"✓",@"✓",@"✓"],
  820. @[@"Split PDFs into multiple files",@"X",@"✓",@"✓",@"✓"],
  821. @"Advanced Editing Tools",
  822. @[@"Merge multiple documents into a new PDF",@"Up to 2 files or 20 MB",@"✓",@"∞",@"∞"],
  823. @[@"Add & edit watermark",@"X",@"✓",@"✓",@"✓"],
  824. @[@"Add header, footer, page numbers",@"X",@"✓",@"✓",@"✓"],
  825. @[@"Add Bates Number",@"X",@"✓",@"✓",@"✓"],
  826. @[@"Insert PDF page background by color or image",@"X",@"✓",@"✓",@"✓"],
  827. @[@"Create fattened copies",@"X",@"✓",@"✓",@"✓"],
  828. @[@"Extract Images",@"X",@"✓",@"✓",@"✓"],
  829. @[@"Extract tables",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
  830. @[@"Measuring Tools",@"X",@"✓",@"✓",@"✓"],
  831. @"Fill & Sign",
  832. @[@"Create digital signature",@"X",@"✓",@"✓",@"✓"],
  833. @[@"Create & Edit & Fill Adobe Fillable PDF Forms",@"X",@"✓",@"✓",@"✓"],
  834. @"Security",
  835. @[@"Batch encrypting PDF documents",@"X",@"✓",@"✓",@"✓"],
  836. @[@"PDF Password Remover",@"X",@"✓",@"✓",@"✓"],
  837. @[@"Redact sensitive information",@"X",@"✓",@"✓",@"✓"],
  838. @"Create PDF",
  839. @[@"Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs",@"1 file",@"✓",@"✓",@"✓"],
  840. @[@"Create PDFs from a scanner and iOS devices",@"X",@"✓",@"✓",@"✓"],
  841. @"Annotations",
  842. @[@"Customize PDF stamps",@"X",@"✓",@"✓",@"✓",@"✓"],
  843. @[@"Hyperlink",@"Page Number",@"Page Number, URL, Email",@"Page Number, URL, Email",@"Page Number, URL, Email"],
  844. @[@"Signature",@"Standard",@"Advanced",@"Advanced",@"Advanced"],
  845. @[@"Table",@"X",@"✓",@"✓",@"✓",@"✓"],
  846. @"View PDF",
  847. @[@"Multi-tab viewer",@"X",@"✓",@"✓",@"✓"],
  848. @[@"Various printing types: poster, booklet, multi-page printing",@"X",@"✓",@"✓",@"✓"],
  849. @[@"Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more",@"X",@"✓",@"✓",@"✓"],
  850. @[@"Split View to compare files",@"X",@"✓",@"✓",@"✓"],
  851. @"Subscription Based Solution",
  852. @[@"Access all premium features in app",@"X",@"6 months",@"∞",@"∞"],
  853. @[@"Priority customer support",@"X",@"✓",@"✓",@"✓"],
  854. @[@"Ad-free",@"X",@"✓",@"✓",@"✓"],
  855. @{}
  856. ];
  857. }
  858. [self.tableView reloadData];
  859. }
  860. - (void)addWaingView:(NSView *)view {
  861. [self removeWaitingView:view];
  862. WaitingView *wView = [[WaitingView alloc] initWithFrame:view.bounds];
  863. [wView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
  864. [view addSubview:wView];
  865. [wView startAnimation];
  866. }
  867. - (void)removeWaitingView:(NSView *)view {
  868. for (id v in view.subviews) {
  869. if ([[v class] isSubclassOfClass:[WaitingView class]]) {
  870. [v removeFromSuperview];
  871. break;
  872. }
  873. }
  874. }
  875. - (void)updateViewColor {
  876. self.box.fillColor = [KMAppearance KMColor_Layout_L1];
  877. self.labelbox.fillColor = [NSColor clearColor];
  878. self.tableView.backgroundColor = [KMAppearance KMColor_Layout_L0];
  879. self.textView.backgroundColor = [NSColor clearColor];
  880. self.textView.textColor = [[NSColor whiteColor] colorWithAlphaComponent:0.5];
  881. self.value1PurchaseSubLabel.textColor = self.value2PurchaseSubLabel.textColor = self.value3PurchaseSubLabel.textColor = [KMAppearance KMColor_Layout_W0];
  882. }
  883. - (BOOL)isCancelAutoRenew {
  884. return [[IAPProductsManager defaultManager] isCancelAutoRenew];
  885. }
  886. - (BOOL)isShowSale {
  887. if (@available(macOS 10.14.4, *)) {
  888. if ([self isCancelAutoRenew]) {
  889. BOOL isSubscribed = [IAPProductsManager defaultManager].allAccessPackNew6months_lite.isSubscribed;
  890. if (isSubscribed) {
  891. return false;
  892. }
  893. isSubscribed = [IAPProductsManager defaultManager].allAccessPack12months_lite.isSubscribed;
  894. if (isSubscribed) {
  895. return false;
  896. }
  897. KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.StoreUserRecovery.content.firstObject;
  898. if ([info.show boolValue] == false) { // 活动结束
  899. return false;
  900. }
  901. return true;
  902. }
  903. }
  904. return false;
  905. }
  906. - (void)showDiscount {
  907. [self.discountYearly setHidden:YES];
  908. [self.discountPermanent setHidden:YES];
  909. [self.discountPremium setHidden:YES];
  910. if (KMAdvertisementManager.manager.info.StoreUserRecovery.content.count > 0) {
  911. for (int i = 0; i < KMAdvertisementManager.manager.info.StoreUserRecovery.content.count; i++) {
  912. if (i == 1) {
  913. KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.StoreUserRecovery.content[1];
  914. if ([KMAdvertisementManager checkAdvertisementValid:info]) {
  915. [self.discountYearly setHidden:NO];
  916. NSURL *url = [NSURL URLWithString:[KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight:NO]];
  917. self.discountYearly.image = [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage * _Nonnull image) {
  918. self.discountYearly.image = image;
  919. }];
  920. } else {
  921. [self.discountYearly setHidden:YES];
  922. }
  923. } else if (i == 2) {
  924. KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.StoreUserRecovery.content[2];
  925. if ([KMAdvertisementManager checkAdvertisementValid:info]) {
  926. [self.discountPermanent setHidden:NO];
  927. NSURL *url = [NSURL URLWithString:[KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight:NO]];
  928. self.discountPermanent.image = [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage * _Nonnull image) {
  929. self.discountPermanent.image = image;
  930. }];
  931. } else {
  932. [self.discountPermanent setHidden:YES];
  933. }
  934. } else if (i == 3) {
  935. KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.StoreUserRecovery.content[3];
  936. if ([KMAdvertisementManager checkAdvertisementValid:info]) {
  937. [self.discountPremium setHidden:NO];
  938. NSURL *url = [NSURL URLWithString:[KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight:NO]];
  939. self.discountPremium.image = [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage * _Nonnull image) {
  940. self.discountPremium.image = image;
  941. }];
  942. } else {
  943. [self.discountPremium setHidden:YES];
  944. }
  945. }
  946. }
  947. }
  948. }
  949. #pragma mark - Button Actions
  950. - (IBAction)buttonItemClicked_Subscribe:(id)sender {
  951. if (self.isPurchaseSwitch) {
  952. [[IAPProductsManager defaultManager] makeSubProduct:[IAPProductsManager defaultManager].allAccessPack12months_lite discount:[self isCancelAutoRenew]];
  953. } else {
  954. [[IAPProductsManager defaultManager] makeSubProduct:[IAPProductsManager defaultManager].allAccessPackNew6months_lite discount:[self isCancelAutoRenew]];
  955. }
  956. [self addWaingView:self.window.contentView];
  957. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_Upgrade_6Mon"}];
  958. if ([self isShowSale]) {
  959. self.kEventTag = 1;
  960. if (self.isPurchaseSwitch) {
  961. [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_7OffUpgrade_12Mon"} platform:KMAnalyticsPlatformAppCenter];
  962. } else {
  963. [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_7OffUpgrade_6Mon"} platform:KMAnalyticsPlatformAppCenter];
  964. }
  965. }
  966. }
  967. - (void)showDiscountToSaveWindow {
  968. if ([KMDiscountToSaveWindowController needShow] == false) {
  969. return;
  970. }
  971. KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.StoreUserRecovery.content.firstObject;
  972. NSURL *url = [NSURL URLWithString: [KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight: YES]];
  973. __weak typeof(self) weakSelf = self;
  974. [self addWaingView:self.window.contentView];
  975. [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage *image) {
  976. [weakSelf removeWaitingView:weakSelf.window.contentView];
  977. if (image == nil) {
  978. return;
  979. }
  980. [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Exposure" : @"PUW_PromotionalOffer"} platform:KMAnalyticsPlatformAppCenter];
  981. KMDiscountToSaveWindowController *winC = [[KMDiscountToSaveWindowController alloc] initWithWindowNibName:@"KMDiscountToSaveWindowController"];
  982. weakSelf.discountToSaveWinC = winC;
  983. [weakSelf.window beginSheet:winC.window completionHandler:^(NSModalResponse returnCode) { }];
  984. winC.imgIv.image = image;
  985. winC.itemClick = ^(NSInteger idx) {
  986. [weakSelf.window endSheet:weakSelf.discountToSaveWinC.window];
  987. weakSelf.discountToSaveWinC = nil;
  988. if (idx == 2) { // 订阅
  989. //// NSLog(@"buttonItemClicked_Subscribe");
  990. [weakSelf trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_PromotionalOffer_Subscribe"} platform:KMAnalyticsPlatformAppCenter];
  991. } else if (idx == 1) {
  992. [weakSelf trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_PromotionalOffer_Cancel"} platform:KMAnalyticsPlatformAppCenter];
  993. }
  994. };
  995. }];
  996. }
  997. - (IBAction)buttonItemClicked_Restore:(id)sender {
  998. [[IAPProductsManager defaultManager] restoreSubscriptions];
  999. [self addWaingView:self.window.contentView];
  1000. }
  1001. - (IBAction)buttonItemClicked_Upgrade:(id)sender {
  1002. [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"macappstore://apps.apple.com/app/id825459243?mt=12"]];
  1003. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_Upgrade_Premium"}];
  1004. }
  1005. - (IBAction)privacyPolicyAction:(NSButton *)sender {
  1006. [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://www.pdfreaderpro.com/privacy-policy"]];
  1007. }
  1008. - (IBAction)termOfSerAction:(NSButton *)sender {
  1009. [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://www.pdfreaderpro.com/terms_of_service"]];
  1010. }
  1011. - (IBAction)buttonItemClicked_LicenseUpgrade:(id)sender {
  1012. [[IAPProductsManager defaultManager] makeProduct:[IAPProductsManager defaultManager].allAccessPackPermanent_lite];
  1013. [self addWaingView:self.window.contentView];
  1014. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_Upgrade_Permanent"}];
  1015. }
  1016. - (IBAction)buttonItemClicked_AboutSubscriptions:(id)sender {
  1017. NSString *tMessage = [NSString stringWithFormat:@"%@\n%@\n\n%@\n%@\n%@\n%@\n%@\n\n%@\n%@\n\n",
  1018. @"Subscription plans: ",
  1019. @"Subscriptions: USD $39.99/(6 months), USD $79.99/(one-time purchase) ",
  1020. @"- Subscriptions will be charged through your iTunes account at the confirmation of purchase. ",
  1021. @"- Your subscriptions will automatically renew unless cancelled at least 24 hours before the end of current subscription period. ",
  1022. @"- 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. ",
  1023. @"- You may manage your subscriptions in your iTunes Account Settings after purchase. ",
  1024. @"- No cancellation of the current subscription is allowed during an active subscription period. ",
  1025. @"- Terms of service: \nhttps://www.pdfreaderpro.com/terms_of_service ",
  1026. @"- Privacy Policy: \nhttps://www.pdfreaderpro.com/privacy-policy "];
  1027. NSAlert *alert = [[NSAlert alloc] init];
  1028. [alert setAlertStyle:NSAlertStyleInformational];
  1029. [alert setMessageText:NSLocalizedString(tMessage, nil)];
  1030. [alert runModal];
  1031. }
  1032. - (IBAction)buttonItemClicked_CloseWindow:(id)sender {
  1033. [self close];
  1034. }
  1035. - (void)switchAction:(NSButton *)sender {
  1036. // NSControlStateValue state = self.switchBtn.state;
  1037. BOOL isSwitch = self.isPurchaseSwitch;
  1038. if (isSwitch) {
  1039. // self.switchBtn.state = NSControlStateValueOff;
  1040. self.isPurchaseSwitch = false;
  1041. // self.switchCircleLeftConst.constant = 4;
  1042. } else {
  1043. // self.switchBtn.state = NSControlStateValueOn;
  1044. self.isPurchaseSwitch = true;
  1045. // self.switchCircleLeftConst.constant = 22;
  1046. }
  1047. // if (self.isPurchaseSwitch) { // 一年
  1048. //
  1049. // } else { // 半年
  1050. //
  1051. // }
  1052. [self reloadDataContent];
  1053. [self reloadData];
  1054. }
  1055. #pragma mark - NSTableViewDataSource Methods
  1056. - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView {
  1057. return self.dataSource.count;
  1058. }
  1059. - (id)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
  1060. id object = [self.dataSource objectAtIndex:row];
  1061. if ([object isKindOfClass:[NSString class]]) {
  1062. KMPurchaseCompareHeaderCell *cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareHeaderCellIdentifier owner:self];
  1063. cellView.textField.stringValue = NSLocalizedString(object, nil);
  1064. return cellView;
  1065. } else if ([object isKindOfClass:[NSArray class]]) {
  1066. KMPurchaseCompareCell *cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareCellIdentifier owner:self];
  1067. NSString *value = [(NSArray *)object count] > 0 ? object[0] : @"";
  1068. NSString *value1 = [(NSArray *)object count] > 1 ? object[1] : @"";
  1069. NSString *value2 = [(NSArray *)object count] > 2 ? object[2] : @"";
  1070. NSString *value3 = [(NSArray *)object count] > 3 ? object[3] : @"";
  1071. NSString *value4 = [(NSArray *)object count] > 4 ? object[4] : @"";
  1072. cellView.textField.stringValue = NSLocalizedString(value, nil);
  1073. cellView.lineBox.hidden = NO;
  1074. if (row + 1 == (NSInteger)self.dataSource.count) {
  1075. cellView.lineBox.hidden = YES;
  1076. } else {
  1077. id nextobject = [self.dataSource objectAtIndex:row+1];
  1078. if ([nextobject isKindOfClass:[NSString class]]) {
  1079. cellView.lineBox.hidden = YES;
  1080. }
  1081. }
  1082. if (row + 2 == (NSInteger)self.dataSource.count) {
  1083. cellView.boxBottomConst.constant = 0;
  1084. } else {
  1085. cellView.boxBottomConst.constant = -4;
  1086. }
  1087. if ([value1 isEqualToString:@"X"]) {
  1088. cellView.value1Label.stringValue = @"";
  1089. cellView.value1ImageView.image = [NSImage imageNamed:@"compare_nosupport"];
  1090. } else if ([value1 isEqualToString:@"✓"]) {
  1091. cellView.value1Label.stringValue = @"";
  1092. cellView.value1ImageView.image = [NSImage imageNamed:@"compare_support"];
  1093. } else if ([value1 isEqualToString:@"∞"]) {
  1094. cellView.value1Label.stringValue = @"";
  1095. cellView.value1ImageView.image = [NSImage imageNamed:@"compare_00"];
  1096. } else {
  1097. cellView.value1Label.stringValue = NSLocalizedString(value1, nil);
  1098. cellView.value1ImageView.image = nil;
  1099. }
  1100. if ([value2 isEqualToString:@"X"]) {
  1101. cellView.value2Label.stringValue = @"";
  1102. cellView.value2ImageView.image = [NSImage imageNamed:@"compare_nosupport"];
  1103. } else if ([value2 isEqualToString:@"✓"]) {
  1104. cellView.value2Label.stringValue = @"";
  1105. cellView.value2ImageView.image = [NSImage imageNamed:@"compare_support"];
  1106. } else if ([value2 isEqualToString:@"∞"]) {
  1107. cellView.value2Label.stringValue = @"";
  1108. cellView.value2ImageView.image = [NSImage imageNamed:@"compare_00"];
  1109. } else {
  1110. cellView.value2Label.stringValue = NSLocalizedString(value2, nil);
  1111. cellView.value2ImageView.image = nil;
  1112. }
  1113. if ([value3 isEqualToString:@"X"]) {
  1114. cellView.value3Label.stringValue = @"";
  1115. cellView.value3ImageView.image = [NSImage imageNamed:@"compare_nosupport"];
  1116. } else if ([value3 isEqualToString:@"✓"]) {
  1117. cellView.value3Label.stringValue = @"";
  1118. cellView.value3ImageView.image = [NSImage imageNamed:@"compare_support"];
  1119. } else if ([value3 isEqualToString:@"∞"]) {
  1120. cellView.value3Label.stringValue = @"";
  1121. cellView.value3ImageView.image = [NSImage imageNamed:@"compare_00"];
  1122. } else {
  1123. cellView.value3Label.stringValue = NSLocalizedString(value3, nil);
  1124. cellView.value3ImageView.image = nil;
  1125. }
  1126. if ([value4 isEqualToString:@"X"]) {
  1127. cellView.value4Label.stringValue = @"";
  1128. cellView.value4ImageView.image = [NSImage imageNamed:@"compare_nosupport"];
  1129. } else if ([value4 isEqualToString:@"✓"]) {
  1130. cellView.value4Label.stringValue = @"";
  1131. cellView.value4ImageView.image = [NSImage imageNamed:@"compare_support"];
  1132. } else if ([value4 isEqualToString:@"∞"]) {
  1133. cellView.value4Label.stringValue = @"";
  1134. cellView.value4ImageView.image = [NSImage imageNamed:@"compare_00"];
  1135. } else {
  1136. cellView.value4Label.stringValue = NSLocalizedString(value4, nil);
  1137. cellView.value4ImageView.image = nil;
  1138. }
  1139. return cellView;
  1140. } else if ([object isKindOfClass:[NSDictionary class]]) {
  1141. KMPurchaseCompareEmptyCell *cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareEmptyCellIdentifier owner:self];
  1142. return cellView;
  1143. }
  1144. return nil;
  1145. }
  1146. - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row {
  1147. NSTableCellView *cellView = nil;
  1148. id object = [self.dataSource objectAtIndex:row];
  1149. if ([object isKindOfClass:[NSString class]]) {
  1150. cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareHeaderCellIdentifier owner:self];
  1151. cellView.textField.stringValue = NSLocalizedString(object, nil);
  1152. } else if ([object isKindOfClass:[NSArray class]]) {
  1153. cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareCellIdentifier owner:self];
  1154. cellView.textField.stringValue = NSLocalizedString(object[0], nil);
  1155. } else if ([object isKindOfClass:[NSDictionary class]]) {
  1156. return 40;
  1157. }
  1158. if (cellView) {
  1159. [cellView layoutSubtreeIfNeeded];
  1160. return cellView.frame.size.height;
  1161. } else {
  1162. return 0;
  1163. }
  1164. }
  1165. #pragma mark - InAppPurchaseManager Notification
  1166. - (void)IAPProductFailedNotification:(NSNotification*)notification {
  1167. [self removeWaitingView:self.window.contentView];
  1168. }
  1169. - (void)IAPProductPurchasedNotification:(NSNotification*)notification {
  1170. [self removeWaitingView:self.window.contentView];
  1171. [self reloadData];
  1172. if (IAPProductsManager.defaultManager.allAccessPackNew6months_lite.isSubscribed) {
  1173. if (self.kEventTag == 1) {
  1174. [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_7OffUpgrade_6MonthPaid"} platform:KMAnalyticsPlatformAppCenter];
  1175. }
  1176. } else if (IAPProductsManager.defaultManager.allAccessPack12months_lite.isSubscribed) {
  1177. if (self.kEventTag == 1) {
  1178. [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_7OffUpgrade_12MonthPaid"} platform:KMAnalyticsPlatformAppCenter];
  1179. }
  1180. }
  1181. }
  1182. - (void)IAPProductLoadedNotification:(NSNotification*)notification {
  1183. [self reloadData];
  1184. }
  1185. - (void)IAPProductRestoreFinishedNotification:(NSNotification *)notification {
  1186. [self removeWaitingView:self.window.contentView];
  1187. [self reloadData];
  1188. }
  1189. - (void)IAPProductRestoreFailedNotification:(NSNotification *)notification {
  1190. [self removeWaitingView:self.window.contentView];
  1191. }
  1192. - (void)IAPSubscriptionLoadedNotification:(NSNotification *)notification {
  1193. [self removeWaitingView:self.window.contentView];
  1194. [self reloadData];
  1195. }
  1196. @end