| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081 |
- //
- // MORankTopView.m
- // MiMoLive
- //
- // Created by SuperC on 2023/11/30.
- //
- #import "MORankTopView.h"
- #import "MOEllipseUpView.h"
- #import "MOHeatRankData.h"
- @interface MORankTopView ()
- @property (nonatomic, strong) MOEllipseUpView *upBgView;
- @property (nonatomic, strong) UIButton *firstTotalBtn;
- @property (nonatomic, strong) UIButton *secondTotalBtn;
- @property (nonatomic, strong) UIButton *thirdTotalBtn;
- @property (nonatomic, strong) UILabel *countDownLab;
- @end
- @implementation MORankTopView
- + (instancetype)moRankTopView{
- return [[[NSBundle mainBundle] loadNibNamed:@"MORankTopView" owner:self options:nil] firstObject];
- }
- - (void)awakeFromNib{
- [super awakeFromNib];
-
- self.firstFollowBtn.hidden = YES;
- self.secondFollowBtn.hidden = YES;
- self.thirdFollowBtn.hidden = YES;
-
- //icon_mine_placeHolder
- self.firstHeadBtn.layer.cornerRadius = 48.0 / 2.0;
- self.firstHeadBtn.layer.masksToBounds = YES;
-
- self.secondHeadBtn.layer.cornerRadius = 48.0 / 2.0;
- self.secondHeadBtn.layer.masksToBounds = YES;
-
- self.thirdHeadBtn.layer.cornerRadius = 48.0 / 2.0;
- self.thirdHeadBtn.layer.masksToBounds = YES;
-
- CGFloat bgImgWidth = SCREENWIDTH - 30.0 * 2;
- CGFloat bgImgHeight = bgImgWidth * 532.0 / 636.0;
- self.rankBgImgHeight.constant = bgImgHeight;
-
- self.layer.masksToBounds = YES;
-
- UIImage *btnImage = [MOTools createImageWithColor:kBaseBtnBgColor];
- UIImage *grayImg = [MOTools createImageWithColor:[UIColor grayColor]];
-
- self.firstFollowBtn.layer.cornerRadius = 20.0 / 2;
- self.firstFollowBtn.layer.masksToBounds = YES;
- [self.firstFollowBtn setBackgroundImage:btnImage forState:UIControlStateNormal];
- [self.firstFollowBtn setBackgroundImage:grayImg forState:UIControlStateSelected];
-
- self.secondFollowBtn.layer.cornerRadius = 20.0 / 2;
- self.secondFollowBtn.layer.masksToBounds = YES;
- [self.secondFollowBtn setBackgroundImage:btnImage forState:UIControlStateNormal];
- [self.secondFollowBtn setBackgroundImage:grayImg forState:UIControlStateSelected];
-
- self.thirdFollowBtn.layer.cornerRadius = 20.0 / 2;
- self.thirdFollowBtn.layer.masksToBounds = YES;
- [self.thirdFollowBtn setBackgroundImage:btnImage forState:UIControlStateNormal];
- [self.thirdFollowBtn setBackgroundImage:grayImg forState:UIControlStateSelected];
-
- [self addSubview:self.upBgView];
- [self.upBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self);
- make.bottom.equalTo(self).offset(10.0);
- make.width.equalTo(@280.0);
- make.height.equalTo(@30.0);
- }];
-
- [self.firstFollowBtn setTitle:NSLocalString(@"mimo_room_user_info_follow") forState:UIControlStateNormal];
- [self.secondFollowBtn setTitle:NSLocalString(@"mimo_room_user_info_follow") forState:UIControlStateNormal];
- [self.thirdFollowBtn setTitle:NSLocalString(@"mimo_room_user_info_follow") forState:UIControlStateNormal];
-
- self.firstHeadBtn.imageView.contentMode = UIViewContentModeScaleAspectFill;
- self.secondHeadBtn.imageView.contentMode = UIViewContentModeScaleAspectFill;
- self.thirdHeadBtn.imageView.contentMode = UIViewContentModeScaleAspectFill;
-
- [self.firstView addSubview:self.firstTotalBtn];
- [self.firstTotalBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(self.firstView).offset(-28.0);
- make.left.equalTo(self.firstView).offset(5.0);
- make.right.equalTo(self.firstView).offset(-5.0);
- make.height.equalTo(@26.0);
- }];
- self.firstTotalBtn.hidden = YES;
-
- [self.secondView addSubview:self.secondTotalBtn];
- [self.secondTotalBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(self.secondView).offset(-28.0);
- make.left.equalTo(self.secondView).offset(5.0);
- make.right.equalTo(self.secondView).offset(-5.0);
- make.height.equalTo(@26.0);
- }];
- self.secondTotalBtn.hidden = YES;
-
- [self.thirdView addSubview:self.thirdTotalBtn];
- [self.thirdTotalBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(self.thirdView).offset(-28.0);
- make.left.equalTo(self.thirdView).offset(5.0);
- make.right.equalTo(self.thirdView).offset(-5.0);
- make.height.equalTo(@26.0);
- }];
- self.thirdTotalBtn.hidden = YES;
-
- [self.firstView insertSubview:self.firstHeadBgView belowSubview:self.rankFirstImg];
- [self.firstHeadBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.firstHeadBtn);
- make.centerY.equalTo(self.firstHeadBtn);
- make.width.height.equalTo(@48.0);
- }];
- self.firstHeadBgView.headImgWidth = 48.0;
-
- [self.secondView insertSubview:self.secondHeadBgView belowSubview:self.rankFirstImg];
- [self.secondHeadBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.secondHeadBtn);
- make.centerY.equalTo(self.secondHeadBtn);
- make.width.height.equalTo(@48.0);
- }];
- self.secondHeadBgView.headImgWidth = 48.0;
-
- [self.thirdView insertSubview:self.thirdHeadBgView belowSubview:self.rankFirstImg];
- [self.thirdHeadBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.thirdHeadBtn);
- make.centerY.equalTo(self.thirdHeadBtn);
- make.width.height.equalTo(@48.0);
- }];
- self.thirdHeadBgView.headImgWidth = 48.0;
-
- self.secondNameLab.font = [MOTextTools poppinsMediumFont:16];
- self.secondNameLab.textColor = kBaseTextColor_1;
- [self.secondFollowBtn setFont:[MOTextTools getTheFontWithSize:12.0 AndFontName:kNormalContentFontStr]];
-
- self.firstNameLab.font = [MOTextTools poppinsMediumFont:16];
- self.firstNameLab.textColor = kBaseTextColor_1;
- [self.firstFollowBtn setFont:[MOTextTools getTheFontWithSize:12.0 AndFontName:kNormalContentFontStr]];
-
- self.thirdNameLab.font = [MOTextTools poppinsMediumFont:16];
- self.thirdNameLab.textColor = kBaseTextColor_1;
- [self.thirdFollowBtn setFont:[MOTextTools getTheFontWithSize:12.0 AndFontName:kNormalContentFontStr]];
-
- // [self.firstGoldBtn setImage:[UIImage imageNamed:@"icon_rank_gold_bean"] forState:UIControlStateNormal];
- self.firstGoldBtn.titleLabel.font = [MOTextTools mediumFont:12];
- [self.firstGoldBtn setTitleColor:[MOTools colorWithHexString:@"#5C5E66"] forState:UIControlStateNormal];
-
- // [self.secondGoldBtn setImage:[UIImage imageNamed:@"icon_rank_gold_bean"] forState:UIControlStateNormal];
- self.secondGoldBtn.titleLabel.font = [MOTextTools mediumFont:12];
- [self.secondGoldBtn setTitleColor:[MOTools colorWithHexString:@"#5C5E66"] forState:UIControlStateNormal];
-
- // [self.thirdGoldBtn setImage:[UIImage imageNamed:@"icon_rank_gold_bean"] forState:UIControlStateNormal];
- self.thirdGoldBtn.titleLabel.font = [MOTextTools mediumFont:12];
- [self.thirdGoldBtn setTitleColor:[MOTools colorWithHexString:@"#5C5E66"] forState:UIControlStateNormal];
-
- self.firstViewHeight.constant = 140.0;
- self.secondViewHeight.constant = 140.0;
- self.thirdViewHeight.constant = 140.0;
-
- [self addSubview:self.countDownLab];
- [self.countDownLab mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.equalTo(@24.0);
- make.centerX.equalTo(self);
- make.width.equalTo(@166.0);
- make.bottom.equalTo(self.firstView.mas_top).offset(-4.0);
- }];
- self.countDownLab.hidden = YES;
- }
- - (void)setIsShowCountDownLab:(BOOL)isShowCountDownLab{
- _isShowCountDownLab = isShowCountDownLab;
-
- if(isShowCountDownLab){
- self.countDownLab.hidden = NO;
- }
- }
- - (void)layoutSubviews {
- [super layoutSubviews];
-
- self.firstView.layer.masksToBounds = YES;
- self.firstView.layer.cornerRadius = 8;
- [self setupGradientLayerWithView:self.firstView
- startColor:[MOTools colorWithHexString:@"#FFEC9E"]
- endColor:[MOTools colorWithHexString:@"#FFFFFF" alpha:1.0]
- layerName:@"gradientLayer"
- startPoint:(CGPoint) { 0.5, 0 }
- endPoint:(CGPoint){0.5, 1}];
-
- self.secondView.layer.masksToBounds = YES;
- self.secondView.layer.cornerRadius = 8;
- [self setupGradientLayerWithView:self.secondView
- startColor:[MOTools colorWithHexString:@"#E9DDFF"]
- endColor:[MOTools colorWithHexString:@"#FFFFFF" alpha:1.0]
- layerName:@"gradientLayer"
- startPoint:(CGPoint) { 0.5, 0 }
- endPoint:(CGPoint){0.5, 1}];
-
- self.thirdView.layer.masksToBounds = YES;
- self.thirdView.layer.cornerRadius = 8;
- [self setupGradientLayerWithView:self.thirdView
- startColor:[MOTools colorWithHexString:@"#FAEADD"]
- endColor:[MOTools colorWithHexString:@"#FFFFFF" alpha:1.0]
- layerName:@"gradientLayer"
- startPoint:(CGPoint) { 0.5, 0 }
- endPoint:(CGPoint){0.5, 1}];
- }
- - (void)setDataArr:(NSArray *)dataArr{
- _dataArr = dataArr;
-
- self.firstView.hidden = NO;
- self.secondView.hidden = NO;
- self.thirdView.hidden = NO;
-
- //每次都需要初始化
- [self.firstHeadBtn setImage:nil forState:UIControlStateNormal];
- self.firstNameLab.text = @"";
- self.firstFollowBtn.selected = NO;
- self.rankFirstImg.hidden = YES;
- self.firstGoldBtn.hidden = YES;
-
- [self.secondHeadBtn setImage:nil forState:UIControlStateNormal];
- self.secondNameLab.text = @"";
- self.secondFollowBtn.selected = NO;
- self.rankSecondImg.hidden = YES;
- self.secondGoldBtn.hidden = YES;
-
- [self.thirdHeadBtn setImage:nil forState:UIControlStateNormal];
- self.thirdNameLab.text = @"";
- self.thirdFollowBtn.selected = NO;
- self.rankThirdImg.hidden = YES;
- self.thirdGoldBtn.hidden = YES;
-
- self.firstHeadBgView.hidden = YES;
- self.secondHeadBgView.hidden = YES;
- self.thirdHeadBgView.hidden = YES;
-
- int x = 0;
- for (MORanklist *model in dataArr) {
-
- if(x == 0){
- if (!model.userBase.userProfile) {
- continue;
- }
- self.firstView.hidden = NO;
- [self.firstHeadBtn sd_setImageWithURL:[NSURL URLWithString:model.userBase.userProfile.avatar] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"icon_mine_placeHolder"]];
-
- if(model.userBase.remark.length > 0){
- self.firstNameLab.text = model.userBase.remark;
- }
- else{
- self.firstNameLab.text = model.userBase.userProfile.nickname;
- }
-
-
- self.firstFollowBtn.selected = model.userBase.follow;
- NSString *firstStr = [MOTextTools numberToStringWith:model.total];
- [self.firstTotalBtn setTitle:firstStr forState:UIControlStateNormal];
-
- if(model.userBase.liveRoomId.length > 0){
- self.firstHeadBgView.hidden = NO;
-
- self.firstHeadBgView.isLiving = YES;
- [self.firstHeadBgView updataViewStatus];
- self.firstHeadBgView.imgUrlStr = @"";
- }
- // else{
- // if(model.userBase.userProfile.adornment.headgearRes.length > 0){
- // self.firstHeadBgView.hidden = NO;
- // self.firstHeadBgView.isLiving = NO;
- // self.firstHeadBgView.effectType = model.userBase.userProfile.adornment.headgearType;
- // self.firstHeadBgView.imgUrlStr = model.userBase.userProfile.adornment.headgearRes;
- // }
- // else{
- // self.firstHeadBgView.hidden = YES;
- // }
- // }
-
- if(model.userBase.vipType == 0){
- ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- config.shimmerStyle = ShimmerStyleNone;
- self.firstNameLab.textColor = [MOTools colorWithHexString:@"#282828" alpha:1.0];
- [self.firstNameLab startShimmerWithConfig:config];
- }
- else{
- // if(model.userBase.vipType == 1 || model.userBase.vipType == 5 || model.userBase.vipType == 6){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleColorsFlow;
- // config.shimmerColorArray = VipNameColorArr_white_1;
- // config.shimmerSpeed = 20;
- // [self.firstNameLab startShimmerWithConfig:config];
- // }
- // else if (model.userBase.vipType == 2){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleColorsFlow;
- // config.shimmerColorArray = VipNameColorArr_white_2;
- // config.shimmerSpeed = 20;
- // [self.firstNameLab startShimmerWithConfig:config];
- // }
- // else if (model.userBase.vipType == 3){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleGradient;
- // config.shimmerColorArray = VipNameColorArr_3;
- // [self.firstNameLab startShimmerWithConfig:config];
- // }
- // else if (model.userBase.vipType == 4){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleNone;
- // self.firstNameLab.textColor = VipNameColor_White_4;
- // [self.firstNameLab startShimmerWithConfig:config];
- // }
- }
-
- NSString *goldNumStr = [MOTextTools numberToStringWith:model.total];
- [self.firstGoldBtn setTitle:goldNumStr forState:UIControlStateNormal];
- if (self.typeNum == 3) {//收入榜,隐藏关注,换成金豆
- [self.firstGoldBtn setImage:[UIImage imageNamed:@"icon_rank_gold_bean"] forState:UIControlStateNormal];
- } else if (self.typeNum == 2) {//探索-财富榜,显示关注,换成钻石
- [self.firstGoldBtn setImage:[UIImage imageNamed:@"icon_rank_zuan"] forState:UIControlStateNormal];
- } else if (self.typeNum == 1) {//房间贡献榜,隐藏关注,换成钻石
- [self.firstGoldBtn setImage:[UIImage imageNamed:@"icon_rank_zuan"] forState:UIControlStateNormal];
- } else {//pk
- [self.firstGoldBtn setImage:[UIImage imageNamed:@"icon_rank_pk"] forState:UIControlStateNormal];
- [self.firstGoldBtn setTitle:[NSString stringWithFormat:@"%.0f", model.winNum] forState:UIControlStateNormal];
- }
-
- self.firstGoldBtn.hidden = NO;
- self.rankFirstImg.hidden = NO;
- }
- else if (x == 1){
- if (!model.userBase.userProfile) {
- continue;
- }
- self.secondView.hidden = NO;
- [self.secondHeadBtn sd_setImageWithURL:[NSURL URLWithString:model.userBase.userProfile.avatar] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"icon_mine_placeHolder"]];
-
- if(model.userBase.remark.length > 0){
- self.secondNameLab.text = model.userBase.remark;
- }
- else{
- self.secondNameLab.text = model.userBase.userProfile.nickname;
- }
-
- self.secondFollowBtn.selected = model.userBase.follow;
- NSString *firstStr = [MOTextTools numberToStringWith:model.total];
- [self.secondTotalBtn setTitle:firstStr forState:UIControlStateNormal];
-
- if(model.userBase.liveRoomId.length > 0){
- self.secondHeadBgView.hidden = NO;
-
- self.secondHeadBgView.isLiving = YES;
- [self.secondHeadBgView updataViewStatus];
- self.secondHeadBgView.imgUrlStr = @"";
- }
- // else{
- // if(model.userBase.userProfile.adornment.headgearRes.length > 0){
- // self.secondHeadBgView.hidden = NO;
- // self.secondHeadBgView.isLiving = NO;
- // self.secondHeadBgView.effectType = model.userBase.userProfile.adornment.headgearType;
- // self.secondHeadBgView.imgUrlStr = model.userBase.userProfile.adornment.headgearRes;
- // }
- // else{
- // self.secondHeadBgView.hidden = YES;
- // }
- // }
-
- if(model.userBase.vipType == 0){
- ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- config.shimmerStyle = ShimmerStyleNone;
- self.secondNameLab.textColor = [MOTools colorWithHexString:@"#282828" alpha:1.0];
- [self.secondNameLab startShimmerWithConfig:config];
- }
- else{
- // if(model.userBase.vipType == 1 || model.userBase.vipType == 5 || model.userBase.vipType == 6){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleColorsFlow;
- // config.shimmerColorArray = VipNameColorArr_white_1;
- // config.shimmerSpeed = 20;
- // [self.secondNameLab startShimmerWithConfig:config];
- // }
- // else if (model.userBase.vipType == 2){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleColorsFlow;
- // config.shimmerColorArray = VipNameColorArr_white_2;
- // config.shimmerSpeed = 20;
- // [self.secondNameLab startShimmerWithConfig:config];
- // }
- // else if (model.userBase.vipType == 3){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleGradient;
- // config.shimmerColorArray = VipNameColorArr_3;
- // [self.secondNameLab startShimmerWithConfig:config];
- // }
- // else if (model.userBase.vipType == 4){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleNone;
- // self.secondNameLab.textColor = VipNameColor_White_4;
- // [self.secondNameLab startShimmerWithConfig:config];
- // }
- }
-
- NSString *goldNumStr = [MOTextTools numberToStringWith:model.total];
- [self.secondGoldBtn setTitle:goldNumStr forState:UIControlStateNormal];
- if (self.typeNum == 3) {//收入榜,隐藏关注,换成金豆
- [self.secondGoldBtn setImage:[UIImage imageNamed:@"icon_rank_gold_bean"] forState:UIControlStateNormal];
- } else if (self.typeNum == 2) {//探索-财富榜,显示关注,换成钻石
- [self.secondGoldBtn setImage:[UIImage imageNamed:@"icon_rank_zuan"] forState:UIControlStateNormal];
- } else if (self.typeNum == 1) {//房间贡献榜,隐藏关注,换成钻石
- [self.secondGoldBtn setImage:[UIImage imageNamed:@"icon_rank_zuan"] forState:UIControlStateNormal];
- } else {//pk
- [self.secondGoldBtn setImage:[UIImage imageNamed:@"icon_rank_pk"] forState:UIControlStateNormal];
- [self.secondGoldBtn setTitle:[NSString stringWithFormat:@"%.0f", model.winNum] forState:UIControlStateNormal];
- }
-
- self.secondGoldBtn.hidden = NO;
- self.rankSecondImg.hidden = NO;
- }
- else if (x == 2){
- if (!model.userBase.userProfile) {
- continue;
- }
- self.thirdView.hidden = NO;
- [self.thirdHeadBtn sd_setImageWithURL:[NSURL URLWithString:model.userBase.userProfile.avatar] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"icon_mine_placeHolder"]];
- if(model.userBase.remark.length > 0){
- self.thirdNameLab.text = model.userBase.remark;
- }
- else{
- self.thirdNameLab.text = model.userBase.userProfile.nickname;
- }
-
-
- self.thirdFollowBtn.selected = model.userBase.follow;
- NSString *firstStr = [MOTextTools numberToStringWith:model.total];
- [self.thirdTotalBtn setTitle:firstStr forState:UIControlStateNormal];
-
- if(model.userBase.liveRoomId.length > 0){
- self.thirdHeadBgView.hidden = NO;
-
- self.thirdHeadBgView.isLiving = YES;
- [self.thirdHeadBgView updataViewStatus];
- self.thirdHeadBgView.imgUrlStr = @"";
- }
- // else{
- // if(model.userBase.userProfile.adornment.headgearRes.length > 0){
- // self.thirdHeadBgView.hidden = NO;
- // self.thirdHeadBgView.isLiving = NO;
- // self.thirdHeadBgView.effectType = model.userBase.userProfile.adornment.headgearType;
- // self.thirdHeadBgView.imgUrlStr = model.userBase.userProfile.adornment.headgearRes;
- // }
- // else{
- // self.thirdHeadBgView.hidden = YES;
- // }
- // }
-
- if(model.userBase.vipType == 0){
- ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- config.shimmerStyle = ShimmerStyleNone;
- self.thirdNameLab.textColor = [MOTools colorWithHexString:@"#282828" alpha:1.0];
- [self.thirdNameLab startShimmerWithConfig:config];
- }
- else{
- // if(model.userBase.vipType == 1 || model.userBase.vipType== 5 || model.userBase.vipType == 6){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleColorsFlow;
- // config.shimmerColorArray = VipNameColorArr_white_1;
- // config.shimmerSpeed = 20;
- // [self.thirdNameLab startShimmerWithConfig:config];
- // }
- // else if (model.userBase.vipType == 2){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleColorsFlow;
- // config.shimmerColorArray = VipNameColorArr_white_2;
- // config.shimmerSpeed = 20;
- // [self.thirdNameLab startShimmerWithConfig:config];
- // }
- // else if (model.userBase.vipType == 3){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleGradient;
- // config.shimmerColorArray = VipNameColorArr_3;
- // [self.thirdNameLab startShimmerWithConfig:config];
- // }
- // else if (model.userBase.vipType == 4){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleNone;
- // self.thirdNameLab.textColor = VipNameColor_White_4;
- // [self.thirdNameLab startShimmerWithConfig:config];
- // }
- }
- NSString *goldNumStr = [MOTextTools numberToStringWith:model.total];
- [self.thirdGoldBtn setTitle:goldNumStr forState:UIControlStateNormal];
- if (self.typeNum == 3) {//收入榜,隐藏关注,换成金豆
- [self.thirdGoldBtn setImage:[UIImage imageNamed:@"icon_rank_gold_bean"] forState:UIControlStateNormal];
- } else if (self.typeNum == 2) {//探索-财富榜,显示关注,换成钻石
- [self.thirdGoldBtn setImage:[UIImage imageNamed:@"icon_rank_zuan"] forState:UIControlStateNormal];
- } else if (self.typeNum == 1) {//房间贡献榜,隐藏关注,换成钻石
- [self.thirdGoldBtn setImage:[UIImage imageNamed:@"icon_rank_zuan"] forState:UIControlStateNormal];
- } else {//pk
- [self.thirdGoldBtn setImage:[UIImage imageNamed:@"icon_rank_pk"] forState:UIControlStateNormal];
- [self.thirdGoldBtn setTitle:[NSString stringWithFormat:@"%.0f", model.winNum] forState:UIControlStateNormal];
- }
-
- self.thirdGoldBtn.hidden = NO;
- self.rankThirdImg.hidden = NO;
- }
-
- x++;
- }
-
- [self.firstView bringSubviewToFront:self.rankFirstImg];
- [self.secondView bringSubviewToFront:self.rankSecondImg];
- [self.thirdView bringSubviewToFront:self.rankThirdImg];
- }
- - (void)setHeatDataArr:(NSArray<MOHeatRankItem *> *)heatDataArr {
- _heatDataArr = heatDataArr;
-
- self.firstView.hidden = NO;
- self.secondView.hidden = NO;
- self.thirdView.hidden = NO;
-
- //每次都需要初始化
- [self.firstHeadBtn setImage:nil forState:UIControlStateNormal];
- self.firstNameLab.text = @"";
- self.firstFollowBtn.selected = NO;
- self.rankFirstImg.hidden = YES;
- self.firstGoldBtn.hidden = YES;
-
- [self.secondHeadBtn setImage:nil forState:UIControlStateNormal];
- self.secondNameLab.text = @"";
- self.secondFollowBtn.selected = NO;
- self.rankSecondImg.hidden = YES;
- self.secondGoldBtn.hidden = YES;
-
- [self.thirdHeadBtn setImage:nil forState:UIControlStateNormal];
- self.thirdNameLab.text = @"";
- self.thirdFollowBtn.selected = NO;
- self.rankThirdImg.hidden = YES;
- self.thirdGoldBtn.hidden = YES;
-
- self.firstHeadBgView.hidden = YES;
- self.secondHeadBgView.hidden = YES;
- self.thirdHeadBgView.hidden = YES;
-
- int x = 0;
- for (MOHeatRankItem *model in heatDataArr) {
-
- if(x == 0){
- if (!model.user.userProfile) {
- continue;
- }
- self.firstView.hidden = NO;
- [self.firstHeadBtn sd_setImageWithURL:[NSURL URLWithString:model.user.userProfile.avatar] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"icon_mine_placeHolder"]];
-
- if(model.user.remark.length > 0){
- self.firstNameLab.text = model.user.remark;
- }
- else{
- self.firstNameLab.text = model.user.userProfile.nickname;
- }
-
-
- self.firstFollowBtn.selected = model.user.follow;
- NSString *firstStr = [MOTextTools numberToStringWith:model.heat];
- [self.firstTotalBtn setTitle:firstStr forState:UIControlStateNormal];
-
- if(model.user.liveRoomId.length > 0){
- self.firstHeadBgView.hidden = NO;
-
- self.firstHeadBgView.isLiving = YES;
- [self.firstHeadBgView updataViewStatus];
- self.firstHeadBgView.imgUrlStr = @"";
- }
- // else{
- // if(model.user.userProfile.adornment.headgearRes.length > 0){
- // self.firstHeadBgView.hidden = NO;
- // self.firstHeadBgView.isLiving = NO;
- // self.firstHeadBgView.effectType = model.user.userProfile.adornment.headgearType;
- // self.firstHeadBgView.imgUrlStr = model.user.userProfile.adornment.headgearRes;
- // }
- // else{
- // self.firstHeadBgView.hidden = YES;
- // }
- // }
-
- if(model.user.vipType == 0){
- ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- config.shimmerStyle = ShimmerStyleNone;
- self.firstNameLab.textColor = [MOTools colorWithHexString:@"#282828" alpha:1.0];
- [self.firstNameLab startShimmerWithConfig:config];
- }
- else{
- // if(model.userBase.vipType == 1 || model.userBase.vipType == 5 || model.userBase.vipType == 6){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleColorsFlow;
- // config.shimmerColorArray = VipNameColorArr_white_1;
- // config.shimmerSpeed = 20;
- // [self.firstNameLab startShimmerWithConfig:config];
- // }
- // else if (model.userBase.vipType == 2){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleColorsFlow;
- // config.shimmerColorArray = VipNameColorArr_white_2;
- // config.shimmerSpeed = 20;
- // [self.firstNameLab startShimmerWithConfig:config];
- // }
- // else if (model.userBase.vipType == 3){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleGradient;
- // config.shimmerColorArray = VipNameColorArr_3;
- // [self.firstNameLab startShimmerWithConfig:config];
- // }
- // else if (model.userBase.vipType == 4){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleNone;
- // self.firstNameLab.textColor = VipNameColor_White_4;
- // [self.firstNameLab startShimmerWithConfig:config];
- // }
- }
-
- NSString *goldNumStr = [MOTextTools numberToStringAboutTwoWith:model.heat];
- [self.firstGoldBtn setImage:[UIImage imageNamed:@"icon_rank_heat"] forState:UIControlStateNormal];
- [self.firstGoldBtn setTitle:goldNumStr forState:UIControlStateNormal];
- self.firstGoldBtn.titleLabel.font = [MOTextTools semiboldFont:12];
- [self.firstGoldBtn setTitleColor:[MOTools colorWithHexString:@"#F23051"] forState:UIControlStateNormal];
- self.firstGoldBtn.hidden = NO;
- self.rankFirstImg.hidden = NO;
- }
- else if (x == 1){
- if (!model.user.userProfile) {
- continue;
- }
- self.secondView.hidden = NO;
- [self.secondHeadBtn sd_setImageWithURL:[NSURL URLWithString:model.user.userProfile.avatar] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"icon_mine_placeHolder"]];
-
- if(model.user.remark.length > 0){
- self.secondNameLab.text = model.user.remark;
- }
- else{
- self.secondNameLab.text = model.user.userProfile.nickname;
- }
-
- self.secondFollowBtn.selected = model.user.follow;
- NSString *firstStr = [MOTextTools numberToStringWith:model.heat];
- [self.secondTotalBtn setTitle:firstStr forState:UIControlStateNormal];
-
- if(model.user.liveRoomId.length > 0){
- self.secondHeadBgView.hidden = NO;
-
- self.secondHeadBgView.isLiving = YES;
- [self.secondHeadBgView updataViewStatus];
- self.secondHeadBgView.imgUrlStr = @"";
- }
- // else{
- // if(model.user.userProfile.adornment.headgearRes.length > 0){
- // self.secondHeadBgView.hidden = NO;
- // self.secondHeadBgView.isLiving = NO;
- // self.secondHeadBgView.effectType = model.user.userProfile.adornment.headgearType;
- // self.secondHeadBgView.imgUrlStr = model.user.userProfile.adornment.headgearRes;
- // }
- // else{
- // self.secondHeadBgView.hidden = YES;
- // }
- // }
-
- if(model.user.vipType == 0){
- ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- config.shimmerStyle = ShimmerStyleNone;
- self.secondNameLab.textColor = [MOTools colorWithHexString:@"#282828" alpha:1.0];
- [self.secondNameLab startShimmerWithConfig:config];
- }
- else{
- // if(model.userBase.vipType == 1 || model.userBase.vipType == 5 || model.userBase.vipType == 6){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleColorsFlow;
- // config.shimmerColorArray = VipNameColorArr_white_1;
- // config.shimmerSpeed = 20;
- // [self.secondNameLab startShimmerWithConfig:config];
- // }
- // else if (model.userBase.vipType == 2){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleColorsFlow;
- // config.shimmerColorArray = VipNameColorArr_white_2;
- // config.shimmerSpeed = 20;
- // [self.secondNameLab startShimmerWithConfig:config];
- // }
- // else if (model.userBase.vipType == 3){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleGradient;
- // config.shimmerColorArray = VipNameColorArr_3;
- // [self.secondNameLab startShimmerWithConfig:config];
- // }
- // else if (model.userBase.vipType == 4){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleNone;
- // self.secondNameLab.textColor = VipNameColor_White_4;
- // [self.secondNameLab startShimmerWithConfig:config];
- // }
- }
-
- NSString *goldNumStr = [MOTextTools numberToStringAboutTwoWith:model.heat];
- [self.secondGoldBtn setImage:[UIImage imageNamed:@"icon_rank_heat"] forState:UIControlStateNormal];
- [self.secondGoldBtn setTitle:goldNumStr forState:UIControlStateNormal];
- self.secondGoldBtn.titleLabel.font = [MOTextTools semiboldFont:12];
- [self.secondGoldBtn setTitleColor:[MOTools colorWithHexString:@"#F23051"] forState:UIControlStateNormal];
- self.secondGoldBtn.hidden = NO;
- self.rankSecondImg.hidden = NO;
- }
- else if (x == 2){
- if (!model.user.userProfile) {
- continue;
- }
- self.thirdView.hidden = NO;
- [self.thirdHeadBtn sd_setImageWithURL:[NSURL URLWithString:model.user.userProfile.avatar] forState:UIControlStateNormal placeholderImage:[UIImage imageNamed:@"icon_mine_placeHolder"]];
- if(model.user.remark.length > 0){
- self.thirdNameLab.text = model.user.remark;
- }
- else{
- self.thirdNameLab.text = model.user.userProfile.nickname;
- }
-
-
- self.thirdFollowBtn.selected = model.user.follow;
- NSString *firstStr = [MOTextTools numberToStringWith:model.heat];
- [self.thirdTotalBtn setTitle:firstStr forState:UIControlStateNormal];
-
- if(model.user.liveRoomId.length > 0){
- self.thirdHeadBgView.hidden = NO;
-
- self.thirdHeadBgView.isLiving = YES;
- [self.thirdHeadBgView updataViewStatus];
- self.thirdHeadBgView.imgUrlStr = @"";
- }
- // else{
- // if(model.user.userProfile.adornment.headgearRes.length > 0){
- // self.thirdHeadBgView.hidden = NO;
- // self.thirdHeadBgView.isLiving = NO;
- // self.thirdHeadBgView.effectType = model.user.userProfile.adornment.headgearType;
- // self.thirdHeadBgView.imgUrlStr = model.user.userProfile.adornment.headgearRes;
- // }
- // else{
- // self.thirdHeadBgView.hidden = YES;
- // }
- // }
-
- if(model.user.vipType == 0){
- ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- config.shimmerStyle = ShimmerStyleNone;
- self.thirdNameLab.textColor = [MOTools colorWithHexString:@"#282828" alpha:1.0];
- [self.thirdNameLab startShimmerWithConfig:config];
- }
- else{
- // if(model.userBase.vipType == 1 || model.userBase.vipType== 5 || model.userBase.vipType == 6){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleColorsFlow;
- // config.shimmerColorArray = VipNameColorArr_white_1;
- // config.shimmerSpeed = 20;
- // [self.thirdNameLab startShimmerWithConfig:config];
- // }
- // else if (model.userBase.vipType == 2){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleColorsFlow;
- // config.shimmerColorArray = VipNameColorArr_white_2;
- // config.shimmerSpeed = 20;
- // [self.thirdNameLab startShimmerWithConfig:config];
- // }
- // else if (model.userBase.vipType == 3){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleGradient;
- // config.shimmerColorArray = VipNameColorArr_3;
- // [self.thirdNameLab startShimmerWithConfig:config];
- // }
- // else if (model.userBase.vipType == 4){
- // ShimmerLabelConfig *config = [[ShimmerLabelConfig alloc] init];
- // config.shimmerStyle = ShimmerStyleNone;
- // self.thirdNameLab.textColor = VipNameColor_White_4;
- // [self.thirdNameLab startShimmerWithConfig:config];
- // }
- }
- NSString *goldNumStr = [MOTextTools numberToStringAboutTwoWith:model.heat];
- [self.thirdGoldBtn setImage:[UIImage imageNamed:@"icon_rank_heat"] forState:UIControlStateNormal];
- [self.thirdGoldBtn setTitle:goldNumStr forState:UIControlStateNormal];
- self.thirdGoldBtn.titleLabel.font = [MOTextTools semiboldFont:12];
- [self.thirdGoldBtn setTitleColor:[MOTools colorWithHexString:@"#F23051"] forState:UIControlStateNormal];
- self.thirdGoldBtn.hidden = NO;
- self.rankThirdImg.hidden = NO;
- }
-
- x++;
- }
-
- [self.firstView bringSubviewToFront:self.rankFirstImg];
- [self.secondView bringSubviewToFront:self.rankSecondImg];
- [self.thirdView bringSubviewToFront:self.rankThirdImg];
- }
- + (CGFloat)theViewHeight{
- CGFloat height = 160.0;
- return height;
- }
- + (CGFloat)theLiveRoomViewHeight{
- CGFloat height = 133.0 + 128.0 + 5.0 + 26.0;
- return height;
- }
- - (IBAction)headBtnClick:(UIButton *)sender {
-
- if(self.dataArr.count == 0 && self.heatDataArr == 0){//heatDataArr有值代表当前是在热度榜
- return;
- }
-
- if(sender == self.firstHeadBtn){
- if (self.dataArr.count > 0) {
- MORanklist *model = self.dataArr.firstObject;
- self.headBtnClickBlock ? self.headBtnClickBlock(model.userBase) : nil;
- } else {
- MOHeatRankItem *model = self.heatDataArr.firstObject;
- self.headBtnClickBlock ? self.headBtnClickBlock(model.user) : nil;
- }
- }
- else if (sender == self.secondHeadBtn){
- if(self.dataArr.count <= 1 && self.heatDataArr.count <= 1){
- return;
- }
-
- if (self.dataArr.count > 0) {
- MORanklist *model = self.dataArr[1];
- self.headBtnClickBlock ? self.headBtnClickBlock(model.userBase) : nil;
- } else {
- MOHeatRankItem *model = self.heatDataArr[1];
- self.headBtnClickBlock ? self.headBtnClickBlock(model.user) : nil;
- }
- }
- else{
- if(self.dataArr.count <= 2 && self.heatDataArr.count <= 2){
- return;
- }
-
- if (self.dataArr.count > 0) {
- MORanklist *model = self.dataArr[2];
- self.headBtnClickBlock ? self.headBtnClickBlock(model.userBase) : nil;
- } else {
- MOHeatRankItem *model = self.heatDataArr[2];
- self.headBtnClickBlock ? self.headBtnClickBlock(model.user) : nil;
- }
- }
- }
- - (IBAction)firstFollowBtnClick:(id)sender {
- UIButton *btn = (UIButton *)sender;
- if(btn.selected){
- return;
- }
- else{
- if(self.dataArr.count >= 1){
- MORanklist *ranklist = self.dataArr[0];
- [self followSomeOneWith:ranklist.userBase.userProfile.id AndIndex:0];
- }
- }
- }
- - (IBAction)secondFollowBtnClick:(id)sender {
- UIButton *btn = (UIButton *)sender;
- if(btn.selected){
- return;
- }
- else{
- if(self.dataArr.count >= 2){
- MORanklist *ranklist = self.dataArr[1];
- [self followSomeOneWith:ranklist.userBase.userProfile.id AndIndex:1];
- }
- }
- }
- - (IBAction)thirdFollowBtnClick:(id)sender {
- UIButton *btn = (UIButton *)sender;
- if(btn.selected){
- return;
- }
- else{
- if(self.dataArr.count >= 3){
- MORanklist *ranklist = self.dataArr[2];
- [self followSomeOneWith:ranklist.userBase.userProfile.id AndIndex:2];
- }
- }
- }
- - (void)followSomeOneWith:(NSString *)targetId AndIndex:(NSInteger)index{
- WEAKSELF
-
- if(targetId.length == 0){
- return;
- }
-
- if([targetId isEqualToString:GetUserId]){
- [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_common_cannot_to_yourself")];
- return;
- }
-
- NSArray *targetArr = @[targetId];
-
- NSDictionary *dict;
-
- if(self.roomId.length > 0){
- dict = @{@"type":@"1",
- @"target":targetArr,
- @"roomId":self.roomId};
- }
- else{
- dict = @{@"type":@"1",
- @"target":targetArr};
- }
-
- [kHttpManager toSubmitForFollowWithParams:dict andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
- if(kCode_Success){
-
- [MBProgressHUD showTipMessageInWindow:NSLocalString(@"mimo_Tip_Follow_Success")];
-
- if(weakSelf.dataArr.count >= index){
- MORanklist *model = weakSelf.dataArr[index];
- model.userBase.follow = YES;
-
- //刷新数据
- weakSelf.dataArr = weakSelf.dataArr;
- weakSelf.followSomeOneBlock ? weakSelf.followSomeOneBlock(model) : nil;
- }
- }
- else{
- kShowNetError(data)
- }
- }];
- }
- - (MOEllipseUpView *)upBgView{
- if(!_upBgView){
- _upBgView = [[MOEllipseUpView alloc] initWithFrame:CGRectMake(0.0, 0.0, 280.0, 30.0)];
- _upBgView.backgroundColor = [UIColor whiteColor];
- _upBgView.hidden = YES;
- }
-
- return _upBgView;
- }
- - (UIButton *)firstTotalBtn{
- if(!_firstTotalBtn){
- _firstTotalBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _firstTotalBtn.backgroundColor = [UIColor clearColor];
- [_firstTotalBtn setImage:[UIImage imageNamed:@"icon_live_golder_bean"] forState:UIControlStateNormal];
- [_firstTotalBtn setTitle:@"0" forState:UIControlStateNormal];
- _firstTotalBtn.titleLabel.font = [UIFont systemFontOfSize:14.0];
- _firstTotalBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 3.0, 0, 0);
- [_firstTotalBtn setTitleColor:[MOTools colorWithHexString:@"#333333" alpha:1.0] forState:UIControlStateNormal];
- _firstTotalBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
- }
- return _firstTotalBtn;
- }
- - (UIButton *)secondTotalBtn{
- if(!_secondTotalBtn){
- _secondTotalBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _secondTotalBtn.backgroundColor = [UIColor clearColor];
- [_secondTotalBtn setImage:[UIImage imageNamed:@"icon_live_golder_bean"] forState:UIControlStateNormal];
- [_secondTotalBtn setTitle:@"0" forState:UIControlStateNormal];
- _secondTotalBtn.titleLabel.font = [UIFont systemFontOfSize:14.0];
- _secondTotalBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 3.0, 0, 0);
- [_secondTotalBtn setTitleColor:[MOTools colorWithHexString:@"#333333" alpha:1.0] forState:UIControlStateNormal];
- _secondTotalBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
- }
- return _secondTotalBtn;
- }
- - (UIButton *)thirdTotalBtn{
- if(!_thirdTotalBtn){
- _thirdTotalBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _thirdTotalBtn.backgroundColor = [UIColor clearColor];
- [_thirdTotalBtn setImage:[UIImage imageNamed:@"icon_live_golder_bean"] forState:UIControlStateNormal];
- [_thirdTotalBtn setTitle:@"0" forState:UIControlStateNormal];
- _thirdTotalBtn.titleLabel.font = [UIFont systemFontOfSize:14.0];
- _thirdTotalBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 3.0, 0, 0);
- [_thirdTotalBtn setTitleColor:[MOTools colorWithHexString:@"#333333" alpha:1.0] forState:UIControlStateNormal];
- _thirdTotalBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
- }
- return _thirdTotalBtn;
- }
- - (MOHeadCustomView *)firstHeadBgView{
- if(!_firstHeadBgView){
- _firstHeadBgView = [[MOHeadCustomView alloc] init];
- }
- return _firstHeadBgView;
- }
- - (MOHeadCustomView *)secondHeadBgView{
- if(!_secondHeadBgView){
- _secondHeadBgView = [[MOHeadCustomView alloc] init];
- }
- return _secondHeadBgView;
- }
- - (MOHeadCustomView *)thirdHeadBgView{
- if(!_thirdHeadBgView){
- _thirdHeadBgView = [[MOHeadCustomView alloc] init];
- }
- return _thirdHeadBgView;
- }
- - (UILabel *)countDownLab{
- if(!_countDownLab){
- _countDownLab = [[UILabel alloc] init];
- _countDownLab.backgroundColor = [MOTools colorWithHexString:@"#F3F4FA" alpha:1.0];
- _countDownLab.layer.cornerRadius = 12.0;
- _countDownLab.layer.masksToBounds = YES;
- _countDownLab.textColor = [MOTools colorWithHexString:@"#5C5E66" alpha:1.0];
- _countDownLab.font = [MOTextTools poppinsMediumFont:12.0];
- _countDownLab.text = @"Countdown: 00d 00h 00m";
- _countDownLab.textAlignment = NSTextAlignmentCenter;
- }
- return _countDownLab;
- }
- - (void)setEndTime:(double)endTime{
- _endTime = endTime;
-
- if(endTime <= 0){
- return;
- }
-
- [self toUpdateTheCountDownLab];
- }
- - (void)toUpdateTheCountDownLab{
- if(self.endTime <= 0){
- return;
- }
-
- NSTimeInterval currentTime = [[NSDate date] timeIntervalSince1970];
- NSTimeInterval interval = self.endTime / 1000.0 - currentTime;
-
- NSDateComponents *components = [[NSCalendar currentCalendar]
- components:(NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond)
- fromDate:[NSDate dateWithTimeIntervalSince1970:0]
- toDate:[NSDate dateWithTimeIntervalSince1970:interval]
- options:0];
-
- if(interval > 0){
-
- NSString *result = [NSString stringWithFormat:@"%02ldm %02lds",
- (long)components.minute,
- (long)components.second];
-
- NSString *timeStr = [NSString stringWithFormat:NSLocalString(@"C60011"),result];
-
- //富文本 宽度
- NSAttributedString *contentStr = [MOTextTools base_colorObjectStringWith:timeStr AndNameStr:result AndBaseColor:kBaseTextColor_2 AndNameColor:kBaseTextColor_1];
- self.countDownLab.attributedText = contentStr;
-
- CGFloat labWidth = [MOTools getWidthWithString:timeStr font:[MOTextTools poppinsMediumFont:12.0]] + 20.0;
- [self.countDownLab mas_updateConstraints:^(MASConstraintMaker *make) {
- make.width.equalTo(@(labWidth));
- }];
- }
- else{
- self.timeEndBlock ? self.timeEndBlock() : nil;
- }
- }
- - (void)oneSecondPassed{
- [self toUpdateTheCountDownLab];
- }
- @end
|