|
|
@@ -15,6 +15,11 @@ class LNRoomGiftItemCell: UICollectionViewCell {
|
|
|
private let iconView = UIImageView()
|
|
|
private let nameLabel = UILabel()
|
|
|
private let priceLabel = UILabel()
|
|
|
+ override var isSelected: Bool {
|
|
|
+ didSet {
|
|
|
+ selectionBackground.isHidden = !isSelected
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
override init(frame: CGRect) {
|
|
|
super.init(frame: frame)
|
|
|
@@ -22,7 +27,7 @@ class LNRoomGiftItemCell: UICollectionViewCell {
|
|
|
setupViews()
|
|
|
}
|
|
|
|
|
|
- func update(_ item: LNGiftItemVO, selected: Bool) {
|
|
|
+ func update(_ item: LNGiftItemVO) {
|
|
|
guard let res = LNGiftManager.shared.resource(for: item.resId) else {
|
|
|
isHidden = true
|
|
|
return
|
|
|
@@ -31,8 +36,31 @@ class LNRoomGiftItemCell: UICollectionViewCell {
|
|
|
nameLabel.text = res.curName
|
|
|
priceLabel.text = item.value.currencyDisplay
|
|
|
iconView.sd_setImage(with: URL(string: res.icon))
|
|
|
+ }
|
|
|
+
|
|
|
+ func showJumpAnimate() {
|
|
|
+ iconView.layer.removeAllAnimations()
|
|
|
+ iconView.transform = .identity
|
|
|
+
|
|
|
+ let totalDuration: TimeInterval = 1.0
|
|
|
+ let firstJumpHeight: CGFloat = 8.0
|
|
|
+ let secondJumpHeight: CGFloat = 6.0
|
|
|
|
|
|
- selectionBackground.isHidden = !selected
|
|
|
+ let perTime = totalDuration / 4.0
|
|
|
+ UIView.animateKeyframes(withDuration: totalDuration, delay: 0, options: [.calculationModeCubic], animations: {
|
|
|
+ UIView.addKeyframe(withRelativeStartTime: 0.0, relativeDuration: perTime) {
|
|
|
+ self.iconView.transform = CGAffineTransform(translationX: 0, y: -firstJumpHeight)
|
|
|
+ }
|
|
|
+ UIView.addKeyframe(withRelativeStartTime: perTime, relativeDuration: perTime) {
|
|
|
+ self.iconView.transform = .identity
|
|
|
+ }
|
|
|
+ UIView.addKeyframe(withRelativeStartTime: 2 * perTime, relativeDuration: perTime) {
|
|
|
+ self.iconView.transform = CGAffineTransform(translationX: 0, y: -secondJumpHeight)
|
|
|
+ }
|
|
|
+ UIView.addKeyframe(withRelativeStartTime: 3 * perTime, relativeDuration: perTime) {
|
|
|
+ self.iconView.transform = .identity
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
required init?(coder: NSCoder) {
|