Commit 1191ddcb by pierce

fixed bugs

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