123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- //
- // UserDetailBodyView.m
- // KulexiuForStudent
- //
- // Created by 王智 on 2022/10/18.
- //
- #import "UserDetailBodyView.h"
- #import "RecentMusicView.h"
- @interface UserDetailBodyView ()
- @property (weak, nonatomic) IBOutlet UIImageView *userAvatar;
- @property (weak, nonatomic) IBOutlet UILabel *userName;
- @property (weak, nonatomic) IBOutlet UIImageView *memberImage;
- @property (weak, nonatomic) IBOutlet UILabel *userSex;
- @property (weak, nonatomic) IBOutlet UILabel *userSubject;
- @property (weak, nonatomic) IBOutlet UIView *subjectView;
- @property (weak, nonatomic) IBOutlet NSLayoutConstraint *subjectViewHeight;
- @property (weak, nonatomic) IBOutlet UILabel *userIdLabel;
- @property (nonatomic, copy) RecentMusicCallback callback;
- @end
- @implementation UserDetailBodyView
- - (void)awakeFromNib {
- [super awakeFromNib];
- }
- + (instancetype)shareInstance {
- UserDetailBodyView *view = [[[NSBundle mainBundle] loadNibNamed:@"UserDetailBodyView" owner:nil options:nil] firstObject];
- return view;
- }
- - (void)configUserMessage:(ChatUserInfo *)userInfo musicArray:(NSMutableArray *)musicArray callback:(RecentMusicCallback)callback {
- if (callback) {
- self.callback = callback;
- }
- NSString *viperImage = @"";
- if (userInfo.isVip == 1) {
- self.userAvatar.layer.borderColor = HexRGB(0xFFE0B9).CGColor;
- viperImage = @"mine_vip";
- }
- else {
- self.userAvatar.layer.borderColor = HexRGB(0xffffff).CGColor;
- viperImage = @"mine_nomal";
- }
-
- [self.memberImage setImage:[UIImage imageNamed:viperImage]];
-
- [self.userAvatar sd_setImageWithURL:[NSURL URLWithString:[userInfo.avatar getUrlEndcodeString]] placeholderImage:[UIImage imageNamed:USERDEFAULT_LOGO]];
- self.userName.text = [NSString returnNoNullStringWithString:userInfo.username];
- self.userIdLabel.text = [NSString stringWithFormat:@"学号:%.0f",userInfo.userId];
- self.userSubject.text = [NSString returnNoNullStringWithString:userInfo.subjectName];
- NSString *sexString = userInfo.gender == 1 ? @"男生" : @"女生";
- self.userSex.text = sexString;
-
- [self evaluateSource:musicArray];
- }
- - (void)evaluateSource:(NSArray *)musicArray {
- [self.subjectView removeAllSubViews];
- NSInteger count = musicArray.count > 3 ? 3 : musicArray.count;
- for (NSInteger i = 0; i < count; i++) {
- // 添加按钮
- RecentMusicView *musicView = [RecentMusicView shareInstance];
- musicView.frame = CGRectMake(0, 84 * i, KPortraitWidth - 28, 84);
- BOOL hideLineView = i == count - 1 ? YES : NO;
- MJWeakSelf;
- [musicView configWithMusicModel:musicArray[i] hiddenLineView:hideLineView callback:^(NSString * _Nonnull songId) {
- if (weakSelf.callback) {
- weakSelf.callback(songId);
- }
- }];
- [self.subjectView addSubview:musicView];
- }
- }
- + (CGFloat)getViewHeight {
- return 590.0f;
- }
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- @end
|