//
//  KMRepeatVerifyExpireController.m
//  PDF Reader Pro Edition
//
//  Created by Niehaoyu on 2023/9/13.
//

#import "KMRepeatVerifyExpireController.h"
#import <PDF_Reader_Pro-Swift.h>

@interface KMRepeatVerifyExpireController ()

@property (assign) IBOutlet NSView *contendView;

@property (assign) IBOutlet NSTextField *titleLbl;
@property (assign) IBOutlet NSTextField *subTitleLbl;

@property (assign) IBOutlet KMCustomButton *enterLicenseBtn;
@property (assign) IBOutlet KMCustomButton *purchaseBtn;
@property (assign) IBOutlet KMCustomButton *laterBtn;

@property (assign) IBOutlet NSView *seplineView;

@property (assign) IBOutlet NSView *descriptionBGView;
@property (assign) IBOutlet NSTextField *convertLbl;
@property (assign) IBOutlet NSTextField *editLbl;
@property (assign) IBOutlet NSTextField *ocrTipLbl;
@property (assign) IBOutlet NSTextField *formfillLbl;


@end

@implementation KMRepeatVerifyExpireController

- (instancetype)init {
    if (self = [super initWithNibName:@"KMRepeatVerifyExpireController" bundle:nil]) {
        
    }
    return self;
}

- (void)dealloc {
    
}

#pragma mark Setter Methods

- (void)loadView {
    [super loadView];
    
}
    
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do view setup here.
     
    self.contendView.wantsLayer = YES;
    self.laterBtn.wantsLayer = self.purchaseBtn.wantsLayer = self.enterLicenseBtn.wantsLayer = YES;
    self.laterBtn.layer.cornerRadius = self.purchaseBtn.layer.cornerRadius = self.enterLicenseBtn.layer.cornerRadius = 1.;
    self.laterBtn.layer.masksToBounds = self.purchaseBtn.layer.masksToBounds = self.enterLicenseBtn.layer.masksToBounds = YES;

    self.descriptionBGView.wantsLayer = YES;
    self.descriptionBGView.layer.cornerRadius = 6.;
    self.descriptionBGView.layer.masksToBounds = YES;
    self.descriptionBGView.layer.borderWidth = 1;
    
    self.seplineView.wantsLayer = YES;
    
    
    self.titleLbl.stringValue = NSLocalizedString(@"Your Trial Has Expired", nil);
    self.subTitleLbl.stringValue = NSLocalizedString(@"Please upgrade PDF Reader Pro to enjoy all features.", nil);
    self.enterLicenseBtn.title = NSLocalizedString(@"Enter License", nil);
    self.laterBtn.title = NSLocalizedString(@"Later", nil);
    self.purchaseBtn.title = NSLocalizedString(@"Buy Now", nil);
    
    self.convertLbl.stringValue = NSLocalizedString(@"Convert PDF to Word/Excel/PPT/Image and more", nil);
    self.editLbl.stringValue = NSLocalizedString(@"Edit PDF text, images and pages", nil);
    self.ocrTipLbl.stringValue = NSLocalizedString(@"Combine multiple PDFs", nil);
    self.formfillLbl.stringValue = NSLocalizedString(@"Create, fill, and sign PDF forms", nil);
    
    [self updateViewColor];
}

- (void)updateViewColor {
    if ([KMAppearance isDarkMode]) {
        self.contendView.layer.backgroundColor = [NSColor colorWithRed:43/255. green:43/255. blue:43/255. alpha:1.].CGColor;
        self.descriptionBGView.layer.backgroundColor = [NSColor colorWithRed:40/255. green:40/255. blue:40/255. alpha:1.].CGColor;
        self.descriptionBGView.layer.borderColor = [NSColor colorWithRed:1 green:1 blue:1 alpha:0.05].CGColor;
        self.seplineView.layer.backgroundColor = [NSColor colorWithRed:1 green:1 blue:1 alpha:0.1].CGColor;
        
        self.enterLicenseBtn.layer.backgroundColor = [NSColor colorWithRed:86/255. green:88/255. blue:90/255. alpha:1.].CGColor;
        self.laterBtn.layer.backgroundColor = [NSColor colorWithRed:86/255. green:88/255. blue:90/255. alpha:1.].CGColor;
        self.purchaseBtn.layer.backgroundColor = [NSColor colorWithRed:78/255. green:127/255. blue:219/255. alpha:1.].CGColor;
    } else {
        self.contendView.layer.backgroundColor = [NSColor colorWithRed:255/255. green:255/255. blue:255/255. alpha:1.].CGColor;
        self.descriptionBGView.layer.backgroundColor = [NSColor colorWithRed:246/255. green:246/255. blue:246/255. alpha:1.].CGColor;
        self.descriptionBGView.layer.borderColor = [NSColor colorWithRed:0 green:0 blue:0 alpha:0.05].CGColor;
        self.seplineView.layer.backgroundColor = [NSColor colorWithRed:0 green:0 blue:0 alpha:0.1].CGColor;
        
        self.enterLicenseBtn.layer.backgroundColor = [NSColor colorWithRed:218/255. green:219/255. blue:222/255. alpha:1.].CGColor;
        self.laterBtn.layer.backgroundColor = [NSColor colorWithRed:218/255. green:219/255. blue:222/255. alpha:1.].CGColor;
        self.purchaseBtn.layer.backgroundColor = [NSColor colorWithRed:39/255. green:60/255. blue:99/255. alpha:1.].CGColor;
    }
    
    [self.enterLicenseBtn setTitleColor:[KMAppearance KMColor_Layout_H0]];
    [self.laterBtn setTitleColor:[KMAppearance KMColor_Layout_H0]];
    [self.purchaseBtn setTitleColor:[KMAppearance KMColor_Layout_W0]];
    
}

- (IBAction)btnAction:(KMCustomButton *)sender {
    if ([sender isEqual:self.enterLicenseBtn]) {
        if (self.callback) {
            self.callback(0, self);
        }
    } else if ([sender isEqual:self.laterBtn]) {
        if (self.callback) {
            self.callback(1, self);
        }
    } else if ([sender isEqual:self.purchaseBtn]) {
        if (self.callback) {
            self.callback(2, self);
        }
    }
}


@end