// // AddFamilyNumberViewController.m // LekangGuard // // Created by ecell on 2022/12/6. // #import "AddFamilyNumberViewController.h" @interface AddFamilyNumberViewController () @property (nonatomic ,weak) UILabel *titleLabel; @property (nonatomic ,weak) UIView *bgView1; @property (nonatomic ,weak) UIButton *typeBtn; @property (nonatomic ,strong) NSMutableArray *btnArr; /// <#arguments#> @property (nonatomic ,weak) UITextField *nameField; @property (nonatomic ,weak) UITextField *phoneField; @property (nonatomic ,strong) NSString *typeStr; @end @implementation AddFamilyNumberViewController - (void)viewDidLoad { [super viewDidLoad]; self.typeStr = @""; // Do any additional setup after loading the view. self.zx_navTitle = self.isRedact == 1 ? GJText(@"添加亲情号") : GJText(@"修改亲情号"); [self zx_setRightBtnWithText:GJText(@"保存") clickedBlock:^(ZXNavItemBtn * _Nonnull btn) { [UICommon resignKeyboard]; self.typeBtn.selected = !self.typeBtn.selected; [self setFamilyDataModel]; }]; UIView *bgView = [UICommon ui_view:CGRectZero backgroundColor:KKWhiteColorColor cornerRadius:10 borderWidth:0 borderColor:KKClearColor]; bgView.frame = CGRectMake(10, iPhoneX_NavHeight+10, SCREEN_WIDTH-20, 180); [self.view addSubview:bgView]; for (int i = 0; i < 3; i++) { UILabel *titleLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentLeft font:FontBoldADA_(14) textColor:KKMainColor text:i == 0 ? GJText(@"关系:") : i == 1 ? GJText(@"电话:") : @"拨号快捷键:" Radius:0]; titleLabel.frame = CGRectMake(15, i*55, 100, i == 2 ? 65 : 55); [bgView addSubview:titleLabel]; // [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.equalTo(bgView).offset(15); // make.top.equalTo(bgView).offset(i*55); // make.height.mas_equalTo(i == 2 ? 65 : 55); // }]; if (i == 2) self.titleLabel = titleLabel; if (i < 2) { UITextField *textfield = [UICommon ui_textField:CGRectZero textColor:KKTextBlackColor backColor:KKClearColor font:FontADA_(14) maxTextNum:13 placeholderColor:KKGrey133 placeholder:i == 0 ? GJText(@"请输入与孩子的关系") : GJText(@"请输入或从通讯录导入") toMaxNum:^(UITextField *textField) { } change:^(UITextField *textField) { self.typeBtn.selected = NO; [self dismiss11]; }]; if (i == 0) self.nameField = textfield; else self.phoneField = textfield; [bgView addSubview:textfield]; [textfield mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(bgView.mas_right).inset(i == 0 ? 28 : 53); make.left.equalTo(bgView).offset(61); make.centerY.equalTo(titleLabel); make.height.mas_equalTo(Adapted(44)); }]; UILabel *line = [UILabel new]; line.backgroundColor = i == 0 ? KKMainColor : KKLineColor; [bgView addSubview:line]; [line mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(titleLabel.mas_bottom); make.left.equalTo(bgView).offset(61); make.right.equalTo(bgView.mas_right).inset(28); make.height.mas_equalTo(0.5); }]; if (i == 1) { UIButton *tongBtn = [UICommon ui_buttonSimple:CGRectZero font:Font_(0) normalColor:KKWhiteColorColor normalText:@"" click:^(id x) { }]; [tongBtn setImage:ImageName_(@"icon_contacts") forState:0]; [bgView addSubview:tongBtn]; [tongBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(bgView.mas_right).inset(28); make.centerY.equalTo(titleLabel); make.size.mas_equalTo(CGSizeMake(15, 17)); }]; } } } UIButton *typeBtn = [UICommon ui_buttonSimple:CGRectZero font:FontADA_(14) normalColor:KKTextBlackColor normalText:GJText(@"快捷键") click:^(UIButton *btn) { [UICommon resignKeyboard]; self.typeBtn.selected = !self.typeBtn.selected; if (self.typeBtn.selected) [self showView11]; else [self dismiss11]; }]; [typeBtn setImage:ImageName_(@"icon_arrow_down") forState:0]; [typeBtn setImage:ImageName_(@"icon_arrow_up") forState:UIControlStateSelected]; [self setButtonsTi:typeBtn]; self.typeBtn = typeBtn; [self.view addSubview:typeBtn]; [typeBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(bgView).offset(150); make.right.equalTo(bgView.mas_right).inset(10); make.centerY.equalTo(self.titleLabel.mas_centerY); make.height.mas_equalTo(50); }]; NSArray *titleArr = @[@"快捷键 1",@"快捷键 2",@"快捷键 3",@"快捷键 4"]; UIView *bgView1 = [UICommon ui_view:CGRectZero backgroundColor:KKWhiteColorColor cornerRadius:8 borderWidth:0 borderColor:KKClearColor]; bgView1.frame = CGRectMake(120, bgView.bottom-20, 118, 0); self.bgView1 = bgView1; [self.view addSubview:bgView1]; self.btnArr = [NSMutableArray new]; for (int i = 0; i< titleArr.count; i++) { UIButton *btn = [UICommon ui_buttonSimple:CGRectZero font:FontADA_(14) normalColor:KKTextBlackColor normalText:titleArr[i] click:^(UIButton *btn) { [self dismiss11]; self.typeBtn.selected = NO; self.typeStr = F(@"%ld", btn.tag); [self.typeBtn setTitle:F(@"快捷键 %ld", btn.tag) forState:0]; [self setButtonsTi:self.typeBtn]; }]; btn.hidden = YES; btn.tag = i+1; [bgView1 addSubview:btn]; [btn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.equalTo(bgView1); make.top.equalTo(bgView1).offset(Adapted(40)*i+i*1); make.height.mas_equalTo(Adapted(40)); }]; [self.btnArr addObject:btn]; if (i