Skip to content

Commit

Permalink
💄 :: [#1186] 재생목록화면 재생버튼UI 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
baekteun committed Aug 17, 2024
1 parent 5548e78 commit c8f1fd1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,53 @@ 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)
required init?(coder: NSCoder) {
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 {
Expand All @@ -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)

Expand All @@ -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)
}
}

0 comments on commit c8f1fd1

Please sign in to comment.