萤石云 iOSSDK,移植跨平台相关工程
Davin
2024-12-18 a67450d72c47f400e56525125318ff1d6ca0a2e8
EZSDK/EZSDK/EZ/TempPassword/Controllers/HDLEZDetectionTypeViewController.m
@@ -6,10 +6,13 @@
//
#import "HDLEZDetectionTypeViewController.h"
#import "HDLESDetectionTypeHeaderView.h"
#import "HDLEZDetectionTypeView.h"
#import "MJRefreshNormalHeader.h"
@interface HDLEZDetectionTypeViewController ()
@property (nonatomic, strong) HDLESDetectionTypeHeaderView *detectionTypeHeaderView;
@property (nonatomic, strong) HDLEZDetectionTypeView *detectionTypeView;
@@ -43,11 +46,18 @@
    self.view.backgroundColor = HDLEZHEXCOLOR(0xF2F3F7, 1.);
    
    self.selectedCode = @"";
    [self.view addSubview:self.detectionTypeHeaderView];
    [self.view addSubview:self.detectionTypeView];
    [self.view addSubview:self.sureButton];
    
    [self.detectionTypeView mas_makeConstraints:^(MASConstraintMaker *make) {
    [self.detectionTypeHeaderView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(HDLEZ_APP_TOP_BAR_HEIGHT);
        make.left.right.equalTo(self.view);
        make.height.mas_equalTo(60);
    }];
    [self.detectionTypeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(HDLEZ_APP_TOP_BAR_HEIGHT + 70);
        make.left.right.equalTo(self.view);
    }];
    
@@ -89,6 +99,32 @@
//    self.detectionTypeView.detectionTypeList = mArray;
    
    __weak __typeof(self)weakSelf = self;
    BOOL isDefence = (self.deviceInfo.defence != 0);
    [self updateDetectionView:isDefence];
    [self.detectionTypeHeaderView configSelected:isDefence switchResult:^(BOOL isSelected) {
        __weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
        hud.labelText = NSLocalizedString(@"setting_switching", @"正在切换,请稍候...");
        /**
         *  注意;该demo只处理了IPC设备的布撤防,所有只有YES/NO,关于A系列设备请判断设备后修改枚举值再处理
         */
        [EZOPENSDK setDefence:isSelected
                 deviceSerial:weakSelf.deviceInfo.deviceSerial
                   completion:^(NSError *error) {
            [hud hide:YES];
            if (error) {
                [weakSelf.view makeToast:NSLocalizedString(@"setting_opration_fail", @"操作失败") duration:2.0 position:@"center"];
                [weakSelf.detectionTypeHeaderView configSelected:!isSelected];
            }
            else{
                weakSelf.deviceInfo.defence = isSelected;
            }
            BOOL isDefence = (weakSelf.deviceInfo.defence != 0);
            [weakSelf updateDetectionView:isDefence];
        }];
    }];
    [self.detectionTypeView didSelectedDetectionType:^(NSString * _Nonnull code) {
        weakSelf.selectedCode = code;
    }];
@@ -108,6 +144,11 @@
    [_header beginRefreshing];
    
    [self.sureButton addTarget:self action:@selector(sureAction) forControlEvents:UIControlEventTouchUpInside];
}
- (void)updateDetectionView:(BOOL)isDefence {
    self.detectionTypeView.hidden = !isDefence;
    self.sureButton.hidden = !isDefence;
}
@@ -150,7 +191,10 @@
- (void)sureAction {
    if (self.selectedCode && self.selectedCode.length > 0) {
        __weak __typeof(self)weakSelf = self;
        __weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
        hud.labelText = NSLocalizedString(@"setting_switching", @"正在切换,请稍候...");
        [[EZHttpUtil sharedManager] setAiSupportDetection:self.deviceInfo.deviceSerial code:self.selectedCode completion:^(ResponseData * _Nonnull responseData) {
            [hud hide:YES];
            if (responseData.success) {
                [weakSelf.view makeToast:HDLEZLocallizedString(@"setting_opration_success")
                                duration:1.5
@@ -166,6 +210,14 @@
}
#pragma mark - Getter
- (HDLESDetectionTypeHeaderView *)detectionTypeHeaderView {
    if (!_detectionTypeHeaderView) {
        _detectionTypeHeaderView = [[HDLESDetectionTypeHeaderView alloc] init];
        _detectionTypeHeaderView.backgroundColor = [UIColor whiteColor];
    }
    return _detectionTypeHeaderView;
}
- (HDLEZDetectionTypeView *)detectionTypeView {
    if (!_detectionTypeView) {
        _detectionTypeView = [[HDLEZDetectionTypeView alloc] init];