From 3e4be5ed4d2c0395dd60e392baf86c59762059b1 Mon Sep 17 00:00:00 2001 From: Davin <591807572@qq.com> Date: 星期五, 30 六月 2023 10:14:50 +0800 Subject: [PATCH] feature 猫眼全屏布局调整 && UI细节适配 --- EZSDK/EZSDK/EZ/UIViewControllers/EZSettingViewController.m | 277 +++++++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 219 insertions(+), 58 deletions(-) diff --git a/EZSDK/EZSDK/EZ/UIViewControllers/EZSettingViewController.m b/EZSDK/EZSDK/EZ/UIViewControllers/EZSettingViewController.m index 8511c5e..9ae55a2 100644 --- a/EZSDK/EZSDK/EZ/UIViewControllers/EZSettingViewController.m +++ b/EZSDK/EZSDK/EZ/UIViewControllers/EZSettingViewController.m @@ -13,9 +13,9 @@ #import "EZDeviceTableViewController.h" #import "EZEditViewController.h" -#import "EZDeviceVersion.h" +#import <EZOpenSDKFramework/EZDeviceVersion.h> #import "EZDeviceUpgradeViewController.h" -#import "EZStorageInfo.h" +#import <EZOpenSDKFramework/EZStorageInfo.h> #import "Toast+UIView.h" //#import "EzvizDeviceManager.h" @@ -26,11 +26,14 @@ @property (nonatomic, weak) IBOutlet UISwitch *videoSwitch; @property (nonatomic, weak) IBOutlet UISwitch *actionSwitch; @property (weak, nonatomic) IBOutlet UISwitch *hdSwitch; +@property (weak, nonatomic) IBOutlet UISwitch *privacyMaskSwitch; +@property (weak, nonatomic) IBOutlet UIImageView *rightArrowImg; @property (nonatomic, weak) IBOutlet UILabel *nameLabel; @property (nonatomic, weak) IBOutlet UILabel *serialLabel; @property (nonatomic, weak) IBOutlet UILabel *currentVersionLabel; @property (nonatomic, weak) IBOutlet UILabel *nVersionLabel; @property (nonatomic, weak) IBOutlet UIImageView *updateImageView; +@property (nonatomic, strong) UIButton *deleteButton; @property (nonatomic, strong) EZDeviceVersion *deviceVersion; @property (nonatomic, strong) NSTimer *timer; @@ -78,26 +81,29 @@ self.videoSwitch.on = self.deviceInfo.isEncrypt; } [_settingList addObject:@[NSLocalizedString(@"setting_hardware_decoding", @"纭В鐮�")]]; + [_settingList addObject:@[NSLocalizedString(@"setting_privacy_masking", @"闅愮閬斀")]]; + [_settingList addObject:@[NSLocalizedString(@"setting_sd_card_formatting", @"SD鍗℃牸寮忓寲")]]; [_settingList addObject:@[NSLocalizedString(@"delete", @"鍒犻櫎")]]; self.serialLabel.text = self.deviceInfo.deviceSerial; self.updateImageView.hidden = YES; + __weak __typeof(self)weakSelf = self; [EZOPENSDK getDeviceVersion:self.deviceInfo.deviceSerial completion:^(EZDeviceVersion *version, NSError *error) { - _deviceVersion = version; - self.currentVersionLabel.text = version.currentVersion; - if(version.isNeedUpgrade) - { - self.nVersionLabel.text = version.latestVersion; - self.updateImageView.hidden = NO; - } - else - { - self.updateImageView.hidden = YES; - self.nVersionLabel.text = version.currentVersion; - } - }]; + weakSelf.deviceVersion = version; + weakSelf.currentVersionLabel.text = version.currentVersion; + if(version.isNeedUpgrade) { + weakSelf.nVersionLabel.text = version.latestVersion; + weakSelf.updateImageView.hidden = NO; + } else { + weakSelf.updateImageView.hidden = YES; + weakSelf.nVersionLabel.text = version.currentVersion; + } + }]; + [self.privacyMaskSwitch setOn:NO]; + [self getPrivacyMaskSwitchStatus]; + self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; // [[EzvizDeviceManager sharedManager] startP2PHolePunching:_cameraInfo.cameraId completion:^(BOOL result, NSError *error) { // NSLog(@"result = %d, error = %@", result, error); // }]; @@ -160,6 +166,15 @@ // Dispose of any resources that can be recreated. } +- (void)getPrivacyMaskSwitchStatus { // 鑾峰彇闀滃ご閬斀寮�鍏崇姸鎬� + __weak __typeof(self)weakSelf = self; + [EZHttpUtil.sharedManager getCoverSwitchStatus:self.deviceInfo.deviceSerial completion:^(ResponseData * _Nonnull responseData) { + if(responseData.success) { + NSLog(@"#############鎵撳嵃鏁版嵁锛�%@", responseData); + } + }]; +} + #pragma mark - Table view data source - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { @@ -174,16 +189,22 @@ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"EZSettingCell" forIndexPath:indexPath]; // Configure the cell... + cell.backgroundColor = [UIColor whiteColor]; + cell.contentView.backgroundColor = [UIColor whiteColor]; cell.textLabel.text = [[_settingList dd_objectAtIndex:indexPath.section] dd_objectAtIndex:indexPath.row]; - + cell.textLabel.textColor = HDLEZHEXCOLOR(0x1B2D4D, 1.0); + cell.textLabel.textAlignment = NSTextAlignmentLeft; cell.accessoryType = UITableViewCellAccessoryNone; if (indexPath.section == 0) { [cell.contentView addSubview:self.nameLabel]; - cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; +// cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; + UIImageView *accessoryImgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"hdl_ez_list_next"]]; + accessoryImgView.frame = CGRectMake(0, 0, 16, 16); + cell.accessoryView = accessoryImgView; [self.nameLabel mas_remakeConstraints:^(MASConstraintMaker *make) { make.leading.mas_equalTo(@140); - make.trailing.mas_equalTo(cell.contentView.mas_trailing); + make.trailing.mas_equalTo(cell.contentView.mas_trailing).offset(-10); make.centerY.mas_equalTo(cell.contentView.mas_centerY); make.height.mas_equalTo(@20); }]; @@ -214,8 +235,38 @@ } else if (indexPath.section == 6) { - cell.textLabel.textColor = [UIColor redColor]; - cell.textLabel.textAlignment = NSTextAlignmentCenter; + [cell.contentView addSubview:self.privacyMaskSwitch]; + [self.privacyMaskSwitch mas_remakeConstraints:^(MASConstraintMaker *make) { + make.trailing.mas_equalTo(@(-17)); + make.centerY.mas_equalTo(cell.contentView.mas_centerY); + make.width.mas_equalTo(@51); + make.height.mas_equalTo(@31); + }]; + self.privacyMaskSwitch.on = !self.privacyMaskSwitch.on; + } + else if (indexPath.section == 7) + { + [cell.contentView addSubview:self.rightArrowImg]; + [self.rightArrowImg mas_remakeConstraints:^(MASConstraintMaker *make) { + make.trailing.mas_equalTo(@(-17)); + make.centerY.mas_equalTo(cell.contentView.mas_centerY); + make.width.mas_equalTo(@16); + make.height.mas_equalTo(@16); + }]; + } + else if (indexPath.section == 8) + { + cell.backgroundColor = [UIColor clearColor]; + cell.contentView.backgroundColor = [UIColor clearColor]; + cell.textLabel.text = @""; + [cell.contentView addSubview:self.deleteButton]; + [self.deleteButton addTarget:self action:@selector(deleteAction) forControlEvents:UIControlEventTouchUpInside]; + [self.deleteButton mas_remakeConstraints:^(MASConstraintMaker *make) { + make.centerX.mas_equalTo(cell.contentView.mas_centerX); + make.left.mas_equalTo(cell.contentView.mas_left).offset(77.); + make.bottom.mas_equalTo(cell.contentView.mas_bottom); + make.height.mas_equalTo(@44); + }]; } else if (indexPath.section == 3) { @@ -269,18 +320,50 @@ return cell; } -- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section -{ - return 5.0f; +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + return (indexPath.section == 8) ? 92 : 50.; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { + return 0.0001f; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { + return (section == 0 || section == 2 || section == 6) ? 8.0f : 0.001f; +} + +- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { + return nil; +} + +- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { + return nil; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; - if (indexPath.section == 6) + if (indexPath.section == 8) { - UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:NSLocalizedString(@"cancel", @"鍙栨秷") destructiveButtonTitle:NSLocalizedString(@"delete",@"鍒犻櫎") otherButtonTitles:nil]; - [actionSheet showInView:self.view]; +// UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:NSLocalizedString(@"cancel", @"鍙栨秷") destructiveButtonTitle:NSLocalizedString(@"delete",@"鍒犻櫎") otherButtonTitles:nil]; +// [actionSheet showInView:self.view]; + +// __weak __typeof(self)weakSelf = self; +// UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; +// +// [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"cancel", @"鍙栨秷") style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { +// [weakSelf dismissViewControllerAnimated:YES completion:^{ +// }]; +// }]]; +// +// [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"delete",@"鍒犻櫎") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { +// [weakSelf deleteCurrentDevice]; +// [weakSelf dismissViewControllerAnimated:YES completion:^{ +// }]; +// }]]; +// +// [self presentViewController:actionSheet animated:YES completion:nil]; + } // else if (indexPath.section == 5) // { @@ -294,9 +377,23 @@ { [self performSegueWithIdentifier:@"go2Upgrade" sender:nil]; } - else if (indexPath.section == 1) + else if (indexPath.section == 7) { - + UIAlertController *alert=[UIAlertController alertControllerWithTitle:HDLEZLocallizedString(@"alert_title") message:HDLEZLocallizedString(@"setting_formatting_alert_message") preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction *cancle=[UIAlertAction actionWithTitle:HDLEZLocallizedString(@"device_temp_cancle") style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) { + }]; + __weak __typeof(self)weakSelf = self; + UIAlertAction *sure=[UIAlertAction actionWithTitle:HDLEZLocallizedString(@"device_temp_sure") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { + [EZOPENSDK formatStorage:self.deviceInfo.deviceSerial + storageIndex:0 + completion:^(NSError *error) { + NSLog(@"format command error = %@", error); + [UIView dd_showMessage:error.description]; + }]; + }]; + [alert addAction:cancle]; + [alert addAction:sure]; + [self presentViewController:alert animated:YES completion:nil]; } } @@ -353,17 +450,57 @@ } #pragma mark - UIActionSheetDelegate Methods +- (void)deleteCurrentDevice { + __weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; + hud.labelText = NSLocalizedString(@"message_deleting", @"姝e湪鍒犻櫎锛岃绋嶅��..."); -- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex -{ - if(buttonIndex == 0) - { - __weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; - hud.labelText = NSLocalizedString(@"message_deleting", @"姝e湪鍒犻櫎锛岃绋嶅��..."); -// [EZOPENSDK deleteDevice:self.deviceInfo.deviceSerial completion:^(NSError *error) { -// if(!error) + [EZHttpUtil.sharedManager deleteDeviceByHDL:self.deviceInfo.deviceSerial completion:^(ResponseData *responseData) { + [hud hide:YES]; + if(responseData.success) { + NSArray *viewControllers = self.navigationController.viewControllers; + for (UIViewController *vc in viewControllers) + { + if([vc isKindOfClass:[EZDeviceTableViewController class]]) + { + ((EZDeviceTableViewController *)vc).needRefresh = YES; + [self.navigationController popToViewController:vc animated:YES]; + break; + } + } + } else { + NSString *mes = [NSString stringWithFormat:@"%@(%@)",NSLocalizedString(@"setting_opration_fail", @"鎿嶄綔澶辫触"),responseData.code]; + [self.view makeToast:mes duration:2.0 position:@"center"]; + } + }]; +} + +//- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex +//{ +// if(buttonIndex == 0) +// { +// __weak MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES]; +// hud.labelText = NSLocalizedString(@"message_deleting", @"姝e湪鍒犻櫎锛岃绋嶅��..."); +//// [EZOPENSDK deleteDevice:self.deviceInfo.deviceSerial completion:^(NSError *error) { +//// if(!error) +//// { +//// [hud hide:YES]; +//// NSArray *viewControllers = self.navigationController.viewControllers; +//// for (UIViewController *vc in viewControllers) +//// { +//// if([vc isKindOfClass:[EZDeviceTableViewController class]]) +//// { +//// ((EZDeviceTableViewController *)vc).needRefresh = YES; +//// [self.navigationController popToViewController:vc animated:YES]; +//// break; +//// } +//// } +//// } +//// }]; +// +// [EZHttpUtil.sharedManager deleteDeviceByHDL:self.deviceInfo.deviceSerial completion:^(ResponseData *responseData) { +// [hud hide:YES]; +// if(responseData.success) // { -// [hud hide:YES]; // NSArray *viewControllers = self.navigationController.viewControllers; // for (UIViewController *vc in viewControllers) // { @@ -374,29 +511,16 @@ // break; // } // } +// }else{ +// NSString *mes = [NSString stringWithFormat:@"%@(%@)",NSLocalizedString(@"setting_opration_fail", @"鎿嶄綔澶辫触"),responseData.code]; +// +// [self.view makeToast:mes duration:2.0 position:@"center"]; // } // }]; - - [EZHttpUtil deleteDeviceByHDL:self.deviceInfo.deviceSerial completion:^(ResponseData *responseData) { - if(responseData.success) - { - [hud hide:YES]; - NSArray *viewControllers = self.navigationController.viewControllers; - for (UIViewController *vc in viewControllers) - { - if([vc isKindOfClass:[EZDeviceTableViewController class]]) - { - ((EZDeviceTableViewController *)vc).needRefresh = YES; - [self.navigationController popToViewController:vc animated:YES]; - break; - } - } - } - }]; - - - } -} +// +// +// } +//} #pragma mark - UIAlertViewDelegate Methods @@ -461,6 +585,11 @@ [[NSUserDefaults standardUserDefaults] synchronize]; } +- (IBAction)privacyMasking:(id)sender { + UISwitch *pmSwitch = (UISwitch*)sender; + BOOL status = pmSwitch.isOn; +} + - (IBAction)encryptChanged:(id)sender { if(!self.videoSwitch.on) @@ -492,4 +621,36 @@ } } +- (void)deleteAction { + __weak __typeof(self)weakSelf = self; + UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; + + [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"cancel", @"鍙栨秷") style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { + [weakSelf dismissViewControllerAnimated:YES completion:^{ + }]; + }]]; + + [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"delete",@"鍒犻櫎") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { + [weakSelf deleteCurrentDevice]; + [weakSelf dismissViewControllerAnimated:YES completion:^{ + }]; + }]]; + + [self presentViewController:actionSheet animated:YES completion:nil]; +} + +#pragma mark - Getter +- (UIButton *)deleteButton { + if (!_deleteButton) { + _deleteButton = [UIButton buttonWithType:UIButtonTypeCustom]; + _deleteButton.backgroundColor = [UIColor whiteColor]; + [_deleteButton setTitle:NSLocalizedString(@"delete", @"鍒犻櫎") forState:UIControlStateNormal]; + [_deleteButton setTitleColor:HDLEZHEXCOLOR(0xFF4747, 1.0) forState:UIControlStateNormal]; + _deleteButton.titleLabel.font = HDLEZ_Get_FontRegularWithSize(HDLEZ_FontSize_16); + _deleteButton.layer.cornerRadius = 22.; + _deleteButton.clipsToBounds = YES; + } + return _deleteButton; +} + @end -- Gitblit v1.8.0