Commit 1191ddcb by pierce

fixed bugs

parent f547837b
...@@ -358,7 +358,8 @@ extension GDRecommendListView: UICollectionViewDelegate, UICollectionViewDataSou ...@@ -358,7 +358,8 @@ extension GDRecommendListView: UICollectionViewDelegate, UICollectionViewDataSou
let sectionModel = viewModel.dataSubject.value[indexPath.section] let sectionModel = viewModel.dataSubject.value[indexPath.section]
if sectionModel.sectionType == .none { if sectionModel.sectionType == .none {
let width = (self.width - layout.sectionInset.left - layout.sectionInset.right - layout.minimumInteritemSpacing) / 2.0 let line = 2.0 + (GDRouter.BaseBusinessRouter?.isCurrentVersionVerified.value == true ? 1.0 : 0)
let width = (self.width - layout.sectionInset.left - layout.sectionInset.right - layout.minimumInteritemSpacing * (line - 1)) / line
return CGSize(width: width, height: width + 40) return CGSize(width: width, height: width + 40)
} else if sectionModel.sectionType == .banner { } else if sectionModel.sectionType == .banner {
return .init(width: GDScreen.width, height: (GDScreen.width * 0.3) + 10) return .init(width: GDScreen.width, height: (GDScreen.width * 0.3) + 10)
......
...@@ -14,15 +14,15 @@ class GDRoomListThemeLabel: BaseView { ...@@ -14,15 +14,15 @@ class GDRoomListThemeLabel: BaseView {
var theme: String? { var theme: String? {
didSet { didSet {
stopAnimation() // stopAnimation()
contentLabel.text = theme contentLabel.text = theme
contentLabel.sizeToFit() contentLabel.sizeToFit()
if contentLabel.width > self.width { // if contentLabel.width > self.width {
startAnimation() // startAnimation()
} // }
} }
} }
...@@ -33,7 +33,7 @@ class GDRoomListThemeLabel: BaseView { ...@@ -33,7 +33,7 @@ class GDRoomListThemeLabel: BaseView {
self.backgroundColor = .clear self.backgroundColor = .clear
contentLabel.font = .gd_pingfang(12) contentLabel.font = .gd_pingfang(11)
contentLabel.textColor = .hexColor("808080") contentLabel.textColor = .hexColor("808080")
contentLabel.numberOfLines = 1 contentLabel.numberOfLines = 1
self.addSubview(contentLabel) self.addSubview(contentLabel)
...@@ -41,6 +41,7 @@ class GDRoomListThemeLabel: BaseView { ...@@ -41,6 +41,7 @@ class GDRoomListThemeLabel: BaseView {
contentLabel.snp.makeConstraints { (make) in contentLabel.snp.makeConstraints { (make) in
make.top.equalToSuperview() make.top.equalToSuperview()
make.left.equalToSuperview() make.left.equalToSuperview()
make.right.equalToSuperview()
} }
} }
...@@ -51,32 +52,33 @@ class GDRoomListThemeLabel: BaseView { ...@@ -51,32 +52,33 @@ class GDRoomListThemeLabel: BaseView {
super.bindViewModel() super.bindViewModel()
} }
// MARK: Method // sh布局容易出问题,所以先不要这个动画: added By Pidan
func startAnimation() { // // MARK: Method
let animation = CAKeyframeAnimation(keyPath: "position.x") // func startAnimation() {
animation.repeatCount = .infinity // let animation = CAKeyframeAnimation(keyPath: "position.x")
animation.values = [contentLabel.width / 2.0, contentLabel.width / 2.0, -contentLabel.width / 2.0] // animation.repeatCount = .infinity
let duration = 30 + CFTimeInterval(contentLabel.width * 0.02) // animation.values = [contentLabel.width / 2.0, contentLabel.width / 2.0, -contentLabel.width / 2.0]
animation.duration = duration // let duration = 30 + CFTimeInterval(contentLabel.width * 0.02)
animation.keyTimes = [0, NSNumber(floatLiteral: 30.0 / duration), 1] // animation.duration = duration
animation.isRemovedOnCompletion = true // animation.keyTimes = [0, NSNumber(floatLiteral: 30.0 / duration), 1]
contentLabel.layer.add(animation, forKey: "ani") // animation.isRemovedOnCompletion = true
} // contentLabel.layer.add(animation, forKey: "ani")
// }
func stopAnimation() { //
// func stopAnimation() {
contentLabel.layer.removeAllAnimations() //
// contentLabel.layer.removeAllAnimations()
} //
// }
override func layoutSubviews() { //
superview?.layoutSubviews() // override func layoutSubviews() {
// superview?.layoutSubviews()
if contentLabel.width > self.width { //
startAnimation() // if contentLabel.width > self.width {
} else { // startAnimation()
stopAnimation() // } else {
} // stopAnimation()
} // }
// }
//
} }
...@@ -103,20 +103,25 @@ class RecommendListCollectionViewCell: GDRecommendListBaseCollectionViewCell { ...@@ -103,20 +103,25 @@ class RecommendListCollectionViewCell: GDRecommendListBaseCollectionViewCell {
// 昵称 Label 搭建 // 昵称 Label 搭建
nicknameLabel.textColor = .hexColor("333333") nicknameLabel.textColor = .hexColor("333333")
nicknameLabel.font = UIFont.gd_defaultBold(14) nicknameLabel.font = UIFont.gd_defaultBold(14)
nicknameLabel.adjustsFontSizeToFitWidth = true
nicknameLabel.minimumScaleFactor = 0.8
nicknameLabel.lineBreakMode = .byTruncatingTail nicknameLabel.lineBreakMode = .byTruncatingTail
self.contentView.addSubview(nicknameLabel) self.contentView.addSubview(nicknameLabel)
// 直播中以及观看人数 // 直播中以及观看人数
self.contentView.addSubview(livingView) self.contentView.addSubview(livingView)
let showLocation = GDRouter.BaseBusinessRouter?.isCurrentVersionVerified.value == false
// 地址btn if showLocation {
locationBtn.setImage(GDShowRoomListBundle.imageNamed("roomlist_city_icon"), for: .normal)
locationBtn.titleLabel?.font = UIFont.gd_default(12) // 地址btn
locationBtn.setTitleShadowColor(UIColor.init(white: 0, alpha: 0.2), for: .normal) locationBtn.setImage(GDShowRoomListBundle.imageNamed("roomlist_city_icon"), for: .normal)
locationBtn.setLayerShadow(UIColor.init(white: 0, alpha: 0.2), offset: CGSize(width: 1, height: 1), radius: 5) locationBtn.titleLabel?.font = UIFont.gd_default(12)
locationBtn.setTitleColor(.hexColor("999999"), for: .normal) locationBtn.setTitleShadowColor(UIColor.init(white: 0, alpha: 0.2), for: .normal)
locationBtn.titleEdgeInsets = UIEdgeInsets(top: -1, left: 3, bottom: 0, right: 0) locationBtn.setLayerShadow(UIColor.init(white: 0, alpha: 0.2), offset: CGSize(width: 1, height: 1), radius: 5)
self.contentView.addSubview(locationBtn) locationBtn.setTitleColor(.hexColor("999999"), for: .normal)
locationBtn.titleEdgeInsets = UIEdgeInsets(top: -1, left: 3, bottom: 0, right: 0)
self.contentView.addSubview(locationBtn)
}
self.contentView.addSubview(themeLabel) self.contentView.addSubview(themeLabel)
...@@ -153,7 +158,11 @@ class RecommendListCollectionViewCell: GDRecommendListBaseCollectionViewCell { ...@@ -153,7 +158,11 @@ class RecommendListCollectionViewCell: GDRecommendListBaseCollectionViewCell {
nicknameLabel.snp.makeConstraints { make in nicknameLabel.snp.makeConstraints { make in
make.left.equalTo(blockView.snp.right).offset(2) make.left.equalTo(blockView.snp.right).offset(2)
make.centerY.equalTo(blockView) make.centerY.equalTo(blockView)
make.right.equalTo(locationBtn.snp.left).priority(.high) if showLocation {
make.right.equalTo(locationBtn.snp.left).priority(.high)
} else {
make.right.equalToSuperview().offset(-2)
}
make.right.equalToSuperview().priority(.low) make.right.equalToSuperview().priority(.low)
} }
...@@ -297,20 +306,4 @@ class RecommendListCollectionViewCell: GDRecommendListBaseCollectionViewCell { ...@@ -297,20 +306,4 @@ class RecommendListCollectionViewCell: GDRecommendListBaseCollectionViewCell {
liveTimeUpdate.accept(liveTimeUpdate.value) liveTimeUpdate.accept(liveTimeUpdate.value)
} }
override func layoutSubviews() {
super.layoutSubviews()
// nicknameLabel.sizeToFit()
// if nicknameLabel.width > self.width {
// nicknameLabel.width = self.width
// }
//
// if locationBtn.isHidden == false && nicknameLabel.maxX > locationBtn.x {
// nicknameLabel.width = locationBtn.x - nicknameLabel.x
// } else {
// nicknameLabel.width = self.width - nicknameLabel.x
// }
}
} }
...@@ -111,7 +111,7 @@ class GDLiveTitleView: BaseView { ...@@ -111,7 +111,7 @@ class GDLiveTitleView: BaseView {
followBtn.frame = CGRect(x: audienceNumLabel.maxX + 12, y: 0, width: 50, height: 30) followBtn.frame = CGRect(x: audienceNumLabel.maxX + 12, y: 0, width: 50, height: 30)
followBtn.centerY = self.height / 2.0 followBtn.centerY = self.height / 2.0
followBtn.setTitle("关注", for: .normal) followBtn.setTitle("关注", for: .normal)
followBtn.setTitleColor(.black, for: .normal) followBtn.setTitleColor(.white, for: .normal)
followBtn.titleLabel?.font = .gd_pingfang(11) followBtn.titleLabel?.font = .gd_pingfang(11)
followBtn.isEnabled = true followBtn.isEnabled = true
self.addSubview(followBtn) self.addSubview(followBtn)
......
...@@ -214,10 +214,9 @@ extension UserModel { ...@@ -214,10 +214,9 @@ extension UserModel {
if var array : Array<Dictionary<String, Any>?> = UserModel.getAllHistoryUser() { if var array : Array<Dictionary<String, Any>?> = UserModel.getAllHistoryUser() {
if let dict = self.convertToDict() { if let dict = self.convertToDict() {
if let index = array.firstIndex(where: { $0?["uid"] as! String == uid }) { if let index = array.firstIndex(where: { $0?["uid"] as! String == uid }) {
array[index] = dict array.remove(at: index)
} else {
array.append(dict)
} }
array.append(dict)
UserDefaults.standard.setValue(array, forKey: GDUserManagerPublicUDKey.historyUserArray) UserDefaults.standard.setValue(array, forKey: GDUserManagerPublicUDKey.historyUserArray)
UserDefaults.standard.setValue(dict, forKey: GDUserManagerUDKey.lastUser) UserDefaults.standard.setValue(dict, forKey: GDUserManagerUDKey.lastUser)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment