privacyModeViewController.m 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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. #ifdef developJSQ
  118. return 2;
  119. #else
  120. return 3;
  121. #endif
  122. }
  123. - (MineViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  124. NSInteger row = indexPath.row;
  125. static NSString *identifier = @"MineViewCell";
  126. MineViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
  127. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  128. if (!cell){
  129. cell = [[MineViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identifier];
  130. [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
  131. [cell setBackgroundColor:[UIColor clearColor]];
  132. [cell setAccessoryType:(UITableViewCellAccessoryNone)];
  133. }
  134. [cell.bgViewLayer removeFromSuperlayer];
  135. [cell.titleLabel2 setHidden:YES];
  136. [cell.rightImage setHidden:NO];
  137. [cell.lineView setHidden:NO];
  138. [cell.maskSwitch setHidden:YES];
  139. if (row == 0){
  140. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_modify_pwd",nil)];
  141. [cell.mImageView setImage:[UIImage imageNamed:@"mdoify_pwd"]];
  142. /*上圆角*/
  143. //设置部分圆角 贝塞尔曲线
  144. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  145. byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
  146. cornerRadii:CGSizeMake(8, 8)];
  147. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  148. maskLayer.frame = cell.cellBgView.bounds;
  149. maskLayer.path = maskPath.CGPath;
  150. cell.bgViewLayer = maskLayer;
  151. cell.cellBgView.layer.mask = cell.bgViewLayer;
  152. }
  153. #ifdef developJSQ
  154. else if (row == 1){
  155. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_fanzhuan_exit",nil)];
  156. [cell.mImageView setImage:[UIImage imageNamed:@"fanzhuan"]];
  157. [cell.rightImage setHidden:YES];
  158. [cell.maskSwitch setHidden:NO];
  159. BOOL haveOpenMask = [HWDataManager getBoolWithKey:Consn_Fanzhuan_Exit_app_Open];
  160. [cell.maskSwitch setOn:haveOpenMask];
  161. /*下圆角*/
  162. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  163. byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
  164. cornerRadii:CGSizeMake(8, 8)];
  165. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  166. maskLayer.frame = cell.cellBgView.bounds;
  167. maskLayer.path = maskPath.CGPath;
  168. cell.bgViewLayer = maskLayer;
  169. cell.cellBgView.layer.mask = cell.bgViewLayer;
  170. [cell.lineView setHidden:YES];
  171. }
  172. #else
  173. else if (row == 1){
  174. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_change_login",nil)];
  175. [cell.mImageView setImage:[UIImage imageNamed:@"icon_change_logo"]];
  176. // }else if (row == 2){
  177. // [cell.titleLabel setText:NSLocalizedString(@"mask_view_hiden_set_hiden",nil)];
  178. // [cell.mImageView setImage:[UIImage imageNamed:@"icon-jincheng"]];
  179. // }else if (row == 3){
  180. }else if (row == 2){
  181. [cell.titleLabel setText:NSLocalizedString(@"my_set_no_fanzhuan_exit",nil)];
  182. [cell.mImageView setImage:[UIImage imageNamed:@"fanzhuan"]];
  183. [cell.rightImage setHidden:YES];
  184. [cell.maskSwitch setHidden:NO];
  185. BOOL haveOpenMask = [HWDataManager getBoolWithKey:Consn_Fanzhuan_Exit_app_Open];
  186. [cell.maskSwitch setOn:haveOpenMask];
  187. /*下圆角*/
  188. UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, SCREEN_W-30 , 60)
  189. byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight
  190. cornerRadii:CGSizeMake(8, 8)];
  191. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
  192. maskLayer.frame = cell.cellBgView.bounds;
  193. maskLayer.path = maskPath.CGPath;
  194. cell.bgViewLayer = maskLayer;
  195. cell.cellBgView.layer.mask = cell.bgViewLayer;
  196. [cell.lineView setHidden:YES];
  197. }
  198. #endif
  199. return cell;
  200. }
  201. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  202. return 60;
  203. }
  204. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  205. [tableView deselectRowAtIndexPath:indexPath animated:YES];
  206. NSInteger row = indexPath.row;
  207. if (0 == row){
  208. /*修改密码*/
  209. ModifyPWDFirstViewController *nextVC = [[ModifyPWDFirstViewController alloc] init];
  210. [self.navigationController pushViewController:nextVC animated:YES];
  211. }
  212. #ifdef developJSQ
  213. //
  214. #else
  215. else if (1 == row){
  216. /*更换图标*/
  217. ChangeLogoViewController *nextVC = [[ChangeLogoViewController alloc] init];
  218. [self.navigationController pushViewController:nextVC animated:YES];
  219. }
  220. // else if (1 == row){/*进城隐藏*/
  221. // HidenMaskSetViewController *nextVC = [[HidenMaskSetViewController alloc] init];
  222. // [self.navigationController pushViewController:nextVC animated:YES];
  223. // }
  224. else if (2 == row){/*设备翻转*/
  225. ;
  226. }
  227. #endif
  228. }
  229. - (void)maskSwitchPressed:(UISwitch *)privacySwitch{
  230. [self setPrivacySwitchStateFun];
  231. // inputPWDViewController *nextVC = [inputPWDViewController new];
  232. // nextVC.isCheckPwdType = YES;
  233. // [self.navigationController pushViewController:nextVC animated:YES];
  234. //
  235. // KWeakSelf
  236. // nextVC.didInputRightPwdFun = ^{
  237. // [weakSelf updatePrivacyModeFun];
  238. // };
  239. [self updatePrivacyModeFun];
  240. }
  241. #pragma mark 设置tabview 是否隐藏
  242. - (void)setPrivacySwitchStateFun{
  243. BOOL haveOpenMask = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode;
  244. [_privacySwitch setOn:haveOpenMask];
  245. if(haveOpenMask){
  246. self.tableView.hidden = NO;
  247. }
  248. else{
  249. self.tableView.hidden = YES;
  250. [self HandleEnterNotPrivacyModeFun];
  251. }
  252. [self.tableView reloadData];
  253. }
  254. #pragma mark 处理进来是非隐私模式的情况
  255. - (void)HandleEnterNotPrivacyModeFun
  256. {
  257. NSInteger maskModel = [HWDataManager getIntegerWithKey:Const_Mask_View_Model];
  258. if (maskModel != 0){
  259. [HWDataManager setIntegerWithKey:Const_Mask_View_Model value:0];
  260. [iTools lc_setAlternateIconName:@"AppIcon1"];
  261. }
  262. [HWDataManager setBoolWithKey:Consn_Fanzhuan_Exit_app_Open value:NO];
  263. }
  264. #pragma mark 联网设置隐私模式
  265. - (void)updatePrivacyModeFun{
  266. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  267. BOOL haveOpenMask = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode;
  268. NSString* curSn = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.changeSn;
  269. if(!curSn || curSn.length == 0){
  270. curSn = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn;
  271. }
  272. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  273. [paraDict setValue:curSn forKey:@"sn"];
  274. [paraDict setValue:[NSNumber numberWithBool:!haveOpenMask] forKey:@"isPrivacyMode"];
  275. KWeakSelf
  276. [[netWorkManager shareInstance] CommonPostCallBackCode:updatePrivacyMode Parameters:paraDict success:^(id _Nonnull responseObject) {
  277. HLog(@"%@", responseObject);
  278. [self removeNewIndicator];
  279. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  280. if (model.status == 0) {
  281. [connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode = ![connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode;
  282. [weakSelf setPrivacySwitchStateFun];
  283. if(!haveOpenMask)
  284. {
  285. [HWDataManager setBoolWithKey:Consn_Fanzhuan_Exit_app_Open value:NO];
  286. }
  287. }
  288. else
  289. {
  290. [[iToast makeText:model.msg] show];
  291. }
  292. } failure:^(NSError * _Nonnull error) {
  293. HLog(@"%@", error);
  294. [[iToast makeText:NSLocalizedString(@"player_link_fail_tip",nil)] show];
  295. [self removeNewIndicator];
  296. }];
  297. }
  298. @end