// // KMVerificationAlertViewController.m // PDF Reader Pro Edition // // Created by 王帅 on 2018/5/8. // #import "KMVerificationAlertViewController.h" #import @interface KMVerificationAlertViewController () @property (nonatomic,assign) IBOutlet NSTextField *label; @property (nonatomic,assign) IBOutlet NSTextField *sublabel; @property (assign) IBOutlet NSView *desView1; @property (assign) IBOutlet NSTextField *desLbl1; @property (assign) IBOutlet NSTextField *desLbl2; @property (assign) IBOutlet NSTextField *desLbl3; @property (assign) IBOutlet NSTextField *desLbl4; @property (assign) IBOutlet KMButton *buyNowBackBtn; @property (nonatomic, assign) IBOutlet KMCustomButton *continueButton; @property (assign) IBOutlet KMCustomButton *buyButton; @property (nonatomic, retain) CALayer *continueButtonLayer; @end @implementation KMVerificationAlertViewController #pragma mark Init Methods - (instancetype)init { if (self = [super initWithNibName:@"KMVerificationAlertViewController" bundle:nil]) { } return self; } - (void)dealloc { } #pragma mark Setter Methods - (void)setAlertTitle:(NSString *)alertTitle { _alertTitle = alertTitle; self.label.stringValue = alertTitle ? : @""; } - (void)setAlertMessage:(NSString *)alertMessage { _alertMessage = alertMessage; self.sublabel.stringValue = alertMessage ? : @""; } #pragma mark View Methods - (void)loadView { [super loadView]; // Do view setup here. self.label.font = [NSFont systemFontOfSize:13.]; self.sublabel.font = [NSFont systemFontOfSize:18.]; self.desLbl1.font = self.desLbl2.font = self.desLbl3.font = self.desLbl4.font = [NSFont systemFontOfSize:12.]; self.label.stringValue = self.alertTitle ? : @""; self.sublabel.stringValue = self.alertMessage ? : @""; self.desLbl1.stringValue = NSLocalizedString(@"Convert PDF from/to Word/Excel/PPT/HTML/Image, etc.", nil); self.desLbl2.stringValue = NSLocalizedString(@"Edit and Modify Texts in PDFs", nil); self.desLbl3.stringValue = NSLocalizedString(@"Optical Character Recognition (OCR)", nil); self.desLbl4.stringValue = NSLocalizedString(@"Create, Fill Forms, Sign PDFs", nil); self.continueButton.title = NSLocalizedString(@"Continue", nil); self.continueButton.wantsLayer = YES; self.continueButton.layer.masksToBounds = YES; self.continueButton.layer.cornerRadius = 1.0; self.continueButtonLayer = [CALayer layer]; [self.continueButton.layer addSublayer:self.continueButtonLayer]; self.continueButtonLayer.frame = CGRectMake(0, 0, CGRectGetWidth(_continueButton.bounds), CGRectGetHeight(_continueButton.bounds)); self.continueButtonLayer.backgroundColor = [KMAppearance KMColor_Status_Sel].CGColor; self.continueButtonLayer.cornerRadius = 0; self.continueButtonLayer.hidden = YES; __block KMVerificationAlertViewController *blockSelf = self; self.continueButton.mouseMoveCallback = ^(BOOL mouseEntered) { if (mouseEntered) blockSelf.continueButtonLayer.hidden = NO; else blockSelf.continueButtonLayer.hidden = YES; }; self.buyNowBackBtn.mouseMoveCallback = ^(BOOL mouseEntered) { if (mouseEntered) blockSelf.buyNowBackBtn.image = [NSImage imageNamed:@"KMImageNameButtonBackground220Hov"]; else blockSelf.buyNowBackBtn.image = [NSImage imageNamed:@"KMImageNameButtonBackground220"]; }; self.buyButton.wantsLayer = YES; self.buyButton.layer.masksToBounds = YES; self.buyButton.layer.cornerRadius = 1.0; if (@available(macOS 10.14, *)) { NSAppearanceName appearanceName = [[NSApp effectiveAppearance] bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]]; if ([appearanceName isEqualToString:NSAppearanceNameDarkAqua]) { [self.label setTextColor:[NSColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0]]; [self.sublabel setTextColor:[NSColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:0.7]]; self.desLbl1.textColor = self.desLbl2.textColor = self.desLbl3.textColor = self.desLbl4.textColor = [NSColor colorWithRed:255/255. green:255/255. blue:255/255. alpha:1]; [self.continueButton setTitleColor:[NSColor whiteColor]]; self.continueButton.layer.backgroundColor = [NSColor colorWithRed:86/255. green:88/255. blue:90/255. alpha:1].CGColor; NSMutableAttributedString *attributedTitle = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"Buy Now", nil)]; NSRange range = NSMakeRange(0, attributedTitle.length); [attributedTitle addAttribute:NSFontAttributeName value:[NSFont boldSystemFontOfSize:13.] range:range]; [attributedTitle addAttribute:NSForegroundColorAttributeName value:[NSColor colorWithRed:78/255. green:127/255. blue:219/255. alpha:1] range:range]; self.buyButton.attributedTitle = attributedTitle; } else { self.label.textColor = [NSColor colorWithRed:66/255. green:70/255. blue:77/255. alpha:1]; self.sublabel.textColor = [NSColor colorWithRed:14/255. green:17/255. blue:20/255. alpha:1]; self.desLbl1.textColor = self.desLbl2.textColor = self.desLbl3.textColor = self.desLbl4.textColor = [NSColor colorWithRed:66/255. green:70/255. blue:77/255. alpha:1]; [self.continueButton setTitleColor:[NSColor colorWithRed:14/255. green:17/255. blue:20/255. alpha:1]]; self.continueButton.layer.backgroundColor = [NSColor colorWithRed:218/255. green:219/255. blue:222/255. alpha:1].CGColor; [self.buyButton setTitleColor:[NSColor colorWithRed:14/255. green:17/255. blue:20/255. alpha:1]]; NSMutableAttributedString *attributedTitle = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"Buy Now", nil)]; NSRange range = NSMakeRange(0, attributedTitle.length); [attributedTitle addAttribute:NSFontAttributeName value:[NSFont boldSystemFontOfSize:13.] range:range]; [attributedTitle addAttribute:NSForegroundColorAttributeName value:[NSColor colorWithRed:14/255. green:17/255. blue:20/255. alpha:1] range:range]; self.buyButton.attributedTitle = attributedTitle; } } } #pragma mark Button Actions - (IBAction)continueButtonAction:(id)sender { if (self.callback) { self.callback(); } } - (IBAction)buyNowAction:(id)sender { if (self.buyActionHandle) { self.buyActionHandle(); } } @end