privacyModeViewController.m 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  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(200);
  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. BOOL haveOpenMask = [HWDataManager getBoolWithKey:Consn_Fanzhuan_Exit_app_Open];
  161. [cell.maskSwitch setOn:haveOpenMask];
  162. /*下圆角*/
  163. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  164. byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
  165. cornerRadii:CGSizeMake(8, 8)];
  166. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  167. maskLayer.frame = cell.cellBgView.bounds;
  168. maskLayer.path = maskPath.CGPath;
  169. cell.bgViewLayer = maskLayer;
  170. cell.cellBgView.layer.mask = cell.bgViewLayer;
  171. [cell.lineView setHidden:YES];
  172. }
  173. return cell;
  174. }
  175. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  176. return 60;
  177. }
  178. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  179. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  180. NSInteger row = indexPath.row;
  181. if (0 == row){
  182. /*修改密码*/
  183. ModifyPWDFirstViewController *nextVC = [[ModifyPWDFirstViewController alloc] init];
  184. [self.navigationController pushViewController:nextVC animated:YES];
  185. }else if (1 == row){
  186. /*更换图标*/
  187. ChangeLogoViewController *nextVC = [[ChangeLogoViewController alloc] init];
  188. [self.navigationController pushViewController:nextVC animated:YES];
  189. }
  190. // else if (1 == row){/*进城隐藏*/
  191. // HidenMaskSetViewController *nextVC = [[HidenMaskSetViewController alloc] init];
  192. // [self.navigationController pushViewController:nextVC animated:YES];
  193. // }
  194. else if (2 == row){/*设备翻转*/
  195. ;
  196. }
  197. }
  198. - (void)maskSwitchPressed:(UISwitch *)privacySwitch{
  199. [self setPrivacySwitchStateFun];
  200. // inputPWDViewController *nextVC = [inputPWDViewController new];
  201. // nextVC.isCheckPwdType = YES;
  202. // [self.navigationController pushViewController:nextVC animated:YES];
  203. //
  204. // KWeakSelf
  205. // nextVC.didInputRightPwdFun = ^{
  206. // [weakSelf updatePrivacyModeFun];
  207. // };
  208. [self updatePrivacyModeFun];
  209. }
  210. #pragma mark 设置tabview 是否隐藏
  211. - (void)setPrivacySwitchStateFun{
  212. BOOL haveOpenMask = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode;
  213. [_privacySwitch setOn:haveOpenMask];
  214. if(haveOpenMask){
  215. self.tableView.hidden = NO;
  216. }
  217. else{
  218. self.tableView.hidden = YES;
  219. [self HandleEnterNotPrivacyModeFun];
  220. }
  221. [self.tableView reloadData];
  222. }
  223. #pragma mark 处理进来是非隐私模式的情况
  224. - (void)HandleEnterNotPrivacyModeFun
  225. {
  226. NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  227. if (maskModel != 0){
  228. [HWDataManager setIntegerWithKey:Const_Mask_View_Model value:0];
  229. [iTools lc_setAlternateIconName:@"AppIcon1"];
  230. }
  231. [HWDataManager setBoolWithKey:Consn_Fanzhuan_Exit_app_Open value:NO];
  232. }
  233. #pragma mark 联网设置隐私模式
  234. - (void)updatePrivacyModeFun{
  235. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  236. BOOL haveOpenMask = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode;
  237. NSString* curSn = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn;
  238. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  239. [paraDict setValue:curSn forKey:@"sn"];
  240. [paraDict setValue:[NSNumber numberWithBool:!haveOpenMask] forKey:@"isPrivacyMode"];
  241. KWeakSelf
  242. [[netWorkManager shareInstance] CommonPostCallBackCode:updatePrivacyMode Parameters:paraDict success:^(id _Nonnull responseObject) {
  243. HLog(@"%@", responseObject);
  244. [self removeNewIndicator];
  245. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  246. if (model.status == 0) {
  247. [connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode = ![connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode;
  248. [weakSelf setPrivacySwitchStateFun];
  249. if(!haveOpenMask)
  250. {
  251. [HWDataManager setBoolWithKey:Consn_Fanzhuan_Exit_app_Open value:NO];
  252. }
  253. }
  254. else
  255. {
  256. [[iToast makeText:model.msg] show];
  257. }
  258. } failure:^(NSError * _Nonnull error) {
  259. HLog(@"%@", error);
  260. [[iToast makeText:NSLocalizedString(@"player_link_fail_tip",nil)] show];
  261. [self removeNewIndicator];
  262. }];
  263. }
  264. @end