ComDynModel.m 1.1 KB
//
//  ComDynModel.m
//  DreamSleep
//
//  Created by peter on 2022/9/27.
//

#import "ComDynModel.h"

@implementation ComDynModel

- (CGFloat)contentHeight {
    CGFloat contentW = kScreenWidth - 60;
    NSString *content = self.content;
    CGFloat contentH = [UILabel getHeightByWidth:contentW text:content font:SysFont(14)];
    return contentH > 100 ? 100 : contentH;
}

- (CGFloat)imgHeight {
    if (self.imgUrls) {
        if (iPhone5) {
            return 100;
        } else {
            switch (self.imgUrls.count) {
                case 1: case 2:
                    return 150;
                    break;
                case 3:
                    return 95;
                    break;
                default:
                    return 0;
                    break;
            }
        }
    }
    return 0;
}

- (CGFloat)cellHeight {
    CGFloat topH = 67;
    CGFloat bottomH = (self.imgUrls && self.imgUrls.count) ? 52 : 56;
    CGFloat contentH = [self contentHeight];
    CGFloat imgTextSpace = (self.imgUrls && self.imgUrls.count) ? 12 : 0;
    CGFloat imgH = [self imgHeight];
    return topH + bottomH + contentH + imgTextSpace + imgH;
}

@end