feat: HomeV2 手表数据区高度动态调整 & 绑定弹窗姓名工号布局优化
- XJHomeWatchDataView 新增 heightChangeBlock,无数据/未登录高度 104,有数据高度 200 - XJHomePageV2HeardView 初始高度改为 104,绑定回调动态更新约束带动画 - BindWatchPopView 姓名工号同行布局,工号固定右侧优先显示,姓名占满剩余空间
This commit is contained in:
@@ -15,6 +15,9 @@
|
||||
@property (nonatomic,strong) UITextField *nameField;
|
||||
@property (nonatomic,strong) UITextField *numberField;
|
||||
@property (nonatomic,strong) UIButton *actionBtn;
|
||||
@property (nonatomic,strong) UIView *gestureView;
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@implementation BindWatchPopView
|
||||
@@ -22,11 +25,10 @@
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
|
||||
|
||||
self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.4];
|
||||
|
||||
|
||||
[self createUI];
|
||||
[self addGesture];
|
||||
[self addKeyboardNotification];
|
||||
}
|
||||
|
||||
@@ -36,20 +38,35 @@
|
||||
#pragma mark - UI
|
||||
|
||||
- (void)createUI {
|
||||
|
||||
|
||||
|
||||
self.bottomView = [[UIView alloc] init];
|
||||
self.bottomView.backgroundColor = UIColor.whiteColor;
|
||||
self.bottomView.layer.cornerRadius = 16;
|
||||
self.bottomView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
|
||||
self.bottomView.layer.masksToBounds = YES;
|
||||
[self addSubview:self.bottomView];
|
||||
|
||||
|
||||
[self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.bottom.offset(0);
|
||||
make.height.offset(342);
|
||||
make.height.offset(254 + SafetyAreaHeight);
|
||||
}];
|
||||
|
||||
|
||||
// 添加透明的手势响应区域(覆盖黑色背景)
|
||||
UIView *gestureView = [[UIView alloc] init];
|
||||
gestureView.backgroundColor = [UIColor clearColor];
|
||||
gestureView.userInteractionEnabled = YES;
|
||||
self.gestureView =gestureView;
|
||||
[self addSubview:gestureView];
|
||||
|
||||
[gestureView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.top.offset(0);
|
||||
make.bottom.equalTo(self.bottomView.mas_top);
|
||||
}];
|
||||
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(close)];
|
||||
[gestureView addGestureRecognizer:tap];
|
||||
|
||||
/// 拖动条
|
||||
UIView *indicator = [[UIView alloc] init];
|
||||
indicator.backgroundColor = UIColorHex(#D8D8D8);
|
||||
@@ -65,7 +82,7 @@
|
||||
|
||||
|
||||
UILabel *titleLab = [[UILabel alloc] init];
|
||||
titleLab.text = @"健康监测";
|
||||
titleLab.text = @"健康监测工具绑定";
|
||||
titleLab.font = [UIFont boldSystemFontOfSize:16];
|
||||
titleLab.textAlignment = NSTextAlignmentCenter;
|
||||
[self.bottomView addSubview:titleLab];
|
||||
@@ -77,71 +94,120 @@
|
||||
|
||||
HQUserInfo * user = [HQCommonUtils keyedUnarchiverWithKey:LoginUserInfo];
|
||||
|
||||
self.workNoField = [self createTextField];
|
||||
[self.bottomView addSubview:self.workNoField];
|
||||
|
||||
[self.workNoField mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.offset(82);
|
||||
make.right.offset(-15);
|
||||
make.height.offset(52);
|
||||
make.top.equalTo(titleLab.mas_bottom).offset(20);
|
||||
}];
|
||||
|
||||
|
||||
UILabel *workLab = [self createLabel:@"工 号:"];
|
||||
if (!ValidStr(user.workNo)) {
|
||||
self.workNoField.text = [NSString stringWithFormat:@"%@",user.workNo];
|
||||
}
|
||||
[self.bottomView addSubview:workLab];
|
||||
|
||||
[workLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.offset(0);
|
||||
make.right.equalTo(self.workNoField.mas_left);
|
||||
make.centerY.equalTo(self.workNoField);
|
||||
}];
|
||||
|
||||
|
||||
self.nameField = [self createTextField];
|
||||
[self.bottomView addSubview:self.nameField];
|
||||
|
||||
[self.nameField mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.height.equalTo(self.workNoField);
|
||||
make.top.equalTo(self.workNoField.mas_bottom).offset(16);
|
||||
}];
|
||||
UILabel * nameLabel = [[UILabel alloc] init];
|
||||
nameLabel.textColor = UIColorHex(#808080);
|
||||
nameLabel.font= [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
|
||||
nameLabel.textAlignment = NSTextAlignmentLeft;
|
||||
if (!ValidStr(user.realname)) {
|
||||
self.nameField.text = [NSString stringWithFormat:@"%@",user.realname];
|
||||
nameLabel.text = [NSString stringWithFormat:@"%@",user.realname];
|
||||
}
|
||||
[self.bottomView addSubview:nameLabel];
|
||||
|
||||
UILabel *nameLab = [self createLabel:@"姓 名:"];
|
||||
[self.bottomView addSubview:nameLab];
|
||||
|
||||
[nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.offset(0);
|
||||
make.right.equalTo(self.nameField.mas_left);
|
||||
make.centerY.equalTo(self.nameField);
|
||||
// workLabel 先布局,固定右侧,宽度自适应内容,不压缩
|
||||
UILabel * workLabel = [[UILabel alloc] init];
|
||||
workLabel.textColor = UIColorHex(#808080);
|
||||
workLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
|
||||
workLabel.textAlignment = NSTextAlignmentRight;
|
||||
// 工号不压缩、不拉伸
|
||||
[workLabel setContentCompressionResistancePriority:UILayoutPriorityRequired
|
||||
forAxis:UILayoutConstraintAxisHorizontal];
|
||||
[workLabel setContentHuggingPriority:UILayoutPriorityRequired
|
||||
forAxis:UILayoutConstraintAxisHorizontal];
|
||||
if (!ValidStr(user.workNo)) {
|
||||
workLabel.text = [NSString stringWithFormat:@"%@", user.workNo];
|
||||
}
|
||||
[self.bottomView addSubview:workLabel];
|
||||
|
||||
[workLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_offset(-21);
|
||||
make.top.mas_equalTo(titleLab.mas_bottom).offset(20);
|
||||
}];
|
||||
|
||||
// nameLabel 左侧固定,右侧距 workLabel 一个字符宽度,姓名优先占满剩余空间
|
||||
[nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_offset(16);
|
||||
make.top.mas_equalTo(titleLab.mas_bottom).offset(20);
|
||||
// 右侧距 workLabel 一个字符间距(约 15pt)
|
||||
make.right.equalTo(workLabel.mas_left).offset(-15);
|
||||
}];
|
||||
// 姓名可压缩,优先级低于工号
|
||||
[nameLabel setContentCompressionResistancePriority:UILayoutPriorityDefaultLow
|
||||
forAxis:UILayoutConstraintAxisHorizontal];
|
||||
[nameLabel setContentHuggingPriority:UILayoutPriorityDefaultLow
|
||||
forAxis:UILayoutConstraintAxisHorizontal];
|
||||
// self.workNoField = [self createTextField];
|
||||
// self.workNoField.userInteractionEnabled = false;
|
||||
// [self.bottomView addSubview:self.workNoField];
|
||||
//
|
||||
// [self.workNoField mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.left.offset(82);
|
||||
// make.right.offset(-15);
|
||||
// make.height.offset(52);
|
||||
// make.top.equalTo(titleLab.mas_bottom).offset(20);
|
||||
// }];
|
||||
//
|
||||
//
|
||||
UILabel * watchSNLab = [[UILabel alloc] init];
|
||||
watchSNLab.text = @"心脑血管监测工具SN编码:";
|
||||
watchSNLab.font = MEDIUMFONT(15);
|
||||
watchSNLab.textAlignment = NSTextAlignmentLeft;
|
||||
[self.bottomView addSubview:watchSNLab];
|
||||
|
||||
|
||||
[watchSNLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(nameLabel.mas_left);
|
||||
make.right.mas_offset(-21);
|
||||
make.top.mas_equalTo(nameLabel.mas_bottom).offset(15);
|
||||
}];
|
||||
//
|
||||
//
|
||||
// self.nameField = [self createTextField];
|
||||
// self.nameField.enabled = false;
|
||||
// [self.bottomView addSubview:self.nameField];
|
||||
//
|
||||
// [self.nameField mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.left.right.height.equalTo(self.workNoField);
|
||||
// make.top.equalTo(self.workNoField.mas_bottom).offset(16);
|
||||
// }];
|
||||
// if (!ValidStr(user.realname)) {
|
||||
// self.nameField.text = [NSString stringWithFormat:@"%@",user.realname];
|
||||
// }
|
||||
//
|
||||
// UILabel *nameLab = [self createLabel:@"姓 名:"];
|
||||
// [self.bottomView addSubview:nameLab];
|
||||
//
|
||||
// [nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.left.offset(0);
|
||||
// make.right.equalTo(self.nameField.mas_left);
|
||||
// make.centerY.equalTo(self.nameField);
|
||||
// }];
|
||||
//
|
||||
//
|
||||
self.numberField = [self createTextField];
|
||||
self.numberField.backgroundColor = KWhiteColor;
|
||||
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:@"请输入SN编码" attributes:
|
||||
@{NSForegroundColorAttributeName:UIColorHex(#B6B6B6),
|
||||
NSFontAttributeName:[UIFont systemFontOfSize:16 weight:UIFontWeightMedium]}
|
||||
];
|
||||
self.numberField.attributedPlaceholder = attrString;
|
||||
[self.bottomView addSubview:self.numberField];
|
||||
|
||||
[self.numberField mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.height.equalTo(self.workNoField);
|
||||
make.top.equalTo(self.nameField.mas_bottom).offset(16);
|
||||
make.left.mas_offset(15);
|
||||
make.right.mas_offset(-15);
|
||||
make.height.mas_offset(52);
|
||||
make.top.equalTo(watchSNLab.mas_bottom).offset(12);
|
||||
}];
|
||||
|
||||
UIView * lineV = [[UIView alloc] init];
|
||||
lineV.backgroundColor = UIColorHex(#EAECF1);
|
||||
[self.bottomView addSubview:lineV];
|
||||
|
||||
UILabel *xulieLab = [self createLabel:@"序列号:"];
|
||||
[self.bottomView addSubview:xulieLab];
|
||||
|
||||
[xulieLab mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.offset(0);
|
||||
make.right.equalTo(self.numberField.mas_left);
|
||||
make.centerY.equalTo(self.numberField);
|
||||
[lineV mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_offset(0);
|
||||
make.height.mas_offset(1);
|
||||
make.top.mas_equalTo(self.numberField.mas_bottom).offset(12);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
UIButton *bindBtn = [[UIButton alloc] init];
|
||||
[bindBtn setTitle:@"解绑" forState:UIControlStateNormal];
|
||||
bindBtn.backgroundColor = UIColorHex(#21BEBD);
|
||||
@@ -155,7 +221,7 @@
|
||||
make.centerX.offset(0);
|
||||
make.width.offset(215);
|
||||
make.height.offset(44);
|
||||
make.top.equalTo(self.numberField.mas_bottom).offset(30);
|
||||
make.top.equalTo(self.numberField.mas_bottom).offset(23);
|
||||
}];
|
||||
|
||||
}
|
||||
@@ -166,13 +232,17 @@
|
||||
|
||||
[self.actionBtn setTitle:@"解绑" forState:UIControlStateNormal];
|
||||
self.numberField.text = self.serialNumber;
|
||||
self.numberField.backgroundColor = UIColorHex(#F5F7FB);
|
||||
self.numberField.enabled = NO;
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
[self.actionBtn setTitle:@"绑定" forState:UIControlStateNormal];
|
||||
self.numberField.text = @"";
|
||||
self.numberField.enabled = YES;
|
||||
self.numberField.backgroundColor = KWhiteColor;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -214,14 +284,6 @@
|
||||
return field;
|
||||
}
|
||||
|
||||
#pragma mark - 点击背景关闭
|
||||
|
||||
- (void)addGesture {
|
||||
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(close)];
|
||||
tap.cancelsTouchesInView = YES;
|
||||
[self addGestureRecognizer:tap];
|
||||
}
|
||||
|
||||
- (void)close {
|
||||
|
||||
@@ -245,20 +307,29 @@
|
||||
}
|
||||
|
||||
- (void)keyboardShow:(NSNotification *)noti {
|
||||
|
||||
|
||||
CGRect rect = [noti.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
|
||||
|
||||
CGFloat keyboardH = rect.size.height;
|
||||
|
||||
|
||||
[UIView animateWithDuration:0.25 animations:^{
|
||||
self.bottomView.transform = CGAffineTransformMakeTranslation(0, -keyboardH);
|
||||
// 同步缩小 gestureView,避免手势区域覆盖 bottomView 上的按钮
|
||||
[self.gestureView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.equalTo(self.bottomView.mas_top).offset(-keyboardH);
|
||||
}];
|
||||
[self layoutIfNeeded];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)keyboardHide:(NSNotification *)noti {
|
||||
|
||||
|
||||
[UIView animateWithDuration:0.25 animations:^{
|
||||
self.bottomView.transform = CGAffineTransformIdentity;
|
||||
// 恢复 gestureView 约束
|
||||
[self.gestureView mas_updateConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.equalTo(self.bottomView.mas_top).offset(0);
|
||||
}];
|
||||
[self layoutIfNeeded];
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user