KMActivityALertViewController.m 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // KMActivityALertViewController.m
  3. // PDF Reader Pro Edition
  4. //
  5. // Created by Niehaoyu on 2023/4/4.
  6. //
  7. #import "KMActivityALertViewController.h"
  8. #import <PDF_Reader_Pro-Swift.h>
  9. @interface KMActivityALertViewController ()
  10. @property (nonatomic,assign) IBOutlet NSTextField *label;
  11. @property (nonatomic,assign) IBOutlet NSTextField *sublabel;
  12. @property (nonatomic,assign) IBOutlet KMCustomButton *continueButton;
  13. @property (nonatomic, retain) CALayer *continueButtonLayer;
  14. @end
  15. @implementation KMActivityALertViewController
  16. #pragma mark Init Methods
  17. - (instancetype)init {
  18. if (self = [super initWithNibName:@"KMActivityALertViewController" bundle:nil]) {
  19. }
  20. return self;
  21. }
  22. - (void)dealloc {
  23. }
  24. #pragma mark Setter Methods
  25. - (void)setAlertTitle:(NSString *)alertTitle {
  26. _alertTitle = alertTitle;
  27. self.label.stringValue = alertTitle ? : @"";
  28. }
  29. - (void)setAlertMessage:(NSString *)alertMessage {
  30. _alertMessage = alertMessage;
  31. self.sublabel.stringValue = alertMessage ? : @"";
  32. }
  33. #pragma mark View Methods
  34. - (void)loadView {
  35. [super loadView];
  36. // Do view setup here.
  37. self.continueButton.wantsLayer = YES;
  38. self.continueButton.layer.masksToBounds = YES;
  39. self.continueButton.layer.cornerRadius = 1.0;
  40. self.label.stringValue = self.alertTitle ? : @"";
  41. self.sublabel.stringValue = self.alertMessage ? : @"";
  42. self.continueButton.title = NSLocalizedString(@"Continue", nil);
  43. [self.continueButton setTitleColor:[NSColor whiteColor]];
  44. self.continueButtonLayer = [CALayer layer];
  45. [self.continueButton.layer addSublayer:self.continueButtonLayer];
  46. self.continueButtonLayer.frame = CGRectMake(0, 0, CGRectGetWidth(_continueButton.bounds), CGRectGetHeight(_continueButton.bounds));
  47. self.continueButtonLayer.backgroundColor = [KMAppearance KMColor_Status_Sel].CGColor;
  48. self.continueButtonLayer.cornerRadius = 0;
  49. self.continueButtonLayer.hidden = YES;
  50. __block KMActivityALertViewController *blockSelf = self;
  51. self.continueButton.mouseMoveCallback = ^(BOOL mouseEntered) {
  52. if (mouseEntered)
  53. blockSelf.continueButtonLayer.hidden = NO;
  54. else
  55. blockSelf.continueButtonLayer.hidden = YES;
  56. };
  57. [self.label setTextColor:[KMAppearance KMColor_Layout_H0]];
  58. [self.sublabel setTextColor:[KMAppearance KM_242424_Color75]];
  59. }
  60. #pragma mark - IBAction
  61. - (IBAction)continueButtonAction:(id)sender {
  62. if (self.callback) {
  63. self.callback();
  64. }
  65. }
  66. @end