frameModel
#import
#import "LocalMallGoodsCommentListModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface LocalMallGoodsCommentListFrameModel : NSObject
@property(nonatomic,assign)CGFloat totalWidth;//总共宽度
@property(nonatomic,strong)LocalMallGoodsCommentListInfoListModel *listModel;
@property(nonatomic,assign,readonly)CGFloat cellHeight;
@property(nonatomic,assign,readonly)CGRect avatarIVFrame;
@property(nonatomic,assign,readonly)CGRect commentatorLabFrame;
@property(nonatomic,assign,readonly)CGRect starViewFrame;
@property(nonatomic,assign,readonly)CGRect goodsSpecLabFrame;
@property(nonatomic,assign,readonly)CGRect contentLabFrame;
@property(nonatomic,assign,readonly)CGRect timeLabFrame;
@property(nonatomic,assign,readonly)CGRect deleteLabFrame;
@property(nonatomic,assign,readonly)CGRect praiseButtonFrame;
@property(nonatomic,assign,readonly)CGRect praiseImageButtonFrame;
@property(nonatomic,assign,readonly)CGRect praiseTitleButtonFrame;
@property(nonatomic,assign,readonly)CGRect commentButtonFrame;
@property(nonatomic,assign,readonly)CGRect commentImageButtonFrame;
@property(nonatomic,assign,readonly)CGRect commentTitleButtonFrame;
@property(nonatomic,assign,readonly)CGRect pictureFrame;
@property(nonatomic,strong,readonly)NSArray *pictureStatusFrameArr;
@end
NS_ASSUME_NONNULL_END
#import "LocalMallGoodsCommentListFrameModel.h"
@interface LocalMallGoodsCommentListFrameModel ()
@property(nonatomic,assign)CGFloat cellHeight;
@property(nonatomic,assign)CGRect avatarIVFrame;
@property(nonatomic,assign)CGRect commentatorLabFrame;
@property(nonatomic,assign)CGRect starViewFrame;
@property(nonatomic,assign)CGRect goodsSpecLabFrame;
@property(nonatomic,assign)CGRect contentLabFrame;
@property(nonatomic,assign)CGRect timeLabFrame;
@property(nonatomic,assign)CGRect deleteLabFrame;
@property(nonatomic,assign)CGRect praiseButtonFrame;
@property(nonatomic,assign)CGRect praiseImageButtonFrame;
@property(nonatomic,assign)CGRect praiseTitleButtonFrame;
@property(nonatomic,assign)CGRect commentButtonFrame;
@property(nonatomic,assign)CGRect commentImageButtonFrame;
@property(nonatomic,assign)CGRect commentTitleButtonFrame;
@property(nonatomic,assign)CGRect pictureFrame;
@property(nonatomic,strong)NSArray *pictureStatusFrameArr;
@end
@implementation LocalMallGoodsCommentListFrameModel
- (void)setListModel:(LocalMallGoodsCommentListInfoListModel *)listModel
{
_listModel = listModel;
//头部
self.avatarIVFrame = CGRectMake(11*ADAPTER_WIDTH, 20*ADAPTER_WIDTH, 40*ADAPTER_WIDTH, 40*ADAPTER_WIDTH);
CGFloat orinX = CGRectGetMaxX(self.avatarIVFrame) + 5*ADAPTER_WIDTH,orinY = CGRectGetMaxY(self.avatarIVFrame) - 11*ADAPTER_WIDTH;//(2+9)
CGFloat maxWidth = WIDTH - orinX - 11*ADAPTER_WIDTH;
//头部
self.commentatorLabFrame = CGRectMake(orinX, 22*ADAPTER_WIDTH, maxWidth, 17*ADAPTER_WIDTH);
CGFloat starViewWidth = listModel.star.integerValue == 0 ? 0 : listModel.star.integerValue * 14*ADAPTER_WIDTH - 5*ADAPTER_WIDTH;
self.starViewFrame = CGRectMake(orinX, orinY, starViewWidth, 9*ADAPTER_WIDTH);
CGFloat starViewRightX = listModel.star.integerValue == 0 ? CGRectGetMaxX(self.starViewFrame) : CGRectGetMaxX(self.starViewFrame) + 9*ADAPTER_WIDTH;
self.goodsSpecLabFrame = CGRectMake(starViewRightX, orinY - 2*ADAPTER_WIDTH, starViewRightX, 14*ADAPTER_WIDTH);
orinY = CGRectGetMaxY(self.starViewFrame) + 10*ADAPTER_WIDTH;
//content
CGFloat contentHeight = [listModel.content sizeWithMaxWidth:maxWidth andFont:[UIFont systemFontOfSize:14*ADAPTER_WIDTH weight:UIFontWeightRegular]].height;
self.contentLabFrame = CGRectMake(orinX, orinY, maxWidth, contentHeight);
orinY = CGRectGetMaxY(self.contentLabFrame) + 10*ADAPTER_WIDTH;
//图片
{
if (listModel.images.count > 0) {
CGFloat itemWidth = (maxWidth - 14*ADAPTER_WIDTH)/3;
self.pictureFrame = CGRectMake(orinX, orinY, maxWidth, itemWidth);
NSMutableArray *imagesFrames = [NSMutableArray array];
for (NSInteger index = 0; index < 3 ; index ++) {
CGRect frame = CGRectMake((itemWidth + 7*ADAPTER_WIDTH) *index, 0, itemWidth, itemWidth);
if (index > (listModel.images.count - 1)) {
frame = CGRectZero;
}
NSValue *value = [NSValue valueWithCGRect:frame];
[imagesFrames addObject:value];
}
self.pictureStatusFrameArr = imagesFrames;
orinY = CGRectGetMaxY(self.pictureFrame) + 10*ADAPTER_WIDTH;
} else {
self.pictureFrame = CGRectZero;
NSMutableArray *imagesFrames = [NSMutableArray array];
for (NSInteger index = 0; index < 3; index ++) {
CGRect frame = CGRectZero;
NSValue *value = [NSValue valueWithCGRect:frame];
[imagesFrames addObject:value];
}
self.pictureStatusFrameArr = imagesFrames;
}
}
{
CGFloat timeWidth = [listModel.create_time sizeWithFont:[UIFont systemFontOfSize:13*ADAPTER_WIDTH weight:UIFontWeightRegular]].width;
self.timeLabFrame = CGRectMake(orinX, orinY, timeWidth, 14*ADAPTER_WIDTH);
orinY = CGRectGetMaxY(self.timeLabFrame) + 10*ADAPTER_WIDTH;
if ([listModel.mid isEqualToString:[UserDefalutObj shareUserObj].mid]) {
self.deleteLabFrame = CGRectMake(CGRectGetMaxX(self.timeLabFrame) + 9*ADAPTER_WIDTH, 0, 40*ADAPTER_WIDTH, 40*ADAPTER_WIDTH);
} else {
self.deleteLabFrame = CGRectZero;
}
}
{
//按钮
CGFloat praiseWidth = [listModel.praise_num sizeWithFont:[UIFont systemFontOfSize:13*ADAPTER_WIDTH weight:UIFontWeightRegular]].width;
CGFloat commentWidth = [listModel.reply_num sizeWithFont:[UIFont systemFontOfSize:13*ADAPTER_WIDTH weight:UIFontWeightRegular]].width;
self.praiseImageButtonFrame = CGRectMake(15*ADAPTER_WIDTH, 10*ADAPTER_WIDTH, 15*ADAPTER_WIDTH, 13*ADAPTER_WIDTH);
self.praiseTitleButtonFrame = CGRectMake(CGRectGetMaxX(self.praiseImageButtonFrame) + 5*ADAPTER_WIDTH, 10*ADAPTER_WIDTH, praiseWidth, 14*ADAPTER_WIDTH);
self.praiseButtonFrame = CGRectMake(WIDTH - 11 *ADAPTER_WIDTH - CGRectGetMaxX(self.praiseTitleButtonFrame), 0, CGRectGetMaxX(self.praiseTitleButtonFrame), 35*ADAPTER_WIDTH);
self.commentImageButtonFrame = CGRectMake(15*ADAPTER_WIDTH, 10*ADAPTER_WIDTH, 15*ADAPTER_WIDTH, 14*ADAPTER_WIDTH);
self.commentTitleButtonFrame = CGRectMake(CGRectGetMaxX(self.praiseImageButtonFrame) + 5*ADAPTER_WIDTH, 10*ADAPTER_WIDTH, commentWidth, 14*ADAPTER_WIDTH);
self.commentButtonFrame = CGRectMake(CGRectGetMinX(self.praiseButtonFrame) - CGRectGetMaxX(self.commentTitleButtonFrame) - 15*ADAPTER_WIDTH, 0, CGRectGetMaxX(self.commentTitleButtonFrame) + 15*ADAPTER_WIDTH, 35*ADAPTER_WIDTH);
}
//底部
self.cellHeight = orinY;
}
@end