Files
my_yuyin/QXLive/Message(音信)/View/QXSystemTopView.m
2025-09-22 18:48:29 +08:00

132 lines
5.0 KiB
Objective-C

//
// QXSystemTopView.m
// QXLive
//
// Created by 启星 on 2025/5/26.
//
#import "QXSystemTopView.h"
@interface QXSystemTopView()
@property(nonatomic,strong)QXSystemTopSubView *noticeView;
@property(nonatomic,strong)QXSystemTopSubView *systemView;
@property(nonatomic,strong)UIView *bottomView;
@end
@implementation QXSystemTopView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initSubviews];
}
return self;
}
-(void)initSubviews{
MJWeakSelf
self.noticeView = [[QXSystemTopSubView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 74)];
self.noticeView.iconImageView.image = [UIImage imageNamed:@"notice_icon"];
self.noticeView.titleLabel.text = QXText(@"官方公告");
[self.noticeView addTapBlock:^(id _Nonnull obj) {
if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(didClickNoticeWithType:)]) {
[weakSelf.delegate didClickNoticeWithType:0];
}
}];
[self addSubview:self.noticeView];
self.systemView = [[QXSystemTopSubView alloc] initWithFrame:CGRectMake(0, 74, SCREEN_WIDTH, 74)];
self.systemView.iconImageView.image = [UIImage imageNamed:@"system_icon"];
self.systemView.titleLabel.text = QXText(@"系统消息");
[self addSubview:self.systemView];
[self.systemView addTapBlock:^(id _Nonnull obj) {
if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(didClickNoticeWithType:)]) {
[weakSelf.delegate didClickNoticeWithType:1];
}
}];
self.bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, self.systemView.bottom, SCREEN_WIDTH, 8)];
// self.bottomView.backgroundColor = RGB16(0xececec);
self.bottomView.backgroundColor = [UIColor clearColor];
[self addSubview:self.bottomView];
}
-(void)setModel:(QXMessageModel *)model{
_model = model;
self.noticeView.subTitleLabel.text = model.announcement_last_message.title;
self.systemView.subTitleLabel.text = model.system_last_message.title;
[self.noticeView.unreadView setNum:model.announcement_read_count.integerValue];
[self.systemView.unreadView setNum:model.system_no_read_count.integerValue];
}
@end
@implementation QXSystemTopSubView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initSubviews];
}
return self;
}
-(void)initSubviews{
self.iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(16, 12, 50, 50)];
[self addSubview:self.iconImageView];
[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(16);
make.top.mas_equalTo(12);
make.size.mas_equalTo(CGSizeMake(50, 50));
}];
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.iconImageView.right+10, self.iconImageView.top, self.width-self.iconImageView.right-10-16, 24)];
self.titleLabel.font = [UIFont boldSystemFontOfSize:16];
self.titleLabel.textColor = RGB16(0x333333);
[self addSubview:self.titleLabel];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.iconImageView.mas_right).offset(10);
make.top.mas_equalTo(12);
make.height.mas_equalTo(24);
make.right.mas_equalTo(-16);
}];
self.subTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.iconImageView.right+10, self.iconImageView.top, self.width-self.iconImageView.right-10-16, 24)];
self.subTitleLabel.font = [UIFont systemFontOfSize:12];
self.subTitleLabel.textColor = RGB16(0x666666);
[self addSubview:self.subTitleLabel];
[self.subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.titleLabel);
make.bottom.mas_equalTo(-16);
make.trailing.mas_equalTo(self).mas_offset(- 2*TConversationCell_Margin_Text);
make.height.mas_equalTo(17);
}];
self.unreadView = [[TUIUnReadView alloc] init];
[self.unreadView setNum:0];
[self addSubview:self.unreadView];
[self.unreadView.unReadLabel sizeToFit];
[self.unreadView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(self.mas_trailing).offset(-16);
make.centerY.mas_equalTo(self.subTitleLabel);
make.width.mas_equalTo(kScale375(20));
make.height.mas_equalTo(kScale375(20));
}];
[self.unreadView.unReadLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.unreadView);
make.size.mas_equalTo(self.unreadView.unReadLabel);
}];
self.unreadView.layer.cornerRadius = kScale375(10);
[self.unreadView.layer masksToBounds];
UIView *line = [[UIView alloc] init];
line.backgroundColor = RGB16(0xDBDBDB);
[self addSubview:line];
[line mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(16);
make.right.mas_equalTo(-16);
make.height.mas_equalTo(0.5);
make.bottom.equalTo(self);
}];
}
@end