privacyModeTipViewController.m 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. //
  2. // privacyModeTipViewController.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2023/11/28.
  6. //
  7. #import "privacyModeTipViewController.h"
  8. #import "connectDeviceManager.h"
  9. @interface privacyModeTipViewController ()
  10. @end
  11. @implementation privacyModeTipViewController
  12. - (void)viewDidLoad {
  13. [super viewDidLoad];
  14. // Do any additional setup after loading the view.
  15. [self.view setBackgroundColor:[UIColor whiteColor]];
  16. [self.toolBar setHidden:YES];
  17. [self.navigationBar setHidden:YES];
  18. [self.navBarBGView setHidden:YES];
  19. [self initBaseUIFun];
  20. }
  21. - (void)initBaseUIFun
  22. {
  23. UIImageView *topImageV = [[UIImageView alloc] init];
  24. topImageV.image = [UIImage imageNamed:@"privacy_Tip_bg"];
  25. [self.view addSubview:topImageV];
  26. CGFloat height = 320 * AUTOSCALE;
  27. [topImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  28. make.left.mas_equalTo(0);
  29. make.top.mas_equalTo(0);
  30. make.right.mas_equalTo(0);
  31. make.height.mas_equalTo(height);
  32. }];
  33. UIImageView *midImageV = [[UIImageView alloc] init];
  34. midImageV.image = [UIImage imageNamed:@"privacy_Tip_set"];
  35. [self.view addSubview:midImageV];
  36. [midImageV mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.centerX.mas_equalTo(0);
  38. make.top.mas_equalTo(56 + safeArea);
  39. make.width.mas_equalTo(193);
  40. make.height.mas_equalTo(176);
  41. }];
  42. UILabel *topLab = [[UILabel alloc] init];
  43. topLab.text = NSLocalizedString(@"my_set_Privacy_Mode_set",nil);
  44. topLab.font = [UIFont systemFontOfSize:16.0];
  45. topLab.textAlignment = NSTextAlignmentCenter;
  46. [self.view addSubview:topLab];
  47. [topLab mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.left.mas_equalTo(0);
  49. make.right.mas_equalTo(0);
  50. make.top.mas_equalTo(topImageV.mas_bottom).offset(10);
  51. make.height.mas_equalTo(20);
  52. }];
  53. UILabel *tipLab1 = [[UILabel alloc] init];
  54. tipLab1.text = NSLocalizedString(@"my_set_Privacy_Mode_tip1",nil);
  55. tipLab1.textColor = [UIColor hwColor:@"#6A6A6A" alpha:1.0];
  56. tipLab1.font = [UIFont systemFontOfSize:14.0];
  57. tipLab1.textAlignment = NSTextAlignmentCenter;
  58. tipLab1.numberOfLines = 0;
  59. [self.view addSubview:tipLab1];
  60. [tipLab1 mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.left.mas_equalTo(30);
  62. make.right.mas_equalTo(-30);
  63. make.top.mas_equalTo(topLab.mas_bottom).offset(15);
  64. make.height.mas_equalTo(40);
  65. }];
  66. UILabel *tipLab2 = [[UILabel alloc] init];
  67. tipLab2.text = NSLocalizedString(@"my_set_Privacy_Mode_tip2",nil);
  68. tipLab2.textColor = [UIColor hwColor:@"#2974DE" alpha:1.0];
  69. tipLab2.font = [UIFont systemFontOfSize:14.0];
  70. tipLab2.textAlignment = NSTextAlignmentCenter;
  71. tipLab2.numberOfLines = 0;
  72. [self.view addSubview:tipLab2];
  73. [tipLab2 mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.left.mas_equalTo(30);
  75. make.right.mas_equalTo(-30);
  76. make.top.mas_equalTo(tipLab1.mas_bottom).offset(10);
  77. make.height.mas_equalTo(20);
  78. }];
  79. //跳过
  80. UIButton *skipBtn = [[UIButton alloc] init];
  81. skipBtn.tag = 1;
  82. [skipBtn addTarget:self action:@selector(didClickButFun:) forControlEvents:(UIControlEventTouchUpInside)];
  83. [skipBtn setTitle:NSLocalizedString(@"guide_skip",nil) forState:(UIControlStateNormal)];
  84. [skipBtn setTitleColor:[UIColor hwColor:@"#2974DE" alpha:1.0] forState:(UIControlStateNormal)];
  85. [skipBtn.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  86. // [skipBtn.layer setCornerRadius:14.f];
  87. // skipBtn.layer.borderColor = [UIColor whiteColor].CGColor;
  88. // skipBtn.layer.borderWidth = 1.0;
  89. // [skipBtn setBackgroundColor:HWE3E8F1Color];
  90. skipBtn.clipsToBounds = YES;
  91. [self.view addSubview:skipBtn];
  92. [skipBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  93. make.centerX.mas_equalTo(0);
  94. make.width.mas_equalTo(100.f);
  95. make.bottom.mas_equalTo(-40);
  96. make.height.mas_equalTo(40);
  97. }];
  98. /*开启隐私模式*/
  99. UIButton* okBtn = [[UIButton alloc] init];
  100. okBtn.tag = 2;
  101. CGFloat okBtn_W= SCREEN_W - 15*2;
  102. // gradient
  103. CAGradientLayer *gl = [CAGradientLayer layer];
  104. gl.frame = CGRectMake(0,0,okBtn_W,48);
  105. gl.startPoint = CGPointMake(0, 0.5);
  106. gl.endPoint = CGPointMake(1, 0.5);
  107. gl.colors = @[(__bridge id)HW0CDEFDColor.CGColor, (__bridge id)HW058DFBColor.CGColor];
  108. gl.locations = @[@(0), @(1.0f)];
  109. okBtn.layer.cornerRadius = 24;
  110. okBtn.clipsToBounds = YES;
  111. [okBtn.layer addSublayer:gl];
  112. [okBtn setTitle:NSLocalizedString(@"my_set_Privacy_Mode_open",nil) forState:(UIControlStateNormal)];
  113. [okBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
  114. [okBtn addTarget:self action:@selector(didClickButFun:) forControlEvents:UIControlEventTouchUpInside];
  115. [self.view addSubview:okBtn];
  116. [okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  117. //make.top.equalTo(pwdAgainTextField.mas_bottom).offset(16.f);
  118. make.bottom.equalTo(skipBtn.mas_top).offset(-10.f);
  119. make.left.mas_equalTo(15.f);
  120. make.width.mas_equalTo(okBtn_W);
  121. make.height.mas_equalTo(48);
  122. }];
  123. }
  124. -(void)didClickButFun:(UIButton*)but
  125. {
  126. NSInteger tag = but.tag;
  127. if(tag == 1){
  128. [self handleOkFun];
  129. }
  130. else{
  131. [self updatePrivacyModeFun];
  132. }
  133. }
  134. #pragma mark 联网设置隐私模式
  135. - (void)updatePrivacyModeFun{
  136. [self showNewIndicatorWithCanBack:YES canTouch:NO];
  137. BOOL haveOpenMask = YES;
  138. NSString* curSn = [connectDeviceManager shareInstance].DeviceThirdIdMod.data.sn;
  139. NSMutableDictionary *paraDict = [NSMutableDictionary dictionary];
  140. [paraDict setValue:curSn forKey:@"sn"];
  141. [paraDict setValue:[NSNumber numberWithBool:!haveOpenMask] forKey:@"isPrivacyMode"];
  142. KWeakSelf
  143. [[netWorkManager shareInstance] CommonPostCallBackCode:updatePrivacyMode Parameters:paraDict success:^(id _Nonnull responseObject) {
  144. HLog(@"%@", responseObject);
  145. [self removeNewIndicator];
  146. SuperModel *model = [[SuperModel alloc] initWithDictionary:responseObject error:nil];
  147. if (model.status == 0) {
  148. [connectDeviceManager shareInstance].DeviceThirdIdMod.data.isPrivacyMode = YES;
  149. [weakSelf handleOkFun];
  150. }
  151. else
  152. {
  153. //[[iToast makeText:model.msg] show];
  154. }
  155. } failure:^(NSError * _Nonnull error) {
  156. HLog(@"%@", error);
  157. [[iToast makeText:NSLocalizedString(@"player_link_fail_tip",nil)] show];
  158. [self removeNewIndicator];
  159. }];
  160. }
  161. -(void)handleOkFun
  162. {
  163. [[NSNotificationCenter defaultCenter] postNotificationName:GuideOkNotification object:nil];
  164. }
  165. @end