// // KMConvertCompareViewController.m // PDF Reader Pro Edition // // Created by 丁林圭 on 2019/5/23. // #import "KMConvertCompareViewController.h" //#import "NSButton+TitleColor.h" #import "NSImage_SKExtensions.h" #import "VerificationManager.h" //#import "KMScrollView.h" //#import "KMBox.h" //#import "KMButton.h" //#import "KMKdanRemoteConfig.h" #import @interface KMHeaderBox : NSBox @property (nonatomic, retain)NSGradient *gradient; @end @implementation KMHeaderBox - (void)dealloc { } - (void)drawRect:(NSRect)dirtyRect { [super drawRect:dirtyRect]; NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:self.frame xRadius:10 yRadius:10]; [self.gradient drawInBezierPath:path relativeCenterPosition:NSMakePoint(-1, -1)]; self.gradient = [[NSGradient alloc] initWithStartingColor:[KMAppearance KMColor_Upgrade_Vip_BG] endingColor:[KMAppearance KMColor_Upgrade_Vip_BG_1]]; } @end @interface KMConvertCompareViewController () @property (assign) IBOutlet KMButton *subscribeBtn1; @property (assign) IBOutlet KMBox *subscribeBox1; @property (assign) IBOutlet KMButton *subscribeBtn2; @property (assign) IBOutlet NSBox *subscribeBox2; @property (assign) IBOutlet NSTextField *subscribeLabel1; @property (assign) IBOutlet NSTextField *subscribeLabel2; @property (assign) IBOutlet NSTextField *subscribeLabel3; @property (assign) IBOutlet NSTextField *subscribeLabel4; @property (assign) IBOutlet NSButton *subscribeBtn3; @property (assign) IBOutlet KMBox *subscribeBox3; @property (assign) IBOutlet NSTextField *subscribe3Label; @property (assign) IBOutlet KMButton *subscribeBtn4; @property (assign) IBOutlet NSBox *subscribeBox4; @property (assign) IBOutlet NSTextField *subscribe4Label; @property (assign) IBOutlet NSButton *restoreBtn; @property (assign) IBOutlet NSButton *compareBtn; @property (assign) IBOutlet NSButton *moreBtn; @property (assign) IBOutlet NSTextField *titleLabel; @property (assign) IBOutlet NSTextField *contentLabel; @property (assign) IBOutlet NSLayoutConstraint *boxBottemOffset; @property (assign) IBOutlet NSLayoutConstraint *buttonBottemOffset; @property (assign) IBOutlet NSTextView *purchaseContenxtTextView; @property (assign) IBOutlet NSBox *purchaseBox1; @property (assign) IBOutlet NSBox *purchaseBox2; @property (assign) IBOutlet NSTextView *bottomTextView; @property (assign) IBOutlet NSButton *moreButton; @property (nonatomic, assign) IBOutlet NSView *specialView; @property (nonatomic, assign) IBOutlet NSImageView *specialImageView; @property (nonatomic, assign) IBOutlet NSTextField *specialLabel; @property (nonatomic, assign) IBOutlet NSView *specialView1; @property (nonatomic, assign) IBOutlet NSImageView *specialImageView1; @property (nonatomic, assign) IBOutlet NSTextField *specialLabel1; @property (nonatomic, retain) NSMutableArray *imageArray; @property (nonatomic, retain) NSMutableArray *titleArray; @property (nonatomic, retain) NSMutableArray *contentArray; @property (nonatomic,assign) IBOutlet NSScrollView *headerScrollview; @property (nonatomic,assign) IBOutlet NSView *roundView1; @property (assign) IBOutlet NSLayoutConstraint *roundView1RightOffset; @property (nonatomic,assign) IBOutlet NSView *roundView2; @property (assign) IBOutlet NSLayoutConstraint *roundView2RightOffset; @property (nonatomic,assign) IBOutlet NSView *roundView3; @property (assign) IBOutlet NSLayoutConstraint *roundView3RightOffset; @property (nonatomic,assign) IBOutlet NSView *roundView4; @property (assign) IBOutlet NSLayoutConstraint *roundView4RightOffset; @property (nonatomic,assign) IBOutlet NSView *roundView5; @property (assign) IBOutlet NSLayoutConstraint *roundView5RightOffset; @property (assign) IBOutlet NSLayoutConstraint *restonButtonBottemOffset; @property (nonatomic,assign) IBOutlet NSBox *bottomBox1; @property (nonatomic,assign) IBOutlet NSBox *bottomBox2; @property (nonatomic,assign) IBOutlet NSBox *bottomBox3; @property (assign) IBOutlet NSButton *nextBtn; @property (assign) IBOutlet NSButton *forwardBtn; @property (assign) IBOutlet NSBox *headerBox; @property (nonatomic, assign) NSInteger selectIndex; @property (nonatomic, assign) NSInteger indexPage; @property (nonatomic, assign) KMCompareWithToolType type; @property (nonatomic, retain) CALayer *subscribeBox1Layer; @property (nonatomic, retain) CALayer *subscribeBox3Layer; @property (nonatomic, retain) CAGradientLayer *viewLayer; @end @implementation KMConvertCompareViewController - (void)dealloc { _block = nil; [NSDistributedNotificationCenter.defaultCenter removeObserver:self]; } - (instancetype)initWithCompareType:(NSInteger)type selectIndex:(NSInteger)selectIndex { if (self = [super initWithNibName:@"KMConvertCompareViewController" bundle:nil]) { self.type = type; self.indexPage = selectIndex; } return self; } - (void)loadView { [super loadView]; if (!self.viewLayer) { self.viewLayer = [CAGradientLayer layer]; } [self.view.layer addSublayer:self.viewLayer]; [self updateUI]; [self localizedLanguage]; [self updateViewColor]; } - (void)viewDidAppear { [super viewDidAppear]; NSScrollView *scrollView = self.headerScrollview; [NSAnimationContext beginGrouping]; [[NSAnimationContext currentContext] setDuration:0.3]; NSClipView* clipView = [scrollView contentView]; NSPoint newOrigin = [clipView bounds].origin; if (self.selectIndex > (NSInteger)(self.imageArray.count - 1)) { self.selectIndex =0; } newOrigin.x = self.selectIndex*560; [[clipView animator] setBoundsOrigin:newOrigin]; [scrollView reflectScrolledClipView: [scrollView contentView]]; // may not bee necessary [NSAnimationContext endGrouping]; [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil]; } - (void)reloadData { #ifndef VERSION_DMG NSString * averagePrice = @""; NSString * subPrice = @""; NSString * allPrice = @""; if ([IAPProductsManager defaultManager].newlyMonthProduct.isOffers) { self.specialView1.hidden = NO; averagePrice = [IAPProductsManager defaultManager].newlyMonthProduct.offersAveragePrice; subPrice = [IAPProductsManager defaultManager].newlyMonthProduct.offersPrice; } else { self.specialView1.hidden = YES; averagePrice = [IAPProductsManager defaultManager].newlyMonthProduct.averagePrice; subPrice = [IAPProductsManager defaultManager].newlyMonthProduct.price; } if ([IAPProductsManager defaultManager].allAccessProduct.isOffers) { self.specialView.hidden = NO; allPrice = [IAPProductsManager defaultManager].allAccessProduct.offersPrice; } else { self.specialView.hidden = YES; allPrice = [IAPProductsManager defaultManager].allAccessProduct.price; } CGFloat off = 1 -[IAPProductsManager defaultManager].newlyMonthProduct.offers; NSString *offString = [NSString stringWithFormat:@"%.f%%",off * 100]; self.specialLabel1.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@ off", @""),offString]; off = 1 -[IAPProductsManager defaultManager].allAccessProduct.offers; offString = [NSString stringWithFormat:@"%.f%%",off * 100]; self.specialLabel.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@ off", @""),offString]; NSImage *image = [NSImage imageNamed:@"KMImageNameCompareTagBG"]; self.specialImageView.image = image; self.specialImageView1.image = image; if ([[KMKdanRemoteConfig remoteConfig] showAPP_AveragePrice]) { self.subscribeLabel1.stringValue = [NSString stringWithFormat:@"%@/%@", averagePrice, NSLocalizedString(@"mon", nil)]; } else { self.subscribeLabel1.stringValue = [NSString stringWithFormat:@"%@/%@", subPrice, NSLocalizedString(@"6mon", nil)]; } NSString *tTips = [NSString stringWithFormat:NSLocalizedString(@"Billed every 6 months at %@", nil), subPrice]; self.subscribeLabel2.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@", nil), tTips]; self.subscribeLabel3.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@", nil), allPrice]; self.subscribeLabel4.stringValue = NSLocalizedString(@"one-time purchase", nil); self.subscribeLabel3.textColor = [KMAppearance KMColor_Interactive_M0]; self.subscribeLabel4.textColor = [KMAppearance KMColor_Upgrade_Vip_BG_1]; if ([IAPProductsManager defaultManager].isAvailableAllFunction) { [self.subscribeBtn1 setEnabled:NO]; [self.subscribeBtn2 setEnabled:NO]; } else { [self.subscribeBtn1 setEnabled:YES]; [self.subscribeBtn2 setEnabled:YES]; } #endif } - (void)removeObserver { [NSDistributedNotificationCenter.defaultCenter removeObserver:self]; } #pragma mark - Setter and Getter - (void)setSelectIndex:(NSInteger)selectIndex { if (selectIndex> (NSInteger)self.imageArray.count - 1) { selectIndex = 0; } _selectIndex = selectIndex; NSColor * color1 = [NSColor whiteColor]; NSColor * color2 = [NSColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.5]; self.contentLabel.stringValue = self.contentArray[selectIndex]?:@""; self.titleLabel.stringValue = self.titleArray[selectIndex]?:@""; if (_selectIndex == 0) { self.roundView1.layer.backgroundColor = color1.CGColor; self.roundView2.layer.backgroundColor = self.roundView3.layer.backgroundColor = self.roundView4.layer.backgroundColor = self.roundView5.layer.backgroundColor = color2.CGColor; } else if(_selectIndex == 1){ self.roundView2.layer.backgroundColor = color1.CGColor; self.roundView1.layer.backgroundColor = self.roundView3.layer.backgroundColor = self.roundView4.layer.backgroundColor = self.roundView5.layer.backgroundColor = color2.CGColor; } else if(_selectIndex == 2){ self.roundView3.layer.backgroundColor = color1.CGColor; self.roundView1.layer.backgroundColor = self.roundView2.layer.backgroundColor = self.roundView4.layer.backgroundColor = self.roundView5.layer.backgroundColor = color2.CGColor; }else if(_selectIndex == 3){ self.roundView4.layer.backgroundColor = color1.CGColor; self.roundView1.layer.backgroundColor = self.roundView2.layer.backgroundColor = self.roundView3.layer.backgroundColor = self.roundView5.layer.backgroundColor = color2.CGColor; } else if(_selectIndex == 4){ self.roundView5.layer.backgroundColor = color1.CGColor; self.roundView1.layer.backgroundColor = self.roundView2.layer.backgroundColor = self.roundView3.layer.backgroundColor = self.roundView4.layer.backgroundColor = color2.CGColor; } dispatch_async(dispatch_get_main_queue(), ^{ NSScrollView *scrollView = self.headerScrollview; [NSAnimationContext beginGrouping]; [[NSAnimationContext currentContext] setDuration:0.3]; NSClipView* clipView = [scrollView contentView]; NSPoint newOrigin = [clipView bounds].origin; newOrigin.x = self->_selectIndex*560; [[clipView animator] setBoundsOrigin:newOrigin]; [scrollView reflectScrolledClipView: [scrollView contentView]]; // may not bee necessary [NSAnimationContext endGrouping]; }); } - (NSMutableArray *)imageArray { if (!_imageArray) { _imageArray = [[NSMutableArray alloc] init]; if (KMCompareWithToolTypeConvert == self.type) { [_imageArray addObjectsFromArray:@[ [NSImage imageNamed:@"KMImageNameUpgradeComvert"], [NSImage imageNamed:@"KMImageNameUpgradeConvertWord"], [NSImage imageNamed:@"KMImageNameUpgradeConvertExcel"], [NSImage imageNamed:@"KMImageNameUpgradeConvertPPT"], [NSImage imageNamed:@"KMImageNameUpgradeConvertOther"]]]; } else if (KMCompareWithToolTypeOCR == self.type) { [_imageArray addObjectsFromArray:@[ [NSImage imageNamed:@"KMImageNameUpgradeOCR"]]]; } else if (KMCompareWithToolTypePageEdit == self.type) { [_imageArray addObjectsFromArray:@[[NSImage imageNamed:@"KMImageNameUpgradePageEdit"], [NSImage imageNamed:@"KMImageNameUpgradeMergeSplit"]]]; } else if (KMCompareWithToolTypePDFEdit == self.type) { [_imageArray addObjectsFromArray:@[ [NSImage imageNamed:@"KMImageNameUpgradePDFEdit"], [NSImage imageNamed:@"KMImageNameUpgradeWatermark"], [NSImage imageNamed:@"KMImageNameUpgradeBates"], [NSImage imageNamed:@"KMImageNameUpgradeSecurity"]]]; } else if (KMCompareWithToolTypeFromSign == self.type) { [_imageArray addObjectsFromArray:@[ [NSImage imageNamed:@"KMImageNameUpgradeFormSignFrom"]]]; } else if (KMCompareWithToolTypeSign == self.type) { [_imageArray addObjectsFromArray:@[ [NSImage imageNamed:@"KMImageNameUpgradeSign"]]]; } else if (KMCompareWithToolTypeEditPDF == self.type) { [_imageArray addObjectsFromArray:@[ [NSImage imageNamed:@"KMImageNameUpgradeEditPDF"]]]; } } return _imageArray; } - (NSMutableArray *)titleArray { if (!_titleArray) { _titleArray = [[NSMutableArray alloc] init]; if (KMCompareWithToolTypeConvert == self.type) { [_titleArray addObjectsFromArray:@[NSLocalizedString(@"PDF To Office", nil), NSLocalizedString(@"PDF To Word", nil), NSLocalizedString(@"PDF To Excel", nil), NSLocalizedString(@"PDF To PPT", nil), NSLocalizedString(@"PDF To Image", nil)]]; } else if (KMCompareWithToolTypeOCR == self.type) { [_titleArray addObjectsFromArray:@[NSLocalizedString(@"OCR", nil)]]; } else if (KMCompareWithToolTypePageEdit == self.type) { [_titleArray addObjectsFromArray:@[NSLocalizedString(@"Page Editor", nil),[NSString stringWithFormat:@"%@ & %@",NSLocalizedString(@"Merge", nil),NSLocalizedString(@"Split", nil)]]]; } else if (KMCompareWithToolTypePDFEdit == self.type) { [_titleArray addObjectsFromArray: @[NSLocalizedString(@"PDF Editor", nil), NSLocalizedString(@"Watermark", nil), NSLocalizedString(@"Bates Numbers", nil), NSLocalizedString(@"Security", nil)]]; } else if (KMCompareWithToolTypeFromSign == self.type || KMCompareWithToolTypeSign == self.type) { [_titleArray addObjectsFromArray:@[NSLocalizedString(@"Form & Sign", nil)]]; } else if (KMCompareWithToolTypeEditPDF == self.type) { [_titleArray addObjectsFromArray:@[NSLocalizedString(@"Edit PDF", nil)]]; } } return _titleArray; } - (NSMutableArray *)contentArray { if (!_contentArray) { _contentArray = [[NSMutableArray alloc] init]; if (KMCompareWithToolTypeConvert == self.type) { [_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)], [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)], 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), 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), 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)]]; } else if (KMCompareWithToolTypeOCR == self.type) { [_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)]]; } else if (KMCompareWithToolTypePageEdit == self.type) { [_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)]]; } else if (KMCompareWithToolTypePDFEdit == self.type) { [_contentArray addObjectsFromArray:@[ 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), 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), 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), 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)]]; } else if (KMCompareWithToolTypeFromSign == self.type || KMCompareWithToolTypeSign == self.type) { [_contentArray addObjectsFromArray:@[ 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)]]; } else if (KMCompareWithToolTypeEditPDF == self.type) { [_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)]]; } } return _contentArray; } - (void)localizedLanguage { #if VERSION_DMG self.boxBottemOffset.constant = 20; self.buttonBottemOffset.constant = 40.0; self.moreButton.hidden = YES; self.bottomTextView.hidden = YES; self.purchaseBox1.hidden = YES; self.purchaseBox2.hidden = NO; self.moreBtn.hidden = NO; self.restoreBtn.hidden = YES; self.restonButtonBottemOffset.constant = 0; self.subscribeBtn3.wantsLayer = YES; self.subscribeBtn3.layer.cornerRadius = 5.0; self.subscribeBtn3.layer.masksToBounds = YES; // self.subscribeBtn3.layer.backgroundColor = [NSColor colorWithRed:0 green:136.0/255.0 blue:255.0/255.0 alpha:1.0].CGColor; self.subscribeBtn3.layer.backgroundColor = [KMAppearance KMColor_Interactive_M0].CGColor; self.moreBtn.title = [NSString stringWithFormat:@"%@",NSLocalizedString(@"Learn More", nil)]; if ([IAPProductsManager defaultManager].DMGAllAccessProduct.isOffers) { self.specialView.hidden = NO; } else { self.specialView.hidden = YES; } self.specialView1.hidden = YES; self.subscribe4Label.stringValue = NSLocalizedString(@"Buy Now", nil); self.subscribe4Label.textColor = [KMAppearance KMColor_Interactive_M0]; if (ActivityStatusVerification == [VerificationManager manager].status) { self.subscribeBtn3.hidden = YES; } else if (ActivityStatusNone == [VerificationManager manager].status) { self.subscribeBtn3.title = NSLocalizedString(@"Free Trial", nil); } else { self.subscribeBtn3.title = NSLocalizedString(@"Enter License", nil); } [self.subscribeBtn3 setTitleColor:[NSColor whiteColor]]; CGFloat off = 1 -[IAPProductsManager defaultManager].DMGAllAccessProduct.offers; NSString *offString = [NSString stringWithFormat:@"%.f%%",off * 100]; self.specialLabel.stringValue = [NSString stringWithFormat:NSLocalizedString(@"%@ off", @""),offString]; NSImage *image = [NSImage imageNamed:@"KMImageNameCompareTagBG"]; self.specialImageView.image = image; NSButtonCell *cell = self.moreBtn.cell; NSColor *txtColor = [NSColor colorWithSRGBRed:0/255.0 green:136.0/255.0 blue:255.0/255.0 alpha:1.0]; NSAttributedString *attrStr1 = [cell attributedTitle]; NSMutableAttributedString *myAttr = [[NSMutableAttributedString alloc] initWithAttributedString:attrStr1]; [myAttr addAttribute:NSForegroundColorAttributeName value:txtColor range:NSMakeRange(0, myAttr.length)]; [myAttr addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:13.0] range:NSMakeRange(0, myAttr.length)]; [cell setAttributedTitle:myAttr]; [self.moreBtn updateCell:cell]; self.subscribeBtn3.wantsLayer = YES; self.subscribeBox3Layer = [CALayer layer]; [self.subscribeBtn3.layer addSublayer:self.subscribeBox3Layer]; self.subscribeBox3Layer.frame = CGRectMake(0, 0, CGRectGetWidth(_subscribeBox3.bounds), CGRectGetHeight(_subscribeBox3.bounds)); self.subscribeBox3Layer.backgroundColor = [KMAppearance KMColor_Status_Sel].CGColor; self.subscribeBox3Layer.cornerRadius = 0; self.subscribeBox3Layer.hidden = YES; __block typeof(self) blockSelf = self; self.subscribeBox3.moveCallback = ^(BOOL mouseEntered, KMBox *mouseBox) { if (mouseEntered) blockSelf.subscribeBox3Layer.hidden = NO; else blockSelf.subscribeBox3Layer.hidden = YES; }; self.subscribeBox3.rightDownCallback = nil; self.subscribeBtn4.mouseMoveCallback = ^(BOOL mouseEntered) { if (mouseEntered) blockSelf.subscribeBtn4.image = [NSImage imageNamed:@"KMImageNameButtonBackground259Hov"]; else blockSelf.subscribeBtn4.image = [NSImage imageNamed:@"KMImageNameButtonBackground259"]; }; #else self.boxBottemOffset.constant = 120.0; self.buttonBottemOffset.constant = 16.0; self.purchaseBox1.hidden = NO; self.purchaseBox2.hidden = YES; self.moreBtn.hidden = YES; self.moreButton.hidden = NO; self.bottomTextView.hidden = NO; self.subscribeBtn1.wantsLayer = YES; self.subscribeBtn1.layer.backgroundColor = [NSColor clearColor].CGColor; self.subscribeBtn2.wantsLayer = YES; self.subscribeBtn2.layer.backgroundColor = [NSColor clearColor].CGColor; [self reloadData]; self.restoreBtn.title = [NSString stringWithFormat:@" %@ ",NSLocalizedString(@"Restore Previous Purchase", nil)]; self.compareBtn.title = [NSString stringWithFormat:@"%@",NSLocalizedString(@"Learn More", nil)]; NSButtonCell *cell = self.compareBtn.cell; NSColor *txtColor = [KMAppearance KMColor_Interactive_A0]; NSAttributedString *attrStr1 = [cell attributedTitle]; NSMutableAttributedString *myAttr = [[NSMutableAttributedString alloc] initWithAttributedString:attrStr1]; [myAttr addAttribute:NSForegroundColorAttributeName value:txtColor range:NSMakeRange(0, myAttr.length)]; [myAttr addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:13.0] range:NSMakeRange(0, myAttr.length)]; [cell setAttributedTitle:myAttr]; [self.compareBtn updateCell:cell]; [self.restoreBtn setTitleColor:[NSColor colorWithSRGBRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.7]]; self.restoreBtn.wantsLayer = YES; self.restoreBtn.layer.cornerRadius = 4.0; self.restoreBtn.layer.backgroundColor = [NSColor colorWithRed:255.0/255.0 green:255.0/255.0 blue:255.0/255.0 alpha:0.15].CGColor; self.subscribeBtn1.wantsLayer = YES; self.subscribeBox1Layer = [CALayer layer]; [self.subscribeBtn1.layer addSublayer:self.subscribeBox1Layer]; self.subscribeBox1Layer.frame = CGRectMake(0, 0, CGRectGetWidth(_subscribeBox1.bounds), CGRectGetHeight(_subscribeBox1.bounds)); self.subscribeBox1Layer.backgroundColor = [KMAppearance KMColor_Status_Sel].CGColor; self.subscribeBox1Layer.cornerRadius = 0; self.subscribeBox1Layer.hidden = YES; __block typeof(self) blockSelf = self; self.subscribeBox1.moveCallback = ^(BOOL mouseEntered, KMBox *mouseBox) { if (mouseEntered) blockSelf.subscribeBox1Layer.hidden = NO; else blockSelf.subscribeBox1Layer.hidden = YES; }; self.subscribeBox1.rightDownCallback = nil; self.subscribeBtn2.mouseMoveCallback = ^(BOOL mouseEntered) { if (mouseEntered) blockSelf.subscribeBtn2.image = [NSImage imageNamed:@"KMImageNameButtonBackground259Hov"]; else blockSelf.subscribeBtn2.image = [NSImage imageNamed:@"KMImageNameButtonBackground259"]; }; #endif } - (void)updateViewColor { self.bottomBox1.fillColor = self.bottomBox2.fillColor = self.bottomBox3.fillColor = [KMAppearance KM_F6F6F6_Color]; self.titleLabel.textColor = [KMAppearance KMColor_Layout_H0]; self.contentLabel.textColor = [KMAppearance KMColor_Layout_H1]; self.purchaseContenxtTextView.textColor = [KMAppearance KMColor_Layout_H2]; self.purchaseContenxtTextView.backgroundColor = [NSColor clearColor]; if ([KMAppearance isDarkMode]) { [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]]; self.viewLayer.startPoint = CGPointMake(0, 0.5); self.viewLayer.endPoint = CGPointMake(1, 0.5); self.viewLayer.frame = self.view.bounds; } else { [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]]; self.viewLayer.startPoint = CGPointMake(0, 0.5); self.viewLayer.endPoint = CGPointMake(1, 0.5); self.viewLayer.frame = self.view.bounds; } } - (void)updateUI { self.view.wantsLayer = YES; self.subscribeBox1.fillColor = self.subscribeBox3.fillColor = [KMAppearance KMColor_Interactive_M0]; self.subscribeBox2.contentView.wantsLayer = self.subscribeBox4.contentView.wantsLayer = YES; self.subscribeBox1.cornerRadius = self.subscribeBox2.cornerRadius = self.subscribeBox3.cornerRadius = self.subscribeBox4.cornerRadius = 1.0f; NSArray *boxArray = @[self.subscribeBox2, self.subscribeBox4]; if (@available(macOS 10.14, *)) { for (NSBox *box in boxArray) { CAGradientLayer *boxLayer = [CAGradientLayer layer]; boxLayer.frame = box.contentView.bounds; boxLayer.startPoint = CGPointMake(0, 0); boxLayer.endPoint = CGPointMake(1, 0); [boxLayer setColors:@[(id)[KMAppearance KMColor_Upgrade_Vip0].CGColor, (id)[KMAppearance KMColor_Upgrade_Vip0_1].CGColor]]; [box.contentView.layer addSublayer:boxLayer]; } }else { self.subscribeBox2.fillColor = self.subscribeBox4.fillColor = [KMAppearance KMColor_Upgrade_Vip0_1]; } self.subscribeBox2.fillColor = self.subscribeBox4.fillColor = [NSColor clearColor]; NSView *contentView = [[NSView alloc] initWithFrame:CGRectMake(0, 0, 560 * self.imageArray.count, 270)]; for (NSUInteger i = 0; i < self.imageArray.count; i++) { NSImage *image = [self.imageArray objectAtIndex:i]; NSImageView * imagev = [[NSImageView alloc] initWithFrame:CGRectMake(560 *i, 0, 560, 270)]; imagev.image = image; [contentView addSubview:imagev]; } self.roundView1.wantsLayer = self.roundView2.wantsLayer = self.roundView3.wantsLayer = self.roundView4.wantsLayer = self.roundView5.wantsLayer = YES; self.roundView1.layer.cornerRadius = self.roundView2.layer.cornerRadius = self.roundView3.layer.cornerRadius = self.roundView4.layer.cornerRadius = self.roundView5.layer.cornerRadius = 4; self.roundView1RightOffset.constant = 72; self.roundView2RightOffset.constant = 54; self.roundView3RightOffset.constant = 36; self.roundView4RightOffset.constant = 18; self.roundView5RightOffset.constant = 0; if (self.imageArray.count == 1) { self.roundView1.hidden = self.roundView2.hidden = self.roundView3.hidden = self.roundView4.hidden = self.roundView5.hidden = YES; self.roundView1RightOffset.constant = 0; self.roundView2RightOffset.constant = 0; self.roundView3RightOffset.constant = 0; self.roundView4RightOffset.constant = 0; self.roundView5RightOffset.constant = 0; self.nextBtn.hidden = self.forwardBtn.hidden = YES; } else if (self.imageArray.count == 2) { self.roundView3.hidden = self.roundView4.hidden = self.roundView5.hidden = YES; self.roundView1RightOffset.constant = 18; self.roundView2RightOffset.constant = 0; self.roundView3RightOffset.constant = 0; self.roundView4RightOffset.constant = 0; self.roundView5RightOffset.constant = 0; } else if (self.imageArray.count == 3) { self.roundView4.hidden = self.roundView5.hidden = YES; self.roundView1RightOffset.constant = 36; self.roundView2RightOffset.constant = 18; self.roundView3RightOffset.constant = 0; self.roundView4RightOffset.constant = 0; self.roundView5RightOffset.constant = 0; } else if (self.imageArray.count == 4) { self.roundView5.hidden = YES; self.roundView1RightOffset.constant = 54; self.roundView2RightOffset.constant = 36; self.roundView3RightOffset.constant = 18; self.roundView4RightOffset.constant = 0; self.roundView5RightOffset.constant = 0; } [self setSelectIndex:self.indexPage]; [self.headerScrollview setDocumentView:contentView]; } #pragma mark - buttonAction - (IBAction)buttonItemClick_Subscribe1:(id)sender { KMConvertCompareType type = KMConvertCompareType_License; #if VERSION_DMG type = KMConvertCompareType_License; #else type = KMConvertCompareType_Month; #endif if (self.block) { self.block(type); } } - (IBAction)buttonItemClick_Subscribe2:(id)sender { if (self.block) { self.block(KMConvertCompareType_OneTime); } } - (IBAction)buttonItemClick_Restore:(id)sender { if (self.block) { self.block(KMConvertCompareType_Restore); } } - (IBAction)buttonItemClick_Compare:(id)sender { if (self.block) { self.block(KMConvertCompareType_Compare); } } - (IBAction)buttonItemClick_Left:(id)sender { NSScrollView *scrollView = self.headerScrollview; [NSAnimationContext beginGrouping]; [[NSAnimationContext currentContext] setDuration:0.3]; NSClipView* clipView = [scrollView contentView]; NSPoint newOrigin = [clipView bounds].origin; if (self.indexPage > 0) { self.indexPage --; } else { self.indexPage = (self.imageArray.count - 1); } newOrigin.x = self.indexPage*560; [[clipView animator] setBoundsOrigin:newOrigin]; [scrollView reflectScrolledClipView: [scrollView contentView]]; // may not bee necessary [NSAnimationContext endGrouping]; [self updateUI]; } - (IBAction)buttonItemClick_Right:(id)sender { NSScrollView *scrollView = self.headerScrollview; [NSAnimationContext beginGrouping]; [[NSAnimationContext currentContext] setDuration:0.3]; NSClipView* clipView = [scrollView contentView]; NSPoint newOrigin = [clipView bounds].origin; if (self.indexPage < (NSInteger)(self.imageArray.count - 1)) { self.indexPage ++; } else { self.indexPage =0; } newOrigin.x = self.indexPage*560; [[clipView animator] setBoundsOrigin:newOrigin]; [scrollView reflectScrolledClipView: [scrollView contentView]]; // may not bee necessary [NSAnimationContext endGrouping]; [self updateUI]; } #pragma mark - Noti - (void)themeChanged:(NSNotification *)notification { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self updateViewColor]; }); } @end