KMConvertCompareViewController.m 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. //
  2. // KMConvertCompareViewController.m
  3. // PDF Reader Pro Edition
  4. //
  5. // Created by 丁林圭 on 2019/5/23.
  6. //
  7. #import "KMConvertCompareViewController.h"
  8. //#import "NSButton+TitleColor.h"
  9. #import "NSImage_SKExtensions.h"
  10. #import "VerificationManager.h"
  11. //#import "KMScrollView.h"
  12. //#import "KMBox.h"
  13. //#import "KMButton.h"
  14. //#import "KMKdanRemoteConfig.h"
  15. #import <PDF_Reader_Pro-Swift.h>
  16. @interface KMHeaderBox : NSBox
  17. @property (nonatomic, retain)NSGradient *gradient;
  18. @end
  19. @implementation KMHeaderBox
  20. - (void)dealloc {
  21. }
  22. - (void)drawRect:(NSRect)dirtyRect {
  23. [super drawRect:dirtyRect];
  24. NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:self.frame xRadius:10 yRadius:10];
  25. [self.gradient drawInBezierPath:path relativeCenterPosition:NSMakePoint(-1, -1)];
  26. self.gradient = [[NSGradient alloc] initWithStartingColor:[KMAppearance KMColor_Upgrade_Vip_BG] endingColor:[KMAppearance KMColor_Upgrade_Vip_BG_1]];
  27. }
  28. @end
  29. @interface KMConvertCompareViewController ()
  30. @property (assign) IBOutlet KMButton *subscribeBtn1;
  31. @property (assign) IBOutlet KMBox *subscribeBox1;
  32. @property (assign) IBOutlet KMButton *subscribeBtn2;
  33. @property (assign) IBOutlet NSBox *subscribeBox2;
  34. @property (assign) IBOutlet NSTextField *subscribeLabel1;
  35. @property (assign) IBOutlet NSTextField *subscribeLabel2;
  36. @property (assign) IBOutlet NSTextField *subscribeLabel3;
  37. @property (assign) IBOutlet NSTextField *subscribeLabel4;
  38. @property (assign) IBOutlet NSButton *subscribeBtn3;
  39. @property (assign) IBOutlet KMBox *subscribeBox3;
  40. @property (assign) IBOutlet NSTextField *subscribe3Label;
  41. @property (assign) IBOutlet KMButton *subscribeBtn4;
  42. @property (assign) IBOutlet NSBox *subscribeBox4;
  43. @property (assign) IBOutlet NSTextField *subscribe4Label;
  44. @property (assign) IBOutlet NSButton *restoreBtn;
  45. @property (assign) IBOutlet NSButton *compareBtn;
  46. @property (assign) IBOutlet NSButton *moreBtn;
  47. @property (assign) IBOutlet NSTextField *titleLabel;
  48. @property (assign) IBOutlet NSTextField *contentLabel;
  49. @property (assign) IBOutlet NSLayoutConstraint *boxBottemOffset;
  50. @property (assign) IBOutlet NSLayoutConstraint *buttonBottemOffset;
  51. @property (assign) IBOutlet NSTextView *purchaseContenxtTextView;
  52. @property (assign) IBOutlet NSBox *purchaseBox1;
  53. @property (assign) IBOutlet NSBox *purchaseBox2;
  54. @property (assign) IBOutlet NSTextView *bottomTextView;
  55. @property (assign) IBOutlet NSButton *moreButton;
  56. @property (nonatomic, assign) IBOutlet NSView *specialView;
  57. @property (nonatomic, assign) IBOutlet NSImageView *specialImageView;
  58. @property (nonatomic, assign) IBOutlet NSTextField *specialLabel;
  59. @property (nonatomic, assign) IBOutlet NSView *specialView1;
  60. @property (nonatomic, assign) IBOutlet NSImageView *specialImageView1;
  61. @property (nonatomic, assign) IBOutlet NSTextField *specialLabel1;
  62. @property (nonatomic, retain) NSMutableArray *imageArray;
  63. @property (nonatomic, retain) NSMutableArray *titleArray;
  64. @property (nonatomic, retain) NSMutableArray *contentArray;
  65. @property (nonatomic,assign) IBOutlet NSScrollView *headerScrollview;
  66. @property (nonatomic,assign) IBOutlet NSView *roundView1;
  67. @property (assign) IBOutlet NSLayoutConstraint *roundView1RightOffset;
  68. @property (nonatomic,assign) IBOutlet NSView *roundView2;
  69. @property (assign) IBOutlet NSLayoutConstraint *roundView2RightOffset;
  70. @property (nonatomic,assign) IBOutlet NSView *roundView3;
  71. @property (assign) IBOutlet NSLayoutConstraint *roundView3RightOffset;
  72. @property (nonatomic,assign) IBOutlet NSView *roundView4;
  73. @property (assign) IBOutlet NSLayoutConstraint *roundView4RightOffset;
  74. @property (nonatomic,assign) IBOutlet NSView *roundView5;
  75. @property (assign) IBOutlet NSLayoutConstraint *roundView5RightOffset;
  76. @property (assign) IBOutlet NSLayoutConstraint *restonButtonBottemOffset;
  77. @property (nonatomic,assign) IBOutlet NSBox *bottomBox1;
  78. @property (nonatomic,assign) IBOutlet NSBox *bottomBox2;
  79. @property (nonatomic,assign) IBOutlet NSBox *bottomBox3;
  80. @property (assign) IBOutlet NSButton *nextBtn;
  81. @property (assign) IBOutlet NSButton *forwardBtn;
  82. @property (assign) IBOutlet NSBox *headerBox;
  83. @property (nonatomic, assign) NSInteger selectIndex;
  84. @property (nonatomic, assign) NSInteger indexPage;
  85. @property (nonatomic, assign) KMCompareWithToolType type;
  86. @property (nonatomic, retain) CALayer *subscribeBox1Layer;
  87. @property (nonatomic, retain) CALayer *subscribeBox3Layer;
  88. @property (nonatomic, retain) CAGradientLayer *viewLayer;
  89. @end
  90. @implementation KMConvertCompareViewController
  91. - (void)dealloc
  92. {
  93. _block = nil;
  94. [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
  95. }
  96. - (instancetype)initWithCompareType:(NSInteger)type selectIndex:(NSInteger)selectIndex
  97. {
  98. if (self = [super initWithNibName:@"KMConvertCompareViewController" bundle:nil]) {
  99. self.type = type;
  100. self.indexPage = selectIndex;
  101. }
  102. return self;
  103. }
  104. - (void)loadView
  105. {
  106. [super loadView];
  107. if (!self.viewLayer) {
  108. self.viewLayer = [CAGradientLayer layer];
  109. }
  110. [self.view.layer addSublayer:self.viewLayer];
  111. [self updateUI];
  112. [self localizedLanguage];
  113. [self updateViewColor];
  114. }
  115. - (void)viewDidAppear {
  116. [super viewDidAppear];
  117. NSScrollView *scrollView = self.headerScrollview;
  118. [NSAnimationContext beginGrouping];
  119. [[NSAnimationContext currentContext] setDuration:0.3];
  120. NSClipView* clipView = [scrollView contentView];
  121. NSPoint newOrigin = [clipView bounds].origin;
  122. if (self.selectIndex > (NSInteger)(self.imageArray.count - 1)) {
  123. self.selectIndex =0;
  124. }
  125. newOrigin.x = self.selectIndex*560;
  126. [[clipView animator] setBoundsOrigin:newOrigin];
  127. [scrollView reflectScrolledClipView: [scrollView contentView]]; // may not bee necessary
  128. [NSAnimationContext endGrouping];
  129. [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil];
  130. }
  131. - (void)reloadData
  132. {
  133. #ifndef VERSION_DMG
  134. NSString * averagePrice = @"";
  135. NSString * subPrice = @"";
  136. NSString * allPrice = @"";
  137. if ([IAPProductsManager defaultManager].newlyMonthProduct.isOffers) {
  138. self.specialView1.hidden = NO;
  139. averagePrice = [IAPProductsManager defaultManager].newlyMonthProduct.offersAveragePrice;
  140. subPrice = [IAPProductsManager defaultManager].newlyMonthProduct.offersPrice;
  141. } else {
  142. self.specialView1.hidden = YES;
  143. averagePrice = [IAPProductsManager defaultManager].newlyMonthProduct.averagePrice;
  144. subPrice = [IAPProductsManager defaultManager].newlyMonthProduct.price;
  145. }
  146. if ([IAPProductsManager defaultManager].allAccessProduct.isOffers) {
  147. self.specialView.hidden = NO;
  148. allPrice = [IAPProductsManager defaultManager].allAccessProduct.offersPrice;
  149. } else {
  150. self.specialView.hidden = YES;
  151. allPrice = [IAPProductsManager defaultManager].allAccessProduct.price;
  152. }
  153. CGFloat off = 1 -[IAPProductsManager defaultManager].newlyMonthProduct.offers;
  154. NSString *offString = [NSString stringWithFormat:@"%.f%%",off * 100];
  155. self.specialLabel1.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@ off", @""),offString];
  156. off = 1 -[IAPProductsManager defaultManager].allAccessProduct.offers;
  157. offString = [NSString stringWithFormat:@"%.f%%",off * 100];
  158. self.specialLabel.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@ off", @""),offString];
  159. NSImage *image = [NSImage imageNamed:@"KMImageNameCompareTagBG"];
  160. self.specialImageView.image = image;
  161. self.specialImageView1.image = image;
  162. if ([[KMKdanRemoteConfig remoteConfig] showAPP_AveragePrice]) {
  163. self.subscribeLabel1.stringValue = [NSString stringWithFormat:@"%@/%@", averagePrice, NSLocalizedString(@"mon", nil)];
  164. } else {
  165. self.subscribeLabel1.stringValue = [NSString stringWithFormat:@"%@/%@", subPrice, NSLocalizedString(@"6mon", nil)];
  166. }
  167. NSString *tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 6 months at %@", nil), subPrice];
  168. self.subscribeLabel2.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@", nil), tTips];
  169. self.subscribeLabel3.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@", nil), allPrice];
  170. self.subscribeLabel4.stringValue = NSLocalizedString(@"one-time purchase", nil);
  171. self.subscribeLabel3.textColor = [KMAppearance KMColor_Interactive_M0];
  172. self.subscribeLabel4.textColor = [KMAppearance KMColor_Upgrade_Vip_BG_1];
  173. if ([IAPProductsManager defaultManager].isAvailableAllFunction) {
  174. [self.subscribeBtn1 setEnabled:NO];
  175. [self.subscribeBtn2 setEnabled:NO];
  176. } else {
  177. [self.subscribeBtn1 setEnabled:YES];
  178. [self.subscribeBtn2 setEnabled:YES];
  179. }
  180. #endif
  181. }
  182. - (void)removeObserver {
  183. [NSDistributedNotificationCenter.defaultCenter removeObserver:self];
  184. }
  185. #pragma mark - Setter and Getter
  186. - (void)setSelectIndex:(NSInteger)selectIndex
  187. {
  188. if (selectIndex> (NSInteger)self.imageArray.count - 1) {
  189. selectIndex = 0;
  190. }
  191. _selectIndex = selectIndex;
  192. NSColor * color1 = [NSColor whiteColor];
  193. NSColor * color2 = [NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.5];
  194. self.contentLabel.stringValue = self.contentArray[selectIndex]?:@"";
  195. self.titleLabel.stringValue = self.titleArray[selectIndex]?:@"";
  196. if (_selectIndex == 0) {
  197. self.roundView1.layer.backgroundColor = color1.CGColor;
  198. self.roundView2.layer.backgroundColor =
  199. self.roundView3.layer.backgroundColor =
  200. self.roundView4.layer.backgroundColor =
  201. self.roundView5.layer.backgroundColor = color2.CGColor;
  202. } else if(_selectIndex == 1){
  203. self.roundView2.layer.backgroundColor = color1.CGColor;
  204. self.roundView1.layer.backgroundColor =
  205. self.roundView3.layer.backgroundColor =
  206. self.roundView4.layer.backgroundColor =
  207. self.roundView5.layer.backgroundColor = color2.CGColor;
  208. } else if(_selectIndex == 2){
  209. self.roundView3.layer.backgroundColor = color1.CGColor;
  210. self.roundView1.layer.backgroundColor =
  211. self.roundView2.layer.backgroundColor =
  212. self.roundView4.layer.backgroundColor =
  213. self.roundView5.layer.backgroundColor = color2.CGColor;
  214. }else if(_selectIndex == 3){
  215. self.roundView4.layer.backgroundColor = color1.CGColor;
  216. self.roundView1.layer.backgroundColor =
  217. self.roundView2.layer.backgroundColor =
  218. self.roundView3.layer.backgroundColor =
  219. self.roundView5.layer.backgroundColor = color2.CGColor;
  220. } else if(_selectIndex == 4){
  221. self.roundView5.layer.backgroundColor = color1.CGColor;
  222. self.roundView1.layer.backgroundColor =
  223. self.roundView2.layer.backgroundColor =
  224. self.roundView3.layer.backgroundColor =
  225. self.roundView4.layer.backgroundColor = color2.CGColor;
  226. }
  227. dispatch_async(dispatch_get_main_queue(), ^{
  228. NSScrollView *scrollView = self.headerScrollview;
  229. [NSAnimationContext beginGrouping];
  230. [[NSAnimationContext currentContext] setDuration:0.3];
  231. NSClipView* clipView = [scrollView contentView];
  232. NSPoint newOrigin = [clipView bounds].origin;
  233. newOrigin.x = self->_selectIndex*560;
  234. [[clipView animator] setBoundsOrigin:newOrigin];
  235. [scrollView reflectScrolledClipView: [scrollView contentView]]; // may not bee necessary
  236. [NSAnimationContext endGrouping];
  237. });
  238. }
  239. - (NSMutableArray *)imageArray
  240. {
  241. if (!_imageArray) {
  242. _imageArray = [[NSMutableArray alloc] init];
  243. if (KMCompareWithToolTypeConvert == self.type) {
  244. [_imageArray addObjectsFromArray:@[
  245. [NSImage imageNamed:@"KMImageNameUpgradeComvert"],
  246. [NSImage imageNamed:@"KMImageNameUpgradeConvertWord"],
  247. [NSImage imageNamed:@"KMImageNameUpgradeConvertExcel"],
  248. [NSImage imageNamed:@"KMImageNameUpgradeConvertPPT"],
  249. [NSImage imageNamed:@"KMImageNameUpgradeConvertOther"]]];
  250. } else if (KMCompareWithToolTypeOCR == self.type) {
  251. [_imageArray addObjectsFromArray:@[
  252. [NSImage imageNamed:@"KMImageNameUpgradeOCR"]]];
  253. } else if (KMCompareWithToolTypePageEdit == self.type) {
  254. [_imageArray addObjectsFromArray:@[[NSImage imageNamed:@"KMImageNameUpgradePageEdit"],
  255. [NSImage imageNamed:@"KMImageNameUpgradeMergeSplit"]]];
  256. } else if (KMCompareWithToolTypePDFEdit == self.type) {
  257. [_imageArray addObjectsFromArray:@[
  258. [NSImage imageNamed:@"KMImageNameUpgradePDFEdit"],
  259. [NSImage imageNamed:@"KMImageNameUpgradeWatermark"],
  260. [NSImage imageNamed:@"KMImageNameUpgradeBates"],
  261. [NSImage imageNamed:@"KMImageNameUpgradeSecurity"]]];
  262. } else if (KMCompareWithToolTypeFromSign == self.type) {
  263. [_imageArray addObjectsFromArray:@[
  264. [NSImage imageNamed:@"KMImageNameUpgradeFormSignFrom"]]];
  265. } else if (KMCompareWithToolTypeSign == self.type) {
  266. [_imageArray addObjectsFromArray:@[
  267. [NSImage imageNamed:@"KMImageNameUpgradeSign"]]];
  268. } else if (KMCompareWithToolTypeEditPDF == self.type) {
  269. [_imageArray addObjectsFromArray:@[
  270. [NSImage imageNamed:@"KMImageNameUpgradeEditPDF"]]];
  271. }
  272. }
  273. return _imageArray;
  274. }
  275. - (NSMutableArray *)titleArray
  276. {
  277. if (!_titleArray) {
  278. _titleArray = [[NSMutableArray alloc] init];
  279. if (KMCompareWithToolTypeConvert == self.type) {
  280. [_titleArray addObjectsFromArray:@[NSLocalizedString(@"PDF To Office", nil),
  281. NSLocalizedString(@"PDF To Word", nil),
  282. NSLocalizedString(@"PDF To Excel", nil),
  283. NSLocalizedString(@"PDF To PPT", nil),
  284. NSLocalizedString(@"PDF To Image", nil)]];
  285. } else if (KMCompareWithToolTypeOCR == self.type) {
  286. [_titleArray addObjectsFromArray:@[NSLocalizedString(@"OCR", nil)]];
  287. } else if (KMCompareWithToolTypePageEdit == self.type) {
  288. [_titleArray addObjectsFromArray:@[NSLocalizedString(@"Page Editor", nil),[NSString stringWithFormat:@"%@ & %@",NSLocalizedString(@"Merge", nil),NSLocalizedString(@"Split", nil)]]];
  289. } else if (KMCompareWithToolTypePDFEdit == self.type) {
  290. [_titleArray addObjectsFromArray:
  291. @[NSLocalizedString(@"PDF Editor", nil),
  292. NSLocalizedString(@"Watermark", nil),
  293. NSLocalizedString(@"Bates Numbers", nil),
  294. NSLocalizedString(@"Security", nil)]];
  295. } else if (KMCompareWithToolTypeFromSign == self.type || KMCompareWithToolTypeSign == self.type) {
  296. [_titleArray addObjectsFromArray:@[NSLocalizedString(@"Form & Sign", nil)]];
  297. } else if (KMCompareWithToolTypeEditPDF == self.type) {
  298. [_titleArray addObjectsFromArray:@[NSLocalizedString(@"Edit PDF", nil)]];
  299. }
  300. }
  301. return _titleArray;
  302. }
  303. - (NSMutableArray *)contentArray
  304. {
  305. if (!_contentArray) {
  306. _contentArray = [[NSMutableArray alloc] init];
  307. if (KMCompareWithToolTypeConvert == self.type) {
  308. [_contentArray addObjectsFromArray:@[[NSString stringWithFormat:@"%@\n\n%@", NSLocalizedString(@"With the best PDF to Office Converter Offline, Does exactly what you want and retains all formatting. The best quality and most accurate PDF to DOCX/PPTX/XLSX conversion for keeping the fonts and layouts intact, including bullets and tables.", nil), NSLocalizedString(@"First 10 pages of each document for free.", nil)],
  309. [NSString stringWithFormat:@"%@ %@", NSLocalizedString(@"Stop retyping. Start making progress.", nil), NSLocalizedString(@"Convert all the great work stored in your PDF to a Word document that’s easy to update. Keep the fonts and layouts intact — including bullets and tables.", nil)],
  310. NSLocalizedString(@"Skip the data entry steps and tedious reformatting tasks, too. When you convert to Excel, your data is preserved along with your columns, layouts, and formatting.", nil),
  311. NSLocalizedString(@"When you use PDF Reader Pro to convert PDFs to PowerPoint, you know your formats will be saved, too. So you don’t have to bother redoing bullets, tables, objects, or master layouts.", nil),
  312. NSLocalizedString(@"Allow a few seconds to turn your PDF pages into high-quality images. All image quality and resolution will remain intact. No file size limit nor registration is required.", nil)]];
  313. } else if (KMCompareWithToolTypeOCR == self.type) {
  314. [_contentArray addObjectsFromArray:@[NSLocalizedString(@"With optical character recognition (OCR), PDF Reader Pro works as a text converter, automatically extracting text from any scanned paper document or image and converting it to a PDF or Text document.", nil)]];
  315. } else if (KMCompareWithToolTypePageEdit == self.type) {
  316. [_contentArray addObjectsFromArray:@[NSLocalizedString(@"It’s super simple to organize your PDF file into a professional-looking document. Insert, replace, extract, split, rotate, copy, delete, rearrange PDF pages and organize those pages just the way you like it, all in a matter of seconds. Drag-and-drop makes it more efficient.", nil),NSLocalizedString(@"Use the PDF splitter to separate one or more PDFs into multiple documents by simply specifying the number of pages, file size, or top-level bookmarks. Or combine more documents into a new PDF.", nil)]];
  317. } else if (KMCompareWithToolTypePDFEdit == self.type) {
  318. [_contentArray addObjectsFromArray:@[
  319. NSLocalizedString(@"The best PDF Editor for you to edit PDF documents. Insert, merge or split PDF pages; Compress and shrink PDF to make it smaller; Add background, watermark, password to protect sensitive PDFs, or header, footer and bates numberings.", nil),
  320. NSLocalizedString(@"Watermark your PDF documents with text or an image that appears either in front of or behind existing document content, like a stamp, to protect your PDF pages from plagiarism. It's a great way to avoid any copyright infringement.", nil),
  321. NSLocalizedString(@"Bates numbering is a method of indexing legal documents for easy identification and retrieval. The Bates identifier is referred to as a number, but it can include an alphanumeric prefix and suffix, making it easier to recognize the central subject matter of the files.", nil),
  322. NSLocalizedString(@"Easily batch encrypt PDF documents with password and apply permissions that recipients have to enter before they can open or view them to prevent unauthorized access. Also, PDF Reader Pro is a password remover helping decrypt the protected files.", nil)]];
  323. } else if (KMCompareWithToolTypeFromSign == self.type || KMCompareWithToolTypeSign == self.type) {
  324. [_contentArray addObjectsFromArray:@[
  325. NSLocalizedString(@"Create fillable PDF forms with all kinds of interactive form controls. Easily fill and sign PDF forms, like business forms. Using Fill & Sign to complete flat forms. You can manually add text and other symbols anywhere on the form.", nil)]];
  326. } else if (KMCompareWithToolTypeEditPDF == self.type) {
  327. [_contentArray addObjectsFromArray:@[NSLocalizedString(@"Change orignal text right in your PDF. Just click or tap to add a new paragraph, fix a typo, or rearrange pages. Add, delete, move or modify texts. With page editing, paragraphs and formatting adjust when you add new text or lines.", nil)]];
  328. }
  329. }
  330. return _contentArray;
  331. }
  332. - (void)localizedLanguage
  333. {
  334. #if VERSION_DMG
  335. self.boxBottemOffset.constant = 20;
  336. self.buttonBottemOffset.constant = 40.0;
  337. self.moreButton.hidden = YES;
  338. self.bottomTextView.hidden = YES;
  339. self.purchaseBox1.hidden = YES;
  340. self.purchaseBox2.hidden = NO;
  341. self.moreBtn.hidden = NO;
  342. self.restoreBtn.hidden = YES;
  343. self.restonButtonBottemOffset.constant = 0;
  344. self.subscribeBtn3.wantsLayer = YES;
  345. self.subscribeBtn3.layer.cornerRadius = 5.0;
  346. self.subscribeBtn3.layer.masksToBounds = YES;
  347. // self.subscribeBtn3.layer.backgroundColor = [NSColor colorWithRed:0 green:136.0/255.0 blue:255.0/255.0 alpha:1.0].CGColor;
  348. self.subscribeBtn3.layer.backgroundColor = [KMAppearance KMColor_Interactive_M0].CGColor;
  349. self.moreBtn.title = [NSString stringWithFormat:@"%@",NSLocalizedString(@"Learn More", nil)];
  350. if ([IAPProductsManager defaultManager].DMGAllAccessProduct.isOffers) {
  351. self.specialView.hidden = NO;
  352. } else {
  353. self.specialView.hidden = YES;
  354. }
  355. self.specialView1.hidden = YES;
  356. self.subscribe4Label.stringValue = NSLocalizedString(@"Buy Now", nil);
  357. self.subscribe4Label.textColor = [KMAppearance KMColor_Interactive_M0];
  358. if (ActivityStatusVerification == [VerificationManager manager].status) {
  359. self.subscribeBtn3.hidden = YES;
  360. } else if (ActivityStatusNone == [VerificationManager manager].status) {
  361. self.subscribeBtn3.title = NSLocalizedString(@"Free Trial", nil);
  362. } else {
  363. self.subscribeBtn3.title = NSLocalizedString(@"Enter License", nil);
  364. }
  365. [self.subscribeBtn3 setTitleColor:[NSColor whiteColor]];
  366. CGFloat off = 1 -[IAPProductsManager defaultManager].DMGAllAccessProduct.offers;
  367. NSString *offString = [NSString stringWithFormat:@"%.f%%",off * 100];
  368. self.specialLabel.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@ off", @""),offString];
  369. NSImage *image = [NSImage imageNamed:@"KMImageNameCompareTagBG"];
  370. self.specialImageView.image = image;
  371. NSButtonCell *cell = self.moreBtn.cell;
  372. NSColor *txtColor = [NSColor colorWithSRGBRed:0/255.0 green:136.0/255.0 blue:255.0/255.0 alpha:1.0];
  373. NSAttributedString *attrStr1 = [cell attributedTitle];
  374. NSMutableAttributedString *myAttr = [[NSMutableAttributedString alloc] initWithAttributedString:attrStr1];
  375. [myAttr addAttribute:NSForegroundColorAttributeName value:txtColor range:NSMakeRange(0, myAttr.length)];
  376. [myAttr addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:13.0] range:NSMakeRange(0, myAttr.length)];
  377. [cell setAttributedTitle:myAttr];
  378. [self.moreBtn updateCell:cell];
  379. self.subscribeBtn3.wantsLayer = YES;
  380. self.subscribeBox3Layer = [CALayer layer];
  381. [self.subscribeBtn3.layer addSublayer:self.subscribeBox3Layer];
  382. self.subscribeBox3Layer.frame = CGRectMake(0, 0, CGRectGetWidth(_subscribeBox3.bounds), CGRectGetHeight(_subscribeBox3.bounds));
  383. self.subscribeBox3Layer.backgroundColor = [KMAppearance KMColor_Status_Sel].CGColor;
  384. self.subscribeBox3Layer.cornerRadius = 0;
  385. self.subscribeBox3Layer.hidden = YES;
  386. __block typeof(self) blockSelf = self;
  387. self.subscribeBox3.moveCallback = ^(BOOL mouseEntered, KMBox *mouseBox) {
  388. if (mouseEntered)
  389. blockSelf.subscribeBox3Layer.hidden = NO;
  390. else
  391. blockSelf.subscribeBox3Layer.hidden = YES;
  392. };
  393. self.subscribeBox3.rightDownCallback = nil;
  394. self.subscribeBtn4.mouseMoveCallback = ^(BOOL mouseEntered) {
  395. if (mouseEntered)
  396. blockSelf.subscribeBtn4.image = [NSImage imageNamed:@"KMImageNameButtonBackground259Hov"];
  397. else
  398. blockSelf.subscribeBtn4.image = [NSImage imageNamed:@"KMImageNameButtonBackground259"];
  399. };
  400. #else
  401. self.boxBottemOffset.constant = 120.0;
  402. self.buttonBottemOffset.constant = 16.0;
  403. self.purchaseBox1.hidden = NO;
  404. self.purchaseBox2.hidden = YES;
  405. self.moreBtn.hidden = YES;
  406. self.moreButton.hidden = NO;
  407. self.bottomTextView.hidden = NO;
  408. self.subscribeBtn1.wantsLayer = YES;
  409. self.subscribeBtn1.layer.backgroundColor = [NSColor clearColor].CGColor;
  410. self.subscribeBtn2.wantsLayer = YES;
  411. self.subscribeBtn2.layer.backgroundColor = [NSColor clearColor].CGColor;
  412. [self reloadData];
  413. self.restoreBtn.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Restore Previous Purchase", nil)];
  414. self.compareBtn.title = [NSString stringWithFormat:@"%@",NSLocalizedString(@"Learn More", nil)];
  415. NSButtonCell *cell = self.compareBtn.cell;
  416. NSColor *txtColor = [KMAppearance KMColor_Interactive_A0];
  417. NSAttributedString *attrStr1 = [cell attributedTitle];
  418. NSMutableAttributedString *myAttr = [[NSMutableAttributedString alloc] initWithAttributedString:attrStr1];
  419. [myAttr addAttribute:NSForegroundColorAttributeName value:txtColor range:NSMakeRange(0, myAttr.length)];
  420. [myAttr addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:13.0] range:NSMakeRange(0, myAttr.length)];
  421. [cell setAttributedTitle:myAttr];
  422. [self.compareBtn updateCell:cell];
  423. [self.restoreBtn setTitleColor:[NSColor colorWithSRGBRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.7]];
  424. self.restoreBtn.wantsLayer = YES;
  425. self.restoreBtn.layer.cornerRadius = 4.0;
  426. self.restoreBtn.layer.backgroundColor = [NSColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.15].CGColor;
  427. self.subscribeBtn1.wantsLayer = YES;
  428. self.subscribeBox1Layer = [CALayer layer];
  429. [self.subscribeBtn1.layer addSublayer:self.subscribeBox1Layer];
  430. self.subscribeBox1Layer.frame = CGRectMake(0, 0, CGRectGetWidth(_subscribeBox1.bounds), CGRectGetHeight(_subscribeBox1.bounds));
  431. self.subscribeBox1Layer.backgroundColor = [KMAppearance KMColor_Status_Sel].CGColor;
  432. self.subscribeBox1Layer.cornerRadius = 0;
  433. self.subscribeBox1Layer.hidden = YES;
  434. __block typeof(self) blockSelf = self;
  435. self.subscribeBox1.moveCallback = ^(BOOL mouseEntered, KMBox *mouseBox) {
  436. if (mouseEntered)
  437. blockSelf.subscribeBox1Layer.hidden = NO;
  438. else
  439. blockSelf.subscribeBox1Layer.hidden = YES;
  440. };
  441. self.subscribeBox1.rightDownCallback = nil;
  442. self.subscribeBtn2.mouseMoveCallback = ^(BOOL mouseEntered) {
  443. if (mouseEntered)
  444. blockSelf.subscribeBtn2.image = [NSImage imageNamed:@"KMImageNameButtonBackground259Hov"];
  445. else
  446. blockSelf.subscribeBtn2.image = [NSImage imageNamed:@"KMImageNameButtonBackground259"];
  447. };
  448. #endif
  449. }
  450. - (void)updateViewColor {
  451. self.bottomBox1.fillColor = self.bottomBox2.fillColor = self.bottomBox3.fillColor = [KMAppearance KM_F6F6F6_Color];
  452. self.titleLabel.textColor = [KMAppearance KMColor_Layout_H0];
  453. self.contentLabel.textColor = [KMAppearance KMColor_Layout_H1];
  454. self.purchaseContenxtTextView.textColor = [KMAppearance KMColor_Layout_H2];
  455. self.purchaseContenxtTextView.backgroundColor = [NSColor clearColor];
  456. if ([KMAppearance isDarkMode]) {
  457. [self.viewLayer setColors:@[(id)[NSColor colorWithRed:23/255. green:24/255. blue:26/255. alpha:1.].CGColor, (id)[NSColor colorWithRed:22/255. green:24/255. blue:28/255. alpha:1.].CGColor]];
  458. self.viewLayer.startPoint = CGPointMake(0, 0.5);
  459. self.viewLayer.endPoint = CGPointMake(1, 0.5);
  460. self.viewLayer.frame = self.view.bounds;
  461. } else {
  462. [self.viewLayer setColors:@[(id)[NSColor colorWithRed:27/255. green:38/255. blue:58/255. alpha:1.].CGColor, (id)[NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.].CGColor]];
  463. self.viewLayer.startPoint = CGPointMake(0, 0.5);
  464. self.viewLayer.endPoint = CGPointMake(1, 0.5);
  465. self.viewLayer.frame = self.view.bounds;
  466. }
  467. }
  468. - (void)updateUI {
  469. self.view.wantsLayer = YES;
  470. self.subscribeBox1.fillColor =
  471. self.subscribeBox3.fillColor = [KMAppearance KMColor_Interactive_M0];
  472. self.subscribeBox2.contentView.wantsLayer =
  473. self.subscribeBox4.contentView.wantsLayer = YES;
  474. self.subscribeBox1.cornerRadius =
  475. self.subscribeBox2.cornerRadius =
  476. self.subscribeBox3.cornerRadius =
  477. self.subscribeBox4.cornerRadius = 1.0f;
  478. NSArray *boxArray = @[self.subscribeBox2, self.subscribeBox4];
  479. if (@available(macOS 10.14, *)) {
  480. for (NSBox *box in boxArray) {
  481. CAGradientLayer *boxLayer = [CAGradientLayer layer];
  482. boxLayer.frame = box.contentView.bounds;
  483. boxLayer.startPoint = CGPointMake(0, 0);
  484. boxLayer.endPoint = CGPointMake(1, 0);
  485. [boxLayer setColors:@[(id)[KMAppearance KMColor_Upgrade_Vip0].CGColor, (id)[KMAppearance KMColor_Upgrade_Vip0_1].CGColor]];
  486. [box.contentView.layer addSublayer:boxLayer];
  487. }
  488. }else {
  489. self.subscribeBox2.fillColor =
  490. self.subscribeBox4.fillColor = [KMAppearance KMColor_Upgrade_Vip0_1];
  491. }
  492. self.subscribeBox2.fillColor =
  493. self.subscribeBox4.fillColor = [NSColor clearColor];
  494. NSView *contentView = [[NSView alloc] initWithFrame:CGRectMake(0, 0, 560 * self.imageArray.count, 270)];
  495. for (NSUInteger i = 0; i < self.imageArray.count; i++) {
  496. NSImage *image = [self.imageArray objectAtIndex:i];
  497. NSImageView * imagev = [[NSImageView alloc] initWithFrame:CGRectMake(560 *i, 0, 560, 270)];
  498. imagev.image = image;
  499. [contentView addSubview:imagev];
  500. }
  501. self.roundView1.wantsLayer =
  502. self.roundView2.wantsLayer =
  503. self.roundView3.wantsLayer =
  504. self.roundView4.wantsLayer =
  505. self.roundView5.wantsLayer = YES;
  506. self.roundView1.layer.cornerRadius =
  507. self.roundView2.layer.cornerRadius =
  508. self.roundView3.layer.cornerRadius =
  509. self.roundView4.layer.cornerRadius =
  510. self.roundView5.layer.cornerRadius = 4;
  511. self.roundView1RightOffset.constant = 72;
  512. self.roundView2RightOffset.constant = 54;
  513. self.roundView3RightOffset.constant = 36;
  514. self.roundView4RightOffset.constant = 18;
  515. self.roundView5RightOffset.constant = 0;
  516. if (self.imageArray.count == 1) {
  517. self.roundView1.hidden =
  518. self.roundView2.hidden =
  519. self.roundView3.hidden =
  520. self.roundView4.hidden =
  521. self.roundView5.hidden = YES;
  522. self.roundView1RightOffset.constant = 0;
  523. self.roundView2RightOffset.constant = 0;
  524. self.roundView3RightOffset.constant = 0;
  525. self.roundView4RightOffset.constant = 0;
  526. self.roundView5RightOffset.constant = 0;
  527. self.nextBtn.hidden = self.forwardBtn.hidden = YES;
  528. } else if (self.imageArray.count == 2) {
  529. self.roundView3.hidden =
  530. self.roundView4.hidden =
  531. self.roundView5.hidden = YES;
  532. self.roundView1RightOffset.constant = 18;
  533. self.roundView2RightOffset.constant = 0;
  534. self.roundView3RightOffset.constant = 0;
  535. self.roundView4RightOffset.constant = 0;
  536. self.roundView5RightOffset.constant = 0;
  537. } else if (self.imageArray.count == 3) {
  538. self.roundView4.hidden =
  539. self.roundView5.hidden = YES;
  540. self.roundView1RightOffset.constant = 36;
  541. self.roundView2RightOffset.constant = 18;
  542. self.roundView3RightOffset.constant = 0;
  543. self.roundView4RightOffset.constant = 0;
  544. self.roundView5RightOffset.constant = 0;
  545. } else if (self.imageArray.count == 4) {
  546. self.roundView5.hidden = YES;
  547. self.roundView1RightOffset.constant = 54;
  548. self.roundView2RightOffset.constant = 36;
  549. self.roundView3RightOffset.constant = 18;
  550. self.roundView4RightOffset.constant = 0;
  551. self.roundView5RightOffset.constant = 0;
  552. }
  553. [self setSelectIndex:self.indexPage];
  554. [self.headerScrollview setDocumentView:contentView];
  555. }
  556. #pragma mark - buttonAction
  557. - (IBAction)buttonItemClick_Subscribe1:(id)sender
  558. {
  559. KMConvertCompareType type = KMConvertCompareType_License;
  560. #if VERSION_DMG
  561. type = KMConvertCompareType_License;
  562. #else
  563. type = KMConvertCompareType_Month;
  564. #endif
  565. if (self.block) {
  566. self.block(type);
  567. }
  568. }
  569. - (IBAction)buttonItemClick_Subscribe2:(id)sender
  570. {
  571. if (self.block) {
  572. self.block(KMConvertCompareType_OneTime);
  573. }
  574. }
  575. - (IBAction)buttonItemClick_Restore:(id)sender
  576. {
  577. if (self.block) {
  578. self.block(KMConvertCompareType_Restore);
  579. }
  580. }
  581. - (IBAction)buttonItemClick_Compare:(id)sender
  582. {
  583. if (self.block) {
  584. self.block(KMConvertCompareType_Compare);
  585. }
  586. }
  587. - (IBAction)buttonItemClick_Left:(id)sender
  588. {
  589. NSScrollView *scrollView = self.headerScrollview;
  590. [NSAnimationContext beginGrouping];
  591. [[NSAnimationContext currentContext] setDuration:0.3];
  592. NSClipView* clipView = [scrollView contentView];
  593. NSPoint newOrigin = [clipView bounds].origin;
  594. if (self.indexPage > 0) {
  595. self.indexPage --;
  596. } else {
  597. self.indexPage = (self.imageArray.count - 1);
  598. }
  599. newOrigin.x = self.indexPage*560;
  600. [[clipView animator] setBoundsOrigin:newOrigin];
  601. [scrollView reflectScrolledClipView: [scrollView contentView]]; // may not bee necessary
  602. [NSAnimationContext endGrouping];
  603. [self updateUI];
  604. }
  605. - (IBAction)buttonItemClick_Right:(id)sender
  606. {
  607. NSScrollView *scrollView = self.headerScrollview;
  608. [NSAnimationContext beginGrouping];
  609. [[NSAnimationContext currentContext] setDuration:0.3];
  610. NSClipView* clipView = [scrollView contentView];
  611. NSPoint newOrigin = [clipView bounds].origin;
  612. if (self.indexPage < (NSInteger)(self.imageArray.count - 1)) {
  613. self.indexPage ++;
  614. } else {
  615. self.indexPage =0;
  616. }
  617. newOrigin.x = self.indexPage*560;
  618. [[clipView animator] setBoundsOrigin:newOrigin];
  619. [scrollView reflectScrolledClipView: [scrollView contentView]]; // may not bee necessary
  620. [NSAnimationContext endGrouping];
  621. [self updateUI];
  622. }
  623. #pragma mark - Noti
  624. - (void)themeChanged:(NSNotification *)notification {
  625. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  626. [self updateViewColor];
  627. });
  628. }
  629. @end