Created
July 3, 2020 07:28
-
-
Save stevencurtis/9d30d10f148d8ac20452367c6738dcfd to your computer and use it in GitHub Desktop.
appstandardcollectionviewcell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppStandardCollectionViewCell: UICollectionViewCell { | |
@IBOutlet weak var getButton: UIButton! | |
@IBOutlet weak var subtitle: UILabel! | |
@IBOutlet weak var title: UILabel! | |
@IBOutlet weak var inAppLabel: UILabel! | |
@IBOutlet weak var appImage: UIImageView! | |
@IBOutlet weak var border: UIView! | |
var subscribeButtonAction: (() -> ())? | |
public func configure(with data: AppDataModel, final: Bool) { | |
title.text = data.title | |
subtitle.text = data.subtitle | |
inAppLabel.isHidden = !((data.inApp) ?? false) | |
(final) ? (border.isHidden = true) : (border.isHidden = false) | |
appImage.image = UIImage(named: data.smallImage) | |
} | |
override func awakeFromNib() { | |
super.awakeFromNib() | |
getButton.layer.cornerRadius = 15 | |
appImage.layer.cornerRadius = 12 | |
self.getButton.addTarget(self, action: #selector(getButtonTapped(_:)), for: .touchUpInside) | |
} | |
@IBAction func getButtonTapped(_ sender: UIButton){ | |
subscribeButtonAction?() | |
} | |
// Gives the cell a chance to modify the attributes provided by the layout object. | |
override func preferredLayoutAttributesFitting(_ layoutAttributes: UICollectionViewLayoutAttributes) | |
-> UICollectionViewLayoutAttributes { | |
return layoutAttributes | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment