KMPurchaseCompareWindowController.m 69 KB

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