|
@@ -0,0 +1,194 @@
|
|
|
+//
|
|
|
+// ASMessageListCell.m
|
|
|
+// Asteria
|
|
|
+//
|
|
|
+// Created by iOS on 2023/7/4.
|
|
|
+//
|
|
|
+
|
|
|
+#import "ASMessageListCell.h"
|
|
|
+
|
|
|
+@interface ASMessageListCell ()
|
|
|
+
|
|
|
+@property (nonatomic,strong) UIView *bgV;
|
|
|
+
|
|
|
+@property (nonatomic,strong) UIStackView *stackV;
|
|
|
+
|
|
|
+@property (nonatomic,strong) UIView *unreadTipV;
|
|
|
+@property (nonatomic,strong) UILabel *titleLb;
|
|
|
+@property (nonatomic,strong) UIImageView *imgV;
|
|
|
+@property (nonatomic,strong) UILabel *desLb;
|
|
|
+@property (nonatomic,strong) UILabel *timeLb;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@implementation ASMessageListCell
|
|
|
+
|
|
|
+//- (void)setData:(KWMessageListModel *)m {
|
|
|
+// self.timeLb.text = m.time;
|
|
|
+// self.unreadTipV.hidden = m.isReaded == 1;
|
|
|
+// self.titleLb.text = m.title;
|
|
|
+// self.desLb.text = m.des;
|
|
|
+// if ([m.imgUrl isEmpty]) {
|
|
|
+// self.imgV.hidden = true;
|
|
|
+// } else {
|
|
|
+// self.imgV.hidden = false;
|
|
|
+// [self.imgV sd_setImageWithURL:[NSURL URLWithString:m.imgUrl.urlEncode]];
|
|
|
+// }
|
|
|
+//}
|
|
|
+
|
|
|
+- (void)setDemoData {
|
|
|
+ self.timeLb.text = @"timtimetimetime";
|
|
|
+ self.unreadTipV.hidden = arc4random()%2 == 1;
|
|
|
+ self.titleLb.text = @"title title title title title title title";
|
|
|
+ self.desLb.text = @"content content content content content content content content content content content content content content content content content content content 134";
|
|
|
+ if (arc4random()%2 == 1) {
|
|
|
+ self.imgV.hidden = true;
|
|
|
+ } else {
|
|
|
+ self.imgV.hidden = false;
|
|
|
+ self.imgV.image = [UIImage imageNamed:@"vip_bg1"];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
|
|
+ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
|
|
+ if (self) {
|
|
|
+ [self configSubV];
|
|
|
+ [self setDemoData];
|
|
|
+ }
|
|
|
+ return 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
|
|
|
+}
|
|
|
+
|
|
|
+- (void)configSubV {
|
|
|
+ self.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
|
+
|
|
|
+ [self.contentView addSubview:self.bgV];
|
|
|
+ [self.bgV addSubview:self.titleLb];
|
|
|
+ [self.bgV addSubview:self.unreadTipV];
|
|
|
+ [self.bgV addSubview:self.stackV];
|
|
|
+ [self.stackV addArrangedSubview:self.imgV];
|
|
|
+ [self.stackV addArrangedSubview:self.desLb];
|
|
|
+ [self.stackV addArrangedSubview:self.timeLb];
|
|
|
+
|
|
|
+ [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.contentView).offset(15);
|
|
|
+ make.bottom.equalTo(self.contentView).offset(-15);
|
|
|
+ make.left.equalTo(self.contentView).offset(10);
|
|
|
+ make.right.equalTo(self.contentView).offset(-10);
|
|
|
+ }];
|
|
|
+ [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.left.equalTo(self.bgV).offset(13);
|
|
|
+ make.height.equalTo(@20);
|
|
|
+ make.centerX.equalTo(self.bgV);
|
|
|
+ }];
|
|
|
+ [self.unreadTipV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.width.height.equalTo(@10);
|
|
|
+ make.centerY.equalTo(self.titleLb);
|
|
|
+ make.right.equalTo(self.bgV).offset(-20);
|
|
|
+ }];
|
|
|
+ [self.stackV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.titleLb.mas_bottom).offset(13);
|
|
|
+ make.left.right.equalTo(self.bgV);
|
|
|
+ make.bottom.equalTo(self.bgV).offset(-20);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.imgV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.width.equalTo(self.bgV);
|
|
|
+ make.width.equalTo(self.imgV.mas_height).multipliedBy(355/115.0);
|
|
|
+ }];
|
|
|
+ [self.timeLb mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.height.equalTo(@14);
|
|
|
+ }];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (UIView *)bgV {
|
|
|
+ if (!_bgV) {
|
|
|
+ UIView *v = [[UIView alloc] init];
|
|
|
+ v.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
|
|
|
+ _bgV = v;
|
|
|
+ }
|
|
|
+ return _bgV;
|
|
|
+}
|
|
|
+
|
|
|
+- (UIView *)unreadTipV {
|
|
|
+ if (!_unreadTipV) {
|
|
|
+ UIView *v = [[UIView alloc] init];
|
|
|
+ v.backgroundColor = [UIColor colorWithHexString:@"#E60013"];
|
|
|
+ v.layer.cornerRadius = 5;
|
|
|
+ v.layer.masksToBounds = true;
|
|
|
+ _unreadTipV = v;
|
|
|
+ }
|
|
|
+ return _unreadTipV;
|
|
|
+}
|
|
|
+
|
|
|
+-(UIStackView *)stackV {
|
|
|
+ if (!_stackV) {
|
|
|
+ UIStackView *stv = [[UIStackView alloc] init];
|
|
|
+ stv.axis = UILayoutConstraintAxisVertical;
|
|
|
+ stv.spacing = 10;
|
|
|
+ stv.alignment = UIStackViewAlignmentFill;
|
|
|
+ stv.distribution = UIStackViewDistributionFill;
|
|
|
+ _stackV = stv;
|
|
|
+ }
|
|
|
+ return _stackV;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)titleLb {
|
|
|
+ if (!_titleLb) {
|
|
|
+ UILabel *lb = [UILabel new];
|
|
|
+ lb.textColor = [UIColor blackColor];
|
|
|
+ lb.textAlignment = NSTextAlignmentCenter;
|
|
|
+ lb.font = [UIFont fontWithName:Rob_Regular size:14];
|
|
|
+ lb.numberOfLines = 1;
|
|
|
+ _titleLb = lb;
|
|
|
+ }
|
|
|
+ return _titleLb;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)desLb {
|
|
|
+ if (!_desLb) {
|
|
|
+ UILabel *lb = [UILabel new];
|
|
|
+ lb.textColor = [[UIColor blackColor] colorWithAlphaComponent:0.8];
|
|
|
+ lb.textAlignment = NSTextAlignmentCenter;
|
|
|
+ lb.font = [UIFont fontWithName:Rob_Regular size:12];
|
|
|
+ lb.numberOfLines = 1;
|
|
|
+ _desLb = lb;
|
|
|
+ }
|
|
|
+ return _desLb;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)timeLb {
|
|
|
+ if (!_timeLb) {
|
|
|
+ UILabel *lb = [UILabel new];
|
|
|
+ lb.textColor = [[UIColor colorWithHexString:@"#0b0b0b"] colorWithAlphaComponent:1];
|
|
|
+ lb.textAlignment = NSTextAlignmentCenter;
|
|
|
+ lb.font = [UIFont fontWithName:Rob_Regular size:12];
|
|
|
+ lb.numberOfLines = 1;
|
|
|
+ _timeLb = lb;
|
|
|
+ }
|
|
|
+ return _timeLb;
|
|
|
+}
|
|
|
+
|
|
|
+- (UIImageView *)imgV {
|
|
|
+ if (!_imgV) {
|
|
|
+ UIImageView *v = [[UIImageView alloc] init];
|
|
|
+ v.contentMode = UIViewContentModeScaleAspectFill;
|
|
|
+ v.clipsToBounds = true;
|
|
|
+ _imgV = v;
|
|
|
+ }
|
|
|
+ return _imgV;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+@end
|