Skip to content

Commit

Permalink
[fix] 플레이리스트 옮기기 -> 플레이리스트 선택, 음악 선택 UI 레이아웃 변경 (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaewift committed Nov 16, 2024
1 parent 6b19180 commit ae33053
Show file tree
Hide file tree
Showing 5 changed files with 166 additions and 168 deletions.
240 changes: 120 additions & 120 deletions PLUV/Select/Cell/SelectPlaylistCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,124 +11,124 @@ import RxCocoa
import Kingfisher

final class SelectPlaylistCollectionViewCell: UICollectionViewCell {

static let identifier = String(describing: SelectPlaylistCollectionViewCell.self)

private let thumbnailImageView = UIImageView().then {
// $0.layer.cornerRadius = 8
$0.clipsToBounds = true
}
private let playButtonImageView = UIImageView().then {
$0.image = UIImage(named: "playbutton_icon")
}
private let playlistTitleLabel = UILabel().then {
$0.textColor = .gray800
$0.font = .systemFont(ofSize: 18, weight: .medium)
}
private let songCountLabel = UILabel().then {
$0.textColor = .gray500
$0.font = .systemFont(ofSize: 12)
}
private let dateLabel = UILabel().then {
$0.textColor = .gray500
$0.font = .systemFont(ofSize: 12)
}

override init(frame: CGRect) {
super.init(frame: .zero)
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func layoutSubviews() {
setUI()
}

private func setUI() {
self.contentView.addSubview(thumbnailImageView)
thumbnailImageView.snp.makeConstraints { make in
make.top.leading.trailing.equalToSuperview()
make.height.equalTo(thumbnailImageView.snp.width)
}

/*
self.thumbnailImageView.addSubview(playButtonImageView)
playButtonImageView.snp.makeConstraints { make in
make.width.equalTo(17)
make.height.equalTo(19)
make.trailing.bottom.equalToSuperview().inset(12)
}
*/

self.contentView.addSubview(playlistTitleLabel)
playlistTitleLabel.snp.makeConstraints { make in
make.top.equalTo(thumbnailImageView.snp.bottom).offset(10)
make.leading.trailing.equalToSuperview()
make.height.equalTo(20) /// g, y, p 같은 문자 이슈로 2point 늘림
}

self.contentView.addSubview(songCountLabel)
songCountLabel.snp.makeConstraints { make in
make.top.equalTo(playlistTitleLabel.snp.bottom).offset(10)
make.leading.equalToSuperview()
make.height.equalTo(12)
}

self.contentView.addSubview(dateLabel)
dateLabel.snp.makeConstraints { make in
make.top.equalTo(songCountLabel.snp.top)
make.leading.equalTo(songCountLabel.snp.trailing).offset(6)
make.height.equalTo(songCountLabel.snp.height)
}
}

func prepare(playlist: Playlist, platform: PlatformRepresentable) {
self.dateLabel.isHidden = true
if let musicPlatform = platform as? MusicPlatform, musicPlatform == .AppleMusic {
self.songCountLabel.isHidden = true
}

let thumbNailUrl = URL(string: playlist.thumbnailURL)
self.thumbnailImageView.kf.setImage(with: thumbNailUrl)
self.playlistTitleLabel.text = playlist.name
self.songCountLabel.text = "\(String(playlist.songCount ?? 0))"
self.dateLabel.text = "2024.04.20"

let borderWidth: CGFloat = 2.4
thumbnailImageView.frame = CGRectInset(self.frame, -borderWidth, -borderWidth)
thumbnailImageView.layer.borderColor = UIColor.mainPurple.cgColor
thumbnailImageView.layer.borderWidth = 0
}

func mePrepare(me: Me, platform: PlatformRepresentable) {
let thumbNailUrl = URL(string: me.imageURL)
self.thumbnailImageView.kf.setImage(with: thumbNailUrl)
self.playlistTitleLabel.text = me.title
self.songCountLabel.text = "\(me.transferredSongCount ?? 0)"
self.dateLabel.text = "\(me.transferredAt)"

let borderWidth: CGFloat = 2.4
thumbnailImageView.frame = CGRectInset(self.frame, -borderWidth, -borderWidth)
thumbnailImageView.layer.borderColor = UIColor.mainPurple.cgColor
thumbnailImageView.layer.borderWidth = 0
}

func savePrepare(feed: Feed, platform: PlatformRepresentable) {
let thumbNailUrl = URL(string: feed.thumbNailURL)
self.thumbnailImageView.kf.setImage(with: thumbNailUrl)
self.playlistTitleLabel.text = feed.title
self.songCountLabel.text = "\(feed.totalSongCount ?? 0)"
self.dateLabel.text = "\(feed.transferredAt)"

let borderWidth: CGFloat = 2.4
thumbnailImageView.frame = CGRectInset(self.frame, -borderWidth, -borderWidth)
thumbnailImageView.layer.borderColor = UIColor.mainPurple.cgColor
thumbnailImageView.layer.borderWidth = 0
}

func updateSelectionUI(isSelected: Bool) {
thumbnailImageView.layer.borderWidth = isSelected ? 2.4 : 0
}
static let identifier = String(describing: SelectPlaylistCollectionViewCell.self)
private let thumbnailImageView = UIImageView().then {
$0.layer.cornerRadius = 8
$0.clipsToBounds = true
}
private let playButtonImageView = UIImageView().then {
$0.image = UIImage(named: "playbutton_icon")
}
private let playlistTitleLabel = UILabel().then {
$0.textColor = .gray800
$0.font = .systemFont(ofSize: 18, weight: .medium)
}
private let songCountLabel = UILabel().then {
$0.textColor = .gray500
$0.font = .systemFont(ofSize: 12)
}
private let dateLabel = UILabel().then {
$0.textColor = .gray500
$0.font = .systemFont(ofSize: 12)
}
override init(frame: CGRect) {
super.init(frame: .zero)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func layoutSubviews() {
setUI()
}
private func setUI() {
self.contentView.addSubview(thumbnailImageView)
thumbnailImageView.snp.makeConstraints { make in
make.top.leading.trailing.equalToSuperview()
make.height.equalTo(thumbnailImageView.snp.width)
}
/*
self.thumbnailImageView.addSubview(playButtonImageView)
playButtonImageView.snp.makeConstraints { make in
make.width.equalTo(17)
make.height.equalTo(19)
make.trailing.bottom.equalToSuperview().inset(12)
}
*/
self.contentView.addSubview(playlistTitleLabel)
playlistTitleLabel.snp.makeConstraints { make in
make.top.equalTo(thumbnailImageView.snp.bottom).offset(10)
make.leading.trailing.equalToSuperview()
make.height.equalTo(20) /// g, y, p 같은 문자 이슈로 2point 늘림
}
self.contentView.addSubview(songCountLabel)
songCountLabel.snp.makeConstraints { make in
make.top.equalTo(playlistTitleLabel.snp.bottom).offset(10)
make.leading.equalToSuperview()
make.height.equalTo(12)
}
self.contentView.addSubview(dateLabel)
dateLabel.snp.makeConstraints { make in
make.top.equalTo(songCountLabel.snp.top)
make.leading.equalTo(songCountLabel.snp.trailing).offset(6)
make.height.equalTo(songCountLabel.snp.height)
}
}
func prepare(playlist: Playlist, platform: PlatformRepresentable) {
self.dateLabel.isHidden = true
if let musicPlatform = platform as? MusicPlatform, musicPlatform == .AppleMusic {
self.songCountLabel.isHidden = true
}
let thumbNailUrl = URL(string: playlist.thumbnailURL)
self.thumbnailImageView.kf.setImage(with: thumbNailUrl)
self.playlistTitleLabel.text = playlist.name
self.songCountLabel.text = "\(String(playlist.songCount ?? 0))"
self.dateLabel.text = "2024.04.20"
let borderWidth: CGFloat = 2.4
thumbnailImageView.frame = CGRectInset(self.frame, -borderWidth, -borderWidth)
thumbnailImageView.layer.borderColor = UIColor.mainPurple.cgColor
thumbnailImageView.layer.borderWidth = 0
}
func mePrepare(me: Me, platform: PlatformRepresentable) {
let thumbNailUrl = URL(string: me.imageURL)
self.thumbnailImageView.kf.setImage(with: thumbNailUrl)
self.playlistTitleLabel.text = me.title
self.songCountLabel.text = "\(me.transferredSongCount ?? 0)"
self.dateLabel.text = "\(me.transferredAt)"
let borderWidth: CGFloat = 2.4
thumbnailImageView.frame = CGRectInset(self.frame, -borderWidth, -borderWidth)
thumbnailImageView.layer.borderColor = UIColor.mainPurple.cgColor
thumbnailImageView.layer.borderWidth = 0
}
func savePrepare(feed: Feed, platform: PlatformRepresentable) {
let thumbNailUrl = URL(string: feed.thumbNailURL)
self.thumbnailImageView.kf.setImage(with: thumbNailUrl)
self.playlistTitleLabel.text = feed.title
self.songCountLabel.text = "\(feed.totalSongCount ?? 0)"
self.dateLabel.text = "\(feed.transferredAt)"
let borderWidth: CGFloat = 2.4
thumbnailImageView.frame = CGRectInset(self.frame, -borderWidth, -borderWidth)
thumbnailImageView.layer.borderColor = UIColor.mainPurple.cgColor
thumbnailImageView.layer.borderWidth = 0
}
func updateSelectionUI(isSelected: Bool) {
thumbnailImageView.layer.borderWidth = isSelected ? 2.4 : 0
}
}
79 changes: 36 additions & 43 deletions PLUV/Select/SelectMusicViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class SelectMusicViewController: UIViewController {

private let selectMusicTitleView = UIView()
private let sourceToDestinationLabel = UILabel().then {
$0.font = .systemFont(ofSize: 14, weight: .regular)
$0.textColor = .subBlue
$0.font = .systemFont(ofSize: 14, weight: .medium)
$0.textColor = .gray800
}
private let backButton = UIButton().then {
$0.setImage(UIImage(named: "xbutton_icon"), for: .normal)
Expand All @@ -50,6 +50,7 @@ class SelectMusicViewController: UIViewController {
private let playlistView = UIView()
private let playlistThumnailImageView = UIImageView().then {
$0.layer.borderColor = UIColor(white: 0, alpha: 0.1).cgColor
$0.layer.cornerRadius = 8
$0.layer.borderWidth = 0.5
$0.clipsToBounds = true
}
Expand Down Expand Up @@ -97,26 +98,20 @@ class SelectMusicViewController: UIViewController {
setUI()
setMusicListAPI()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.setNavigationBarHidden(true, animated: false)
}

private func setUI() {
self.view.backgroundColor = .white
self.navigationItem.setHidesBackButton(true, animated: false)
self.navigationController?.setNavigationBarHidden(true, animated: false)

self.view.addSubview(scrollView)
scrollView.snp.makeConstraints { make in
make.top.bottom.leading.trailing.equalTo(view.safeAreaLayoutGuide)
}

self.scrollView.addSubview(contentView)
contentView.snp.makeConstraints { make in
make.top.bottom.leading.trailing.equalTo(view.safeAreaLayoutGuide)
}

self.contentView.addSubview(selectMusicTitleView)
self.view.addSubview(selectMusicTitleView)
selectMusicTitleView.snp.makeConstraints { make in
make.top.leading.trailing.equalToSuperview()
make.height.equalTo(213)
make.height.equalTo(221)
}

self.selectMusicTitleView.addSubview(sourceToDestinationLabel)
Expand Down Expand Up @@ -147,54 +142,52 @@ class SelectMusicViewController: UIViewController {
playlistTitleLabel.snp.makeConstraints { make in
make.top.equalTo(progressView.snp.bottom).offset(24)
make.leading.trailing.equalToSuperview().inset(24)
make.bottom.equalToSuperview().inset(28)
make.height.equalTo(68)
}

self.contentView.addSubview(playlistView)
self.view.addSubview(playlistView)
playlistView.snp.makeConstraints { make in
make.leading.trailing.equalToSuperview()
make.top.equalTo(selectMusicTitleView.snp.bottom)
make.height.equalTo(126)
make.top.equalTo(selectMusicTitleView.snp.bottom)
make.height.equalTo(110)
}

self.playlistView.addSubview(playlistThumnailImageView)
playlistThumnailImageView.snp.makeConstraints { make in
make.width.height.equalTo(86)
make.top.equalToSuperview()
make.centerY.equalToSuperview()
make.leading.equalToSuperview().offset(24)
}

self.playlistView.addSubview(playlistMenuImageView)
playlistMenuImageView.snp.makeConstraints { make in
make.top.equalToSuperview().offset(14)
make.leading.equalTo(playlistThumnailImageView.snp.trailing).offset(12)
make.width.height.equalTo(20)
}

self.playlistView.addSubview(playlistNameLabel)
playlistNameLabel.snp.makeConstraints { make in
make.leading.equalTo(playlistMenuImageView.snp.trailing).offset(4)
make.centerY.equalTo(playlistMenuImageView)
make.trailing.equalToSuperview().inset(24)
}

self.playlistView.addSubview(sourcePlatformLabel)
sourcePlatformLabel.snp.makeConstraints { make in
make.top.equalToSuperview().offset(3)
make.leading.equalTo(playlistThumnailImageView.snp.trailing).offset(12)
make.top.equalTo(playlistNameLabel.snp.bottom).offset(12)
make.leading.equalTo(playlistThumnailImageView.snp.trailing).offset(12)
make.height.equalTo(14)
make.trailing.equalToSuperview().inset(24)
}

self.playlistView.addSubview(playlistMenuImageView)
playlistMenuImageView.snp.makeConstraints { make in
make.top.equalTo(sourcePlatformLabel.snp.bottom).offset(10)
make.leading.equalTo(sourcePlatformLabel.snp.leading)
make.width.height.equalTo(20)
}

self.playlistView.addSubview(playlistNameLabel)
playlistNameLabel.snp.makeConstraints { make in
make.leading.equalTo(playlistMenuImageView.snp.trailing).offset(4)
make.centerY.equalTo(playlistMenuImageView)
make.trailing.equalToSuperview().inset(24)
}

self.playlistView.addSubview(playlistSongCountLabel)
playlistSongCountLabel.snp.makeConstraints { make in
make.leading.equalTo(sourcePlatformLabel.snp.leading)
make.bottom.equalTo(playlistThumnailImageView.snp.bottom).offset(-3)
make.top.equalTo(playlistNameLabel.snp.bottom).offset(12)
make.leading.equalTo(sourcePlatformLabel.snp.trailing).offset(4)
make.height.equalTo(14)
make.trailing.equalToSuperview().inset(24)
}

self.contentView.addSubview(selectSongView)
self.view.addSubview(selectSongView)
selectSongView.snp.makeConstraints { make in
make.top.equalTo(playlistView.snp.bottom)
make.leading.trailing.equalToSuperview()
Expand Down Expand Up @@ -222,7 +215,7 @@ class SelectMusicViewController: UIViewController {
make.width.height.equalTo(16)
}

self.contentView.addSubview(selectMusicTableView)
self.view.addSubview(selectMusicTableView)
selectMusicTableView.snp.makeConstraints { make in
make.top.equalTo(selectSongView.snp.bottom)
make.leading.trailing.equalToSuperview()
Expand Down Expand Up @@ -333,7 +326,7 @@ class SelectMusicViewController: UIViewController {

private func goNextStep() {
if self.searchArr.count == self.completeArr.count {
self.setValidationView(title: "플레이리스트의 모든 음악을 찾았어요!", image: "check_image")
self.setValidationView(title: "플레이리스트의 모든 음악을 찾았어요!", image: "ok_image")
let movePlaylistVC = MovePlaylistViewController(musicArr: completeArr, source: self.sourcePlatform!, destination: self.destinationPlatform)
movePlaylistVC.viewModel.playlistItem = viewModel.playlistItem
movePlaylistVC.meViewModel.meItem = meViewModel.meItem
Expand Down
Loading

0 comments on commit ae33053

Please sign in to comment.