mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-17 18:53:40 +01:00
Replaces BrowseCollectionViewCell with AppCardCollectionViewCell
* Handles dynamic screenshot sizes * Allows swiping through screenshots * Supports iPhone + iPad screenshots
This commit is contained in:
@@ -10,6 +10,20 @@ import UIKit
|
||||
|
||||
import AltStoreCore
|
||||
|
||||
extension AppScreenshotCollectionViewCell
|
||||
{
|
||||
private class ImageView: UIImageView
|
||||
{
|
||||
override func layoutSubviews()
|
||||
{
|
||||
super.layoutSubviews()
|
||||
|
||||
// Explicitly layout cell to ensure rounded corners are accurate.
|
||||
self.superview?.superview?.setNeedsLayout()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AppScreenshotCollectionViewCell: UICollectionViewCell
|
||||
{
|
||||
let imageView: UIImageView
|
||||
@@ -31,21 +45,21 @@ class AppScreenshotCollectionViewCell: UICollectionViewCell
|
||||
|
||||
override init(frame: CGRect)
|
||||
{
|
||||
self.imageView = UIImageView(frame: .zero)
|
||||
self.imageView = ImageView(frame: .zero)
|
||||
self.imageView.clipsToBounds = true
|
||||
self.imageView.layer.cornerCurve = .continuous
|
||||
self.imageView.layer.borderColor = UIColor.tertiaryLabel.cgColor
|
||||
|
||||
|
||||
super.init(frame: frame)
|
||||
|
||||
self.imageView.translatesAutoresizingMaskIntoConstraints = false
|
||||
self.contentView.addSubview(self.imageView)
|
||||
|
||||
let widthConstraint = self.imageView.widthAnchor.constraint(equalTo: self.contentView.widthAnchor)
|
||||
widthConstraint.priority = UILayoutPriority(999)
|
||||
widthConstraint.priority = .defaultHigh
|
||||
|
||||
let heightConstraint = self.imageView.heightAnchor.constraint(equalTo: self.contentView.heightAnchor)
|
||||
heightConstraint.priority = UILayoutPriority(999)
|
||||
heightConstraint.priority = .defaultHigh
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
widthConstraint,
|
||||
@@ -64,7 +78,7 @@ class AppScreenshotCollectionViewCell: UICollectionViewCell
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?)
|
||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?)
|
||||
{
|
||||
super.traitCollectionDidChange(previousTraitCollection)
|
||||
|
||||
@@ -75,11 +89,6 @@ class AppScreenshotCollectionViewCell: UICollectionViewCell
|
||||
{
|
||||
super.layoutSubviews()
|
||||
|
||||
guard self.imageView.bounds.width != 0 else {
|
||||
self.setNeedsLayout()
|
||||
return
|
||||
}
|
||||
|
||||
if self.isRounded
|
||||
{
|
||||
let cornerRadius = self.imageView.bounds.width / 9.0 // Based on iPhone 15
|
||||
|
||||
Reference in New Issue
Block a user