// // LMLovelsTableHeaderView.m // SweetParty // // Created by Xmac on 2024/8/7. // #import "LMLovelsTableHeaderView.h" #import "LMLoveLsListModel.h" @interface LMLovelsTableHeaderView () @property (weak, nonatomic) IBOutlet UIView *yesterdayTopView_1; @property (weak, nonatomic) IBOutlet UIImageView *topViewLeftHeader_1; @property (weak, nonatomic) IBOutlet UIImageView *topViewRightHeader_1; @property (weak, nonatomic) IBOutlet UILabel *topViewLeftName_1; @property (weak, nonatomic) IBOutlet UILabel *topViewRightName_1; @property (weak, nonatomic) IBOutlet UILabel *topViewValue_1; @property (weak, nonatomic) IBOutlet UIView *yesterdayTopView_2; @property (weak, nonatomic) IBOutlet UIImageView *topViewLeftHeader_2; @property (weak, nonatomic) IBOutlet UIImageView *topViewRightHeader_2; @property (weak, nonatomic) IBOutlet UILabel *topViewLeftName_2; @property (weak, nonatomic) IBOutlet UILabel *topViewRightName_2; @property (weak, nonatomic) IBOutlet UILabel *topViewValue_2; @property (weak, nonatomic) IBOutlet UIView *yesterdayTopView_3; @property (weak, nonatomic) IBOutlet UIImageView *topViewLeftHeader_3; @property (weak, nonatomic) IBOutlet UIImageView *topViewRightHeader_3; @property (weak, nonatomic) IBOutlet UILabel *topViewLeftName_3; @property (weak, nonatomic) IBOutlet UILabel *topViewRightName_3; @property (weak, nonatomic) IBOutlet UILabel *topViewValue_3; @property (weak, nonatomic) IBOutlet UIView *yesterdayTopView_4; @property (weak, nonatomic) IBOutlet UIImageView *topViewLeftHeader_4; @property (weak, nonatomic) IBOutlet UIImageView *topViewRightHeader_4; @property (weak, nonatomic) IBOutlet UILabel *topViewLeftName_4; @property (weak, nonatomic) IBOutlet UILabel *topViewRightName_4; @property (weak, nonatomic) IBOutlet UILabel *topViewValue_4; @property (weak, nonatomic) IBOutlet UIView *yesterdayTopView_5; @property (weak, nonatomic) IBOutlet UIImageView *topViewLeftHeader_5; @property (weak, nonatomic) IBOutlet UIImageView *topViewRightHeader_5; @property (weak, nonatomic) IBOutlet UILabel *topViewLeftName_5; @property (weak, nonatomic) IBOutlet UILabel *topViewRightName_5; @property (weak, nonatomic) IBOutlet UILabel *topViewValue_5; @property (nonatomic, strong) SVGAPlayer *player; @property (nonatomic, strong) SVGAParser *parser; @property (weak, nonatomic) IBOutlet UIView *svgaCover; @property (nonatomic, strong) NSMutableArray *lastDataArr; @end @implementation LMLovelsTableHeaderView - (void)awakeFromNib { [super awakeFromNib]; [self requestmotianLunLastWeekRank]; } - (void)requestmotianLunLastWeekRank { [BJHttpTool BJ_Get_motian_rankWithParameters:@{@"type":@"1"} success:^(id response) { self.lastDataArr = [LMLoveLsListModel mj_objectArrayWithKeyValuesArray:response[@"data"]]; [self setupYesterdayInfo]; } failure:^(NSError *error) { }]; } - (NSMutableArray *)lastDataArr { if (!_lastDataArr){ _lastDataArr = [NSMutableArray array]; } return _lastDataArr; } - (SVGAPlayer *)player { if (!_player) { _player = [[SVGAPlayer alloc] init]; _player.delegate = self; _player.loops = 0; _player.clearsAfterStop = YES; _player.contentMode = UIViewContentModeScaleAspectFit; _player.userInteractionEnabled = NO; } return _player; } - (void)onPlaySvgaWithUrl { //ui add if (self.player.superview) { [self.player removeFromSuperview]; } self.player.frame = self.svgaCover.bounds; [self.svgaCover addSubview:self.player]; __weak typeof(self) weakSelf = self; if (_parser == nil) { _parser = [[SVGAParser alloc] init]; } [_parser parseWithNamed:@"motianlunTX" inBundle:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) { if (videoItem) { weakSelf.player.videoItem = videoItem; [weakSelf.player startAnimation]; WEAK_SELF [weakSelf.fiveArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { LMLoveLsListModel *model = obj; [weakSelf.player setImageWithURL:URL(model.head_pic) forKey:[NSString stringWithFormat:@"img%ld",idx+1]]; [weakSelf.player setImageWithURL:URL(model.receive_head_pic) forKey:[NSString stringWithFormat:@"img%ld%ld",idx+1,idx+1]]; NSAttributedString *str_1 = [[NSAttributedString alloc] initWithString:model.nick_name attributes:@{NSFontAttributeName:YBBoldFont(13), NSForegroundColorAttributeName:kWhiteColor}]; [weakSelf.player setAttributedText:str_1 forKey:[NSString stringWithFormat:@"name%ld",idx+1]]; NSAttributedString *str_2 = [[NSAttributedString alloc] initWithString:model.receive_nick_name attributes:@{NSFontAttributeName:YBBoldFont(13), NSForegroundColorAttributeName:kWhiteColor}]; NSString *key2 = [NSString stringWithFormat:@"name%ld%ld",idx+1,idx+1]; [weakSelf.player setAttributedText:str_2 forKey:key2]; NSAttributedString *str_3 = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",model.rank_value] attributes:@{NSFontAttributeName:YBBoldFont(20), NSForegroundColorAttributeName:HEXCOLOR(0xFFF600)}]; [weakSelf.player setAttributedText:str_3 forKey:[NSString stringWithFormat:@"intimate%ld",idx+1]]; }]; } } failureBlock:^(NSError * _Nonnull error) { }]; // [_parser parseMemoryWithURL:[NSURL fileURLWithPath:url] Version:@"1" completionBlock:^(SVGAVideoEntity * _Nullable videoItem) { // if (videoItem) { // weakSelf.player.videoItem = videoItem; // [weakSelf.player startAnimation]; // //// if (name2.length > 0) { //// [weakSelf.player setImageWithURL:URL(tx1) forKey:@"tx1"]; //// NSAttributedString *str_1 = [[NSAttributedString alloc] initWithString:name1 attributes:@{NSFontAttributeName:YBBoldFont(24), NSForegroundColorAttributeName:kWhiteColor}]; //// [weakSelf.player setAttributedText:str_1 forKey:@"name1"]; //// //// [weakSelf.player setImageWithURL:URL(tx2) forKey:@"tx2"]; //// NSAttributedString *str_2 = [[NSAttributedString alloc] initWithString:name2 attributes:@{NSFontAttributeName:YBBoldFont(24), NSForegroundColorAttributeName:kWhiteColor}]; //// [weakSelf.player setAttributedText:str_2 forKey:@"name2"]; //// } // // } // } failureBlock:^(NSError * _Nullable error) { // if (error) { // [weakSelf.player removeFromSuperview]; // } // }]; } - (void)setupYesterdayInfo { WEAK_SELF [self.lastDataArr enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { LMLoveLsListModel *model = obj; if (idx == 0){ [weakSelf.topViewLeftHeader_1 sd_setImageWithURL:[NSURL URLWithString:model.head_pic] placeholderImage:kDefaultUserIcon]; [weakSelf.topViewRightHeader_1 sd_setImageWithURL:[NSURL URLWithString:model.receive_head_pic] placeholderImage:kDefaultUserIcon]; weakSelf.topViewLeftName_1.text = model.nick_name; weakSelf.topViewRightName_1.text = model.receive_nick_name; weakSelf.topViewValue_1.text = model.rank_value; }else if (idx == 1){ [weakSelf.topViewLeftHeader_2 sd_setImageWithURL:[NSURL URLWithString:model.head_pic] placeholderImage:kDefaultUserIcon]; [weakSelf.topViewRightHeader_2 sd_setImageWithURL:[NSURL URLWithString:model.receive_head_pic] placeholderImage:kDefaultUserIcon]; weakSelf.topViewLeftName_2.text = model.nick_name; weakSelf.topViewRightName_2.text = model.receive_nick_name; weakSelf.topViewValue_2.text = model.rank_value; }else if (idx == 2){ [weakSelf.topViewLeftHeader_3 sd_setImageWithURL:[NSURL URLWithString:model.head_pic] placeholderImage:kDefaultUserIcon]; [weakSelf.topViewRightHeader_3 sd_setImageWithURL:[NSURL URLWithString:model.receive_head_pic] placeholderImage:kDefaultUserIcon]; weakSelf.topViewLeftName_3.text = model.nick_name; weakSelf.topViewRightName_3.text = model.receive_nick_name; weakSelf.topViewValue_3.text = model.rank_value; }else if (idx == 3){ [weakSelf.topViewLeftHeader_4 sd_setImageWithURL:[NSURL URLWithString:model.head_pic] placeholderImage:kDefaultUserIcon]; [weakSelf.topViewRightHeader_4 sd_setImageWithURL:[NSURL URLWithString:model.receive_head_pic] placeholderImage:kDefaultUserIcon]; weakSelf.topViewLeftName_4.text = model.nick_name; weakSelf.topViewRightName_4.text = model.receive_nick_name; weakSelf.topViewValue_4.text = model.rank_value; }else if (idx == 4){ [weakSelf.topViewLeftHeader_5 sd_setImageWithURL:[NSURL URLWithString:model.head_pic] placeholderImage:kDefaultUserIcon]; [weakSelf.topViewRightHeader_5 sd_setImageWithURL:[NSURL URLWithString:model.receive_head_pic] placeholderImage:kDefaultUserIcon]; weakSelf.topViewLeftName_5.text = model.nick_name; weakSelf.topViewRightName_5.text = model.receive_nick_name; weakSelf.topViewValue_5.text = model.rank_value; } }]; } - (void)setFiveArr:(NSMutableArray *)fiveArr { _fiveArr = fiveArr; [self onPlaySvgaWithUrl]; } @end