KMVerificationAlertViewController.m 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. //
  2. // KMVerificationAlertViewController.m
  3. // PDF Reader Pro Edition
  4. //
  5. // Created by 王帅 on 2018/5/8.
  6. //
  7. #import "KMVerificationAlertViewController.h"
  8. #import <PDF_Reader_Pro-Swift.h>
  9. @interface KMVerificationAlertViewController ()
  10. @property (nonatomic,assign) IBOutlet NSTextField *label;
  11. @property (nonatomic,assign) IBOutlet NSTextField *sublabel;
  12. @property (assign) IBOutlet NSView *desView1;
  13. @property (assign) IBOutlet NSTextField *desLbl1;
  14. @property (assign) IBOutlet NSTextField *desLbl2;
  15. @property (assign) IBOutlet NSTextField *desLbl3;
  16. @property (assign) IBOutlet NSTextField *desLbl4;
  17. @property (assign) IBOutlet KMButton *buyNowBackBtn;
  18. @property (nonatomic, assign) IBOutlet KMCustomButton *continueButton;
  19. @property (assign) IBOutlet KMCustomButton *buyButton;
  20. @property (nonatomic, retain) CALayer *continueButtonLayer;
  21. @end
  22. @implementation KMVerificationAlertViewController
  23. #pragma mark Init Methods
  24. - (instancetype)init {
  25. if (self = [super initWithNibName:@"KMVerificationAlertViewController" bundle:nil]) {
  26. }
  27. return self;
  28. }
  29. - (void)dealloc {
  30. }
  31. #pragma mark Setter Methods
  32. - (void)setAlertTitle:(NSString *)alertTitle {
  33. _alertTitle = alertTitle;
  34. self.label.stringValue = alertTitle ? : @"";
  35. }
  36. - (void)setAlertMessage:(NSString *)alertMessage {
  37. _alertMessage = alertMessage;
  38. self.sublabel.stringValue = alertMessage ? : @"";
  39. }
  40. #pragma mark View Methods
  41. - (void)loadView {
  42. [super loadView];
  43. // Do view setup here.
  44. self.label.font = [NSFont systemFontOfSize:13.];
  45. self.sublabel.font = [NSFont systemFontOfSize:18.];
  46. self.desLbl1.font = self.desLbl2.font = self.desLbl3.font = self.desLbl4.font = [NSFont systemFontOfSize:12.];
  47. self.label.stringValue = self.alertTitle ? : @"";
  48. self.sublabel.stringValue = self.alertMessage ? : @"";
  49. self.desLbl1.stringValue = NSLocalizedString(@"Convert PDF from/to Word/Excel/PPT/HTML/Image, etc.", nil);
  50. self.desLbl2.stringValue = NSLocalizedString(@"Edit and Modify Texts in PDFs", nil);
  51. self.desLbl3.stringValue = NSLocalizedString(@"Optical Character Recognition (OCR)", nil);
  52. self.desLbl4.stringValue = NSLocalizedString(@"Create, Fill Forms, Sign PDFs", nil);
  53. self.continueButton.title = NSLocalizedString(@"Continue", nil);
  54. self.continueButton.wantsLayer = YES;
  55. self.continueButton.layer.masksToBounds = YES;
  56. self.continueButton.layer.cornerRadius = 1.0;
  57. self.continueButtonLayer = [CALayer layer];
  58. [self.continueButton.layer addSublayer:self.continueButtonLayer];
  59. self.continueButtonLayer.frame = CGRectMake(0, 0, CGRectGetWidth(_continueButton.bounds), CGRectGetHeight(_continueButton.bounds));
  60. self.continueButtonLayer.backgroundColor = [KMAppearance KMColor_Status_Sel].CGColor;
  61. self.continueButtonLayer.cornerRadius = 0;
  62. self.continueButtonLayer.hidden = YES;
  63. __block KMVerificationAlertViewController *blockSelf = self;
  64. self.continueButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  65. if (mouseEntered)
  66. blockSelf.continueButtonLayer.hidden = NO;
  67. else
  68. blockSelf.continueButtonLayer.hidden = YES;
  69. };
  70. self.buyNowBackBtn.mouseMoveCallback = ^(BOOL mouseEntered) {
  71. if (mouseEntered)
  72. blockSelf.buyNowBackBtn.image = [NSImage imageNamed:@"KMImageNameButtonBackground220Hov"];
  73. else
  74. blockSelf.buyNowBackBtn.image = [NSImage imageNamed:@"KMImageNameButtonBackground220"];
  75. };
  76. self.buyButton.wantsLayer = YES;
  77. self.buyButton.layer.masksToBounds = YES;
  78. self.buyButton.layer.cornerRadius = 1.0;
  79. if (@available(macOS 10.14, *)) {
  80. NSAppearanceName appearanceName = [[NSApp effectiveAppearance] bestMatchFromAppearancesWithNames:@[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]];
  81. if ([appearanceName isEqualToString:NSAppearanceNameDarkAqua]) {
  82. [self.label setTextColor:[NSColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0]];
  83. [self.sublabel setTextColor:[NSColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:0.7]];
  84. self.desLbl1.textColor = self.desLbl2.textColor = self.desLbl3.textColor = self.desLbl4.textColor = [NSColor colorWithRed:255/255. green:255/255. blue:255/255. alpha:1];
  85. [self.continueButton setTitleColor:[NSColor whiteColor]];
  86. self.continueButton.layer.backgroundColor = [NSColor colorWithRed:86/255. green:88/255. blue:90/255. alpha:1].CGColor;
  87. NSMutableAttributedString *attributedTitle = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"Buy Now", nil)];
  88. NSRange range = NSMakeRange(0, attributedTitle.length);
  89. [attributedTitle addAttribute:NSFontAttributeName value:[NSFont boldSystemFontOfSize:13.] range:range];
  90. [attributedTitle addAttribute:NSForegroundColorAttributeName value:[NSColor colorWithRed:78/255. green:127/255. blue:219/255. alpha:1] range:range];
  91. self.buyButton.attributedTitle = attributedTitle;
  92. } else {
  93. self.label.textColor = [NSColor colorWithRed:66/255. green:70/255. blue:77/255. alpha:1];
  94. self.sublabel.textColor = [NSColor colorWithRed:14/255. green:17/255. blue:20/255. alpha:1];
  95. self.desLbl1.textColor = self.desLbl2.textColor = self.desLbl3.textColor = self.desLbl4.textColor = [NSColor colorWithRed:66/255. green:70/255. blue:77/255. alpha:1];
  96. [self.continueButton setTitleColor:[NSColor colorWithRed:14/255. green:17/255. blue:20/255. alpha:1]];
  97. self.continueButton.layer.backgroundColor = [NSColor colorWithRed:218/255. green:219/255. blue:222/255. alpha:1].CGColor;
  98. [self.buyButton setTitleColor:[NSColor colorWithRed:14/255. green:17/255. blue:20/255. alpha:1]];
  99. NSMutableAttributedString *attributedTitle = [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"Buy Now", nil)];
  100. NSRange range = NSMakeRange(0, attributedTitle.length);
  101. [attributedTitle addAttribute:NSFontAttributeName value:[NSFont boldSystemFontOfSize:13.] range:range];
  102. [attributedTitle addAttribute:NSForegroundColorAttributeName value:[NSColor colorWithRed:14/255. green:17/255. blue:20/255. alpha:1] range:range];
  103. self.buyButton.attributedTitle = attributedTitle;
  104. }
  105. }
  106. }
  107. #pragma mark Button Actions
  108. - (IBAction)continueButtonAction:(id)sender {
  109. if (self.callback) {
  110. self.callback();
  111. }
  112. }
  113. - (IBAction)buyNowAction:(id)sender {
  114. if (self.buyActionHandle) {
  115. self.buyActionHandle();
  116. }
  117. }
  118. @end