// // RejectStrangeCallViewController.m // tongxin // // Created by ecell on 2023/5/13. // Copyright © 2023 xTT. All rights reserved. // #import "RejectStrangeCallViewController.h" @interface RejectStrangeCallViewController () @property (nonatomic ,weak) UIButton *stateBtn; @property (nonatomic ,weak) UIImageView *bgImg; @end @implementation RejectStrangeCallViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. self.zx_navTitle = @"拒接陌生人来电"; self.view.backgroundColor = KKWhiteColorColor; CGFloat yy = iPhoneX_TabbarSafeBottomMargin > 0 ? iPhoneX_TabbarSafeBottomMargin + 10 : 30; UIButton *stateBtn = [UICommon ui_buttonSimple:CGRectZero font:Font_(16) normalColor:KKWhiteColorColor normalText:[cUser.cDevice.opRejectStrangeCall boolValue] ? @"关闭守护" : @"开启守护" click:^(id x) { [self SetSwitchData:[cUser.cDevice.opRejectStrangeCall boolValue] ? 0 : 1]; }]; stateBtn.backgroundColor = [cUser.cDevice.opRejectStrangeCall boolValue] ? RGB(240, 240, 240) : mainColor; [stateBtn setTitleColor:[cUser.cDevice.opRejectStrangeCall boolValue] ? RGB(204, 203, 200) : KKWhiteColorColor forState:0]; stateBtn.layer.cornerRadius = Adapted(22); stateBtn.layer.masksToBounds = YES; self.stateBtn = stateBtn; [self.view addSubview:stateBtn]; [stateBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.equalTo(self.view).inset(16); make.bottom.equalTo(self.view.mas_bottom).inset(yy); make.height.mas_equalTo(Adapted(44)); }]; UIImageView *bgImg = [UICommon ui_imageView:CGRectZero fileName:[cUser.cDevice.opRejectStrangeCall boolValue] ? @"strangeCall_bg_yes" : @"strangeCall_bg_no"]; self.bgImg = bgImg; [self.view addSubview:bgImg]; [bgImg mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.equalTo(self.view); make.top.equalTo(self.view).offset(iPhoneX_NavHeight); make.bottom.equalTo(stateBtn.mas_top).inset(8); }]; } - (void)SetSwitchData:(NSInteger)state { WEAKSELF CommonPopView *popView = [CommonPopView new]; [popView subPopView:popViewType_zx PopTitle:@"拒接陌生人来电" PopText:@"开启时,只有通讯录的联系人才能双向通话,防止陌生人骚扰" okTouchBlock:^{ [cUser.cDevice editOperationDeviceInfoWithParameters:@{@"opRejectStrangeCall":@(state)} success:^(id responseObject) { cUser.cDevice.opRejectStrangeCall = @(state); self.stateBtn.backgroundColor = [cUser.cDevice.opRejectStrangeCall boolValue] ? RGB(240, 240, 240) : mainColor; [self.stateBtn setTitleColor:[cUser.cDevice.opRejectStrangeCall boolValue] ? RGB(204, 203, 200) : KKWhiteColorColor forState:0]; [self.stateBtn setTitle:[cUser.cDevice.opRejectStrangeCall boolValue] ? @"关闭守护" : @"开启守护" forState:0]; self.bgImg.image = ImageName_([cUser.cDevice.opRejectStrangeCall boolValue] ? @"strangeCall_bg_yes" : @"strangeCall_bg_no"); } failure:^(id faiObject) { }]; }]; } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end