123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- //
- // KMVerificationViewController.m
- // PDF Reader Pro Edition
- //
- // Created by 王帅 on 2018/5/9.
- //
- #import "KMVerificationViewController.h"
- #import <PDF_Reader_Pro-Swift.h>
- #import "VerificationManager.h"
- @interface KMVerificationViewController ()
- @property (nonatomic,assign) IBOutlet NSTextField *label;
- @property (nonatomic,assign) IBOutlet NSTextField *sublabel;
- @property (nonatomic,assign) IBOutlet KMCustomButton *licenseButton;
- @property (nonatomic,assign) IBOutlet KMCustomButton *laterButton;
- @property (nonatomic,assign) IBOutlet KMCustomButton *buyButton;
- @property (nonatomic, retain) CALayer *buyButtonLayer;
- @property (assign) IBOutlet NSLayoutConstraint *laterBtnWidthConst;
- @property (assign) IBOutlet NSLayoutConstraint *buyBtnWidthConst;
- @end
- @implementation KMVerificationViewController
- #pragma mark Init Methods
- - (instancetype)init {
- if (self = [super initWithNibName:@"KMVerificationViewController" bundle:nil]) {
-
- }
- return self;
- }
- - (void)dealloc {
-
- }
- #pragma mark Setter Methods
- - (void)setTitleText:(NSString *)titleText {
- _titleText = titleText;
- self.label.stringValue = titleText;
- }
- - (void)setMessageText:(NSString *)messageText {
- _messageText = messageText;
- self.sublabel.stringValue = messageText;
- }
- - (void)setButtonText:(NSString *)buttonText {
- _buttonText = buttonText;
-
- self.laterButton.title = buttonText;
- }
- #pragma mark View Methods
- - (void)loadView {
- [super loadView];
- // Do view setup here.
- self.view.wantsLayer = YES;
- [self.label setTextColor:[KMAppearance KMColor_Layout_H0]];
- [self.sublabel setTextColor:[KMAppearance KMColor_Layout_H1]];
-
- self.licenseButton.wantsLayer = YES;
- self.licenseButton.layer.masksToBounds = YES;
- self.licenseButton.layer.cornerRadius = 1.0;
-
- self.laterButton.wantsLayer = YES;
- self.laterButton.layer.masksToBounds = YES;
- self.laterButton.layer.cornerRadius = 1.0;
-
- self.buyButton.wantsLayer = YES;
- self.buyButton.layer.masksToBounds = YES;
- self.buyButton.layer.cornerRadius = 1.0;
-
- self.label.stringValue = self.titleText ? : @"";
- self.sublabel.stringValue = self.messageText ? : @"";
- self.laterButton.title = self.buttonText ? : NSLocalizedString(@"Later", nil);
-
- self.licenseButton.title = NSLocalizedString(@"Enter License Number", nil);
- self.buyButton.title = NSLocalizedString(@"Buy Full Version", nil);
- CGSize size = [self.buyButton sizeThatFits:CGSizeMake(MAXFLOAT, self.buyButton.frame.size.width)];
- self.buyBtnWidthConst.constant = MAX(size.width + 10, 140);
-
- [self.licenseButton setTitleColor:[KMAppearance KMColor_Layout_H0]];
- [self.laterButton setTitleColor:[KMAppearance KMColor_Layout_H0]];
- [self.buyButton setTitleColor:[NSColor whiteColor]];
-
- self.buyButtonLayer = [CALayer layer];
- [self.buyButton.layer addSublayer:self.buyButtonLayer];
- self.buyButtonLayer.frame = CGRectMake(0, 0, CGRectGetWidth(_buyButton.bounds), CGRectGetHeight(_buyButton.bounds));
- self.buyButtonLayer.backgroundColor = [KMAppearance KMColor_Status_Sel].CGColor;
- self.buyButtonLayer.cornerRadius = 0;
- self.buyButtonLayer.hidden = YES;
- __block KMVerificationViewController *blockSelf = self;
- self.buyButton.mouseMoveCallback = ^(BOOL mouseEntered) {
- if (mouseEntered) {
- blockSelf.buyButtonLayer.hidden = NO;
- }else {
- blockSelf.buyButtonLayer.hidden = YES;
- }
- };
- self.licenseButton.mouseMoveCallback = self.laterButton.mouseMoveCallback = nil;
-
- }
- #pragma mark Button Actions
- - (IBAction)licenseButtonAction:(id)sender {
- if (self.callback) {
- self.callback(0);
- }
- }
- - (IBAction)laterButtonAction:(id)sender {
- if (self.callback) {
- self.callback(1);
- }
- }
- - (IBAction)buyButtonAction:(id)sender {
- if (self.callback) {
- self.callback(2);
- }
- }
- @end
|