// // ApplicationManageViewController.m // tongxin // // Created by ecell on 2023/7/12. // Copyright © 2023 xTT. All rights reserved. // #import "ApplicationManageViewController.h" #import "CommonTableView.h" #import "ApplicationManageTableViewCell.h" #import "TimeframeListViewController.h" #import "ApplicationManageModel.h" @interface ApplicationManageViewController () @property (nonatomic ,strong) CommonTableView *listTable; @property (nonatomic ,strong) UIView *headerView; @end @implementation ApplicationManageViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.zx_navTitle = @"应用管理"; self.view.backgroundColor = tabViewBG; [self.view addSubview:self.listTable]; [self.listTable mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.equalTo(self.view); make.top.equalTo(self.view).offset(iPhoneX_NavHeight); make.bottom.equalTo(self.view.mas_bottom); }]; [self GetListModel]; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; } - (CommonTableView *)listTable { if (!_listTable) { WeakSelf _listTable = [[CommonTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain cellHeight:80 cellRow:0 isAdaptive:NO isLine:YES commonCell:ApplicationManageTableViewCell.class createCell:^(ZZTableViewCell * _Nonnull cells, NSIndexPath * _Nonnull indexPath) { ApplicationManageTableViewCell *cell = (ApplicationManageTableViewCell *)cells; cell.listModel = self.myDataSource[indexPath.row]; } selectedCell:^(UITableView * _Nonnull tableView, NSIndexPath * _Nonnull indexPath) { TimeframeListViewController *vc = [[TimeframeListViewController alloc] init]; vc.model = self.myDataSource[indexPath.row]; [weakSelf.navigationController pushViewController:vc animated:YES]; } DidscrollView:^(UIScrollView * _Nonnull scrollView) { }]; _listTable.backgroundColor = KKClearColor; _listTable.tableHeaderView = self.headerView; _listTable.tableHeaderView.height = 35; // _listTable.emptyDataSetSource = self; // _listTable.emptyDataSetDelegate = self; // _listTable.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{ // weakSelf.page = 0; // [weakSelf.myDataSource removeAllObjects]; // [weakSelf GetListModel]; // }]; // _listTable.mj_footer = [MJRefreshFooter footerWithRefreshingBlock:^{ // [weakSelf GetListModel]; // }]; } return _listTable; } - (void)GetListModel { WEAKSELF [cUser.cDevice getManagerSuccess:^(id responseObject) { NSArray *arr = responseObject[@"appList"]; [arr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { ApplicationManageModel *model = [ApplicationManageModel yy_modelWithJSON:obj]; [weakSelf.myDataSource addObject:model]; }]; NSLog(@"%@",weakSelf.myDataSource); weakSelf.listTable.cellRow = weakSelf.myDataSource.count; [weakSelf.listTable reloadData]; } failure:^(id faiObject) { }]; } - (UIView *)headerView { if (!_headerView) { _headerView = [UIView new]; _headerView.frame = CGRectMake(0, 0, ScreenWidth, 35); _headerView.backgroundColor = RGBA(88, 157, 245, .6); UILabel *titleLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentLeft font:Font_(15) textColor:KKWhiteColorColor text:@"应用名称" Radius:0]; [_headerView addSubview:titleLabel]; [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(_headerView).offset(20); make.centerY.equalTo(_headerView); }]; UILabel *titleLabel1 = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentLeft font:Font_(15) textColor:KKWhiteColorColor text:@"禁用" Radius:0]; [_headerView addSubview:titleLabel1]; [titleLabel1 mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(_headerView.mas_right).inset(20); make.centerY.equalTo(_headerView); }]; UILabel *titleLabel2 = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentLeft font:Font_(15) textColor:KKWhiteColorColor text:@"使用时长" Radius:0]; [_headerView addSubview:titleLabel2]; [titleLabel2 mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(titleLabel1.mas_left).inset(40); make.centerY.equalTo(_headerView); }]; } return _headerView; } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end