123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725 |
- //
- // 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 <PDF_Reader_Pro-Swift.h>
- @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),
- [NSString stringWithFormat: NSLocalizedString(@"When you use %@ 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), Swift_oc_Tool.KMAPPNameValue_OC],
- 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:@[[NSString stringWithFormat: NSLocalizedString(@"With optical character recognition (OCR), %@ 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), Swift_oc_Tool.KMAPPNameValue_OC]]];
- } 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), [NSString stringWithFormat: 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), Swift_oc_Tool.KMAPPNameValue_OC]]];
- } 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),
- [NSString stringWithFormat: 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, %@ is a password remover helping decrypt the protected files.", nil), Swift_oc_Tool.KMAPPNameValue_OC]]];
- } 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
|