import UIKit
import SDWebImage

class AddParticipantsTableCell: UITableViewCell {
    
    @IBOutlet weak var userNameLabel: UILabel!
    @IBOutlet weak var profileImage: UIImageView!
    @IBOutlet weak var aboutLabel: UILabel!
    @IBOutlet weak var verifiedImage: UIImageView!
    @IBOutlet weak var radioButton: UIButton!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        // Initialization code
        
        self.initialConfig()
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        
        // Configure the view for the selected state
    }
    
    // Initial Config
    func initialConfig() {
        self.selectionStyle = .none
    }
    
    // Set Data
    func setData(object: UserData, isSelected: Bool) {
        self.userNameLabel.text = object.name ?? ""
        if object.about == "" {
            self.aboutLabel.text = "Hi there i am using WoWonder Messanger"
        } else {
            self.aboutLabel.text = object.about
        }
        self.verifiedImage.isHidden = object.is_verified == 0
        let imageUrl = URL.init(string: object.avatar ?? "")
        let indicator = SDWebImageActivityIndicator.medium
        self.profileImage.sd_imageIndicator = indicator
        DispatchQueue.global(qos: .userInteractive).async {
            self.profileImage.sd_setImage(with: imageUrl, placeholderImage: UIImage(named: ""))
        }
        if isSelected {
            self.radioButton.setImage(R.image.ic_radio_on(), for: .normal)
        } else {
            self.radioButton.setImage(R.image.ic_radio_off(), for: .normal)
        }
    }
    
}
