//
//  WPUserPravcyVC.m
//  HD wallpaper
//
//  Created by aaa on 2024/7/3.
//

#import "WPUserPravcyVC.h"
#import <WebKit/WebKit.h>
#define WPScreen_w  [UIScreen mainScreen].bounds.size.width
#define WPScreen_h [UIScreen mainScreen].bounds.size.height
#define WP_COLOR_WITH_HEX(HEX) [UIColor colorWithRed:((HEX >> 16) & 0xFF) / 255.0f green:((HEX >> 8) & 0xFF) / 255.0f blue:((HEX) & 0xFF) / 255.0f alpha:1.0f]
@interface WPUserPravcyVC ()
@property(nonatomic,strong)UIButton *backItem;
@property(nonatomic,strong)UIImageView *navImage;

@end

@implementation WPUserPravcyVC

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.hidesBottomBarWhenPushed = YES;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.hidesBackButton = YES;
//    UIImageView *bgImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, WPScreen_w, 360)];
//    bgImage.image = [UIImage imageNamed:@"bgsearch"];
//    bgImage.userInteractionEnabled = YES;
//    [self.view addSubview:bgImage];
    
    UIButton *backItem = [[UIButton alloc] initWithFrame:CGRectMake(20, 0, 74, 44)];
    [backItem setImage:[UIImage imageNamed:@"backitem"] forState:UIControlStateNormal];
    [backItem addTarget:self action:@selector(backItemEvent) forControlEvents:UIControlEventTouchUpInside];
    self.backItem = backItem;
    
//    UILabel *titleLabel = [UILabel new];
//    [self.view addSubview:titleLabel];
//    titleLabel.text = @"用户隐私";
//    titleLabel.font = [UIFont systemFontOfSize:16];
//    titleLabel.textColor = [UIColor blackColor];
//    titleLabel.backgroundColor = [UIColor redColor];
//    titleLabel.frame = CGRectMake((self.view.frame.size.width - 200)*0.5, 0, 200, 44);
//    UIImageView *navImage = [[UIImageView alloc] initWithFrame:CGRectMake(WPScreen_w-150, 8, 130, 28)];
//    navImage.image = [UIImage imageNamed:@"navsearch"];
//    self.navImage = navImage;
    
    WKWebView *webView = [WKWebView new];
    [self.view addSubview:webView];
    webView.frame = self.view.bounds;
    NSURL *url = [NSURL URLWithString:@"https://trendwallpaper.bitbucket.io/privacy.html"];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    [webView loadRequest:request];
}

- (void)backItemEvent{
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar addSubview:self.backItem];
    [self.navigationController.navigationBar addSubview:self.navImage];
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.backItem removeFromSuperview];
    [self.navImage removeFromSuperview];
}

@end
