privacyModeViewController.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. //
  2. // privacyModeViewController.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/11/28.
  6. //
  7. #import "privacyModeViewController.h"
  8. #import "connectDeviceManager.h"
  9. #import "MineViewCell.h"
  10. #import "ModifyPWDFirstViewController.h"
  11. #import "ChangeLogoViewController.h"
  12. #import "inputPWDViewController.h"
  13. @interface privacyModeViewController ()<UITableViewDelegate,UITableViewDataSource>
  14. @property(nonatomic,strong)UIView* headView;//
  15. @property(nonatomic, strong) UISwitch *privacySwitch;
  16. @property (nonatomic, strong, nullable) UITableView *tableView;
  17. @end
  18. @implementation privacyModeViewController
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. // Do any additional setup after loading the view.
  22. [self.view setBackgroundColor:HWF5F7FAColor];
  23. [self.toolBar setHidden:YES];
  24. [self.navigationBar setHidden:YES];
  25. [self.navBarBGView setHidden:NO];
  26. [self.titleLabel setText:NSLocalizedString(@"my_set_Privacy_Model",nil)];
  27. [self drawAnyView];
  28. }
  29. - (void)drawAnyView{
  30. [self initHeadUIFun];
  31. [self.view addSubview:self.tableView];
  32. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.left.mas_equalTo(0);
  34. make.right.mas_equalTo(0);
  35. make.bottom.mas_equalTo(0);
  36. make.top.equalTo(_headView.mas_bottom).offset(20.f);
  37. }];
  38. }
  39. - (void)initHeadUIFun
  40. {
  41. _headView = [[UIView alloc] init];
  42. _headView.backgroundColor = [UIColor whiteColor];
  43. _headView.layer.cornerRadius = 8;
  44. [self.view addSubview:_headView];
  45. [_headView mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.left.mas_equalTo(15);
  47. make.right.mas_equalTo(-15);
  48. make.height.mas_equalTo(108);
  49. make.top.equalTo(self.navBarBGView.mas_bottom).offset(16.f);
  50. }];
  51. UIImageView *topImageV = [[UIImageView alloc] init];
  52. topImageV.image = [UIImage imageNamed:@"icon_Privacy_model"];
  53. [_headView addSubview:topImageV];
  54. [topImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.left.mas_equalTo(15);
  56. make.top.mas_equalTo(15);
  57. make.width.mas_equalTo(28);
  58. make.height.mas_equalTo(28);
  59. }];
  60. UILabel *topLab = [[UILabel alloc] init];
  61. topLab.text = NSLocalizedString(@"my_set_Privacy_Model",nil);
  62. topLab.font = [UIFont boldSystemFontOfSize:14.0];
  63. topLab.textColor = [UIColor hwColor:@"#0A132B" alpha:1.0];
  64. [_headView addSubview:topLab];
  65. [topLab mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.left.mas_equalTo(topImageV.mas_right).offset(5);
  67. make.top.mas_equalTo(topImageV.mas_top).offset(0);
  68. make.width.mas_equalTo(100);
  69. make.height.mas_equalTo(28);
  70. }];
  71. _privacySwitch = [[UISwitch alloc] init];
  72. [_headView addSubview:_privacySwitch];
  73. [_privacySwitch mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.right.mas_equalTo(-15.f);
  75. make.centerY.equalTo(topImageV.mas_centerY);
  76. }];
  77. [_privacySwitch setOnTintColor:HW13B2EBColor];
  78. [_privacySwitch addTarget:self action:@selector(maskSwitchPressed:) forControlEvents:(UIControlEventValueChanged)];
  79. [self setPrivacySwitchStateFun];
  80. UILabel *tipLab = [[UILabel alloc] init];
  81. tipLab.text = NSLocalizedString(@"my_set_Privacy_Model_tip",nil);
  82. tipLab.font = [UIFont systemFontOfSize:12.0];
  83. tipLab.textColor = [UIColor hwColor:@"#6A6A6A" alpha:1.0];
  84. tipLab.numberOfLines = 0;
  85. [_headView addSubview:tipLab];
  86. [tipLab mas_makeConstraints:^(MASConstraintMaker *make) {
  87. make.top.mas_equalTo(topImageV.mas_bottom).offset(10);
  88. make.left.mas_equalTo(topImageV.mas_left).offset(0);
  89. make.right.mas_equalTo(_privacySwitch.mas_right).offset(0);
  90. }];
  91. }
  92. #pragma mark - 懒加载
  93. - (UITableView *)tableView{
  94. if (!_tableView) {
  95. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_H - TABBARHEIGHT) style:UITableViewStylePlain];
  96. _tableView.delegate = self;
  97. _tableView.dataSource = self;
  98. _tableView.showsVerticalScrollIndicator = NO;
  99. _tableView.showsHorizontalScrollIndicator = NO;
  100. // _tableView.contentInset = UIEdgeInsetsMake(-H_STATE_BAR, 0, 0, 0);
  101. [_tableView setSeparatorStyle:(UITableViewCellSeparatorStyleNone)];
  102. [_tableView setSeparatorColor:[UIColor clearColor]];
  103. [_tableView setBackgroundColor:[UIColor clearColor]];
  104. [_tableView setTableFooterView:[UIView new]];
  105. [_tableView setBounces:YES];
  106. if (@available(iOS 15.0, *)) {
  107. _tableView.sectionHeaderTopPadding = 0;
  108. }
  109. }
  110. return _tableView;
  111. }
  112. #pragma mark - 列表委托
  113. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  114. return 1;
  115. }
  116. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  117. return 3;
  118. }
  119. - (MineViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  120. NSInteger row = indexPath.row;
  121. static NSString *identifier = @"MineViewCell";
  122. MineViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  123. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  124. if (!cell){
  125. cell = [[MineViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  126. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  127. [cell setBackgroundColor:[UIColor clearColor]];
  128. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  129. }
  130. [cell.bgViewLayer removeFromSuperlayer];
  131. [cell.titleLabel2 setHidden:YES];
  132. [cell.rightImage setHidden:NO];
  133. [cell.lineView setHidden:NO];
  134. [cell.maskSwitch setHidden:YES];
  135. if (row == 0){
  136. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_modify_pwd",nil)];
  137. [cell.mImageView setImage:[UIImage imageNamed:@"mdoify_pwd"]];
  138. /*上圆角*/
  139. //设置部分圆角 贝塞尔曲线
  140. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  141. byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
  142. cornerRadii:CGSizeMake(8, 8)];
  143. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  144. maskLayer.frame = cell.cellBgView.bounds;
  145. maskLayer.path = maskPath.CGPath;
  146. cell.bgViewLayer = maskLayer;
  147. cell.cellBgView.layer.mask = cell.bgViewLayer;
  148. }else if (row == 1){
  149. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_change_login",nil)];
  150. [cell.mImageView setImage:[UIImage imageNamed:@"icon_change_logo"]];
  151. // }else if (row == 2){
  152. // [cell.titleLabel setText:NSLocalizedString(@"mask_view_hiden_set_hiden",nil)];
  153. // [cell.mImageView setImage:[UIImage imageNamed:@"icon-jincheng"]];
  154. // }else if (row == 3){
  155. }else if (row == 2){
  156. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_fanzhuan_exit",nil)];
  157. [cell.mImageView setImage:[UIImage imageNamed:@"fanzhuan"]];
  158. [cell.rightImage setHidden:YES];
  159. [cell.maskSwitch setHidden:NO];
  160. /*下圆角*/
  161. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  162. byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
  163. cornerRadii:CGSizeMake(8, 8)];
  164. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  165. maskLayer.frame = cell.cellBgView.bounds;
  166. maskLayer.path = maskPath.CGPath;
  167. cell.bgViewLayer = maskLayer;
  168. cell.cellBgView.layer.mask = cell.bgViewLayer;
  169. [cell.lineView setHidden:YES];
  170. }
  171. return cell;
  172. }
  173. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  174. return 60;
  175. }
  176. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  177. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  178. NSInteger row = indexPath.row;
  179. if (0 == row){
  180. /*修改密码*/
  181. ModifyPWDFirstViewController *nextVC = [[ModifyPWDFirstViewController alloc] init];
  182. [self.navigationController pushViewController:nextVC animated:YES];
  183. }else if (1 == row){
  184. /*更换图标*/
  185. ChangeLogoViewController *nextVC = [[ChangeLogoViewController alloc] init];
  186. [self.navigationController pushViewController:nextVC animated:YES];
  187. }
  188. // else if (1 == row){/*进城隐藏*/
  189. // HidenMaskSetViewController *nextVC = [[HidenMaskSetViewController alloc] init];
  190. // [self.navigationController pushViewController:nextVC animated:YES];
  191. // }
  192. else if (2 == row){/*设备翻转*/
  193. ;
  194. }
  195. }
  196. - (void)maskSwitchPressed:(UISwitch *)privacySwitch{
  197. [self setPrivacySwitchStateFun];
  198. inputPWDViewController *nextVC = [inputPWDViewController new];
  199. nextVC.isCheckPwdType = YES;
  200. [self.navigationController pushViewController:nextVC animated:YES];
  201. KWeakSelf
  202. nextVC.didInputRightPwdFun = ^{
  203. [weakSelf updatePrivacyModeFun];
  204. };
  205. }
  206. #pragma mark 设置tabview 是否隐藏
  207. - (void)setPrivacySwitchStateFun{
  208. BOOL haveOpenMask = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode;
  209. [_privacySwitch setOn:haveOpenMask];
  210. if(haveOpenMask){
  211. self.tableView.hidden = NO;
  212. }
  213. else{
  214. self.tableView.hidden = YES;
  215. [self HandleEnterNotPrivacyModeFun];
  216. }
  217. }
  218. #pragma mark 处理进来是非隐私模式的情况
  219. - (void)HandleEnterNotPrivacyModeFun
  220. {
  221. NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  222. if (maskModel != 0){
  223. [HWDataManager setIntegerWithKey:Const_Mask_View_Model value:0];
  224. [iTools lc_setAlternateIconName:@"AppIcon1"];
  225. }
  226. }
  227. #pragma mark 联网设置隐私模式
  228. - (void)updatePrivacyModeFun{
  229. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  230. BOOL haveOpenMask = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode;
  231. NSString* curSn = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn;
  232. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  233. [paraDict setValue:curSn forKey:@"sn"];
  234. [paraDict setValue:[NSNumber numberWithBool:!haveOpenMask] forKey:@"isPrivacyMode"];
  235. KWeakSelf
  236. [[netWorkManager shareInstance] CommonPostCallBackCode:updatePrivacyMode Parameters:paraDict success:^(id _Nonnull responseObject) {
  237. HLog(@"%@", responseObject);
  238. [self removeNewIndicator];
  239. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  240. if (model.status == 0) {
  241. [connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode = ![connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode;
  242. [weakSelf setPrivacySwitchStateFun];
  243. }
  244. else
  245. {
  246. [[iToast makeText:model.msg] show];
  247. }
  248. } failure:^(NSError * _Nonnull error) {
  249. HLog(@"%@", error);
  250. [[iToast makeText:@"网络异常,请稍后重试!"] show];
  251. [self removeNewIndicator];
  252. }];
  253. }
  254. @end