privacyModeViewController.m 13 KB

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