[AltStore] Refactors BrowseViewController screenshot size logic

This commit is contained in:
Riley Testut
2019-07-30 12:41:50 -07:00
parent 52cb01c6c7
commit 0efa3c4694
7 changed files with 248 additions and 159 deletions

View File

@@ -13,15 +13,25 @@ import Roxas
@objc(ScreenshotCollectionViewCell)
class ScreenshotCollectionViewCell: UICollectionViewCell
{
let imageView: UIImageView
let imageView = UIImageView(image: nil)
override init(frame: CGRect)
{
super.init(frame: frame)
self.initialize()
}
required init?(coder aDecoder: NSCoder)
{
self.imageView = UIImageView(image: nil)
self.imageView.layer.masksToBounds = true
super.init(coder: aDecoder)
self.initialize()
}
private func initialize()
{
self.imageView.layer.masksToBounds = true
self.addSubview(self.imageView, pinningEdgesWith: .zero)
}
@@ -29,14 +39,6 @@ class ScreenshotCollectionViewCell: UICollectionViewCell
{
super.layoutSubviews()
if let image = self.imageView.image, (image.size.height / image.size.width) > ((16.0 / 9.0) + 0.1)
{
// Image aspect ratio is taller than 16:9, so assume it's an X-style screenshot and set corner radius.
self.imageView.layer.cornerRadius = max(self.imageView.bounds.width / 9.8, 8)
}
else
{
self.imageView.layer.cornerRadius = 0
}
self.imageView.layer.cornerRadius = 4
}
}