Files
peko-ios/YuMi/Modules/YMMessage/View/SessionListHeadView/XPSessionHelloEnterView.m
2024-04-11 17:05:27 +08:00

119 lines
3.5 KiB
Objective-C

//
// YMSessionHelloEnterView.m
// YUMI
//
// Created by YUMI on 2023/1/31.
//
#import "XPSessionHelloEnterView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "DJDKMIMOMColor.h"
@interface XPSessionHelloEnterView ()
///图标
@property (nonatomic,strong) UIImageView *logoImageView;
///打招呼
@property (nonatomic,strong) UILabel *titleLabel;
///副标题
@property (nonatomic,strong) UILabel *subTitleLabel;
///分割线
@property (nonatomic,strong) UIView *lineView;
@end
@implementation XPSessionHelloEnterView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.logoImageView];
[self addSubview:self.titleLabel];
[self addSubview:self.subTitleLabel];
[self addSubview:self.lineView];
}
- (void)initSubViewConstraints {
[self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(35, 30));
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(self);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.logoImageView);
make.top.mas_equalTo(self.logoImageView.mas_bottom).offset(2);
}];
[self.subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(0);
make.leading.trailing.mas_equalTo(self);
}];
[self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(1);
make.height.mas_equalTo(28);
make.top.mas_equalTo(self.logoImageView).offset(20);
make.trailing.mas_equalTo(self);
}];
}
- (void)createPersonNumberAttribute:(NSInteger)number {
NSString * numbnerStr = [NSString stringWithFormat:@"%ld", number];
NSString * title = [NSString stringWithFormat:YMLocalizedString(@"XPSessionHelloEnterView0"), numbnerStr];
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:8], NSForegroundColorAttributeName:[DJDKMIMOMColor colorWithHexString:@"#8A8CAB"]}];
[attribute addAttribute:NSForegroundColorAttributeName value:[DJDKMIMOMColor colorWithHexString:@"#FFA027"] range:[title rangeOfString:numbnerStr]];
self.subTitleLabel.attributedText = attribute;
self.subTitleLabel.textAlignment = NSTextAlignmentCenter;
}
#pragma mark - Getters And Setters
- (void)setNumber:(NSInteger)number {
_number = number;
[self createPersonNumberAttribute:number];
}
- (UIImageView *)logoImageView {
if (!_logoImageView) {
_logoImageView = [[UIImageView alloc] init];
_logoImageView.userInteractionEnabled = YES;
_logoImageView.image = [UIImage imageNamed:@"session_list_hello_enter"];
}
return _logoImageView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
_titleLabel.textColor = [DJDKMIMOMColor colorWithHexString:@"#171A58"];
_titleLabel.text = YMLocalizedString(@"XPSessionHelloEnterView1");
_titleLabel.textAlignment = NSTextAlignmentCenter;
}
return _titleLabel;
}
- (UILabel *)subTitleLabel {
if (!_subTitleLabel) {
_subTitleLabel = [[UILabel alloc] init];
}
return _subTitleLabel;
}
- (UIView *)lineView {
if (!_lineView) {
_lineView = [[UIView alloc] init];
_lineView.backgroundColor = [DJDKMIMOMColor colorWithHexString:@"#D8D8D8"];
}
return _lineView;
}
@end