//
//  WKWebViewController.m
//  iOSJSBridgeDemo
//
//  Created by 罗坚(EX-LUOJIAN004) on 2018/5/2.
//  Copyright © 2018年 罗坚(EX-LUOJIAN004). All rights reserved.
//

#import "WKWebViewController.h"
#import "ACBridgeWKWebView.h"
#import "UINavigationController+ACWebPlus.h"

@interface WKWebViewController ()

@end

@implementation WKWebViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"WKWebView";
    self.view.backgroundColor = [UIColor whiteColor];
    
    WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc] init];
    configuration.userContentController = [WKUserContentController new];
    
    WKPreferences *preferences = [WKPreferences new];
    preferences.javaScriptCanOpenWindowsAutomatically = YES;
    preferences.minimumFontSize = 30.0;
    configuration.preferences = preferences;
    
    ACBridgeWKWebView *webView = [[ACBridgeWKWebView alloc] initWithFrame:self.view.bounds configuration:configuration];
    webView.vc = self;
    
    NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"assets/web/index.html" ofType:nil];
    NSURL *fileURL = [NSURL fileURLWithPath:urlStr];
    [webView loadFileURL:fileURL allowingReadAccessToURL:fileURL];
    
    [self.view addSubview:webView];
}

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    
    [self.navigationController setDefaultAppearance];
}

@end
