KMVerificationAlertViewController.m 6.6 KB

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