//
|
// HDLEZDetectionTypeViewController.m
|
// EZSDK
|
//
|
// Created by Davin on 2023/8/5.
|
//
|
|
#import "HDLEZDetectionTypeViewController.h"
|
#import "HDLEZDetectionTypeView.h"
|
#import "MJRefreshNormalHeader.h"
|
|
@interface HDLEZDetectionTypeViewController ()
|
|
@property (nonatomic, strong) HDLEZDetectionTypeView *detectionTypeView;
|
|
@property (nonatomic, strong) MJRefreshNormalHeader *header;//刷新header
|
|
@property (nonatomic, strong) UIButton *sureButton;
|
|
@property (nonatomic, strong) NSArray <HDLEZDetectionTypeModel *>*detectionTypeArray;
|
|
@property (nonatomic, strong) NSString *selectedCode; // 选中要设置的检测类型
|
|
@end
|
|
@implementation HDLEZDetectionTypeViewController
|
|
- (void)viewWillAppear:(BOOL)animated {
|
[super viewWillAppear:animated];
|
[self.navigationController.navigationBar setHidden:YES];
|
}
|
|
- (void)viewDidLoad {
|
[super viewDidLoad];
|
// Do any additional setup after loading the view.
|
[self setTopBarViewWithTitle:HDLEZLocallizedString(@"device_detection_type")];
|
[self.topBarView.bottomLine setHidden:YES];
|
// [self.navigationController.navigationBar setHidden:YES];
|
[self createSubviews];
|
}
|
|
- (void)createSubviews {
|
self.view.backgroundColor = HDLEZHEXCOLOR(0xF2F3F7, 1.);
|
|
self.selectedCode = @"";
|
[self.view addSubview:self.detectionTypeView];
|
[self.view addSubview:self.sureButton];
|
|
[self.detectionTypeView mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.equalTo(self.view).offset(HDLEZ_APP_TOP_BAR_HEIGHT);
|
make.left.right.equalTo(self.view);
|
}];
|
|
[self.sureButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
make.top.mas_equalTo(self.detectionTypeView.mas_bottom).offset(16.);
|
make.bottom.mas_equalTo(self.view.mas_bottom).offset(-56.);
|
make.centerX.mas_equalTo(self.view.mas_centerX);
|
make.width.mas_equalTo(220.);
|
make.height.mas_equalTo(44.);
|
}];
|
|
//#warning mock test
|
// NSMutableArray *mArray = [NSMutableArray arrayWithCapacity:0];
|
// HDLEZDetectionTypeModel *firstModel = [[HDLEZDetectionTypeModel alloc] init];
|
// firstModel.title = @"AI人形或车型检测";
|
// firstModel.isSelected = NO;
|
// [mArray addObject:firstModel];
|
//
|
// HDLEZDetectionTypeModel *secondModel = [[HDLEZDetectionTypeModel alloc] init];
|
// secondModel.title = @"AI人形检测";
|
// secondModel.isSelected = NO;
|
// [mArray addObject:secondModel];
|
//
|
// HDLEZDetectionTypeModel *thirdmodel = [[HDLEZDetectionTypeModel alloc] init];
|
// thirdmodel.title = @"车型检测";
|
// thirdmodel.isSelected = NO;
|
// [mArray addObject:thirdmodel];
|
//
|
// HDLEZDetectionTypeModel *fourthModel = [[HDLEZDetectionTypeModel alloc] init];
|
// fourthModel.title = @"画面变化检测";
|
// fourthModel.isSelected = NO;
|
// [mArray addObject:fourthModel];
|
//
|
// HDLEZDetectionTypeModel *fifthModel = [[HDLEZDetectionTypeModel alloc] init];
|
// fifthModel.title = @"关闭活动检测提醒";
|
// fifthModel.isSelected = NO;
|
// [mArray addObject:fifthModel];
|
//
|
// self.detectionTypeView.detectionTypeList = mArray;
|
|
__weak __typeof(self)weakSelf = self;
|
[self.detectionTypeView didSelectedDetectionType:^(NSString * _Nonnull code) {
|
weakSelf.selectedCode = code;
|
}];
|
|
//下拉刷新
|
// 设置回调(一旦进入刷新状态,就调用target的action,也就是调用self的loadNewData方法)
|
_header = [MJRefreshNormalHeader headerWithRefreshingTarget:self refreshingAction:@selector(refreshData)];
|
// 设置自动切换透明度(在导航栏下面自动隐藏)
|
_header.automaticallyChangeAlpha = YES;
|
// 隐藏时间
|
_header.lastUpdatedTimeLabel.hidden = YES;
|
// 隐藏刷新状态文本
|
_header.stateLabel.hidden = YES;
|
_detectionTypeView.mj_header=_header;
|
|
//开始加载数据
|
[_header beginRefreshing];
|
|
[self.sureButton addTarget:self action:@selector(sureAction) forControlEvents:UIControlEventTouchUpInside];
|
}
|
|
|
/*刷新数据
|
*/
|
-(void)refreshData{
|
self.detectionTypeArray=[[NSMutableArray alloc] init];
|
|
[self getMsgList];
|
}
|
|
/*获取历史记录
|
*/
|
-(void)getMsgList{
|
__weak __typeof(self)weakSelf = self;
|
[[EZHttpUtil sharedManager] getAiSupportDetectionList:self.deviceInfo.deviceSerial completion:^(ResponseData * _Nonnull responseData) {
|
[weakSelf.header endRefreshing];
|
|
if (responseData.success) {
|
weakSelf.detectionTypeArray=[NSArray yy_modelArrayWithClass:[HDLEZDetectionTypeModel class] json:responseData.data];
|
weakSelf.detectionTypeView.detectionTypeList = weakSelf.detectionTypeArray;
|
}else{
|
[weakSelf.view makeToast:responseData.message
|
duration:1.5
|
position:@"center"];
|
}
|
}];
|
}
|
|
#pragma mark - PrivateMethod
|
- (void)checkSelectedCode {
|
for (HDLEZDetectionTypeModel *typeModel in self.detectionTypeArray) {
|
if (typeModel.status) {
|
self.selectedCode = typeModel.code;
|
break;
|
}
|
}
|
}
|
|
- (void)sureAction {
|
if (self.selectedCode && self.selectedCode.length > 0) {
|
__weak __typeof(self)weakSelf = self;
|
[[EZHttpUtil sharedManager] setAiSupportDetection:self.deviceInfo.deviceSerial code:self.selectedCode completion:^(ResponseData * _Nonnull responseData) {
|
if (responseData.success) {
|
[weakSelf.view makeToast:HDLEZLocallizedString(@"setting_opration_success")
|
duration:1.5
|
position:@"center"];
|
[weakSelf.navigationController popViewControllerAnimated:YES];
|
} else {
|
[weakSelf.view makeToast:responseData.message
|
duration:1.5
|
position:@"center"];
|
}
|
}];
|
}
|
}
|
|
#pragma mark - Getter
|
- (HDLEZDetectionTypeView *)detectionTypeView {
|
if (!_detectionTypeView) {
|
_detectionTypeView = [[HDLEZDetectionTypeView alloc] init];
|
_detectionTypeView.backgroundColor = [UIColor clearColor];
|
}
|
return _detectionTypeView;
|
}
|
|
- (UIButton *)sureButton {
|
if (!_sureButton) {
|
_sureButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
[_sureButton setTitle:HDLEZLocallizedString(@"device_temp_sure") forState:UIControlStateNormal];
|
[_sureButton setTitleColor:HDLEZ_COLOR_TITLE_BLACK forState:UIControlStateNormal];
|
_sureButton.titleLabel.font = HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_16);
|
_sureButton.backgroundColor = UIColor.whiteColor;
|
_sureButton.layer.cornerRadius = 22.;
|
_sureButton.clipsToBounds = YES;
|
|
}
|
return _sureButton;
|
}
|
|
|
@end
|