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