//
//  BaseNavigationController.m
//  keyBoard
//
//  Created by Mac on 2025/10/29.
//

#import "BaseNavigationController.h"

@interface BaseNavigationController ()

@end

@implementation BaseNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    // 统一返回箭头样式与颜色
    UIImage *backImg = [UIImage imageNamed:@"back_black_icon"];
    if (backImg) {
        self.navigationBar.backIndicatorImage = backImg;
        self.navigationBar.backIndicatorTransitionMaskImage = backImg;
    }
    self.navigationBar.tintColor = [UIColor blackColor]; // 箭头/按钮的着色

    if (@available(iOS 14.0, *)) {
        self.navigationBar.topItem.backButtonDisplayMode = UINavigationItemBackButtonDisplayModeMinimal;
    }
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = true;
        UIViewController *prev = self.topViewController;
        if (@available(iOS 14.0, *)) {
            prev.navigationItem.backButtonDisplayMode = UINavigationItemBackButtonDisplayModeMinimal;
        } else {
            prev.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
        }
    }
    [super pushViewController:viewController animated:animated];
}

@end
