You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
158 lines
5.4 KiB
158 lines
5.4 KiB
// |
|
// VoiceAlarmTableViewCell.m |
|
// tongxin |
|
// |
|
// Created by ecell on 2023/5/15. |
|
// Copyright © 2023 xTT. All rights reserved. |
|
// |
|
|
|
#import "VoiceAlarmTableViewCell.h" |
|
|
|
@interface VoiceAlarmTableViewCell () |
|
|
|
@property (nonatomic ,weak) UILabel *timeLabel; |
|
|
|
@property (nonatomic ,weak) UILabel *titleLabel; |
|
|
|
@property (nonatomic ,weak) UILabel *msgLabel; |
|
|
|
@property (nonatomic ,weak) UISwitch *uiSwitch; |
|
|
|
@end |
|
|
|
@implementation VoiceAlarmTableViewCell |
|
|
|
|
|
- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier |
|
{ |
|
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; |
|
if (self) |
|
{ |
|
self.selectionStyle = UITableViewCellSelectionStyleNone; |
|
self.backgroundColor = KKWhiteColorColor; |
|
|
|
self.layer.cornerRadius = 12; |
|
self.layer.masksToBounds = YES; |
|
[self subCellView]; |
|
} |
|
|
|
return self; |
|
} |
|
|
|
- (void)setDisturbBanModel:(DisturbBan *)disturbBanModel |
|
{ |
|
_disturbBanModel = disturbBanModel; |
|
self.timeLabel.text = [NSString stringWithFormat:@"%@-%@",disturbBanModel.starttime,disturbBanModel.endedtime]; |
|
self.msgLabel.text = [myHelper getWeekDayStr:[disturbBanModel week]]; |
|
self.uiSwitch.on = [disturbBanModel.status boolValue]; |
|
} |
|
|
|
- (void)setVoiceAlarmModel:(VoiceAlarm *)voiceAlarmModel |
|
{ |
|
_voiceAlarmModel = voiceAlarmModel; |
|
self.timeLabel.text = voiceAlarmModel.time; |
|
|
|
self.titleLabel.text = voiceAlarmModel.text; |
|
self.titleLabel.backgroundColor = [voiceAlarmModel.status boolValue] ? RGB(255, 243, 236) : RGB(240, 240, 240); |
|
self.titleLabel.textColor = [voiceAlarmModel.status boolValue] ? mainColor : KKGrey163; |
|
|
|
self.msgLabel.text = [myHelper getWeekDayStr:[voiceAlarmModel week]]; |
|
|
|
self.uiSwitch.on = [voiceAlarmModel.status boolValue]; |
|
|
|
CGRect ww = [UICommon GetTextWidth:voiceAlarmModel.text ViewHeight:20 fontSize:Font_(12) type:@"w"]; |
|
[self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) { |
|
make.left.equalTo(self.timeLabel.mas_right).offset(5); |
|
make.centerY.equalTo(self.timeLabel); |
|
make.size.mas_equalTo(CGSizeMake(ww.size.width+20, 20)); |
|
}]; |
|
} |
|
|
|
- (void)subCellView |
|
{ |
|
UILabel *timeLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:FontBold_(20) textColor:KKBlack20 text:@"" Radius:0]; |
|
self.timeLabel = timeLabel; |
|
[self.contentView addSubview:timeLabel]; |
|
[timeLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.equalTo(self.contentView).offset(15); |
|
make.top.equalTo(self.contentView).offset(15); |
|
}]; |
|
|
|
UILabel *titleLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentCenter font:Font_(12) textColor:KKBlack20 text:@"" Radius:10]; |
|
self.titleLabel = titleLabel; |
|
[self.contentView addSubview:titleLabel]; |
|
[titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.equalTo(timeLabel.mas_right).offset(5); |
|
make.centerY.equalTo(timeLabel); |
|
make.height.mas_equalTo(20); |
|
}]; |
|
|
|
UILabel *msgLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentLeft font:Font_(14) textColor:KKGrey102 text:@"" Radius:0]; |
|
self.msgLabel = msgLabel; |
|
[self.contentView addSubview:msgLabel]; |
|
[msgLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.right.equalTo(self.contentView).inset(15); |
|
make.top.equalTo(timeLabel.mas_bottom).offset(10); |
|
}]; |
|
|
|
UIImageView *line = [UIImageView new]; |
|
line.backgroundColor = RGB(240, 240, 240); |
|
[self.contentView addSubview:line]; |
|
[line mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.left.right.equalTo(self.contentView).inset(16); |
|
make.bottom.equalTo(msgLabel.mas_bottom).offset(15); |
|
make.height.mas_equalTo(0.5); |
|
}]; |
|
|
|
UISwitch *uiSwitch = [[UISwitch alloc] init]; |
|
[uiSwitch addTarget:self |
|
action:@selector(cellClick:) |
|
forControlEvents:UIControlEventValueChanged]; |
|
uiSwitch.onTintColor = mainColor; |
|
self.uiSwitch = uiSwitch; |
|
[self.contentView addSubview:uiSwitch]; |
|
[uiSwitch mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.right.equalTo(self.contentView.mas_right).inset(15); |
|
make.top.equalTo(line.mas_bottom).offset(15); |
|
make.size.mas_equalTo(CGSizeMake(48, 28)); |
|
}]; |
|
|
|
UIButton *editBtn = [UICommon ui_buttonSimple:CGRectZero font:Font_(0) normalColor:KKGrey102 normalText:@"" click:^(id x) { |
|
|
|
}]; |
|
[editBtn setImage:ImageName_(@"icon_voice_edit") forState:0]; |
|
[self.contentView addSubview:editBtn]; |
|
[editBtn mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.centerY.equalTo(uiSwitch); |
|
make.left.equalTo(timeLabel); |
|
make.size.mas_equalTo(CGSizeMake(24, 24)); |
|
}]; |
|
|
|
UILabel *editLabel = [UICommon ui_label:CGRectZero lines:0 align:NSTextAlignmentLeft font:Font_(14) textColor:KKGrey102 text:@"编辑" Radius:0]; |
|
[self.contentView addSubview:editLabel]; |
|
[editLabel mas_makeConstraints:^(MASConstraintMaker *make) { |
|
make.centerY.equalTo(editBtn); |
|
make.left.equalTo(editBtn.mas_right).offset(5); |
|
}]; |
|
} |
|
|
|
- (void)cellClick:(UISwitch *)sender |
|
{ |
|
if (self.BlockBtnClick) |
|
self.BlockBtnClick(sender, self); |
|
} |
|
|
|
|
|
|
|
- (void)awakeFromNib { |
|
[super awakeFromNib]; |
|
// Initialization code |
|
} |
|
|
|
- (void)setSelected:(BOOL)selected animated:(BOOL)animated { |
|
[super setSelected:selected animated:animated]; |
|
|
|
// Configure the view for the selected state |
|
} |
|
|
|
@end
|
|
|