diff --git a/Tusker/Screens/Explore/TrendingLinkCardCollectionViewCell.swift b/Tusker/Screens/Explore/TrendingLinkCardCollectionViewCell.swift index c3cc2291..f9fdad85 100644 --- a/Tusker/Screens/Explore/TrendingLinkCardCollectionViewCell.swift +++ b/Tusker/Screens/Explore/TrendingLinkCardCollectionViewCell.swift @@ -22,6 +22,8 @@ class TrendingLinkCardCollectionViewCell: UICollectionViewCell { @IBOutlet weak var activityLabel: UILabel! @IBOutlet weak var historyView: TrendHistoryView! + private var hoverGestureAnimator: UIViewPropertyAnimator? + override func awakeFromNib() { super.awakeFromNib() @@ -32,6 +34,8 @@ class TrendingLinkCardCollectionViewCell: UICollectionViewCell { updateLayerColors() NotificationCenter.default.addObserver(self, selector: #selector(updateUIForPreferences), name: .preferencesChanged, object: nil) + + addGestureRecognizer(UIHoverGestureRecognizer(target: self, action: #selector(hoverRecognized))) } override func layoutSubviews() { @@ -138,12 +142,30 @@ class TrendingLinkCardCollectionViewCell: UICollectionViewCell { private func updateLayerColors() { if traitCollection.userInterfaceStyle == .dark { -// clippingView.layer.borderColor = UIColor.darkGray.withAlphaComponent(0.5).cgColor layer.shadowColor = UIColor.darkGray.cgColor } else { -// clippingView.layer.borderColor = UIColor.lightGray.withAlphaComponent(0.5).cgColor layer.shadowColor = UIColor.black.cgColor } } + // MARK: Interaction + + @objc private func hoverRecognized(_ recognizer: UIHoverGestureRecognizer) { + switch recognizer.state { + case .began, .changed: + hoverGestureAnimator = UIViewPropertyAnimator(duration: 0.2, curve: .easeInOut, animations: { + self.transform = CGAffineTransform(scaleX: 1.05, y: 1.05) + }) + hoverGestureAnimator!.startAnimation() + case .ended: + hoverGestureAnimator?.stopAnimation(true) + hoverGestureAnimator?.addAnimations { + self.transform = .identity + } + hoverGestureAnimator?.startAnimation() + default: + break + } + } + } diff --git a/Tusker/Screens/Explore/TrendingLinkCardCollectionViewCell.xib b/Tusker/Screens/Explore/TrendingLinkCardCollectionViewCell.xib index 8549f22b..53111e9b 100644 --- a/Tusker/Screens/Explore/TrendingLinkCardCollectionViewCell.xib +++ b/Tusker/Screens/Explore/TrendingLinkCardCollectionViewCell.xib @@ -56,9 +56,9 @@ - + - +