From c8f1fd1e1bda79137e39ca3a23173801b39b384d Mon Sep 17 00:00:00 2001 From: baegteun Date: Sat, 17 Aug 2024 22:35:12 +0900 Subject: [PATCH] =?UTF-8?q?:lipstick:=20::=20[#1186]=20=EC=9E=AC=EC=83=9D?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=ED=99=94=EB=A9=B4=20=EC=9E=AC=EC=83=9D?= =?UTF-8?q?=EB=B2=84=ED=8A=BCUI=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlaylistViewController+Delegate.swift | 2 +- .../Views/RandomPlayButtonHeaderView.swift | 48 +++++++++++++++---- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/Projects/Features/PlaylistFeature/Sources/ViewControllers/PlaylistViewController+Delegate.swift b/Projects/Features/PlaylistFeature/Sources/ViewControllers/PlaylistViewController+Delegate.swift index 4167aebcd..2494abed3 100644 --- a/Projects/Features/PlaylistFeature/Sources/ViewControllers/PlaylistViewController+Delegate.swift +++ b/Projects/Features/PlaylistFeature/Sources/ViewControllers/PlaylistViewController+Delegate.swift @@ -70,7 +70,7 @@ extension PlaylistViewController: UITableViewDelegate { public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { let randomPlayButton = RandomPlayButtonHeaderView(frame: .zero) - randomPlayButton.addAction { [weak self] in + randomPlayButton.setPlayButtonHandler { [weak self] in guard let self else { return } LogManager.analytics( CommonAnalyticsLog.clickPlayButton(location: .playlist, type: .random) diff --git a/Projects/Features/PlaylistFeature/Sources/Views/RandomPlayButtonHeaderView.swift b/Projects/Features/PlaylistFeature/Sources/Views/RandomPlayButtonHeaderView.swift index b1ba55ad1..277ae476d 100644 --- a/Projects/Features/PlaylistFeature/Sources/Views/RandomPlayButtonHeaderView.swift +++ b/Projects/Features/PlaylistFeature/Sources/Views/RandomPlayButtonHeaderView.swift @@ -5,13 +5,19 @@ import Then import UIKit import Utility -final class RandomPlayButtonHeaderView: UIView { +final class RandomPlayButtonHeaderView: UICollectionReusableView { private let randomPlayButton = RandomPlayButton() + private let blurEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .regular)).then { + $0.layer.cornerRadius = 8 + $0.clipsToBounds = true + } + + private var playButtonHandler: (() -> Void)? override init(frame: CGRect) { super.init(frame: frame) - setupView() - self.backgroundColor = DesignSystemAsset.BlueGrayColor.gray100.color + setupViews() + bind() } @available(*, unavailable) @@ -19,19 +25,33 @@ final class RandomPlayButtonHeaderView: UIView { fatalError("init(coder:) has not been implemented") } - func addAction(didTap: @escaping () -> Void) { - randomPlayButton.addAction { - didTap() - } + override func apply(_ layoutAttributes: UICollectionViewLayoutAttributes) { + super.apply(layoutAttributes) + layer.zPosition = 1 } - private func setupView() { - addSubviews(randomPlayButton) + func setPlayButtonHandler(handler: @escaping () -> Void) { + self.playButtonHandler = handler + } + + private func setupViews() { + addSubviews(blurEffectView, randomPlayButton) + blurEffectView.snp.makeConstraints { + $0.horizontalEdges.equalToSuperview().inset(20) + $0.verticalEdges.equalToSuperview().inset(8) + } + randomPlayButton.snp.makeConstraints { $0.horizontalEdges.equalToSuperview().inset(20) $0.verticalEdges.equalToSuperview().inset(8) } } + + private func bind() { + randomPlayButton.addAction { [weak self] in + self?.playButtonHandler?() + } + } } private final class RandomPlayButton: UIButton { @@ -57,6 +77,14 @@ private final class RandomPlayButton: UIButton { fatalError("init(coder:) has not been implemented") } + func updateTitle(isOverMaximumNumber: Bool) { + playLabel.text = if isOverMaximumNumber { + LocalizationStrings.title50RandomPlay + } else { + LocalizationStrings.titleRandomPlay + } + } + private func setupView() { addSubviews(randomImageView, playLabel) @@ -74,6 +102,6 @@ private final class RandomPlayButton: UIButton { layer.borderColor = DesignSystemAsset.BlueGrayColor.blueGray200.color .withAlphaComponent(0.4).cgColor layer.cornerRadius = 8 - backgroundColor = DesignSystemAsset.PrimaryColorV2.white.color + backgroundColor = DesignSystemAsset.PrimaryColorV2.white.color.withAlphaComponent(0.4) } }