KMPurchaseCompareWindowController.m 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407
  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:@"https://www.anyrecover.com/buy-pdf-editor-reader-converter"];
  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 = NSLocalizedString(@"Subscription plans:\nSubscriptions: USD $39.99/(6 months), USD $79.99/(one-time purchase)\n\n- Subscriptions will be charged through your iTunes account at the confirmation of purchase.\n- Your subscriptions will automatically renew unless cancelled at least 24 hours before the end of current subscription period.\n- Your iTunes account will be charged for renewal within 24-hours prior to the end of the current period, for the same duration and at the current subscription price.\n- You may manage your subscriptions in your iTunes Account Settings after purchase.\n- No cancellation of the current subscription is allowed during an active subscription period.\n\n- Terms of service:\nhttps://www.anyrecover.com/company/terms-conditions\n- Privacy Policy:\nhttps://www.anyrecover.com/company/privacy-policy", nil);
  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. //
  487. // [self showDiscount];
  488. }
  489. - (BOOL)windowShouldClose:(id)sender {
  490. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_Upgrade_Cancel"}];
  491. if ([self isShowSale]) {
  492. [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_7OffUpgrade_Cancel"} platform:KMAnalyticsPlatformAppCenter];
  493. }
  494. [self endModal:sender];
  495. return YES;
  496. }
  497. - (void)close {
  498. [super close];
  499. [self endModal:nil];
  500. }
  501. - (IBAction)startModal:(id)sender {
  502. [NSApp stopModal];
  503. NSInteger modalCode;
  504. self.modalSession = [NSApp beginModalSessionForWindow:self.window];
  505. do {
  506. modalCode = [NSApp runModalSession:self.modalSession];
  507. } while (modalCode == NSModalResponseContinue);
  508. }
  509. - (IBAction)endModal:(id)sender {
  510. if (self.modalSession) {
  511. [NSApp stopModal];
  512. [NSApp endModalSession:self.modalSession];
  513. [self.window orderOut:self];
  514. self.modalSession = nil;
  515. }
  516. }
  517. - (void)showWindowRestore:(id)sender {
  518. [self showWindow:sender];
  519. [self buttonItemClicked_Restore:nil];
  520. }
  521. - (void)showWindow:(id)sender {
  522. [super showWindow:sender];
  523. [self reloadData];
  524. if ([self isShowSale]) {
  525. [self showDiscountToSaveWindow];
  526. }
  527. }
  528. #pragma mark - Private Methods
  529. - (void)reloadData {
  530. if (self.isPurchaseSwitch) {
  531. self.sixMouthProLabel.textColor = [NSColor colorWithRed:117/255.0 green:119/255.0 blue:128/255.0 alpha:1.0];
  532. self.oneYearProLabel.textColor = NSColor.whiteColor;
  533. self.switchCircleLeftConst.constant = 22;
  534. self.value1InfoLabel.stringValue = NSLocalizedString(@"1-year Plan", nil);
  535. } else {
  536. self.sixMouthProLabel.textColor = NSColor.whiteColor;
  537. self.oneYearProLabel.textColor = [NSColor colorWithRed:117/255.0 green:119/255.0 blue:128/255.0 alpha:1.0];
  538. self.switchCircleLeftConst.constant = 4;
  539. self.value1InfoLabel.stringValue = NSLocalizedString(@"6-Month Plan", nil);
  540. }
  541. self.saleBox.hidden = true;
  542. self.saleIv.hidden = true;
  543. if ([self isShowSale]) {
  544. KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.StoreUserRecovery.content.firstObject;
  545. NSURL *url = [NSURL URLWithString:[KMAdvertisementModelTransition transitionImagePathWithImage:info.saleImage highlight:true]];
  546. [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage * _Nonnull image) {
  547. if (image != nil) {
  548. self.saleIv.image = image;
  549. self.saleBox.hidden = false;
  550. self.saleIv.hidden = false;
  551. [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Exposure" : @"PUW_7OffUpgrade"} platform:KMAnalyticsPlatformAppCenter];
  552. }
  553. }];
  554. } else {
  555. self.saleBox.hidden = true;
  556. }
  557. if ([IAPProductsManager defaultManager].isAvailableAllFunction) {
  558. self.value1PurchaseButton.enabled = NO;
  559. self.value2PurchaseButton.enabled = NO;
  560. self.value2PurchaseLbl.textColor = [NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:0.5];
  561. } else {
  562. self.value1PurchaseButton.enabled = YES;
  563. self.value2PurchaseButton.enabled = YES;
  564. self.value2PurchaseLbl.textColor = [NSColor colorWithRed:85/255. green:40/255.0 blue:255.0/255.0 alpha:1.0];
  565. }
  566. self.value1PurchaseBtnLblBtn.enabled = self.value1PurchaseButton.enabled;
  567. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
  568. if ([IAPProductsManager defaultManager].newlyMonthProduct.isTrialPeriod) {
  569. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
  570. if ([IAPProductsManager defaultManager].newlyMonthProduct.isSubscribed) {
  571. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribed", nil);
  572. }
  573. } else if ([IAPProductsManager defaultManager].yearProduct.isTrialPeriod) {
  574. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
  575. if ([IAPProductsManager defaultManager].yearProduct.isSubscribed) {
  576. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribed", nil);
  577. }
  578. } else {
  579. if ([IAPProductsManager defaultManager].newlyMonthProduct.isSubscribed) {
  580. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribed", nil);
  581. } else if ([IAPProductsManager defaultManager].yearProduct.isSubscribed) {
  582. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribed", nil);
  583. } else {
  584. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Free Trial", nil);
  585. if (@available(macOS 10.13.2, *)) {
  586. #if !VERSION_DMG
  587. if (![IAPProductsManager defaultManager].newlyMonthProduct.product.introductoryPrice) {
  588. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
  589. } else if (![IAPProductsManager defaultManager].yearProduct.product.introductoryPrice) {
  590. self.value1PurchaseBtnLbl.stringValue = NSLocalizedString(@"Subscribe", nil);
  591. }
  592. #endif
  593. }
  594. }
  595. }
  596. if (self.value1PurchaseBtnLblBtn.enabled) {
  597. [self.value1PurchaseBtnLbl setTextColor:[NSColor whiteColor]];
  598. } else {
  599. [self.value1PurchaseBtnLbl setTextColor:[[NSColor whiteColor] colorWithAlphaComponent:0.5]];
  600. }
  601. self.value2PurchaseLblBtn.enabled = self.value2PurchaseButton.enabled;
  602. NSString *averageMonthPrice = nil;
  603. NSString *monthPrice = nil;
  604. NSString *averageMonthPrice_discount = nil;
  605. NSString *monthPrice_discount = nil;
  606. NSString *allPrice = nil;
  607. if ([IAPProductsManager defaultManager].newlyMonthProduct.isOffers) {
  608. self.specialView1.hidden = NO;
  609. averageMonthPrice = [IAPProductsManager defaultManager].newlyMonthProduct.offersAveragePrice;
  610. monthPrice = [IAPProductsManager defaultManager].newlyMonthProduct.offersPrice;
  611. averageMonthPrice_discount = [IAPProductsManager defaultManager].newlyMonthProduct.discountAveragePrice;
  612. monthPrice_discount = [IAPProductsManager defaultManager].newlyMonthProduct.discountPrice;
  613. self.topButtonOffset.constant = 20;
  614. } else if ([IAPProductsManager defaultManager].yearProduct.isOffers) {
  615. averageMonthPrice = [IAPProductsManager defaultManager].yearProduct.offersAveragePrice;
  616. monthPrice = [IAPProductsManager defaultManager].yearProduct.offersPrice;
  617. averageMonthPrice_discount = [IAPProductsManager defaultManager].yearProduct.discountAveragePrice;
  618. monthPrice_discount = [IAPProductsManager defaultManager].yearProduct.discountPrice;
  619. self.topButtonOffset.constant = 20;
  620. } else {
  621. self.specialView1.hidden = YES;
  622. if (self.isPurchaseSwitch == false) {
  623. averageMonthPrice = [IAPProductsManager defaultManager].newlyMonthProduct.averagePrice;
  624. monthPrice = [IAPProductsManager defaultManager].newlyMonthProduct.price;
  625. averageMonthPrice_discount = [IAPProductsManager defaultManager].newlyMonthProduct.discountAveragePrice;
  626. monthPrice_discount = [IAPProductsManager defaultManager].newlyMonthProduct.discountPrice;
  627. } else {
  628. averageMonthPrice = [IAPProductsManager defaultManager].yearProduct.averagePrice;
  629. monthPrice = [IAPProductsManager defaultManager].yearProduct.price;
  630. averageMonthPrice_discount = [IAPProductsManager defaultManager].yearProduct.discountAveragePrice;
  631. monthPrice_discount = [IAPProductsManager defaultManager].yearProduct.discountPrice;
  632. }
  633. self.topButtonOffset.constant = 10;
  634. }
  635. if ([IAPProductsManager defaultManager].allAccessProduct.isOffers) {
  636. self.topButtonOffset.constant = 20;
  637. self.specialView.hidden = NO;
  638. allPrice = [IAPProductsManager defaultManager].allAccessProduct.offersPrice;
  639. } else {
  640. self.topButtonOffset.constant = 10;
  641. self.specialView.hidden = YES;
  642. allPrice = [IAPProductsManager defaultManager].allAccessProduct.price;
  643. }
  644. CGFloat off = 1 -[IAPProductsManager defaultManager].allAccessProduct.offers;
  645. NSString *offString = [NSString stringWithFormat:@"%.f%%",off * 100];
  646. self.specialLabel.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@ off", @""),offString];
  647. if (self.isPurchaseSwitch) {
  648. off = 1 -[IAPProductsManager defaultManager].yearProduct.offers;
  649. } else {
  650. off = 1 -[IAPProductsManager defaultManager].newlyMonthProduct.offers;
  651. }
  652. offString = [NSString stringWithFormat:@"%.f%%",off * 100];
  653. self.specialLabel1.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@ off", @""),offString];
  654. NSImage *image = [NSImage imageNamed:@"KMImageNameCompareTagBG"];
  655. self.specialImageView.image = image;
  656. self.specialImageView1.image = image;
  657. BOOL isShowSale = [self isShowSale];
  658. if (KMKdanRemoteConfig.remoteConfig.showAPP_AveragePrice) {
  659. if (isShowSale) {
  660. self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", averageMonthPrice_discount, NSLocalizedString(@"mon", nil)];
  661. self.value1PurchaseOriPriceLbl.stringValue = [NSString stringWithFormat:@"%@/%@", averageMonthPrice, NSLocalizedString(@"mon", nil)];
  662. self.value1PurchaseOriPriceLbl.hidden = false;
  663. self.billedTopConst.constant = 16;
  664. } else {
  665. self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", averageMonthPrice, NSLocalizedString(@"mon", nil)];
  666. self.value1PurchaseOriPriceLbl.hidden = true;
  667. self.billedTopConst.constant = 0;
  668. }
  669. } else {
  670. if (self.isPurchaseSwitch) {
  671. if (isShowSale) {
  672. self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice_discount, NSLocalizedString(@"12 months", nil)];
  673. self.value1PurchaseOriPriceLbl.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice, NSLocalizedString(@"12 months", nil)];
  674. self.value1PurchaseOriPriceLbl.hidden = false;
  675. self.billedTopConst.constant = 16;
  676. } else {
  677. self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice, NSLocalizedString(@"12 months", nil)];
  678. self.value1PurchaseOriPriceLbl.hidden = true;
  679. self.billedTopConst.constant = 0;
  680. }
  681. } else {
  682. if (isShowSale) {
  683. self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice_discount, NSLocalizedString(@"6mon", nil)];
  684. self.value1PurchaseOriPriceLbl.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice, NSLocalizedString(@"6mon", nil)];
  685. self.value1PurchaseOriPriceLbl.hidden = false;
  686. self.billedTopConst.constant = 16;
  687. } else {
  688. self.value1PurchaseLabel.stringValue = [NSString stringWithFormat:@"%@/%@", monthPrice, NSLocalizedString(@"6mon", nil)];
  689. self.value1PurchaseOriPriceLbl.hidden = true;
  690. self.billedTopConst.constant = 0;
  691. }
  692. }
  693. }
  694. self.value1PurchaseLabel.textColor = [NSColor colorWithRed:1 green:231/255. blue:106/255. alpha:1.];
  695. self.value1PurchaseOriPriceLbl.textColor = [NSColor colorWithWhite:1 alpha:0.7];
  696. self.value1PurchaseOriPriceLbl.attributedStringValue = [[NSAttributedString alloc] initWithString:self.value1PurchaseOriPriceLbl.stringValue attributes:@{
  697. NSFontAttributeName : [NSFont SFProTextRegularFont:12],
  698. NSForegroundColorAttributeName: [NSColor colorWithWhite:1 alpha:0.7],
  699. NSStrikethroughStyleAttributeName : @(1)
  700. }];
  701. NSString *tTips = @"";
  702. if (isShowSale) {
  703. tTips = [NSString stringWithFormat:NSLocalizedString(@"%@ for the first 6-month subscription", nil), monthPrice_discount];
  704. } else {
  705. tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 6 months at %@", nil), monthPrice];
  706. }
  707. if ([self.value1PurchaseBtnLbl.stringValue isEqualToString:NSLocalizedString(@"Free Trial", nil)]) {
  708. tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 6 months at %@ after 7-day trial ends.", nil), monthPrice];
  709. #if !VERSION_DMG
  710. if (self.isPurchaseSwitch) {
  711. if ([IAPProductsManager defaultManager].yearProduct.product) {
  712. if (@available(macOS 10.13.2, *)) {
  713. tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 12 months at %@ after %@-day trial ends.", nil), monthPrice,@([IAPProductsManager defaultManager].yearProduct.product.introductoryPrice.subscriptionPeriod.numberOfUnits)];
  714. }
  715. }
  716. } else {
  717. if ([IAPProductsManager defaultManager].newlyMonthProduct.product) {
  718. if (@available(macOS 10.13.2, *)) {
  719. tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 6 months at %@ after %@-day trial ends.", nil), monthPrice,@([IAPProductsManager defaultManager].newlyMonthProduct.product.introductoryPrice.subscriptionPeriod.numberOfUnits)];
  720. }
  721. }
  722. }
  723. #endif
  724. }
  725. if (@available(macOS 10.13.2, *)) {
  726. #if !VERSION_DMG
  727. if (self.isPurchaseSwitch) {
  728. if (![IAPProductsManager defaultManager].yearProduct.product.introductoryPrice) {
  729. if (isShowSale) {
  730. tTips = [NSString stringWithFormat:NSLocalizedString(@"%@ for the first year's subscription", nil), monthPrice_discount];
  731. } else {
  732. tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 12 months at %@", nil), monthPrice];
  733. }
  734. }
  735. } else {
  736. if (![IAPProductsManager defaultManager].newlyMonthProduct.product.introductoryPrice) {
  737. if (isShowSale) {
  738. tTips = [NSString stringWithFormat:NSLocalizedString(@"%@ for the first 6-month subscription", nil), monthPrice_discount];
  739. } else {
  740. tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 6 months at %@", nil), monthPrice];
  741. }
  742. }
  743. }
  744. #endif
  745. }
  746. self.value1PurchaseSubLabel.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@", nil), tTips];
  747. self.value2PurchaseLabel.stringValue = allPrice?:@"";
  748. self.value2PurchaseLabel.textColor = [NSColor colorWithRed:1 green:231/255. blue:106/255. alpha:1.];
  749. self.value2PurchaseSubLabel.stringValue = NSLocalizedString(@"one-time purchase", nil);
  750. self.value3PurchaseLabel.stringValue = NSLocalizedString(@"USD $59.99", nil);
  751. self.value3PurchaseLabel.textColor = [NSColor colorWithRed:1 green:231/255. blue:106/255. alpha:1.];
  752. self.value3PurchaseSubLabel.stringValue = NSLocalizedString(@"one-time purchase", nil);
  753. self.value1PurchaseBtnLbl.font = [NSFont UbuntuBoldFontWithSize:16];
  754. self.value2PurchaseLbl.font = [NSFont UbuntuBoldFontWithSize:16];
  755. self.value3PurchaseBtnLbl.font = [NSFont UbuntuBoldFontWithSize:16];
  756. self.value1PurchaseLabel.font = [NSFont UbuntuBoldFontWithSize:22];
  757. self.value2PurchaseLabel.font = [NSFont UbuntuBoldFontWithSize:22];
  758. self.value3PurchaseLabel.font = [NSFont UbuntuBoldFontWithSize:22];
  759. self.value1PurchaseOriPriceLbl.font = [NSFont SFProTextRegularFont:12];
  760. }
  761. - (void)reloadDataContent {
  762. if (self.isPurchaseSwitch) {
  763. self.dataSource = @[@"PDF to Office",
  764. @[@"Convert PDFs to Word, HTML, TXT, JPEG or PNG files",@"Only first 10 pages",@"Advanced",@"Advanced",@"Standard"],
  765. @[@"Turn PDF to PPT, Excel, RTF, CSV, and more",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
  766. @[@"Convert PDF to TIFF, BMP, GIF or TGA files",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
  767. @"Edit PDF",
  768. @[@"Add and edit text in PDF",@"X",@"✓",@"✓",@"✓"],
  769. @[@"Edit, crop, replace image in PDF",@"X",@"✓",@"✓",@"✓"],
  770. @"OCR",
  771. @[@"Extract texts from image-based or scanned PDF",@"X",@"✓",@"✓",@"✓"],
  772. @"Organize Pages",
  773. @[@"Extract, rotate, rearrange, replace, add, delete pages",@"X",@"✓",@"✓",@"✓"],
  774. @[@"Split PDFs into multiple files",@"X",@"✓",@"✓",@"✓"],
  775. @"Advanced Editing Tools",
  776. @[@"Merge multiple documents into a new PDF",@"Up to 2 files or 20 MB",@"✓",@"∞",@"∞"],
  777. @[@"Add & edit watermark",@"X",@"✓",@"✓",@"✓"],
  778. @[@"Add header, footer, page numbers",@"X",@"✓",@"✓",@"✓"],
  779. @[@"Add Bates Number",@"X",@"✓",@"✓",@"✓"],
  780. @[@"Insert PDF page background by color or image",@"X",@"✓",@"✓",@"✓"],
  781. @[@"Create fattened copies",@"X",@"✓",@"✓",@"✓"],
  782. @[@"Extract Images",@"X",@"✓",@"✓",@"✓"],
  783. @[@"Extract tables",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
  784. @[@"Measuring Tools",@"X",@"✓",@"✓",@"✓"],
  785. @"Fill & Sign",
  786. @[@"Create digital signature",@"X",@"✓",@"✓",@"✓"],
  787. @[@"Create & Edit & Fill Adobe Fillable PDF Forms",@"X",@"✓",@"✓",@"✓"],
  788. @"Security",
  789. @[@"Batch encrypting PDF documents",@"X",@"✓",@"✓",@"✓"],
  790. @[@"PDF Password Remover",@"X",@"✓",@"✓",@"✓"],
  791. @[@"Redact sensitive information",@"X",@"✓",@"✓",@"✓"],
  792. @"Create PDF",
  793. @[@"Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs",@"1 file",@"✓",@"✓",@"✓"],
  794. @[@"Create PDFs from a scanner and iOS devices",@"X",@"✓",@"✓",@"✓"],
  795. @"Annotations",
  796. @[@"Customize PDF stamps",@"X",@"✓",@"✓",@"✓",@"✓"],
  797. @[@"Hyperlink",@"Page Number",@"Page Number, URL, Email",@"Page Number, URL, Email",@"Page Number, URL, Email"],
  798. @[@"Signature",@"Standard",@"Advanced",@"Advanced",@"Advanced"],
  799. @[@"Table",@"X",@"✓",@"✓",@"✓",@"✓"],
  800. @"View PDF",
  801. @[@"Multi-tab viewer",@"X",@"✓",@"✓",@"✓"],
  802. @[@"Various printing types: poster, booklet, multi-page printing",@"X",@"✓",@"✓",@"✓"],
  803. @[@"Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more",@"X",@"✓",@"✓",@"✓"],
  804. @[@"Split View to compare files",@"X",@"✓",@"✓",@"✓"],
  805. @"Subscription Based Solution",
  806. @[@"Access all premium features in app",@"X",@"12 months",@"∞",@"∞"],
  807. @[@"Priority customer support",@"X",@"✓",@"✓",@"✓"],
  808. @[@"Ad-free",@"X",@"✓",@"✓",@"✓"],
  809. @{}
  810. ];
  811. } else {
  812. self.dataSource = @[@"PDF to Office",
  813. @[@"Convert PDFs to Word, HTML, TXT, JPEG or PNG files",@"Only first 10 pages",@"Advanced",@"Advanced",@"Standard"],
  814. @[@"Turn PDF to PPT, Excel, RTF, CSV, and more",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
  815. @[@"Convert PDF to TIFF, BMP, GIF or TGA files",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
  816. @"Edit PDF",
  817. @[@"Add and edit text in PDF",@"X",@"✓",@"✓",@"✓"],
  818. @[@"Edit, crop, replace image in PDF",@"X",@"✓",@"✓",@"✓"],
  819. @"OCR",
  820. @[@"Extract texts from image-based or scanned PDF",@"X",@"✓",@"✓",@"✓"],
  821. @"Organize Pages",
  822. @[@"Extract, rotate, rearrange, replace, add, delete pages",@"X",@"✓",@"✓",@"✓"],
  823. @[@"Split PDFs into multiple files",@"X",@"✓",@"✓",@"✓"],
  824. @"Advanced Editing Tools",
  825. @[@"Merge multiple documents into a new PDF",@"Up to 2 files or 20 MB",@"✓",@"∞",@"∞"],
  826. @[@"Add & edit watermark",@"X",@"✓",@"✓",@"✓"],
  827. @[@"Add header, footer, page numbers",@"X",@"✓",@"✓",@"✓"],
  828. @[@"Add Bates Number",@"X",@"✓",@"✓",@"✓"],
  829. @[@"Insert PDF page background by color or image",@"X",@"✓",@"✓",@"✓"],
  830. @[@"Create fattened copies",@"X",@"✓",@"✓",@"✓"],
  831. @[@"Extract Images",@"X",@"✓",@"✓",@"✓"],
  832. @[@"Extract tables",@"Only first 10 pages",@"✓",@"✓",@"Only first 10 pages"],
  833. @[@"Measuring Tools",@"X",@"✓",@"✓",@"✓"],
  834. @"Fill & Sign",
  835. @[@"Create digital signature",@"X",@"✓",@"✓",@"✓"],
  836. @[@"Create & Edit & Fill Adobe Fillable PDF Forms",@"X",@"✓",@"✓",@"✓"],
  837. @"Security",
  838. @[@"Batch encrypting PDF documents",@"X",@"✓",@"✓",@"✓"],
  839. @[@"PDF Password Remover",@"X",@"✓",@"✓",@"✓"],
  840. @[@"Redact sensitive information",@"X",@"✓",@"✓",@"✓"],
  841. @"Create PDF",
  842. @[@"Convert JPEG, JPG, PNG, TIFF, BMP or PSD files to PDFs",@"1 file",@"✓",@"✓",@"✓"],
  843. @[@"Create PDFs from a scanner and iOS devices",@"X",@"✓",@"✓",@"✓"],
  844. @"Annotations",
  845. @[@"Customize PDF stamps",@"X",@"✓",@"✓",@"✓",@"✓"],
  846. @[@"Hyperlink",@"Page Number",@"Page Number, URL, Email",@"Page Number, URL, Email",@"Page Number, URL, Email"],
  847. @[@"Signature",@"Standard",@"Advanced",@"Advanced",@"Advanced"],
  848. @[@"Table",@"X",@"✓",@"✓",@"✓",@"✓"],
  849. @"View PDF",
  850. @[@"Multi-tab viewer",@"X",@"✓",@"✓",@"✓"],
  851. @[@"Various printing types: poster, booklet, multi-page printing",@"X",@"✓",@"✓",@"✓"],
  852. @[@"Customize theme colors: Light Mode, Dark Mode, Sepia Mode and more",@"X",@"✓",@"✓",@"✓"],
  853. @[@"Split View to compare files",@"X",@"✓",@"✓",@"✓"],
  854. @"Subscription Based Solution",
  855. @[@"Access all premium features in app",@"X",@"6 months",@"∞",@"∞"],
  856. @[@"Priority customer support",@"X",@"✓",@"✓",@"✓"],
  857. @[@"Ad-free",@"X",@"✓",@"✓",@"✓"],
  858. @{}
  859. ];
  860. }
  861. [self.tableView reloadData];
  862. }
  863. - (void)addWaingView:(NSView *)view {
  864. [self removeWaitingView:view];
  865. WaitingView *wView = [[WaitingView alloc] initWithFrame:view.bounds];
  866. [wView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
  867. [view addSubview:wView];
  868. [wView startAnimation];
  869. }
  870. - (void)removeWaitingView:(NSView *)view {
  871. for (id v in view.subviews) {
  872. if ([[v class] isSubclassOfClass:[WaitingView class]]) {
  873. [v removeFromSuperview];
  874. break;
  875. }
  876. }
  877. }
  878. - (void)updateViewColor {
  879. self.box.fillColor = [KMAppearance KMColor_Layout_L1];
  880. self.labelbox.fillColor = [NSColor clearColor];
  881. self.tableView.backgroundColor = [KMAppearance KMColor_Layout_L0];
  882. self.textView.backgroundColor = [NSColor clearColor];
  883. self.textView.textColor = [[NSColor whiteColor] colorWithAlphaComponent:0.5];
  884. self.value1PurchaseSubLabel.textColor = self.value2PurchaseSubLabel.textColor = self.value3PurchaseSubLabel.textColor = [KMAppearance KMColor_Layout_W0];
  885. }
  886. - (BOOL)isCancelAutoRenew {
  887. return [[IAPProductsManager defaultManager] isCancelAutoRenew];
  888. }
  889. - (BOOL)isShowSale {
  890. if (@available(macOS 10.14.4, *)) {
  891. if ([self isCancelAutoRenew]) {
  892. BOOL isSubscribed = [IAPProductsManager defaultManager].newlyMonthProduct.isSubscribed;
  893. if (isSubscribed) {
  894. return false;
  895. }
  896. isSubscribed = [IAPProductsManager defaultManager].yearProduct.isSubscribed;
  897. if (isSubscribed) {
  898. return false;
  899. }
  900. KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.StoreUserRecovery.content.firstObject;
  901. if ([info.show boolValue] == false) { // 活动结束
  902. return false;
  903. }
  904. return true;
  905. }
  906. }
  907. return false;
  908. }
  909. - (void)showDiscount {
  910. [self.discountYearly setHidden:YES];
  911. [self.discountPermanent setHidden:YES];
  912. [self.discountPremium setHidden:YES];
  913. if (KMAdvertisementManager.manager.info.StoreUserRecovery.content.count > 0) {
  914. for (int i = 0; i < KMAdvertisementManager.manager.info.StoreUserRecovery.content.count; i++) {
  915. if (i == 1) {
  916. KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.StoreUserRecovery.content[1];
  917. if ([KMAdvertisementManager checkAdvertisementValid:info]) {
  918. [self.discountYearly setHidden:NO];
  919. NSURL *url = [NSURL URLWithString:[KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight:NO]];
  920. self.discountYearly.image = [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage * _Nonnull image) {
  921. self.discountYearly.image = image;
  922. }];
  923. } else {
  924. [self.discountYearly setHidden:YES];
  925. }
  926. } else if (i == 2) {
  927. KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.StoreUserRecovery.content[2];
  928. if ([KMAdvertisementManager checkAdvertisementValid:info]) {
  929. [self.discountPermanent setHidden:NO];
  930. NSURL *url = [NSURL URLWithString:[KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight:NO]];
  931. self.discountPermanent.image = [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage * _Nonnull image) {
  932. self.discountPermanent.image = image;
  933. }];
  934. } else {
  935. [self.discountPermanent setHidden:YES];
  936. }
  937. } else if (i == 3) {
  938. KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.StoreUserRecovery.content[3];
  939. if ([KMAdvertisementManager checkAdvertisementValid:info]) {
  940. [self.discountPremium setHidden:NO];
  941. NSURL *url = [NSURL URLWithString:[KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight:NO]];
  942. self.discountPremium.image = [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage * _Nonnull image) {
  943. self.discountPremium.image = image;
  944. }];
  945. } else {
  946. [self.discountPremium setHidden:YES];
  947. }
  948. }
  949. }
  950. }
  951. }
  952. #pragma mark - Button Actions
  953. - (IBAction)buttonItemClicked_Subscribe:(id)sender {
  954. if (self.isPurchaseSwitch) {
  955. [[IAPProductsManager defaultManager] makeSubProduct:[IAPProductsManager defaultManager].yearProduct discount:[self isCancelAutoRenew]];
  956. } else {
  957. [[IAPProductsManager defaultManager] makeSubProduct:[IAPProductsManager defaultManager].newlyMonthProduct discount:[self isCancelAutoRenew]];
  958. }
  959. [self addWaingView:self.window.contentView];
  960. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_Upgrade_6Mon"}];
  961. if ([self isShowSale]) {
  962. self.kEventTag = 1;
  963. if (self.isPurchaseSwitch) {
  964. [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_7OffUpgrade_12Mon"} platform:KMAnalyticsPlatformAppCenter];
  965. } else {
  966. [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_7OffUpgrade_6Mon"} platform:KMAnalyticsPlatformAppCenter];
  967. }
  968. }
  969. }
  970. - (void)showDiscountToSaveWindow {
  971. if ([KMDiscountToSaveWindowController needShow] == false) {
  972. return;
  973. }
  974. KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.StoreUserRecovery.content.firstObject;
  975. NSURL *url = [NSURL URLWithString: [KMAdvertisementModelTransition transitionImagePathWithImage:info.image highlight: YES]];
  976. __weak typeof(self) weakSelf = self;
  977. [self addWaingView:self.window.contentView];
  978. [KMAdvertisementImage imageWithURLWithUrl:url completion:^(NSImage *image) {
  979. [weakSelf removeWaitingView:weakSelf.window.contentView];
  980. if (image == nil) {
  981. return;
  982. }
  983. [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Exposure" : @"PUW_PromotionalOffer"} platform:KMAnalyticsPlatformAppCenter];
  984. KMDiscountToSaveWindowController *winC = [[KMDiscountToSaveWindowController alloc] initWithWindowNibName:@"KMDiscountToSaveWindowController"];
  985. weakSelf.discountToSaveWinC = winC;
  986. [weakSelf.window beginSheet:winC.window completionHandler:^(NSModalResponse returnCode) { }];
  987. winC.imgIv.image = image;
  988. winC.itemClick = ^(NSInteger idx) {
  989. [weakSelf.window endSheet:weakSelf.discountToSaveWinC.window];
  990. weakSelf.discountToSaveWinC = nil;
  991. if (idx == 2) { // 订阅
  992. //// NSLog(@"buttonItemClicked_Subscribe");
  993. [weakSelf trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_PromotionalOffer_Subscribe"} platform:KMAnalyticsPlatformAppCenter];
  994. } else if (idx == 1) {
  995. [weakSelf trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_PromotionalOffer_Cancel"} platform:KMAnalyticsPlatformAppCenter];
  996. }
  997. };
  998. }];
  999. }
  1000. - (IBAction)buttonItemClicked_Restore:(id)sender {
  1001. [[IAPProductsManager defaultManager] restoreSubscriptions];
  1002. [self addWaingView:self.window.contentView];
  1003. }
  1004. - (IBAction)buttonItemClicked_Upgrade:(id)sender {
  1005. [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"macappstore://apps.apple.com/app/id825459243?mt=12"]];
  1006. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_Upgrade_Premium"}];
  1007. }
  1008. - (IBAction)privacyPolicyAction:(NSButton *)sender {
  1009. [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://www.anyrecover.com/company/privacy-policy"]];
  1010. }
  1011. - (IBAction)termOfSerAction:(NSButton *)sender {
  1012. [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://www.anyrecover.com/company/terms-conditions"]];
  1013. }
  1014. - (IBAction)buttonItemClicked_LicenseUpgrade:(id)sender {
  1015. [[IAPProductsManager defaultManager] makeProduct:[IAPProductsManager defaultManager].allAccessProduct];
  1016. [self addWaingView:self.window.contentView];
  1017. [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"PUW_Btn_Upgrade_Permanent"}];
  1018. }
  1019. - (IBAction)buttonItemClicked_AboutSubscriptions:(id)sender {
  1020. NSString *tMessage = [NSString stringWithFormat:@"%@\n%@\n\n%@\n%@\n%@\n%@\n%@\n\n%@\n%@\n\n",
  1021. @"Subscription plans: ",
  1022. @"Subscriptions: USD $39.99/(6 months), USD $79.99/(one-time purchase) ",
  1023. @"- Subscriptions will be charged through your iTunes account at the confirmation of purchase. ",
  1024. @"- Your subscriptions will automatically renew unless cancelled at least 24 hours before the end of current subscription period. ",
  1025. @"- 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. ",
  1026. @"- You may manage your subscriptions in your iTunes Account Settings after purchase. ",
  1027. @"- No cancellation of the current subscription is allowed during an active subscription period. ",
  1028. @"- Terms of service: \nhttps://www.anyrecover.com/company/terms-conditions ",
  1029. @"- Privacy Policy: \nhttps://www.anyrecover.com/company/privacy-policy "];
  1030. NSAlert *alert = [[NSAlert alloc] init];
  1031. [alert setAlertStyle:NSAlertStyleInformational];
  1032. [alert setMessageText:NSLocalizedString(tMessage, nil)];
  1033. [alert runModal];
  1034. }
  1035. - (IBAction)buttonItemClicked_CloseWindow:(id)sender {
  1036. [self close];
  1037. }
  1038. - (void)switchAction:(NSButton *)sender {
  1039. // NSControlStateValue state = self.switchBtn.state;
  1040. BOOL isSwitch = self.isPurchaseSwitch;
  1041. if (isSwitch) {
  1042. // self.switchBtn.state = NSControlStateValueOff;
  1043. self.isPurchaseSwitch = false;
  1044. // self.switchCircleLeftConst.constant = 4;
  1045. } else {
  1046. // self.switchBtn.state = NSControlStateValueOn;
  1047. self.isPurchaseSwitch = true;
  1048. // self.switchCircleLeftConst.constant = 22;
  1049. }
  1050. // if (self.isPurchaseSwitch) { // 一年
  1051. //
  1052. // } else { // 半年
  1053. //
  1054. // }
  1055. [self reloadDataContent];
  1056. [self reloadData];
  1057. }
  1058. #pragma mark - NSTableViewDataSource Methods
  1059. - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView {
  1060. return self.dataSource.count;
  1061. }
  1062. - (id)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
  1063. id object = [self.dataSource objectAtIndex:row];
  1064. if ([object isKindOfClass:[NSString class]]) {
  1065. KMPurchaseCompareHeaderCell *cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareHeaderCellIdentifier owner:self];
  1066. cellView.textField.stringValue = NSLocalizedString(object, nil);
  1067. return cellView;
  1068. } else if ([object isKindOfClass:[NSArray class]]) {
  1069. KMPurchaseCompareCell *cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareCellIdentifier owner:self];
  1070. NSString *value = [(NSArray *)object count] > 0 ? object[0] : @"";
  1071. NSString *value1 = [(NSArray *)object count] > 1 ? object[1] : @"";
  1072. NSString *value2 = [(NSArray *)object count] > 2 ? object[2] : @"";
  1073. NSString *value3 = [(NSArray *)object count] > 3 ? object[3] : @"";
  1074. NSString *value4 = [(NSArray *)object count] > 4 ? object[4] : @"";
  1075. cellView.textField.stringValue = NSLocalizedString(value, nil);
  1076. cellView.lineBox.hidden = NO;
  1077. if (row + 1 == (NSInteger)self.dataSource.count) {
  1078. cellView.lineBox.hidden = YES;
  1079. } else {
  1080. id nextobject = [self.dataSource objectAtIndex:row+1];
  1081. if ([nextobject isKindOfClass:[NSString class]]) {
  1082. cellView.lineBox.hidden = YES;
  1083. }
  1084. }
  1085. if (row + 2 == (NSInteger)self.dataSource.count) {
  1086. cellView.boxBottomConst.constant = 0;
  1087. } else {
  1088. cellView.boxBottomConst.constant = -4;
  1089. }
  1090. if ([value1 isEqualToString:@"X"]) {
  1091. cellView.value1Label.stringValue = @"";
  1092. cellView.value1ImageView.image = [NSImage imageNamed:@"compare_nosupport"];
  1093. } else if ([value1 isEqualToString:@"✓"]) {
  1094. cellView.value1Label.stringValue = @"";
  1095. cellView.value1ImageView.image = [NSImage imageNamed:@"compare_support"];
  1096. } else if ([value1 isEqualToString:@"∞"]) {
  1097. cellView.value1Label.stringValue = @"";
  1098. cellView.value1ImageView.image = [NSImage imageNamed:@"compare_00"];
  1099. } else {
  1100. cellView.value1Label.stringValue = NSLocalizedString(value1, nil);
  1101. cellView.value1ImageView.image = nil;
  1102. }
  1103. if ([value2 isEqualToString:@"X"]) {
  1104. cellView.value2Label.stringValue = @"";
  1105. cellView.value2ImageView.image = [NSImage imageNamed:@"compare_nosupport"];
  1106. } else if ([value2 isEqualToString:@"✓"]) {
  1107. cellView.value2Label.stringValue = @"";
  1108. cellView.value2ImageView.image = [NSImage imageNamed:@"compare_support"];
  1109. } else if ([value2 isEqualToString:@"∞"]) {
  1110. cellView.value2Label.stringValue = @"";
  1111. cellView.value2ImageView.image = [NSImage imageNamed:@"compare_00"];
  1112. } else {
  1113. cellView.value2Label.stringValue = NSLocalizedString(value2, nil);
  1114. cellView.value2ImageView.image = nil;
  1115. }
  1116. if ([value3 isEqualToString:@"X"]) {
  1117. cellView.value3Label.stringValue = @"";
  1118. cellView.value3ImageView.image = [NSImage imageNamed:@"compare_nosupport"];
  1119. } else if ([value3 isEqualToString:@"✓"]) {
  1120. cellView.value3Label.stringValue = @"";
  1121. cellView.value3ImageView.image = [NSImage imageNamed:@"compare_support"];
  1122. } else if ([value3 isEqualToString:@"∞"]) {
  1123. cellView.value3Label.stringValue = @"";
  1124. cellView.value3ImageView.image = [NSImage imageNamed:@"compare_00"];
  1125. } else {
  1126. cellView.value3Label.stringValue = NSLocalizedString(value3, nil);
  1127. cellView.value3ImageView.image = nil;
  1128. }
  1129. if ([value4 isEqualToString:@"X"]) {
  1130. cellView.value4Label.stringValue = @"";
  1131. cellView.value4ImageView.image = [NSImage imageNamed:@"compare_nosupport"];
  1132. } else if ([value4 isEqualToString:@"✓"]) {
  1133. cellView.value4Label.stringValue = @"";
  1134. cellView.value4ImageView.image = [NSImage imageNamed:@"compare_support"];
  1135. } else if ([value4 isEqualToString:@"∞"]) {
  1136. cellView.value4Label.stringValue = @"";
  1137. cellView.value4ImageView.image = [NSImage imageNamed:@"compare_00"];
  1138. } else {
  1139. cellView.value4Label.stringValue = NSLocalizedString(value4, nil);
  1140. cellView.value4ImageView.image = nil;
  1141. }
  1142. return cellView;
  1143. } else if ([object isKindOfClass:[NSDictionary class]]) {
  1144. KMPurchaseCompareEmptyCell *cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareEmptyCellIdentifier owner:self];
  1145. return cellView;
  1146. }
  1147. return nil;
  1148. }
  1149. - (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row {
  1150. NSTableCellView *cellView = nil;
  1151. id object = [self.dataSource objectAtIndex:row];
  1152. if ([object isKindOfClass:[NSString class]]) {
  1153. cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareHeaderCellIdentifier owner:self];
  1154. cellView.textField.stringValue = NSLocalizedString(object, nil);
  1155. } else if ([object isKindOfClass:[NSArray class]]) {
  1156. cellView = [tableView makeViewWithIdentifier:KMPurchaseCompareCellIdentifier owner:self];
  1157. cellView.textField.stringValue = NSLocalizedString(object[0], nil);
  1158. } else if ([object isKindOfClass:[NSDictionary class]]) {
  1159. return 40;
  1160. }
  1161. if (cellView) {
  1162. [cellView layoutSubtreeIfNeeded];
  1163. return cellView.frame.size.height;
  1164. } else {
  1165. return 0;
  1166. }
  1167. }
  1168. #pragma mark - InAppPurchaseManager Notification
  1169. - (void)IAPProductFailedNotification:(NSNotification*)notification {
  1170. [self removeWaitingView:self.window.contentView];
  1171. }
  1172. - (void)IAPProductPurchasedNotification:(NSNotification*)notification {
  1173. [self removeWaitingView:self.window.contentView];
  1174. [self reloadData];
  1175. if (IAPProductsManager.defaultManager.newlyMonthProduct.isSubscribed) {
  1176. if (self.kEventTag == 1) {
  1177. [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_7OffUpgrade_6MonthPaid"} platform:KMAnalyticsPlatformAppCenter];
  1178. }
  1179. } else if (IAPProductsManager.defaultManager.yearProduct.isSubscribed) {
  1180. if (self.kEventTag == 1) {
  1181. [self trackEvent_freeWithEventName:@"PromotionalOffer" params:@{@"PUW_Btn" : @"PUW_7OffUpgrade_12MonthPaid"} platform:KMAnalyticsPlatformAppCenter];
  1182. }
  1183. }
  1184. }
  1185. - (void)IAPProductLoadedNotification:(NSNotification*)notification {
  1186. [self reloadData];
  1187. }
  1188. - (void)IAPProductRestoreFinishedNotification:(NSNotification *)notification {
  1189. [self removeWaitingView:self.window.contentView];
  1190. [self reloadData];
  1191. }
  1192. - (void)IAPProductRestoreFailedNotification:(NSNotification *)notification {
  1193. [self removeWaitingView:self.window.contentView];
  1194. }
  1195. - (void)IAPSubscriptionLoadedNotification:(NSNotification *)notification {
  1196. [self removeWaitingView:self.window.contentView];
  1197. [self reloadData];
  1198. }
  1199. @end