| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356 | 
							- //
 
- //  ASBaseViewController.m
 
- //  Asteria
 
- //
 
- //  Created by iOS on 2023/4/24.
 
- //
 
- #import "ASBaseViewController.h"
 
- #import "AppDelegate.h"
 
- @interface ASBaseViewController ()
 
- @property (nonatomic, strong) UIImageView *leftImgV;
 
- @property (nonatomic, strong) UITextField *searchTf;
 
- @property (nonatomic, strong) UIButton *tfBt;
 
- @property (nonatomic, copy) btnClickBlock tapSearchBlock;
 
- @property (nonatomic, strong) UIButton *backBt;
 
- @property (nonatomic, strong) UIButton *searchNavBt;
 
- @property (nonatomic, copy) btnClickBlock nav_searchBlock;
 
- @property (nonatomic, strong) UIView *emptyV;
 
- @property (nonatomic, strong) UILabel *emptylb;
 
- @end
 
- @implementation ASBaseViewController
 
- - (void)toHomeVc {
 
-     if (self.navigationController != nil) {
 
-         [self.navigationController popToRootViewControllerAnimated:false];
 
-     }
 
-     QMUITabBarViewController *tabVC = (QMUITabBarViewController *)((AppDelegate *)UIApplication.sharedApplication.delegate).window.rootViewController;
 
-     
 
-     tabVC.selectedIndex = 0;
 
- }
 
- - (void)popAndToLogin {
 
-     QMUITabBarViewController *tabVC = (QMUITabBarViewController *)((AppDelegate *)UIApplication.sharedApplication.delegate).window.rootViewController;
 
-     
 
-     tabVC.selectedIndex = 0;
 
-     UITabBar *tabbar = tabVC.tabBar;
 
-     if (tabbar.items.count > 2) {
 
-         UITabBarItem *temp = tabbar.items[2];
 
-         temp.qmui_badgeInteger = 0;
 
-         
 
-     }
 
-     
 
-     UIViewController *loginC = [[CTMediator sharedInstance] Login_LoginC:@{}];
 
-     
 
-     QMUINavigationController *uikitNavController = [[QMUINavigationController alloc] initWithRootViewController:loginC];
 
-     uikitNavController.navigationBar.hidden = YES;
 
-     uikitNavController.modalPresentationStyle = UIModalPresentationFullScreen;
 
-     [tabVC presentViewController:uikitNavController animated:YES completion:nil];
 
- }
 
- - (void)toLoginVC {
 
-     UIViewController *loginC = [[CTMediator sharedInstance] Login_LoginC:@{}];
 
-     
 
-     QMUINavigationController *uikitNavController = [[QMUINavigationController alloc] initWithRootViewController:loginC];
 
-     uikitNavController.navigationBar.hidden = YES;
 
-     uikitNavController.modalPresentationStyle = UIModalPresentationFullScreen;
 
-     [self presentViewController:uikitNavController animated:YES completion:nil];
 
- }
 
- - (void)setTitleStr:(NSString *)titleStr {
 
-     _titleStr = titleStr;
 
-     self.nav_titleLB.text = _titleStr;
 
- }
 
- - (void)hiddenEmpty {
 
-     self.emptyV.hidden = true;
 
- }
 
- - (void)setEmptyTip:(NSString *)tipStr {
 
-     self.emptylb.text = tipStr;
 
- }
 
- - (void)showEmptyV:(UIView *)v {
 
-     if (self.emptyV.superview == v) {
 
-         self.emptyV.hidden = false;
 
-         [self.emptyV.superview bringSubviewToFront:self.emptyV];
 
-         return;
 
-     }
 
-     if (v == nil) {
 
-         [self.view addSubview:self.emptyV];
 
-         [self.emptyV mas_makeConstraints:^(MASConstraintMaker *make) {
 
-             make.top.equalTo(self.customNavBar.mas_bottom);
 
-             make.leading.trailing.bottom.equalTo(self.view);
 
-         }];
 
-     } else {
 
-         [v addSubview:self.emptyV];
 
-         [self.emptyV mas_remakeConstraints:^(MASConstraintMaker *make) {
 
-             make.edges.equalTo(v);
 
-             make.width.height.equalTo(v);
 
-         }];
 
-     }
 
-     self.emptyV.hidden = false;
 
-     [self.emptyV.superview bringSubviewToFront:self.emptyV];
 
-     
 
-     dispatch_async(dispatch_get_main_queue(), ^{
 
-         [UIView viewAddHorColorBg:self.emptyV colorArr:@[
 
-             (id)_E0FFF5.CGColor,
 
-             (id)Col_FFF.CGColor
 
-         ] startP:CGPointMake(0.5, 0.25) endP:CGPointMake(0.5, 1)];
 
-         [self.emptyV bringSubviewToFront:self.emptylb];
 
-     });
 
-     
 
- }
 
- - (void)viewDidLoad {
 
-     [super viewDidLoad];
 
-     [self addBaseNav];
 
-     
 
-     self.navigationController.navigationBar.hidden = true;
 
-     
 
-     self.customNavBar.backgroundColor = Col_FFF;
 
-     self.view.backgroundColor = _F8F8F8;
 
- }
 
- - (void)viewWillAppear:(BOOL)animated {
 
-     [super viewWillAppear:animated];
 
-     self.tabBarController.tabBar.hidden = self.navigationController.viewControllers.count > 1;
 
- }
 
- - (void)viewWillDisappear:(BOOL)animated {
 
-     [super viewWillAppear:animated];
 
-     
 
- }
 
- - (void)setNavRightSearch:(btnClickBlock)nav_searchAction {
 
-     self.nav_searchBlock = nav_searchAction;
 
-     [self.customNavBar addSubview:self.searchNavBt];
 
-     
 
-     [self.searchNavBt mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.width.height.equalTo(@44);
 
-         make.trailing.equalTo(self.customNavBar).offset(-10);
 
-         make.centerY.equalTo(self.customNavBar);
 
-     }];
 
- }
 
- - (void)ucHomeStyle:(btnClickBlock)tapSearch {
 
-     self.tapSearchBlock = tapSearch;
 
-     [self.customNavBar addSubview:self.leftImgV];
 
-     [self.customNavBar addSubview:self.searchTf];
 
-     [self.customNavBar addSubview:self.tfBt];
 
-     
 
-     [self.leftImgV mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.leading.equalTo(self.customNavBar).offset(20);
 
-         make.width.equalTo(@140);
 
-         make.height.equalTo(@43.5);
 
-         make.centerY.equalTo(self.customNavBar);
 
-     }];
 
-     
 
-     [self.searchTf mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.leading.equalTo(self.leftImgV.mas_trailing).offset(20);
 
-         make.height.equalTo(@36);
 
-         make.centerY.equalTo(self.leftImgV);
 
-         make.trailing.equalTo(self.customNavBar).offset(-10);
 
-     }];
 
-     [self.tfBt mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.edges.equalTo(self.searchTf);
 
-     }];
 
-     
 
- }
 
- - (void)addBaseNav {
 
-     
 
-     [self.view addSubview:self.statusBgV];
 
-     [self.view addSubview:self.customNavBar];
 
-     [self.customNavBar addSubview:self.nav_bottomLineV];
 
-     self.statusBgV.frame = CGRectMake(0, 0, KScreenWidth, kStatusBarH);
 
-     self.customNavBar.frame = CGRectMake(0, kStatusBarH, KScreenWidth, kCustomNavBarH);
 
-     self.nav_bottomLineV.frame = CGRectMake(0, kCustomNavBarH-1, KScreenWidth, 1);
 
-     
 
-     [self.customNavBar addSubview:self.backBt];
 
-     [self.customNavBar addSubview:self.nav_titleLB];
 
-     [self.backBt mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.leading.equalTo(self.customNavBar).offset(10);
 
-         make.centerY.equalTo(self.customNavBar);
 
-         make.width.height.equalTo(@44);
 
-     }];
 
-     
 
-     [self.nav_titleLB mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.center.equalTo(self.customNavBar);
 
-         make.width.equalTo(self.customNavBar).offset(-120);
 
-         make.height.equalTo(@40);
 
-     }];
 
-     self.backBt.hidden = true;
 
-     if (self.navigationController.viewControllers.count > 1) {
 
-         self.backBt.hidden = false;
 
-     }
 
-     
 
-     
 
-     [self.emptyV addSubview:self.emptylb];
 
-     [self.emptylb mas_makeConstraints:^(MASConstraintMaker *make) {
 
-         make.leading.equalTo(self.emptyV).offset(30);
 
-         make.trailing.equalTo(self.emptyV).offset(-30);
 
-         make.centerY.equalTo(self.emptyV).offset(-30);
 
-         make.top.greaterThanOrEqualTo(self.emptyV).offset(20);
 
-     }];
 
- }
 
- // MARK: - actions
 
- - (void)searchBtAction {
 
-     UIViewController *vc = [CTMediator.sharedInstance getSearchVc:@{}];
 
-     [self presentViewController:vc animated:true completion:nil];
 
-     if (self.tapSearchBlock) {
 
-         self.tapSearchBlock();
 
-     }
 
- }
 
- // MARK: - subVs
 
- - (UIView *)emptyV {
 
-     if (!_emptyV) {
 
-         UIView *v = [UIView baseV];
 
-         v.backgroundColor = Col_FFF;
 
-         v.hidden = true;
 
-         _emptyV = v;
 
-     }
 
-     return _emptyV;
 
- }
 
- - (UILabel *)emptylb {
 
-     if (!_emptylb) {
 
-         UILabel *lb = [UILabel baseLb];
 
-         lb.font = [UIFont fontWithName:Rob_Medium size:72];
 
-         lb.textAlignment = NSTextAlignmentCenter;
 
-         lb.numberOfLines = 0;
 
-         lb.text = @"No Data";
 
-         lb.textColor = _043632;
 
-         _emptylb = lb;
 
-     }
 
-     return _emptylb;
 
- }
 
- - (UIView *)statusBgV {
 
-     if (!_statusBgV) {
 
-         UIView *v = [UIView baseV];
 
-         v.backgroundColor = _32CFB0;
 
-         _statusBgV = v;
 
-     }
 
-     return _statusBgV;
 
- }
 
- - (UIView *)customNavBar {
 
-     if (!_customNavBar) {
 
-         UIView *v = [UIView baseV];
 
-         v.backgroundColor = _32CFB0;
 
-         _customNavBar = v;
 
-     }
 
-     return _customNavBar;
 
- }
 
- - (UIView *)nav_bottomLineV {
 
-     if (!_nav_bottomLineV) {
 
-         UIView *v = [UIView baseV];
 
-         v.backgroundColor = [UIColor.blackColor colorWithAlphaComponent:0.05];
 
-         _nav_bottomLineV = v;
 
-     }
 
-     return _nav_bottomLineV;
 
- }
 
- - (UIImageView *)leftImgV {
 
-     if (!_leftImgV) {
 
-         UIImageView *v = [UIImageView baseImgV];
 
-         v.image = [UIImage imageNamed:@"nav_icon"];
 
-         _leftImgV = v;
 
-     }
 
-     return _leftImgV;
 
- }
 
- - (UITextField *)searchTf {
 
-     if (!_searchTf) {
 
-         UITextField *tf = [[UITextField alloc] init];
 
-         tf.borderStyle = UITextBorderStyleNone;
 
-         UIView *leftV = [[UIView alloc] init];
 
-         leftV.backgroundColor = UIColor.clearColor;
 
-         UIImageView *imgV = [UIImageView baseImgV];
 
-         imgV.backgroundColor = UIColor.clearColor;
 
-         imgV.image = [UIImage imageNamed:@"nav_search"];
 
-         leftV.frame = CGRectMake(0, 0, 44, 36);
 
-         imgV.frame = CGRectMake(10, 6, 24, 24);
 
-         [leftV addSubview:imgV];
 
-         tf.leftView = leftV;
 
-         tf.leftViewMode = UITextFieldViewModeAlways;
 
-         tf.backgroundColor = _F5F5F5;
 
-         tf.layer.cornerRadius = 5;
 
-         tf.layer.masksToBounds = true;
 
-         _searchTf = tf;
 
-     }
 
-     return _searchTf;
 
- }
 
- - (UIButton *)tfBt {
 
-     if (!_tfBt) {
 
-         UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
 
-         [bt addTarget:self action:@selector(searchBtAction) forControlEvents:UIControlEventTouchUpInside];
 
-         _tfBt = bt;
 
-     }
 
-     return _tfBt;
 
- }
 
- - (UIButton *)backBt {
 
-     if (!_backBt) {
 
-         UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
 
-         [bt setImage:[UIImage imageNamed:@"nav_back"] forState:UIControlStateNormal];
 
-         [bt addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
 
-         _backBt = bt;
 
-     }
 
-     return _backBt;
 
- }
 
- - (UILabel *)nav_titleLB {
 
-     if (!_nav_titleLB) {
 
-         UILabel *lb = [[UILabel alloc] init];
 
-         lb.font = [UIFont fontWithName:Rob_Regular size:20];
 
-         lb.textAlignment = NSTextAlignmentCenter;
 
-         lb.textColor = Col_000;
 
-         _nav_titleLB = lb;
 
-     }
 
-     return _nav_titleLB;
 
- }
 
- - (void)backAction {
 
-     [self.navigationController popViewControllerAnimated:true];
 
- }
 
- - (UIButton *)searchNavBt {
 
-     if (!_searchNavBt) {
 
-         UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
 
-         [bt setImage:[UIImage imageNamed:@"nav_search"] forState:UIControlStateNormal];
 
-         [bt addTarget:self action:@selector(search_navAction) forControlEvents:UIControlEventTouchUpInside];
 
-         _searchNavBt = bt;
 
-     }
 
-     return _searchNavBt;
 
- }
 
- // MARK: - actions
 
- - (void)search_navAction {
 
-     UIViewController *vc = [CTMediator.sharedInstance getSearchVc:@{}];
 
-     [self presentViewController:vc animated:true completion:nil];
 
-     if (self.nav_searchBlock) {
 
-         self.nav_searchBlock();
 
-     }
 
- }
 
- @end
 
 
  |