Commit 6b96f32a1b187307db2ed898c51d7361cd6f1506

Authored by liushiyu
1 parent 2536d551

昵称被挤压问题修复

metaCode/Classes/Main/VideoPage/Model/CNLiveShortVideoHomeModel.swift
@@ -31,8 +31,8 @@ class ShortVideoHomeCommentListModel: BaseModel { @@ -31,8 +31,8 @@ class ShortVideoHomeCommentListModel: BaseModel {
31 tableView_h += replyModel.cellH 31 tableView_h += replyModel.cellH
32 } 32 }
33 if replyData.replyCount ?? 0 > 2 { 33 if replyData.replyCount ?? 0 > 2 {
34 - tableView_top += 30.0  
35 - cell_h += 30 34 + tableView_top += adapt_length(length: 30)
  35 + cell_h += adapt_length(length: 30)
36 } 36 }
37 cell_h += tableView_h 37 cell_h += tableView_h
38 } 38 }
@@ -60,7 +60,7 @@ class ShortVideoHomeCommentFListModel: BaseModel { @@ -60,7 +60,7 @@ class ShortVideoHomeCommentFListModel: BaseModel {
60 var iconSize: CGSize = CGSize(width: 50, height: 50) 60 var iconSize: CGSize = CGSize(width: 50, height: 50)
61 var textLayout: YYTextLayout! 61 var textLayout: YYTextLayout!
62 var nickLayout: YYTextLayout! 62 var nickLayout: YYTextLayout!
63 - var cellH: CGFloat! = 50.0 63 + var cellH: CGFloat! = adapt_length(length: 50)
64 64
65 override func didFinishMapping() { 65 override func didFinishMapping() {
66 super.didFinishMapping() 66 super.didFinishMapping()
@@ -72,17 +72,18 @@ class ShortVideoHomeCommentFListModel: BaseModel { @@ -72,17 +72,18 @@ class ShortVideoHomeCommentFListModel: BaseModel {
72 let attributes = NSMutableAttributedString(attributedString: temp_string) 72 let attributes = NSMutableAttributedString(attributedString: temp_string)
73 attributes.addAttribute(NSAttributedString.Key.foregroundColor, value: HexColor("#333333")!, range: NSRange(location: 0, length: temp_string.length)) 73 attributes.addAttribute(NSAttributedString.Key.foregroundColor, value: HexColor("#333333")!, range: NSRange(location: 0, length: temp_string.length))
74 attributes.addAttribute(NSAttributedString.Key.font, value: medium_adapt_font(pointSize: 16), range: NSRange(location: 0, length: temp_string.length)) 74 attributes.addAttribute(NSAttributedString.Key.font, value: medium_adapt_font(pointSize: 16), range: NSRange(location: 0, length: temp_string.length))
75 - let textContainer = YYTextContainer(size: CGSize(width: KSreenWidth-80, height: CGFloat(HUGE))) 75 + let textContainer = YYTextContainer(size: CGSize(width: KSreenWidth-adapt_length(length: 80), height: CGFloat(HUGE)))
76 textContainer.linePositionModifier = modifier; 76 textContainer.linePositionModifier = modifier;
77 let textLayout = YYTextLayout(container: textContainer, text: attributes) 77 let textLayout = YYTextLayout(container: textContainer, text: attributes)
78 self.textLayout = textLayout 78 self.textLayout = textLayout
79 self.cellH += (textLayout?.textBoundingRect.size.height ?? 0) 79 self.cellH += (textLayout?.textBoundingRect.size.height ?? 0)
80 80
  81 + let nick_modifier = CNLiveShortVideoMateCodeLinePositionModifier(font: medium_adapt_font(pointSize: 12), paddingTop: 0, paddingBottom: 0, lineHeightMultiple: 1.5)
81 let textAttributedString = NSMutableAttributedString.init(string: self.nick ?? "") 82 let textAttributedString = NSMutableAttributedString.init(string: self.nick ?? "")
82 textAttributedString.addAttribute(NSAttributedString.Key.foregroundColor, value: HexColor("#AFAFAF")!, range: NSRange(location: 0, length: textAttributedString.length)) 83 textAttributedString.addAttribute(NSAttributedString.Key.foregroundColor, value: HexColor("#AFAFAF")!, range: NSRange(location: 0, length: textAttributedString.length))
83 textAttributedString.addAttribute(NSAttributedString.Key.font, value: medium_adapt_font(pointSize: 12), range: NSRange(location: 0, length: textAttributedString.length)) 84 textAttributedString.addAttribute(NSAttributedString.Key.font, value: medium_adapt_font(pointSize: 12), range: NSRange(location: 0, length: textAttributedString.length))
84 - let nickContainer = YYTextContainer(size: CGSize(width: KSreenWidth-80, height: 20))  
85 - nickContainer.linePositionModifier = modifier; 85 + let nickContainer = YYTextContainer(size: CGSize(width: KSreenWidth-adapt_length(length: 80), height: CGFloat(HUGE)))
  86 + nickContainer.linePositionModifier = nick_modifier;
86 self.nickLayout = YYTextLayout(container: nickContainer, text: textAttributedString) 87 self.nickLayout = YYTextLayout(container: nickContainer, text: textAttributedString)
87 self.cellH += (self.nickLayout?.textBoundingRect.size.height ?? 0) 88 self.cellH += (self.nickLayout?.textBoundingRect.size.height ?? 0)
88 } 89 }
@@ -115,7 +116,7 @@ class ShortVideoHomeCommentRListItemModel: BaseModel { @@ -115,7 +116,7 @@ class ShortVideoHomeCommentRListItemModel: BaseModel {
115 116
116 var textLayout: YYTextLayout! 117 var textLayout: YYTextLayout!
117 var nickLayout: YYTextLayout! 118 var nickLayout: YYTextLayout!
118 - var cellH: CGFloat! = 50.0 119 + var cellH: CGFloat! = adapt_length(length: 50)
119 120
120 override func didFinishMapping() { 121 override func didFinishMapping() {
121 super.didFinishMapping() 122 super.didFinishMapping()
@@ -127,18 +128,19 @@ class ShortVideoHomeCommentRListItemModel: BaseModel { @@ -127,18 +128,19 @@ class ShortVideoHomeCommentRListItemModel: BaseModel {
127 let attributes = NSMutableAttributedString(attributedString: temp_string) 128 let attributes = NSMutableAttributedString(attributedString: temp_string)
128 attributes.addAttribute(NSAttributedString.Key.foregroundColor, value: HexColor("#333333")!, range: NSRange(location: 0, length: temp_string.length)) 129 attributes.addAttribute(NSAttributedString.Key.foregroundColor, value: HexColor("#333333")!, range: NSRange(location: 0, length: temp_string.length))
129 attributes.addAttribute(NSAttributedString.Key.font, value: medium_adapt_font(pointSize: 16), range: NSRange(location: 0, length: temp_string.length)) 130 attributes.addAttribute(NSAttributedString.Key.font, value: medium_adapt_font(pointSize: 16), range: NSRange(location: 0, length: temp_string.length))
130 - let textContainer = YYTextContainer(size: CGSize(width: KSreenWidth-80-40, height: CGFloat(HUGE))) 131 + let textContainer = YYTextContainer(size: CGSize(width: KSreenWidth-adapt_length(length: 120), height: CGFloat(HUGE)))
131 textContainer.linePositionModifier = modifier; 132 textContainer.linePositionModifier = modifier;
132 self.textLayout = YYTextLayout(container: textContainer, text: attributes) 133 self.textLayout = YYTextLayout(container: textContainer, text: attributes)
133 self.cellH += (self.textLayout?.textBoundingRect.size.height ?? 0) 134 self.cellH += (self.textLayout?.textBoundingRect.size.height ?? 0)
134 135
  136 + let nick_modifier = CNLiveShortVideoMateCodeLinePositionModifier(font: medium_adapt_font(pointSize: 12), paddingTop: 0, paddingBottom: 0, lineHeightMultiple: 1.5)
135 let textAttributedString = NSMutableAttributedString.init(string: "\(self.fromNick ?? "") ?? \(self.toNick ?? "")") 137 let textAttributedString = NSMutableAttributedString.init(string: "\(self.fromNick ?? "") ?? \(self.toNick ?? "")")
136 textAttributedString.addAttribute(NSAttributedString.Key.foregroundColor, value: HexColor("#AFAFAF")!, range: NSRange(location: 0, length: textAttributedString.length)) 138 textAttributedString.addAttribute(NSAttributedString.Key.foregroundColor, value: HexColor("#AFAFAF")!, range: NSRange(location: 0, length: textAttributedString.length))
137 textAttributedString.addAttribute(NSAttributedString.Key.font, value: medium_adapt_font(pointSize: 12), range: NSRange(location: 0, length: textAttributedString.length)) 139 textAttributedString.addAttribute(NSAttributedString.Key.font, value: medium_adapt_font(pointSize: 12), range: NSRange(location: 0, length: textAttributedString.length))
138 let attachText = NSAttributedString.yy_attachmentString(withContent: UIImage(named: "short_video_reply_name"), contentMode: .scaleAspectFill, attachmentSize: CGSize(width: adapt_length(length: 8), height: adapt_length(length: 8)), alignTo: medium_adapt_font(pointSize: 12), alignment: .center) 140 let attachText = NSAttributedString.yy_attachmentString(withContent: UIImage(named: "short_video_reply_name"), contentMode: .scaleAspectFill, attachmentSize: CGSize(width: adapt_length(length: 8), height: adapt_length(length: 8)), alignTo: medium_adapt_font(pointSize: 12), alignment: .center)
139 textAttributedString.replaceCharacters(in: NSRange(location: self.fromNick!.count + 2, length: 2), with: attachText) 141 textAttributedString.replaceCharacters(in: NSRange(location: self.fromNick!.count + 2, length: 2), with: attachText)
140 - let nickContainer = YYTextContainer(size: CGSize(width: KSreenWidth-80-40, height: 20))  
141 - nickContainer.linePositionModifier = modifier; 142 + let nickContainer = YYTextContainer(size: CGSize(width: KSreenWidth-adapt_length(length: 120), height: adapt_length(length: 40)))
  143 + nickContainer.linePositionModifier = nick_modifier;
142 self.nickLayout = YYTextLayout(container: nickContainer, text: textAttributedString) 144 self.nickLayout = YYTextLayout(container: nickContainer, text: textAttributedString)
143 self.cellH += (self.nickLayout?.textBoundingRect.size.height ?? 0) 145 self.cellH += (self.nickLayout?.textBoundingRect.size.height ?? 0)
144 } 146 }
metaCode/Classes/Main/VideoPage/View/CNLiveShortVideoCommentListView.swift
@@ -526,7 +526,7 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel @@ -526,7 +526,7 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel
526 contentView.addSubview(likeButton) 526 contentView.addSubview(likeButton)
527 likeButton.snp.makeConstraints { make in 527 likeButton.snp.makeConstraints { make in
528 make.right.equalToSuperview().offset(-10) 528 make.right.equalToSuperview().offset(-10)
529 - make.height.equalTo(20) 529 + make.height.equalTo(adapt_length(length: 20))
530 make.width.equalTo(50) 530 make.width.equalTo(50)
531 make.top.equalTo(commentLabel.snp.bottom).offset(10) 531 make.top.equalTo(commentLabel.snp.bottom).offset(10)
532 } 532 }
@@ -534,19 +534,19 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel @@ -534,19 +534,19 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel
534 timeLabel.snp.makeConstraints { make in 534 timeLabel.snp.makeConstraints { make in
535 make.top.equalTo(commentLabel.snp.bottom).offset(10) 535 make.top.equalTo(commentLabel.snp.bottom).offset(10)
536 make.left.equalTo(titleLabel.snp.left) 536 make.left.equalTo(titleLabel.snp.left)
537 - make.height.equalTo(20) 537 + make.height.equalTo(adapt_length(length: 20))
538 } 538 }
539 contentView.addSubview(replyButton) 539 contentView.addSubview(replyButton)
540 replyButton.snp.makeConstraints { make in 540 replyButton.snp.makeConstraints { make in
541 make.left.equalTo(timeLabel.snp.right).offset(10) 541 make.left.equalTo(timeLabel.snp.right).offset(10)
542 - make.height.equalTo(20) 542 + make.height.equalTo(adapt_length(length: 20))
543 make.width.equalTo(40) 543 make.width.equalTo(40)
544 make.top.equalTo(commentLabel.snp.bottom).offset(10) 544 make.top.equalTo(commentLabel.snp.bottom).offset(10)
545 } 545 }
546 contentView.addSubview(deleteButton) 546 contentView.addSubview(deleteButton)
547 deleteButton.snp.makeConstraints { make in 547 deleteButton.snp.makeConstraints { make in
548 make.left.equalTo(replyButton.snp.right).offset(adapt_length(length: 5)) 548 make.left.equalTo(replyButton.snp.right).offset(adapt_length(length: 5))
549 - make.height.equalTo(20) 549 + make.height.equalTo(adapt_length(length: 20))
550 make.width.equalTo(40) 550 make.width.equalTo(40)
551 make.top.equalTo(commentLabel.snp.bottom).offset(10) 551 make.top.equalTo(commentLabel.snp.bottom).offset(10)
552 } 552 }
@@ -554,7 +554,7 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel @@ -554,7 +554,7 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel
554 replyUnfoldButton.snp.makeConstraints { make in 554 replyUnfoldButton.snp.makeConstraints { make in
555 make.top.equalTo(timeLabel.snp.bottom) 555 make.top.equalTo(timeLabel.snp.bottom)
556 make.left.equalTo(titleLabel.snp.left) 556 make.left.equalTo(titleLabel.snp.left)
557 - make.height.equalTo(30) 557 + make.height.equalTo(adapt_length(length: 30))
558 } 558 }
559 contentView.addSubview(tableView) 559 contentView.addSubview(tableView)
560 } 560 }
@@ -585,20 +585,20 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel @@ -585,20 +585,20 @@ class CNLiveShortVideoCommentListTableViewCell: UITableViewCell , UITableViewDel
585 } 585 }
586 DispatchQueue.main.async {[weak self] in 586 DispatchQueue.main.async {[weak self] in
587 guard let self = self else { return } 587 guard let self = self else { return }
588 - self.commentLabel.textLayout = commentData.textLayout  
589 - self.commentLabel.snp.remakeConstraints { make in  
590 - make.top.equalTo(self.titleLabel.snp.bottom).offset(10)  
591 - make.left.equalTo(self.iconView.snp.right).offset(10)  
592 - make.right.equalToSuperview().offset(-10)  
593 - make.height.equalTo(commentData.textLayout.textBoundingRect.size.height)  
594 - }  
595 self.titleLabel.textLayout = commentData.nickLayout 588 self.titleLabel.textLayout = commentData.nickLayout
596 self.titleLabel.snp.remakeConstraints { make in 589 self.titleLabel.snp.remakeConstraints { make in
597 make.left.equalTo(self.iconView.snp.right).offset(10) 590 make.left.equalTo(self.iconView.snp.right).offset(10)
598 - make.top.equalToSuperview().offset(10) 591 + make.top.equalToSuperview().offset(adapt_length(length: 10))
599 make.right.equalToSuperview().offset(-10) 592 make.right.equalToSuperview().offset(-10)
600 make.height.equalTo(commentData.nickLayout.textBoundingRect.size.height) 593 make.height.equalTo(commentData.nickLayout.textBoundingRect.size.height)
601 } 594 }
  595 + self.commentLabel.textLayout = commentData.textLayout
  596 + self.commentLabel.snp.remakeConstraints { make in
  597 + make.top.equalTo(self.titleLabel.snp.bottom).offset(adapt_length(length: 10))
  598 + make.left.equalTo(self.iconView.snp.right).offset(10)
  599 + make.right.equalToSuperview().offset(-10)
  600 + make.height.equalTo(commentData.textLayout.textBoundingRect.size.height)
  601 + }
602 self.tableView.snp.removeConstraints() 602 self.tableView.snp.removeConstraints()
603 self.tableView.removeFromSuperview() 603 self.tableView.removeFromSuperview()
604 if replyData.replyCount ?? 0 > 0 { 604 if replyData.replyCount ?? 0 > 0 {