Files
SideStore/AltStore/My Apps/UpdateCollectionViewCell.swift
Riley Testut eb5b1a616a [AltStore] Adds basic Patreon integration
- Lists beta versions of apps when signed in to Patreon
- Lists names of Patrons with the Credits benefit
2019-08-28 11:13:22 -07:00

84 lines
2.1 KiB
Swift

//
// UpdateCollectionViewCell.swift
// AltStore
//
// Created by Riley Testut on 7/16/19.
// Copyright © 2019 Riley Testut. All rights reserved.
//
import UIKit
extension UpdateCollectionViewCell
{
enum Mode
{
case collapsed
case expanded
}
}
@objc class UpdateCollectionViewCell: UICollectionViewCell
{
var mode: Mode = .expanded {
didSet {
self.update()
}
}
@IBOutlet var appIconImageView: UIImageView!
@IBOutlet var nameLabel: UILabel!
@IBOutlet var dateLabel: UILabel!
@IBOutlet var updateButton: PillButton!
@IBOutlet var versionDescriptionTitleLabel: UILabel!
@IBOutlet var versionDescriptionTextView: CollapsingTextView!
@IBOutlet var betaBadgeView: UIImageView!
override func awakeFromNib()
{
super.awakeFromNib()
self.contentView.layer.cornerRadius = 20
self.contentView.layer.masksToBounds = true
self.update()
}
override func tintColorDidChange()
{
super.tintColorDidChange()
self.update()
}
override func apply(_ layoutAttributes: UICollectionViewLayoutAttributes)
{
// Animates transition to new attributes.
let animator = UIViewPropertyAnimator(springTimingParameters: UISpringTimingParameters()) {
self.layoutIfNeeded()
}
animator.startAnimation()
}
}
private extension UpdateCollectionViewCell
{
func update()
{
switch self.mode
{
case .collapsed: self.versionDescriptionTextView.isCollapsed = true
case .expanded: self.versionDescriptionTextView.isCollapsed = false
}
self.versionDescriptionTitleLabel.textColor = self.tintColor
self.contentView.backgroundColor = self.tintColor.withAlphaComponent(0.1)
self.updateButton.setTitleColor(self.tintColor, for: .normal)
self.updateButton.backgroundColor = self.tintColor.withAlphaComponent(0.15)
self.updateButton.progressTintColor = self.tintColor
self.setNeedsLayout()
self.layoutIfNeeded()
}
}