//
//  ICGuideCollectionViewCell.m
//  superCleaner
//
//  Created by Mazy on 2020/7/5.
//  Copyright © 2020 Mazy. All rights reserved.
//

#import "ICGuideCollectionViewCell.h"
#import "ICWebViewController.h"

@implementation ICGuideCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.welcomeTipLabel.text = ICLocalized(@"WelcomeQuickCleaner");
    [self.nextButton setTitle:ICLocalized(@"NextStep") forState:UIControlStateNormal];
    
    NSString * clauseStr = ICLocalized(@"PrivacyMainDesc");
    NSString * privacyStr = ICLocalized(@"PrivacySubDesc");
    NSString * privacy = ICLocalized(@"PrivacyPolicy");

    self.mainContentLabel.text = clauseStr;

    NSMutableAttributedString * attStr = [[NSMutableAttributedString alloc] initWithString:privacyStr];
    [attStr addAttributes:@{NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle), NSForegroundColorAttributeName: UIColor.whiteColor, NSFontAttributeName:[UIFont systemFontOfSize:18]} range:[privacyStr rangeOfString: privacy]];
    
    self.commitContentLabel.attributedText = attStr;
    
    self.commitContentLabel.userInteractionEnabled = true;
    UITapGestureRecognizer *gueture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showPrivacyPolicy)];
    [self.commitContentLabel addGestureRecognizer:gueture];
}

- (void)showPrivacyPolicy {
    
    ICWebViewController *webView = [[ICWebViewController alloc] init];
    //    webView.url = privacyPolicy;
    NSDictionary * dic = [ICUserManager shared].h5_url;
    webView.url = [dic objectForKey:@"privacy"];
    webView.webTitle = ICLocalized(@"PrivacyPolicy");
    
    ICNavigationController *navc = [[ICNavigationController alloc] initWithRootViewController:webView];
    self.webNavc = navc;
    webView.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"global_navi_bar_back_icon"] style:UIBarButtonItemStylePlain target:self action:@selector(dismissAction)];
    [[UIApplication sharedApplication].windows.lastObject.rootViewController presentViewController:navc animated:true completion: nil];
}

- (void)dismissAction {
    [self.webNavc dismissViewControllerAnimated:true completion:nil];
}

@end
