Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”€ :: (#1186) μž¬μƒλͺ©λ‘ν™”λ©΄ μž¬μƒλ²„νŠΌ UI λ³€κ²½ #1188

Merged
merged 1 commit into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}
Loading