From bff9eef2dd53ce70c7b35b04aaf558ace9b47799 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Mon, 16 Oct 2023 18:59:43 -0500 Subject: [PATCH] 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. --- AltStore/Components/AppBannerView.swift | 55 ++++++++++++++++++++++++- AltStore/Components/AppBannerView.xib | 20 +++++---- 2 files changed, 64 insertions(+), 11 deletions(-) diff --git a/AltStore/Components/AppBannerView.swift b/AltStore/Components/AppBannerView.swift index 02bd9609..86cb2b8b 100644 --- a/AltStore/Components/AppBannerView.swift +++ b/AltStore/Components/AppBannerView.swift @@ -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 + } + } } } diff --git a/AltStore/Components/AppBannerView.xib b/AltStore/Components/AppBannerView.xib index c27095f2..cb8cfdd9 100644 --- a/AltStore/Components/AppBannerView.xib +++ b/AltStore/Components/AppBannerView.xib @@ -1,9 +1,9 @@ - + - + @@ -17,6 +17,8 @@ + + @@ -43,18 +45,18 @@ - + - + - + @@ -76,13 +78,13 @@ - + - + - +