// // KMRepeatTrialAlertController.m // PDF Reader Pro Edition // // Created by Niehaoyu on 2023/9/13. // #import "KMRepeatTrialAlertController.h" #import @interface KMRepeatTrialAlertController () @property (assign) IBOutlet NSView *contendView; @property (assign) IBOutlet NSImageView *iconImg; @property (assign) IBOutlet NSTextField *titleLbl; @property (assign) IBOutlet NSView *infoContendView; @property (assign) IBOutlet NSTextField *infoTitleLabel; @property (assign) IBOutlet NSTextField *infoSubTitleLabel; @property (assign) IBOutlet NSTextField *featureLbl; @property (assign) IBOutlet NSView *nTipView; @property (assign) IBOutlet NSTextField *nTipLabel; @property (assign) IBOutlet NSTextField *nInfoLabel; @property (assign) IBOutlet NSTextField *featureInfoLabel1; @property (assign) IBOutlet NSTextField *featureInfoLabel2; @property (assign) IBOutlet NSTextField *featureInfoLabel3; @property (assign) IBOutlet NSTextField *featureInfoLabel4; @property (assign) IBOutlet NSTextField *featureInfoLabel5; @property (assign) IBOutlet NSBox *freeTrialBox; @property (assign) IBOutlet KMButton *freeTrialButton; @property (assign) IBOutlet HyperLinkButton *learnMoreButton; @property (assign) IBOutlet HyperLinkButton *enterLicenseButton; @end @implementation KMRepeatTrialAlertController - (instancetype)init { if (self = [super initWithNibName:@"KMRepeatTrialAlertController" bundle:nil]) { } return self; } - (void)dealloc { [NSDistributedNotificationCenter.defaultCenter removeObserver:self]; } #pragma mark Setter Methods - (void)loadView { [super loadView]; } - (void)viewDidLoad { [super viewDidLoad]; // Do view setup here. self.contendView.wantsLayer = YES; [self refreshUI]; } - (void)refreshUI { __weak typeof(self) weakSelf = self; self.titleLbl.stringValue = NSLocalizedString(@"Unlock All Features for Free", nil); self.infoTitleLabel.stringValue = [@"👋🏻 " stringByAppendingString:NSLocalizedString(@"7-day Free Trial", nil)]; self.infoSubTitleLabel.stringValue = NSLocalizedString(@"PDF Reader Pro offers a 7-day free trial of the full functions.", nil); self.featureLbl.stringValue = NSLocalizedString(@"Key Features", nil); self.nTipLabel.stringValue = NSLocalizedString(@"New", nil); self.nInfoLabel.stringValue = NSLocalizedString(@"Digital signature", nil); self.featureInfoLabel1.stringValue = NSLocalizedString(@"Edit PDF", nil); self.featureInfoLabel2.stringValue = NSLocalizedString(@"Organize pages", nil); self.featureInfoLabel3.stringValue = NSLocalizedString(@"Convert PDF", nil); self.featureInfoLabel4.stringValue = NSLocalizedString(@"Create & fill form", nil); self.featureInfoLabel5.stringValue = NSLocalizedString(@"OCR", nil); self.freeTrialButton.title = NSLocalizedString(@"Free Trial", nil); self.learnMoreButton.title = NSLocalizedString(@"Buy Now", nil); self.enterLicenseButton.title = NSLocalizedString(@"Enter License", nil); self.nInfoLabel.toolTip = NSLocalizedString(@"Digital signature", nil); self.featureInfoLabel1.toolTip = NSLocalizedString(@"Edit PDF", nil); self.featureInfoLabel2.toolTip = NSLocalizedString(@"Organize pages", nil); self.featureInfoLabel3.toolTip = NSLocalizedString(@"Convert PDF", nil); self.featureInfoLabel4.toolTip = NSLocalizedString(@"Create & fill form", nil); self.featureInfoLabel5.toolTip = NSLocalizedString(@"OCR", nil); self.titleLbl.font = [NSFont UbuntuBoldFontWithSize:20]; self.infoTitleLabel.font = [NSFont UbuntuBoldFontWithSize:26]; self.infoSubTitleLabel.font = [NSFont SFProTextRegularFont:14]; self.featureLbl.font = [NSFont SFProTextSemiboldFont:16.]; self.nTipLabel.font = [NSFont SFProTextRegularFont:11]; self.nInfoLabel.font = self.featureInfoLabel1.font = self.featureInfoLabel2.font = self.featureInfoLabel3.font = self.featureInfoLabel4.font = self.featureInfoLabel5.font = [NSFont SFProTextRegularFont:14.]; self.titleLbl.textColor = [NSColor colorWithRed:68/255. green:66/255. blue:67/255. alpha:1]; self.infoSubTitleLabel.textColor = [KMAppearance KMColor_Layout_H0]; self.featureLbl.textColor = [KMAppearance KMColor_Layout_H0]; self.nInfoLabel.textColor = [KMAppearance KMColor_Layout_H0]; self.featureInfoLabel1.textColor = [KMAppearance KMColor_Layout_H0]; self.featureInfoLabel2.textColor = [KMAppearance KMColor_Layout_H0]; self.featureInfoLabel3.textColor = [KMAppearance KMColor_Layout_H0]; self.featureInfoLabel4.textColor = [KMAppearance KMColor_Layout_H0]; self.featureInfoLabel5.textColor = [KMAppearance KMColor_Layout_H0]; self.infoContendView.wantsLayer = YES; self.infoContendView.layer.cornerRadius = 8; self.infoContendView.layer.masksToBounds = YES; self.nTipView.wantsLayer = YES; self.nTipView.layer.cornerRadius = 4; self.nTipView.layer.masksToBounds = YES; self.nTipView.layer.backgroundColor = [NSColor colorWithRed:0 green:207/255. blue:133/255. alpha:1.].CGColor; self.freeTrialBox.wantsLayer = YES; self.freeTrialBox.cornerRadius = CGRectGetHeight(self.freeTrialBox.frame)/2.; self.freeTrialButton.mouseMoveCallback = ^(BOOL mouseEntered) { if ([KMAppearance isDarkMode]) { if (mouseEntered) { weakSelf.freeTrialBox.fillColor = [NSColor whiteColor]; } else { weakSelf.freeTrialBox.fillColor = [NSColor colorWithRed:181/255. green:177/255. blue:239/255. alpha:1.]; } } else { if (mouseEntered) { weakSelf.freeTrialBox.fillColor = [NSColor colorWithRed:0 green:207/255. blue:133/255. alpha:1.]; } else { weakSelf.freeTrialBox.fillColor = [NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.]; } } }; self.learnMoreButton.mouseMoveCallback = ^(BOOL mouseEntered) { if ([KMAppearance isDarkMode]) { if (mouseEntered) { [weakSelf.learnMoreButton setTitleColor:[NSColor whiteColor]]; } else { [weakSelf.learnMoreButton setTitleColor:[NSColor colorWithRed:181/255. green:177/255. blue:239/255. alpha:1.]]; } } else { if (mouseEntered) { [weakSelf.learnMoreButton setTitleColor:[NSColor colorWithRed:8/255. green:124/255. blue:255/255. alpha:1.]]; } else { [weakSelf.learnMoreButton setTitleColor:[NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.]]; } } }; self.enterLicenseButton.mouseMoveCallback = ^(BOOL mouseEntered) { if ([KMAppearance isDarkMode]) { if (mouseEntered) { [weakSelf.enterLicenseButton setTitleColor:[NSColor whiteColor]]; } else { [weakSelf.enterLicenseButton setTitleColor:[NSColor colorWithRed:181/255. green:177/255. blue:239/255. alpha:1.]]; } } else { if (mouseEntered) { [weakSelf.enterLicenseButton setTitleColor:[NSColor colorWithRed:8/255. green:124/255. blue:255/255. alpha:1.]]; } else { [weakSelf.enterLicenseButton setTitleColor:[NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.]]; } } }; [NSDistributedNotificationCenter.defaultCenter addObserver:self selector:@selector(themeChanged:) name:@"AppleInterfaceThemeChangedNotification" object: nil]; [self updateViewColor]; } - (void)updateViewColor { if ([KMAppearance isDarkMode]) { self.infoContendView.layer.backgroundColor = [NSColor colorWithRed:24/255. green:22/255. blue:31/255. alpha:0.9].CGColor; self.freeTrialBox.fillColor = [NSColor colorWithRed:181/255. green:177/255. blue:239/255. alpha:1.]; self.nTipLabel.textColor = [NSColor colorWithRed:47/255. green:45/255. blue:54/255. alpha:1.]; [self.freeTrialButton setTitleColor:[NSColor colorWithRed:7/255. green:1/255. blue:34/255. alpha:1.]]; [self.learnMoreButton setTitleColor:[NSColor colorWithRed:181/255. green:177/255. blue:239/255. alpha:1.]]; [self.enterLicenseButton setTitleColor:[NSColor colorWithRed:181/255. green:177/255. blue:239/255. alpha:1.]]; } else { self.infoContendView.layer.backgroundColor = [NSColor colorWithRed:248/255. green:249/255. blue:1 alpha:1].CGColor; self.freeTrialBox.fillColor = [NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.]; self.nTipLabel.textColor = [NSColor whiteColor]; [self.freeTrialButton setTitleColor:[NSColor whiteColor]]; [self.learnMoreButton setTitleColor:[NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.]]; [self.enterLicenseButton setTitleColor:[NSColor colorWithRed:39/255. green:60/255. blue:98/255. alpha:1.]]; } } - (IBAction)btnAction:(id)sender { if ([sender isEqual:self.freeTrialButton]) { if (self.callback) { self.callback(0, self); } [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"Btn_PUW_DigitalSignTrial_Start"}]; } else if ([sender isEqual:self.learnMoreButton]) { if (self.callback) { self.callback(1, self); } [[FMTrackEventManager defaultManager] trackEventWithEvent:@"PUW" withProperties:@{@"PUW_Btn":@"Btn_PUW_DigitalSignTrial_LearnMore"}]; } else if ([sender isEqual:self.enterLicenseButton]) { if (self.callback) { self.callback(2, self); } } } #pragma mark - NSNotification - (void)themeChanged:(NSNotification *)notification { dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self updateViewColor]; }); } @end