cdts/xdts-ios 3/TreeHole/CYHResetCode/Home(首页)/View/THBottleInfoCardContainerView.m
2023-07-27 09:20:00 +08:00

344 lines
13 KiB
Objective-C

//
// THBottleInfoCardContainerView.m
// TreeHole
//
// Created by iOS on 2023/2/9.
// Copyright © 2023 CYH. All rights reserved.
//
#import "THBottleInfoCardContainerView.h"
#import "THBottleInfoCardContentView.h"
#import "THBottleInfoBuyVipView.h"
@interface THBottleInfoCardContainerView ()
@property(nonatomic, strong)UIImageView *bgImgView;
@property(nonatomic, strong)UILabel *titleLb;
@property(nonatomic, strong)UIImageView *userTagView;
@property(nonatomic, strong)UILabel *nickLb;
@property(nonatomic, strong)UIButton *reportBtn;
@property(nonatomic, strong)THBottleInfoCardContentView *contentView;
@property(nonatomic, strong)UILabel *timeLb;
@property(nonatomic, strong)CALayer *spaceLineLayer;
@property(nonatomic, strong)QMUITextView *replyTextView;
@property(nonatomic, strong)UILabel *replyTipLb;
@property(nonatomic, strong)UIView *bottomToolView;
@property(nonatomic, strong)UIButton *addHotBtn;
@property(nonatomic, strong)UIButton *nextBtn;
@property(nonatomic, strong)QMUIButton *interactBtn;
//管理员
///审核状态
@property(nonatomic, strong)UILabel *auditStateLb;
///标为good瓶
@property(nonatomic, strong)UIButton *setGoodBottleBtn;
///被回应了?次--->在contentView中显示
//@property(nonatomic, strong)UILabel *<#name#>;
///审核工具条
@property(nonatomic, strong)QMUIFloatLayoutView *managerToolView;
///关闭按钮---弹框时才需要显示
@property(nonatomic, strong)UIButton *closeBtn;
@property(nonatomic, strong)THBottleInfoBuyVipView *buyVipView;
@end
@implementation THBottleInfoCardContainerView
- (void)setInfoModel:(THBottleInfoModel *)infoModel {
_infoModel = infoModel;
//普通用户
self.buyVipView.hidden = YES;
self.managerToolView.hidden = YES;
self.bottomToolView.hidden = NO;
self.addHotBtn.hidden = NO;
self.setGoodBottleBtn.hidden = YES;
self.closeBtn.hidden = YES;
//fill数据
self.titleLb.text = infoModel.bottle_type_name;
self.userTagView.image = infoModel.TH_genderImg;
self.nickLb.text = infoModel.user_des;
self.contentView.bottleType = infoModel.TH_bottleType;
self.contentView.contentText = infoModel.content;
self.contentView.imgs = infoModel.images;
// self.contentView.voiceUrl = ?
//管理员这里显示不同,管理员可点击
self.timeLb.text = THNetworkInterfaceService.isManager ? infoModel.user_des : infoModel.bottle_create_time;
self.replyTipLb.hidden = YES;
self.replyTextView.hidden = NO;
self.replyTextView.placeholder = infoModel.block_see_tips ?: @"输入你想对Ta说的话";
self.replyTipLb.text = infoModel.block_see_tips;
// self.buyVipView fillData
[self.buyVipView setVipDesc:infoModel.vip_des buyTip:infoModel.vip_promotion_des];
//setUIHidden
self.replyTextView.hidden = YES;
self.replyTipLb.hidden = NO;
NSString *interactBtnTitle = @"回应";
if ([THNetworkInterfaceService isExchangeBottleType:infoModel.TH_bottleType]) {
//交换类型
if (infoModel.TH_bottleType == THBottleType_Exchange_SecretText) {
//交换秘密
self.replyTextView.hidden = NO;
self.replyTipLb.hidden = YES;
}
interactBtnTitle = @"交换";
}
[self.interactBtn setTitle:interactBtnTitle forState:UIControlStateNormal];
if (infoModel.TH_bottleType == THBottleType_TextAndPicture) {
//写真
self.contentView.imgIsSee = !infoModel.need_vip;
}
if (infoModel.TH_bottleType == THBottleType_Exchange_Picture) {
//交换图片-->是否已经交换
// self.contentView.imgIsSee = !infoModel.need_vip;
}
if (THNetworkInterfaceService.isManager) {
//管理员
self.buyVipView.hidden = YES;
self.managerToolView.hidden = NO;
self.bottomToolView.hidden = NO;
self.addHotBtn.hidden = YES;
self.setGoodBottleBtn.hidden = NO;
self.contentView.imgIsSee = YES;
[self setNeedsLayout];
return;
}
if (infoModel.need_vip) {
//需要VIP
self.buyVipView.hidden = NO;
self.managerToolView.hidden = YES;
self.bottomToolView.hidden = YES;
self.addHotBtn.hidden = YES;
self.setGoodBottleBtn.hidden = YES;
self.replyTipLb.hidden = YES;
self.replyTextView.hidden = YES;
[self setNeedsLayout];
return;
}
[self setNeedsLayout];
}
- (void)setupSubViews {
UIColor *whiteColor_65 = UIColorMakeWhiteAlpha(0.65);
_bgImgView = [UIImageView creatViewInSuperView:self];
_bgImgView.image = UIImageMake(@"TH_bottleInfoCardBg");
_titleLb = [UILabel creatLabelWithFontSize:W_Scale(30) fontWeight:UIFontWeightBold textColorHex:@"#FFFFFF" inSuperView:self];
_closeBtn = [UIButton creatViewInSuperView:self];
[_closeBtn setImage:UIImageMake(@"TH_bottleManagerDele") forState:UIControlStateNormal];
_closeBtn.hidden = YES;
_userTagView = [UIImageView creatViewInSuperView:self];
_nickLb = [UILabel creatLabelWithFont:UIFontRegularMake(W_Scale(13)) textColor:UIColorMakeWithHex(@"#FFFFFF") inSuperView:self];
_reportBtn = [UIButton creatButtonWithFont:UIFontRegularMake(W_Scale(13)) textColor:whiteColor_65 textState:UIControlStateNormal inSuperView:self];
[_reportBtn setTitle:@"举报" forState:UIControlStateNormal];
_contentView = [THBottleInfoCardContentView creatViewInSuperView:self];
_timeLb = [UILabel creatLabelWithFont:UIFontRegularMake(W_Scale(11)) textColor:whiteColor_65 inSuperView:self];
_spaceLineLayer = [CALayer layer];
_spaceLineLayer.backgroundColor = [UIColor colorWithWhite:1 alpha:0.15].CGColor;
[self.layer addSublayer:_spaceLineLayer];
_replyTextView = [QMUITextView creatViewInSuperView:self];
_replyTextView.font = UIFontRegularMake(W_Scale(15));
_replyTextView.textColor = [UIColor colorWithWhite:1 alpha:1];
_replyTextView.placeholderColor = whiteColor_65;
_replyTextView.placeholder = @"输入你想对Ta说的话";
_replyTextView.hidden = YES;
_replyTipLb = [UILabel creatLabelWithFont:UIFontMediumMake(W_Scale(16)) textColor:[UIColor colorWithWhite:1 alpha:0.65] inSuperView:self];
_replyTipLb.numberOfLines = 0;
_replyTipLb.hidden = YES;
_bottomToolView = [UIView creatViewInSuperView:self];
_addHotBtn = [UIButton creatButtonWithFont:UIFontMediumMake(W_Scale(16)) textColor:whiteColor_65 textState:UIControlStateNormal inSuperView:_bottomToolView];
[_addHotBtn setTitle:@"上推荐?" forState:UIControlStateNormal];
_nextBtn = [UIButton creatButtonWithFont:UIFontMediumMake(W_Scale(16)) textColor:whiteColor_65 textState:UIControlStateNormal inSuperView:_bottomToolView];
[_nextBtn setTitle:@"下一个" forState:UIControlStateNormal];
_interactBtn = [QMUIButton creatButtonWithFont:UIFontMediumMake(W_Scale(14)) textColor:UIColorMakeWithHex(@"#16112F") textState:UIControlStateNormal inSuperView:_bottomToolView];
_interactBtn.contentEdgeInsets = UIEdgeInsetsMake(6, 22, 6, 22);
_interactBtn.backgroundColor = UIColorMakeWithHex(@"#FFBA8B");
[_interactBtn setTitle:@"回应" forState:UIControlStateNormal];
_interactBtn.cornerRadius = QMUIButtonCornerRadiusAdjustsBounds;
_bottomToolView.hidden = YES;
//managerUI
// _managerToolView = [UIView creatViewInSuperView:self];
// [self managerToolView];
self.managerToolView.hidden = YES;
_setGoodBottleBtn = [UIButton creatButtonWithFont:UIFontRegularMake(W_Scale(13)) textColor:whiteColor_65 textState:UIControlStateNormal inSuperView:self];
[_setGoodBottleBtn setTitle:@"标为good瓶" forState:UIControlStateNormal];
_buyVipView.hidden = YES;
_buyVipView = [THBottleInfoBuyVipView creatViewInSuperView:self];
_buyVipView.hidden = YES;
///测试占位
// _titleLb.text = NSStringFromClass(_titleLb.class);
// _userTagView.image = UIImageMake(@"TH_HotParty_home");
// _nickLb.text = NSStringFromClass(_nickLb.class);
// _replyTipLb.text = @"UILabel\nUILabel";
// _timeLb.text = NSStringFromClass(_timeLb.class);
// self.infoModel = [NSObject new];
}
- (QMUIFloatLayoutView *)managerToolView {
if (!_managerToolView) {
_managerToolView = [QMUIFloatLayoutView creatViewInSuperView:self];
_managerToolView.itemMargins = UIEdgeInsetsMake(2, 5, 2, 5);
for (int i = 0; i < 5; i++) {
QMUIButton *typeBtn = [QMUIButton creatButtonWithFont:UIFontRegularMake(W_Scale(12)) textColor:UIColorMakeWhiteAlpha(0.8) textState:UIControlStateNormal inSuperView:_managerToolView];
typeBtn.contentEdgeInsets = UIEdgeInsetsMake(5, 3, 5, 3);
NSString *title = @"";
switch (i) {
case 1:
title = @"标色瓶";
break;
case 2:
title = @"下架";
break;
case 3:
title = @"处理瓶子";
break;
case 4:
title = @"处理账号";
break;
default:
//0
title = @"普通瓶";
break;
}
[typeBtn setTitle:title forState:UIControlStateNormal];
}
}
return _managerToolView;
}
- (void)layoutSubviews {
[super layoutSubviews];
CGFloat layoutLeft = 22;
self.bgImgView.frame = self.bounds;
[self.titleLb sizeToFit];
self.titleLb.qmui_left = 25;
self.titleLb.qmui_top = 20;
self.closeBtn.frame = CGRectMake(self.qmui_width - 30 - 15, 15, 30, 30);
self.userTagView.frame = CGRectMake(layoutLeft, self.titleLb.qmui_bottom + 22, 31, 18);
[self.reportBtn sizeToFit];
self.reportBtn.centerY = self.userTagView.centerY;
self.reportBtn.qmui_right = self.qmui_width - 15;
[self.setGoodBottleBtn sizeToFit];
self.setGoodBottleBtn.centerY = self.userTagView.centerY;
self.setGoodBottleBtn.qmui_right = self.qmui_width - 15;
[self.nickLb sizeToFit];
CGFloat nickLbLeft = self.userTagView.qmui_right + 8;
self.nickLb.qmui_width = self.reportBtn.qmui_left - 8 - nickLbLeft;
self.nickLb.centerY = self.userTagView.centerY;
self.nickLb.qmui_left = nickLbLeft;
CGFloat layoutW = self.qmui_width - layoutLeft * 2;
CGSize contentViewSize = [self.contentView sizeThatFits:CGSizeMake(layoutW, CGFLOAT_MAX)];
self.contentView.size = contentViewSize;
self.contentView.qmui_top = self.userTagView.qmui_bottom + 11;
self.contentView.qmui_left = layoutLeft;
//-------------
//先计算下部分布局所需的高度H,和最大高度比较后,再布局
// if (小屏幕) {
//
// }
// if (need_vip) {
// //需要VIP才能查看---写真
//
// }
CGSize buyVipViewSize = [self.buyVipView sizeThatFits:CGSizeMake(layoutW, CGFLOAT_MAX)];
self.buyVipView.size = buyVipViewSize;
self.buyVipView.qmui_left = layoutLeft;
self.buyVipView.qmui_bottom = self.qmui_height;
CGFloat testToolH = 60;
self.managerToolView.qmui_height = testToolH;
self.managerToolView.qmui_width = layoutW * 0.5;
self.managerToolView.qmui_left = layoutLeft;
self.managerToolView.qmui_bottom = self.qmui_height;
self.bottomToolView.qmui_height = testToolH;
self.bottomToolView.qmui_width = layoutW;
self.bottomToolView.qmui_left = layoutLeft;
self.bottomToolView.qmui_bottom = self.qmui_height;
[self.addHotBtn sizeToFit];
self.addHotBtn.qmui_left = 0;
self.addHotBtn.qmui_top = self.addHotBtn.qmui_topWhenCenterInSuperview;
[self.interactBtn sizeToFit];
self.interactBtn.qmui_right = self.bottomToolView.qmui_width;
self.interactBtn.qmui_top = self.interactBtn.qmui_topWhenCenterInSuperview;
[self.nextBtn sizeToFit];
self.nextBtn.qmui_right = self.interactBtn.qmui_left - 10;
self.nextBtn.qmui_top = self.nextBtn.qmui_topWhenCenterInSuperview;
self.replyTextView.qmui_height = self.replyTextView.font.lineHeight * 2;
self.replyTextView.qmui_width = layoutW;
self.replyTextView.qmui_left = layoutLeft;
self.replyTextView.qmui_bottom = self.bottomToolView.qmui_top;
[self.replyTipLb sizeToFit];
self.replyTipLb.qmui_width = layoutW;
self.replyTipLb.qmui_left = layoutLeft;
self.replyTipLb.centerY = self.replyTextView.centerY;
self.spaceLineLayer.frame = CGRectMake(layoutLeft, self.replyTextView.qmui_top - 11, layoutW, 0.5);
[self.timeLb sizeToFit];
self.timeLb.qmui_left = layoutLeft;
self.timeLb.qmui_bottom = CGRectGetMidY(self.spaceLineLayer.frame) - 10;
}
//- (CGSize)sizeThatFits:(CGSize)size {
// return CGSizeMake(<#CGFloat width#>, <#CGFloat height#>);
//}
@end