//
//  CustomNavigationController.m
//  iCloset
//
//  Created by Castiel on 15/7/14.
//  Copyright (c) 2015年 Castiel. All rights reserved.
//

#import "CustomNavigationController.h"

@implementation CustomNavigationController

static UIImage *imgBG;
+ (void)initialize
{
  // 设置整个项目所有item的主题样式
  UIBarButtonItem *item = [UIBarButtonItem appearance];
  
  // 设置普通状态
  // key：NS****AttributeName
  NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
  textAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:15];
  [item setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
  
  // 设置不可用状态
  NSMutableDictionary *disableTextAttrs = [NSMutableDictionary dictionary];
  disableTextAttrs[NSForegroundColorAttributeName] = [UIColor colorWithRed:0.6 green:0.6 blue:0.6 alpha:0.7];
  disableTextAttrs[NSFontAttributeName] = textAttrs[NSFontAttributeName];
  [item setTitleTextAttributes:disableTextAttrs forState:UIControlStateDisabled];
  
}


- (void)viewDidLoad
{
  [super viewDidLoad];
  
  // 统一导航条的背景
  [self.navigationBar setBackgroundImage:imgBG forBarMetrics:UIBarMetricsDefault];
  
  //消除IOS7以后导航栏黑线
  [self.navigationBar setShadowImage:[[UIImage alloc] init]];
  
  [self setNavigationBarHidden:YES];
  //    //black line
  //    //add for iCloset mod by tmq 2015.07.15
  //    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 43, SCREEN_WIDTH, 0.5)];
  //    [view setBackgroundColor:[UIColor blackColor]];
  //    [self.navigationBar addSubview:view];
}


/**
 *  重写这个方法目的：能够拦截所有push进来的控制器
 *
 *  @param viewController 即将push进来的控制器
 */
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
  if (self.viewControllers.count > 0) {
    viewController.hidesBottomBarWhenPushed = YES;
    
    //        /* 设置导航栏上面的内容 */
    //        // 设置左边的返回按钮
    //        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(back) image:@"back" highImage:@"back"];
    //
    //        // 设置右边的更多按钮
    //        viewController.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(more) image:@"confirm" highImage:@"confirm"];
  }
  
  [super pushViewController:viewController animated:animated];
}

//- (UIViewController *)popViewControllerAnimated:(BOOL)animated {
//    if (((BaseViewController *)[self.viewControllers lastObject]).delegate) {
//        [((BaseViewController *)[self.viewControllers lastObject]).delegate changeUIInfo];
//    }
//    return [super popViewControllerAnimated:YES];
//}

- (void) startPanBack {
  //[super startPanBack];
}
@end
