mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
Adds AppBannerView.style to switch between app and source styles
`app` banners have rounded rect icons and use a lighter version of tint color as background, while `source` banners have circular icons and use the original tint color as background.
This commit is contained in:
@@ -11,6 +11,15 @@ import UIKit
|
||||
import AltStoreCore
|
||||
import Roxas
|
||||
|
||||
extension AppBannerView
|
||||
{
|
||||
enum Style
|
||||
{
|
||||
case app
|
||||
case source
|
||||
}
|
||||
}
|
||||
|
||||
class AppBannerView: RSTNibView
|
||||
{
|
||||
override var accessibilityLabel: String? {
|
||||
@@ -38,6 +47,8 @@ class AppBannerView: RSTNibView
|
||||
set { self.accessibilityView?.accessibilityTraits = newValue }
|
||||
}
|
||||
|
||||
var style: Style = .app
|
||||
|
||||
private var originalTintColor: UIColor?
|
||||
|
||||
@IBOutlet var titleLabel: UILabel!
|
||||
@@ -50,8 +61,11 @@ class AppBannerView: RSTNibView
|
||||
@IBOutlet var backgroundEffectView: UIVisualEffectView!
|
||||
|
||||
@IBOutlet private var vibrancyView: UIVisualEffectView!
|
||||
@IBOutlet private var stackView: UIStackView!
|
||||
@IBOutlet private var accessibilityView: UIView!
|
||||
|
||||
@IBOutlet private var iconImageViewHeightConstraint: NSLayoutConstraint!
|
||||
|
||||
override init(frame: CGRect)
|
||||
{
|
||||
super.init(frame: frame)
|
||||
@@ -74,6 +88,10 @@ class AppBannerView: RSTNibView
|
||||
self.accessibilityElements = [self.accessibilityView, self.button].compactMap { $0 }
|
||||
|
||||
self.betaBadgeView.isHidden = true
|
||||
|
||||
self.layoutMargins = self.stackView.layoutMargins
|
||||
self.stackView.preservesSuperviewLayoutMargins = true
|
||||
self.stackView.isLayoutMarginsRelativeArrangement = true
|
||||
}
|
||||
|
||||
override func tintColorDidChange()
|
||||
@@ -138,7 +156,40 @@ private extension AppBannerView
|
||||
self.clipsToBounds = true
|
||||
self.layer.cornerRadius = 22
|
||||
|
||||
self.subtitleLabel.textColor = self.originalTintColor ?? self.tintColor
|
||||
self.backgroundEffectView.backgroundColor = self.originalTintColor ?? self.tintColor
|
||||
let tintColor = self.originalTintColor ?? self.tintColor
|
||||
self.subtitleLabel.textColor = tintColor
|
||||
|
||||
switch self.style
|
||||
{
|
||||
case .app:
|
||||
self.iconImageViewHeightConstraint.constant = 60
|
||||
self.iconImageView.style = .icon
|
||||
|
||||
self.titleLabel.textColor = .label
|
||||
|
||||
self.backgroundEffectView.contentView.backgroundColor = UIColor(resource: .blurTint)
|
||||
self.backgroundEffectView.backgroundColor = tintColor
|
||||
|
||||
case .source:
|
||||
self.iconImageViewHeightConstraint.constant = 44
|
||||
self.iconImageView.style = .circular
|
||||
|
||||
self.titleLabel.textColor = .white
|
||||
|
||||
self.backgroundEffectView.contentView.backgroundColor = tintColor?.adjustedForDisplay
|
||||
self.backgroundEffectView.backgroundColor = nil
|
||||
|
||||
if let tintColor, tintColor.isTooBright
|
||||
{
|
||||
let textVibrancyEffect = UIVibrancyEffect(blurEffect: .init(style: .systemChromeMaterialLight), style: .fill)
|
||||
self.vibrancyView.effect = textVibrancyEffect
|
||||
}
|
||||
else
|
||||
{
|
||||
// Thinner == more dull
|
||||
let textVibrancyEffect = UIVibrancyEffect(blurEffect: .init(style: .systemThinMaterialDark), style: .secondaryLabel)
|
||||
self.vibrancyView.effect = textVibrancyEffect
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user