|
@@ -97,33 +97,43 @@ class CardContentTitleTableViewCell: UITableViewCell {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
var cardContentTitleTableViewCellType: CardContentTitleTableViewCellType? {
|
|
|
didSet {
|
|
|
switch cardContentTitleTableViewCellType {
|
|
|
case .noTitleMoreThan?:
|
|
|
titleLabel.isHidden = true
|
|
|
- var str = (communityRecommendDataModel?.content)!
|
|
|
-
|
|
|
- if str.count >= 46 {
|
|
|
- str = String(str.prefix(46) + "...更多")
|
|
|
- let str1 = str.suffix(2)
|
|
|
- subtitleLabel.attributedText = str.changeTextColorFont(rangStr: String(str1), rangColor: k313334Color, font: kMediumFont14!)
|
|
|
-
|
|
|
+ if PostType(rawValue: communityRecommendDataModel?.type ?? "image") != .html {
|
|
|
+ subtitleLabel.isHidden = false
|
|
|
+ var str = communityRecommendDataModel?.content ?? ""
|
|
|
+
|
|
|
+ if str.count >= 46 {
|
|
|
+ str = String(str.prefix(46) + "...更多")
|
|
|
+ let str1 = str.suffix(2)
|
|
|
+ subtitleLabel.attributedText = str.changeTextColorFont(rangStr: String(str1), rangColor: k313334Color, font: kMediumFont14!)
|
|
|
+
|
|
|
+ }else {
|
|
|
+ let attr = NSMutableAttributedString.init(string: str)
|
|
|
+ subtitleLabel.attributedText = attr
|
|
|
+ }
|
|
|
}else {
|
|
|
- let attr = NSMutableAttributedString.init(string: str)
|
|
|
- subtitleLabel.attributedText = attr
|
|
|
+ subtitleLabel.isHidden = true
|
|
|
}
|
|
|
-
|
|
|
subtitleLabel.snp_remakeConstraints { (make) in
|
|
|
make.top.bottom.equalToSuperview()
|
|
|
make.left.equalTo(14)
|
|
|
make.right.equalTo(-14)
|
|
|
}
|
|
|
+
|
|
|
break
|
|
|
case .noTitleNoMoreThan?:
|
|
|
titleLabel.isHidden = true
|
|
|
- subtitleLabel.text = communityRecommendDataModel?.content
|
|
|
+ if PostType(rawValue: communityRecommendDataModel?.type ?? "image") != .html {
|
|
|
+ subtitleLabel.text = communityRecommendDataModel?.content
|
|
|
+ subtitleLabel.isHidden = false
|
|
|
+ }else {
|
|
|
+ subtitleLabel.isHidden = true
|
|
|
+ }
|
|
|
+
|
|
|
subtitleLabel.snp_remakeConstraints { (make) in
|
|
|
make.top.bottom.equalToSuperview()
|
|
|
make.left.equalTo(14)
|
|
@@ -133,48 +143,199 @@ class CardContentTitleTableViewCell: UITableViewCell {
|
|
|
case .titleMoreThan?:
|
|
|
titleLabel.isHidden = false
|
|
|
titleLabel.text = communityRecommendDataModel?.title
|
|
|
- var str = (communityRecommendDataModel?.content)!
|
|
|
- if str.count >= 46 {
|
|
|
- str = String(str.prefix(46) + "...更多")
|
|
|
- let str1 = str.suffix(2)
|
|
|
- subtitleLabel.attributedText = str.changeTextColorFont(rangStr: String(str1), rangColor: k313334Color, font: kMediumFont14!)
|
|
|
+ if PostType(rawValue: communityRecommendDataModel?.type ?? "image") != .html {
|
|
|
+ subtitleLabel.isHidden = false
|
|
|
+ var str = communityRecommendDataModel?.content ?? ""
|
|
|
+ if str.count >= 46 {
|
|
|
+ str = String(str.prefix(46) + "...更多")
|
|
|
+ let str1 = str.suffix(2)
|
|
|
+ subtitleLabel.attributedText = str.changeTextColorFont(rangStr: String(str1), rangColor: k313334Color, font: kMediumFont14!)
|
|
|
+
|
|
|
+ }else {
|
|
|
+ let attr = NSMutableAttributedString.init(string: str)
|
|
|
+ subtitleLabel.attributedText = attr
|
|
|
+ }
|
|
|
+ titleLabel.snp_remakeConstraints { (make) in
|
|
|
+ make.top.equalToSuperview()
|
|
|
+ make.left.equalTo(14)
|
|
|
+ make.right.equalTo(-14)
|
|
|
+ make.height.equalTo(22)
|
|
|
+ }
|
|
|
+
|
|
|
+ subtitleLabel.snp_remakeConstraints { (make) in
|
|
|
+ make.top.equalTo(titleLabel.snp_bottom).offset(10)
|
|
|
+ make.bottom.equalToSuperview()
|
|
|
+ make.left.equalTo(14)
|
|
|
+ make.right.equalTo(-14)
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ subtitleLabel.isHidden = true
|
|
|
+ titleLabel.snp_remakeConstraints { (make) in
|
|
|
+ make.top.bottom.equalToSuperview()
|
|
|
+ make.left.equalTo(14)
|
|
|
+ make.right.equalTo(-14)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ break
|
|
|
+ case .titleNoMoreThan?:
|
|
|
+ titleLabel.isHidden = false
|
|
|
+ titleLabel.text = communityRecommendDataModel?.title
|
|
|
+ if PostType(rawValue: communityRecommendDataModel?.type ?? "image") != .html {
|
|
|
+ subtitleLabel.text = communityRecommendDataModel?.content
|
|
|
+ subtitleLabel.isHidden = false
|
|
|
+ titleLabel.snp_remakeConstraints { (make) in
|
|
|
+ make.top.equalToSuperview()
|
|
|
+ make.leading.equalTo(14)
|
|
|
+ make.trailing.equalTo(-14)
|
|
|
+ make.height.equalTo(22)
|
|
|
+ }
|
|
|
+ subtitleLabel.snp_remakeConstraints { (make) in
|
|
|
+ make.top.equalTo(titleLabel.snp_bottom).offset(10)
|
|
|
+ make.bottom.equalToSuperview()
|
|
|
+ make.leading.equalTo(14)
|
|
|
+ make.trailing.equalTo(-14)
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ subtitleLabel.isHidden = true
|
|
|
+ titleLabel.snp_remakeConstraints { (make) in
|
|
|
+ make.top.bottom.equalToSuperview()
|
|
|
+ make.left.equalTo(14)
|
|
|
+ make.right.equalTo(-14)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break
|
|
|
+ default:
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var communityFollowDataModel : CommunityFollowDataModel? {
|
|
|
+ didSet {
|
|
|
+ if (communityFollowDataModel?.relateData?.title == "" || communityFollowDataModel?.relateData?.title == nil) {
|
|
|
+ if communityFollowDataModel?.relateData?.content?.count ?? 0 >= 46 {
|
|
|
+ cardContentTitleTableViewCellType1 = .noTitleMoreThan
|
|
|
+ }else {
|
|
|
+ cardContentTitleTableViewCellType1 = .noTitleNoMoreThan
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if communityFollowDataModel?.relateData?.content?.count ?? 0 >= 46 {
|
|
|
+ cardContentTitleTableViewCellType1 = .titleMoreThan
|
|
|
+ }else {
|
|
|
+ cardContentTitleTableViewCellType1 = .titleNoMoreThan
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var cardContentTitleTableViewCellType1: CardContentTitleTableViewCellType? {
|
|
|
+ didSet {
|
|
|
+ switch cardContentTitleTableViewCellType1 {
|
|
|
+ case .noTitleMoreThan?:
|
|
|
+ titleLabel.isHidden = true
|
|
|
+ if PostType(rawValue: communityFollowDataModel?.relateData?.type ?? "image") != .html {
|
|
|
+ subtitleLabel.isHidden = false
|
|
|
+ var str = communityFollowDataModel?.relateData?.content ?? ""
|
|
|
|
|
|
+ if str.count >= 46 {
|
|
|
+ str = String(str.prefix(46) + "...更多")
|
|
|
+ let str1 = str.suffix(2)
|
|
|
+ subtitleLabel.attributedText = str.changeTextColorFont(rangStr: String(str1), rangColor: k313334Color, font: kMediumFont14!)
|
|
|
+
|
|
|
+ }else {
|
|
|
+ let attr = NSMutableAttributedString.init(string: str)
|
|
|
+ subtitleLabel.attributedText = attr
|
|
|
+ }
|
|
|
}else {
|
|
|
- let attr = NSMutableAttributedString.init(string: str)
|
|
|
- subtitleLabel.attributedText = attr
|
|
|
+ subtitleLabel.isHidden = true
|
|
|
}
|
|
|
- titleLabel.snp_remakeConstraints { (make) in
|
|
|
- make.top.equalToSuperview()
|
|
|
+ subtitleLabel.snp_remakeConstraints { (make) in
|
|
|
+ make.top.bottom.equalToSuperview()
|
|
|
make.left.equalTo(14)
|
|
|
make.right.equalTo(-14)
|
|
|
- make.height.equalTo(22)
|
|
|
+ }
|
|
|
+
|
|
|
+ break
|
|
|
+ case .noTitleNoMoreThan?:
|
|
|
+ titleLabel.isHidden = true
|
|
|
+ if PostType(rawValue: communityFollowDataModel?.relateData?.type ?? "image") != .html {
|
|
|
+ subtitleLabel.text = communityFollowDataModel?.relateData?.content
|
|
|
+ subtitleLabel.isHidden = false
|
|
|
+ }else {
|
|
|
+ subtitleLabel.isHidden = true
|
|
|
}
|
|
|
|
|
|
subtitleLabel.snp_remakeConstraints { (make) in
|
|
|
- make.top.equalTo(titleLabel.snp_bottom).offset(10)
|
|
|
- make.bottom.equalToSuperview()
|
|
|
+ make.top.bottom.equalToSuperview()
|
|
|
make.left.equalTo(14)
|
|
|
make.right.equalTo(-14)
|
|
|
}
|
|
|
-
|
|
|
break
|
|
|
- case .titleNoMoreThan?:
|
|
|
+ case .titleMoreThan?:
|
|
|
titleLabel.isHidden = false
|
|
|
- titleLabel.text = communityRecommendDataModel?.title
|
|
|
- subtitleLabel.text = communityRecommendDataModel?.content
|
|
|
- titleLabel.snp_remakeConstraints { (make) in
|
|
|
- make.top.equalToSuperview()
|
|
|
- make.leading.equalTo(14)
|
|
|
- make.trailing.equalTo(-14)
|
|
|
- make.height.equalTo(22)
|
|
|
+ titleLabel.text = communityFollowDataModel?.relateData?.title
|
|
|
+ if PostType(rawValue: communityFollowDataModel?.relateData?.type ?? "image") != .html {
|
|
|
+ subtitleLabel.isHidden = false
|
|
|
+ var str = communityFollowDataModel?.relateData?.content ?? ""
|
|
|
+ if str.count >= 46 {
|
|
|
+ str = String(str.prefix(46) + "...更多")
|
|
|
+ let str1 = str.suffix(2)
|
|
|
+ subtitleLabel.attributedText = str.changeTextColorFont(rangStr: String(str1), rangColor: k313334Color, font: kMediumFont14!)
|
|
|
+
|
|
|
+ }else {
|
|
|
+ let attr = NSMutableAttributedString.init(string: str)
|
|
|
+ subtitleLabel.attributedText = attr
|
|
|
+ }
|
|
|
+ titleLabel.snp_remakeConstraints { (make) in
|
|
|
+ make.top.equalToSuperview()
|
|
|
+ make.left.equalTo(14)
|
|
|
+ make.right.equalTo(-14)
|
|
|
+ make.height.equalTo(22)
|
|
|
+ }
|
|
|
+
|
|
|
+ subtitleLabel.snp_remakeConstraints { (make) in
|
|
|
+ make.top.equalTo(titleLabel.snp_bottom).offset(10)
|
|
|
+ make.bottom.equalToSuperview()
|
|
|
+ make.left.equalTo(14)
|
|
|
+ make.right.equalTo(-14)
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ subtitleLabel.isHidden = true
|
|
|
+ titleLabel.snp_remakeConstraints { (make) in
|
|
|
+ make.top.bottom.equalToSuperview()
|
|
|
+ make.left.equalTo(14)
|
|
|
+ make.right.equalTo(-14)
|
|
|
+ }
|
|
|
}
|
|
|
- subtitleLabel.snp_remakeConstraints { (make) in
|
|
|
- make.top.equalTo(titleLabel.snp_bottom).offset(10)
|
|
|
- make.bottom.equalToSuperview()
|
|
|
- make.leading.equalTo(14)
|
|
|
- make.trailing.equalTo(-14)
|
|
|
+
|
|
|
+ break
|
|
|
+ case .titleNoMoreThan?:
|
|
|
+ titleLabel.isHidden = false
|
|
|
+ titleLabel.text = communityFollowDataModel?.relateData?.title
|
|
|
+ if PostType(rawValue: communityFollowDataModel?.relateData?.type ?? "image") != .html {
|
|
|
+ subtitleLabel.text = communityFollowDataModel?.relateData?.content
|
|
|
+ subtitleLabel.isHidden = false
|
|
|
+ titleLabel.snp_remakeConstraints { (make) in
|
|
|
+ make.top.equalToSuperview()
|
|
|
+ make.leading.equalTo(14)
|
|
|
+ make.trailing.equalTo(-14)
|
|
|
+ make.height.equalTo(22)
|
|
|
+ }
|
|
|
+ subtitleLabel.snp_remakeConstraints { (make) in
|
|
|
+ make.top.equalTo(titleLabel.snp_bottom).offset(10)
|
|
|
+ make.bottom.equalToSuperview()
|
|
|
+ make.leading.equalTo(14)
|
|
|
+ make.trailing.equalTo(-14)
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ subtitleLabel.isHidden = true
|
|
|
+ titleLabel.snp_remakeConstraints { (make) in
|
|
|
+ make.top.bottom.equalToSuperview()
|
|
|
+ make.left.equalTo(14)
|
|
|
+ make.right.equalTo(-14)
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
break
|
|
|
default:
|
|
|
break
|