Files
featherVoice/QXLive/Dynamic(语圈)/View/QXExpansionCell.m

172 lines
6.3 KiB
Mathematica
Raw Normal View History

2025-08-08 10:49:36 +08:00
//
// QXExpansionCell.m
// QXLive
//
// Created by on 2025/5/27.
//
#import "QXExpansionCell.h"
#import "YBImageBrowser.h"
#import "QXChatViewController.h"
@interface QXExpansionCell()
@property (nonatomic, strong) NSMutableArray *imgViewsArray;
@end
@implementation QXExpansionCell
- (void)createUI {
CGFloat imgWidth = (SCREEN_WIDTH-16*2-12*2-10*2)/3;
for (NSInteger i = 0; i < 6; i++) {
UIImageView *imgV = [[UIImageView alloc] init];
imgV.tag = i+100;
imgV.userInteractionEnabled = YES;
MJWeakSelf
[imgV addTapBlock:^(id _Nonnull obj) {
[weakSelf previewPhotoWithCurrentIndex:imgV.tag-100];
}];
imgV.hidden = YES;
imgV.layer.masksToBounds = YES;
imgV.layer.cornerRadius = 10;
imgV.contentMode = UIViewContentModeScaleAspectFill;
[self.imgsBgView addSubview:imgV];
[self.imgViewsArray addObject:imgV];
[imgV mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.imgsBgView).offset((imgWidth+10)*(i/3));
make.left.equalTo(self.imgsBgView).offset((imgWidth+10)*(i%3));
make.size.mas_equalTo(CGSizeMake(imgWidth, imgWidth));
}];
}
2025-11-21 16:17:05 +08:00
self.nameLabel.textColor = RGB16(0x212121);
self.nameLabel.shimmerWidth = 20;
self.nameLabel.shimmerRadius = 20;
self.nameLabel.durationTime = 1;;
self.nameLabel.font = [UIFont boldSystemFontOfSize:15];
[self.nameLabel stopShimmer];
2025-08-08 10:49:36 +08:00
}
- (IBAction)chatAction:(id)sender {
if (self.model.room_id.intValue > 0) {
//
[[QXGlobal shareGlobal] joinRoomWithRoomId:self.model.room_id isRejoin:NO navagationController:self.navigationController];
}else{
[[QXGlobal shareGlobal] chatWithUserID:self.model.user_id nickname:self.model.nickname avatar:self.model.avatar navagationController:self.navigationController];
}
}
-(void)setModel:(QXUserHomeModel *)model{
_model = model;
[self.avatarImgV setHeadIcon:model.avatar dress:@""];
2025-11-11 17:19:21 +08:00
if ([model.nobility_image isExist]) {
[self.avatarImgV.nobilityImageView sd_setImageWithURL:[NSURL URLWithString:model.nobility_image]];
}else{
self.avatarImgV.nobilityImageView.image = nil;
}
if ([model.nickname_color isExist]) {
2025-11-21 16:17:05 +08:00
self.nameLabel.shimmerColor = [UIColor colorWithHexString:model.nickname_color];
// [self.nameLabel startShimmer];
2025-11-11 17:19:21 +08:00
}else{
2025-11-21 16:17:05 +08:00
self.nameLabel.shimmerColor = [UIColor clearColor];
// [self.nameLabel stopShimmer];
2025-11-11 17:19:21 +08:00
}
2025-11-21 16:17:05 +08:00
self.nameLabel.text = model.nickname;
2025-08-08 10:49:36 +08:00
self.ageLabel.text = [NSString stringWithFormat:@"%ld岁 ip属地: %@",[model.birthday ageWithDateOfBirth],model.loginip];
CGFloat imgWidth = (SCREEN_WIDTH-16*2-12*2-10*2)/3;
UIImageView *firstImgV = self.imgViewsArray.firstObject;
[firstImgV mas_updateConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(imgWidth, imgWidth));
}];
UIImage *sexImage = [UIImage imageNamed:model.sex.intValue==1?@"user_sex_boy":@"user_sex_girl"];
self.sexImageView.image = sexImage;
NSArray *images;
if (model.home_bgimages.length > 0) {
images = [model.home_bgimages componentsSeparatedByString:@","];
}
for (UIImageView *imgV in self.imgViewsArray) {
imgV.hidden = YES;
}
for (NSInteger i = 0; i < images.count; i++) {
if (i < self.imgViewsArray.count) {
UIImageView *imgV = self.imgViewsArray[i];
imgV.hidden = NO;
NSString *imageUrl = images[i];
[imgV sd_setImageWithURL:[NSURL URLWithString:imageUrl]];
}
}
self.imgsBgView.hidden = YES;
if (images.count > 0) {
if (images.count == 1) {//
CGFloat itemW = (SCREEN_WIDTH-15-15-15)/2;
CGFloat imgBgHeight = itemW;
self.imgsBgView.hidden = NO;
self.imgsBgViewHeightCon.constant = imgBgHeight;
[firstImgV mas_updateConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(itemW, imgBgHeight));
}];
}else {
CGFloat itemW = (SCREEN_WIDTH-16*2-12*2-10*2)/3;
CGFloat imgBgHeight = 0;
NSInteger lines = images.count%3 == 0 ? images.count/3 : images.count/3+1;
imgBgHeight = itemW*lines + 10*(lines-1);
self.imgsBgView.hidden = NO;
if (images.count == 0) {
self.imgsBgViewHeightCon.constant = 0;
}else{
self.imgsBgViewHeightCon.constant = imgBgHeight;
}
}
}
if (self.model.room_id.intValue > 0) {
self.followBtn.selected = YES;
}else{
self.followBtn.selected = NO;
}
}
2025-11-21 16:17:05 +08:00
-(void)nameStartAnimate{
if ([self.model.nickname_color isExist]) {
[self.nameLabel stopShimmer];
[self.nameLabel layoutSubviews];
self.nameLabel.shimmerWidth = 20;
self.nameLabel.shimmerRadius = 20;
self.nameLabel.durationTime = 1;
self.nameLabel.shimmerColor = [UIColor colorWithHexString:self.model.nickname_color];
[self.nameLabel startShimmer];
}
}
-(void)nameStopAnimate{
if ([self.model.nickname_color isExist]) {
self.nameLabel.shimmerColor = [UIColor colorWithHexString:self.model.nickname_color];
[self.nameLabel stopShimmer];
}
}
2025-08-08 10:49:36 +08:00
-(void)previewPhotoWithCurrentIndex:(NSInteger)currentIndex{
NSArray *images = [self.model.home_bgimages componentsSeparatedByString:@","];
YBImageBrowser *browser = [YBImageBrowser new];
NSMutableArray *sourceArray = [NSMutableArray array];
for (int i = 0 ; i <images.count;i++) {
NSString *url = images[i];
YBIBImageData *data = [[YBIBImageData alloc] init];
data.imageURL = [NSURL URLWithString:url];
UIImageView *imageView = [self viewWithTag:100+i];
data.projectiveView = imageView;
[sourceArray addObject:data];
}
browser.dataSourceArray = sourceArray;
browser.currentPage = currentIndex;
[browser show];
}
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
self.imgViewsArray = [NSMutableArray arrayWithCapacity:6];
[self createUI];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end