//
//  FWZViewController.m
//  smartRhino
//
//  Created by tederen on 2019/11/8.
//  Copyright © 2019 tederen. All rights reserved.
//

#import "FWZViewController.h"
#import "TDNavigationBar.h"
#import "DrawerView.h"
@interface FWZViewController ()<TDNavigationBarDelegate>
@end

@implementation FWZViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.myBackImageView];
    [self.view addSubview:self.myNavigationBar];
    self.fd_prefersNavigationBarHidden = YES;
    self.myNavigationBar.titleLabel.text = self.title;
    self.myNavigationBar.titleLabel.font = [UIFont systemFontOfSize:19.0];
}
#pragma mark - 导航栏事件处理
-(void)back{
    if (self.navigationController.viewControllers.count > 1) {
        [self.navigationController popViewControllerAnimated:YES];
    }else{
        [self dismissViewControllerAnimated:YES completion:nil];
    }
}
- (void)secondBarButtonItems:(TDButton *)sender{
        
    DrawerView *vi = [[DrawerView alloc] initWithFrame:self.view.bounds];
        
    [self.view addSubview:vi];
}

- (void)backButtonAction {
    [self back];
}
- (void)backButtonAction2:(TDButton *)sender{
    [self secondBarButtonItems:sender];
}


- (void)rightButtonAction:(nonnull TDButton *)sender {
    
}

#pragma mark - setter
- (TDNavigationBar *)myNavigationBar{
    if (!_myNavigationBar) {
        _myNavigationBar = [[TDNavigationBar alloc]initNavigationBar];
        _myNavigationBar.delegate = self;
        _myNavigationBar.backButton2.hidden = NO;
        _myNavigationBar.titleLabel.textColor = UIColorHex(#0A0A0A);
        _myNavigationBar.titleLabel.font = [UIFont systemFontOfSize:16.f];
        [_myNavigationBar.backButton2 setImage:IMG(@"icon_menu") forState:UIControlStateNormal];
        [_myNavigationBar.backButton  setImage:IMG(@"首页-书籍详情-返回") forState:UIControlStateNormal];
    }
    return _myNavigationBar;
}
- (UIView *)myBackImageView{
    if (!_myBackImageView) {
        _myBackImageView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kGXScreenHeigh, kNavigationHeight)];
        _myBackImageView.backgroundColor = [UIColor colorWithRed:92/255.0 green:118.0/255.0 blue:167.0/255.f alpha:1.0];
        _myBackImageView.hidden = YES;
    }
    return _myBackImageView;
}
@end