//
//  FindFriendsCell.swift
//  WoWonder
//
//  Created by UnikApp on 05/12/22.
//  Copyright © 2022 ScriptSun. All rights reserved.
//

import UIKit
import SkeletonView

protocol FindFriendsCellDelegate {
    func handleFollowButtonTap(_ sender: UIButton, indexPath: IndexPath)
}

class FindFriendsCell: UICollectionViewCell {
    
    @IBOutlet weak var cellView: UIView!
    @IBOutlet weak var userImageView: UIImageView!
    @IBOutlet weak var statusImageView: UIImageView!
    @IBOutlet weak var followButton: UIButton!
    @IBOutlet weak var userNameLabel: UILabel!
    @IBOutlet weak var lastSeenLabel: UILabel!
    
    var indexPath = IndexPath()
    var delegate: FindFriendsCellDelegate?
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        // Initialization code
        
    }

    @IBAction func followButtonAction(_ sender: UIButton) {
        self.delegate?.handleFollowButtonTap(sender, indexPath: self.indexPath)
    }
    
    func showAnimation() {
        [lastSeenLabel, userNameLabel].forEach { $0?.showAnimatedSkeleton() }
        followButton.showAnimatedSkeleton()
        statusImageView.showAnimatedSkeleton()
        userImageView.showAnimatedSkeleton()
    }
    
    func hideAnimation() {
        [lastSeenLabel, userNameLabel].forEach { $0?.hideSkeleton() }
        followButton.hideSkeleton()
        statusImageView.hideSkeleton()
        userImageView.hideSkeleton()
    }
    
}
