diff --git a/StreetDrop/ShareExtension/View/ReSearchingMusic/ReSearchingMusicForSharingView.swift b/StreetDrop/ShareExtension/View/ReSearchingMusic/ReSearchingMusicForSharingView.swift new file mode 100644 index 0000000..9699b73 --- /dev/null +++ b/StreetDrop/ShareExtension/View/ReSearchingMusic/ReSearchingMusicForSharingView.swift @@ -0,0 +1,173 @@ +// +// ReSearchingMusicForSharingView.swift +// ShareExtension +// +// Created by 차요셉 on 8/16/24. +// + +import UIKit + +import RxSwift +import RxRelay +import SnapKit + +final class ReSearchingMusicForSharingView: UIView { + private let reSearchingEventRelay: PublishRelay = .init() + // View -> ViewController + var reSearchingEvent: Observable { + reSearchingEventRelay.asObservable() + } + // ViewController -> View + let settingMusicDataRelay: PublishRelay<[Music]> = .init() + private let disposeBag: DisposeBag = .init() + + override init(frame: CGRect) { + super.init(frame: frame) + bindData() + configureUI() + } + + @available(*, unavailable) + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + private let backbutton: UIButton = { + let button: UIButton = .init() + button.setImage(.init(named: "backButton"), for: .normal) + + return button + }() + + private let titleLabel: UILabel = { + let label: UILabel = .init() + label.text = "직접 검색" + label.textColor = .textPrimary + label.font = .pretendard(size: 16, weight: 700) + label.setLineHeight(lineHeight: 24) + + return label + }() + + private let exitButton: UIButton = { + let button: UIButton = .init() + button.setImage(.init(named: "exit"), for: .normal) + + return button + }() + + private lazy var searchTextField: UITextField = { + let textField: UITextField = UITextField() + textField.backgroundColor = UIColor.gray700 + textField.attributedPlaceholder = NSAttributedString( + string: "드랍할 음악 검색", + attributes: [ + .foregroundColor: UIColor.gray400 + ] + ) + textField.textColor = .textPrimary + textField.layer.cornerRadius = 12.0 + + textField.returnKeyType = .search + + let leftPaddingView = UIView( + frame: CGRect( + x: 0, + y: 0, + width: 16, + height: 44 + ) + ) + textField.leftView = leftPaddingView + textField.leftViewMode = .always + + textField.rightView = searchCancelView + textField.rightViewMode = .whileEditing + return textField + }() + + private lazy var searchCancelView: UIView = { + let view: UIView = .init() + + return view + }() + + private lazy var searchCancelButton: UIButton = { + let button: UIButton = .init() + button.setImage(UIImage(named: "cancleButton"), for: .normal) + + return button + }() + + private lazy var tableView: UITableView = { + let tableView: UITableView = .init() + tableView.backgroundColor = .clear + tableView.register( + ReSearchingMusicTableViewCell.self, + forCellReuseIdentifier: ReSearchingMusicTableViewCell.identifier + ) + tableView.rowHeight = 80 + tableView.keyboardDismissMode = .onDrag + + return tableView + }() +} + +private extension ReSearchingMusicForSharingView { + func bindData() { + settingMusicDataRelay + .bind( + to: tableView.rx.items( + cellIdentifier: ReSearchingMusicTableViewCell.identifier, + cellType: ReSearchingMusicTableViewCell.self + ) + ) { (row, music, reSearchingMusicTableViewCell) in + reSearchingMusicTableViewCell.setData(music: music) + } + .disposed(by: disposeBag) + } + + func configureUI() { + [ + backbutton, + titleLabel, + searchTextField, + exitButton, + tableView + ].forEach { + addSubview($0) + } + + searchCancelView.addSubview(searchCancelButton) + + backbutton.snp.makeConstraints { + $0.width.height.equalTo(32) + $0.top.equalToSuperview().inset(14) + $0.leading.equalToSuperview().inset(24) + } + + titleLabel.snp.makeConstraints { + $0.height.equalTo(18) + $0.top.equalToSuperview().inset(18) + $0.centerX.equalToSuperview() + } + + exitButton.snp.makeConstraints { + $0.width.equalTo(44) + $0.height.equalTo(32) + $0.top.equalToSuperview().inset(14) + $0.trailing.equalToSuperview().inset(24) + } + + searchTextField.snp.makeConstraints { + $0.height.equalTo(44) + $0.top.equalTo(titleLabel.snp.bottom).offset(26) + $0.horizontalEdges.equalToSuperview().inset(24) + } + + tableView.snp.makeConstraints { + $0.top.equalTo(searchTextField.snp.bottom).offset(12) + $0.horizontalEdges.bottom.equalToSuperview() + } + } +} diff --git a/StreetDrop/ShareExtension/View/ReSearchingMusic/ReSearchingMusicTableViewCell.swift b/StreetDrop/ShareExtension/View/ReSearchingMusic/ReSearchingMusicTableViewCell.swift new file mode 100644 index 0000000..7475d93 --- /dev/null +++ b/StreetDrop/ShareExtension/View/ReSearchingMusic/ReSearchingMusicTableViewCell.swift @@ -0,0 +1,122 @@ +// +// ReSearchingMusicTableViewCell.swift +// ShareExtension +// +// Created by 차요셉 on 8/16/24. +// + +import UIKit + +import RxSwift +import SnapKit +import Kingfisher + +final class ReSearchingMusicTableViewCell: UITableViewCell { + static let identifier = "SearchingMusicTableViewCell" + private var disposeBag: DisposeBag = DisposeBag() + + override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { + super.init(style: style, reuseIdentifier: reuseIdentifier) + self.backgroundColor = .clear + self.selectionStyle = .none + self.configureUI() + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been impl") + } + + override func setSelected(_ selected: Bool, animated: Bool) { + super.setSelected(selected, animated: animated) + } + + override func prepareForReuse() { + super.prepareForReuse() + self.albumImageView.image = nil + self.disposeBag = DisposeBag() + } + + func setData(music: Music) { + albumImageView.setImage(with: music.albumImage) + songNameLabel.text = music.songName + artistNameLabel.text = music.artistName + durationTimeLabel.text = music.durationTime + } + + private lazy var albumImageView: UIImageView = { + let imageView: UIImageView = .init() + imageView.layer.cornerRadius = 12.0 + imageView.contentMode = .scaleAspectFill + imageView.clipsToBounds = true + return imageView + }() + + private lazy var songNameLabel: UILabel = { + let label: UILabel = .init() + label.font = .pretendard(size: 16, weight: 600) + label.setLineHeight(lineHeight: 24) + label.textColor = UIColor.white + label.numberOfLines = 1 + return label + }() + + private lazy var artistNameLabel: UILabel = { + let label: UILabel = .init() + label.font = .pretendard(size: 12, weight: 400) + label.setLineHeight(lineHeight: 16) + label.numberOfLines = 1 + label.textColor = UIColor.gray200 + return label + }() + + private lazy var durationTimeLabel: UILabel = { + let label: UILabel = .init() + label.font = .pretendard(size: 12, weight: 400) + label.setLineHeight(lineHeight: 16) + label.numberOfLines = 1 + label.textColor = UIColor.gray200 + label.adjustsFontSizeToFitWidth = true + + return label + }() +} + +private extension ReSearchingMusicTableViewCell { + func configureUI() { + [ + albumImageView, + songNameLabel, + artistNameLabel, + durationTimeLabel + ].forEach { + addSubview($0) + } + + albumImageView.snp.makeConstraints { + $0.width.height.equalTo(56) + $0.centerY.equalToSuperview() + $0.leading.equalToSuperview().offset(24) + } + + songNameLabel.snp.makeConstraints { + $0.height.equalTo(24) + $0.top.equalToSuperview().inset(19) + $0.leading.equalTo(albumImageView.snp.trailing).offset(12) + $0.trailing.equalToSuperview().inset(60) + } + + artistNameLabel.snp.makeConstraints { + $0.top.equalTo(songNameLabel.snp.bottom).offset(2) + $0.leading.equalTo(albumImageView.snp.trailing).offset(12) + $0.trailing.equalTo(durationTimeLabel.snp.leading) + } + + durationTimeLabel.snp.makeConstraints { + $0.width.equalTo(36) + $0.height.equalTo(16) + $0.bottom.equalTo(artistNameLabel.snp.bottom) + $0.trailing.equalToSuperview().inset(24) + } + } +} + diff --git a/StreetDrop/StreetDrop.xcodeproj/project.pbxproj b/StreetDrop/StreetDrop.xcodeproj/project.pbxproj index a4faacf..973acb4 100644 --- a/StreetDrop/StreetDrop.xcodeproj/project.pbxproj +++ b/StreetDrop/StreetDrop.xcodeproj/project.pbxproj @@ -401,6 +401,8 @@ C44A549A2BBC097E00354F8F /* FetchingPopUpInfomationUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = C44A54992BBC097E00354F8F /* FetchingPopUpInfomationUseCase.swift */; }; C44A549C2BBC099E00354F8F /* DefaultFetchingPopUpInfomationUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = C44A549B2BBC099E00354F8F /* DefaultFetchingPopUpInfomationUseCase.swift */; }; C44A549E2BBC0DC500354F8F /* TipPopUpViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C44A549D2BBC0DC500354F8F /* TipPopUpViewController.swift */; }; + C44DE1F92C6EDC04004F211C /* ReSearchingMusicForSharingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C44DE1F82C6EDC04004F211C /* ReSearchingMusicForSharingView.swift */; }; + C44DE1FB2C6EE07D004F211C /* ReSearchingMusicTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C44DE1FA2C6EE07D004F211C /* ReSearchingMusicTableViewCell.swift */; }; C45A4CB02A3710AC00EE9C36 /* ImageCacheError.swift in Sources */ = {isa = PBXBuildFile; fileRef = C45A4CAF2A3710AC00EE9C36 /* ImageCacheError.swift */; }; C45BF3972A1D0ADF00CEDE74 /* UserDefaultKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = C45BF3962A1D0ADF00CEDE74 /* UserDefaultKey.swift */; }; C45BF39E2A1D113200CEDE74 /* UserDefaultsRecentMusicSearches.swift in Sources */ = {isa = PBXBuildFile; fileRef = C45BF39D2A1D113200CEDE74 /* UserDefaultsRecentMusicSearches.swift */; }; @@ -741,6 +743,8 @@ C44A54992BBC097E00354F8F /* FetchingPopUpInfomationUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchingPopUpInfomationUseCase.swift; sourceTree = ""; }; C44A549B2BBC099E00354F8F /* DefaultFetchingPopUpInfomationUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DefaultFetchingPopUpInfomationUseCase.swift; sourceTree = ""; }; C44A549D2BBC0DC500354F8F /* TipPopUpViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TipPopUpViewController.swift; sourceTree = ""; }; + C44DE1F82C6EDC04004F211C /* ReSearchingMusicForSharingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReSearchingMusicForSharingView.swift; sourceTree = ""; }; + C44DE1FA2C6EE07D004F211C /* ReSearchingMusicTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReSearchingMusicTableViewCell.swift; sourceTree = ""; }; C45A4CAF2A3710AC00EE9C36 /* ImageCacheError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageCacheError.swift; sourceTree = ""; }; C45BF3962A1D0ADF00CEDE74 /* UserDefaultKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultKey.swift; sourceTree = ""; }; C45BF39D2A1D113200CEDE74 /* UserDefaultsRecentMusicSearches.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDefaultsRecentMusicSearches.swift; sourceTree = ""; }; @@ -1768,6 +1772,7 @@ isa = PBXGroup; children = ( C42182BC2C697F9700B73A99 /* ShareViewController.swift */, + C44DE1FC2C6EE089004F211C /* ReSearchingMusic */, ); path = View; sourceTree = ""; @@ -1836,6 +1841,15 @@ path = PopUp; sourceTree = ""; }; + C44DE1FC2C6EE089004F211C /* ReSearchingMusic */ = { + isa = PBXGroup; + children = ( + C44DE1F82C6EDC04004F211C /* ReSearchingMusicForSharingView.swift */, + C44DE1FA2C6EE07D004F211C /* ReSearchingMusicTableViewCell.swift */, + ); + path = ReSearchingMusic; + sourceTree = ""; + }; C45BF3982A1D0AE200CEDE74 /* Constant */ = { isa = PBXGroup; children = ( @@ -2904,6 +2918,7 @@ C432DF4B2C69F7F3003DBA18 /* Music.swift in Sources */, C432DF4C2C69F7F3003DBA18 /* RecommendMusic.swift in Sources */, C432DF4D2C69F7F3003DBA18 /* ModalOption.swift in Sources */, + C44DE1F92C6EDC04004F211C /* ReSearchingMusicForSharingView.swift in Sources */, C432DF4E2C69F7F3003DBA18 /* MyLevelProgress.swift in Sources */, C432DF4F2C69F7F3003DBA18 /* LevelPolicy.swift in Sources */, C432DF502C69F7F3003DBA18 /* PopUpInfomation.swift in Sources */, @@ -2930,6 +2945,7 @@ C432DF652C69F7F3003DBA18 /* DefaultClaimingCommentUseCase.swift in Sources */, C432DF662C69F7F3003DBA18 /* DeletingMusicUseCase.swift in Sources */, C432DF672C69F7F3003DBA18 /* DefaultDeletingMusicUseCase.swift in Sources */, + C44DE1FB2C6EE07D004F211C /* ReSearchingMusicTableViewCell.swift in Sources */, C432DF682C69F7F3003DBA18 /* BlockUserUseCase.swift in Sources */, C432DF692C69F7F3003DBA18 /* DefaultBlockUserUseCase.swift in Sources */, C432DF6A2C69F7F3003DBA18 /* FetchingMyInfoUseCase.swift in Sources */, diff --git a/StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/Contents.json b/StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/Contents.json new file mode 100644 index 0000000..f23258b --- /dev/null +++ b/StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "filename" : "exit.png", + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "exit@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "exit@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/exit.png b/StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/exit.png new file mode 100644 index 0000000..39facb1 Binary files /dev/null and b/StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/exit.png differ diff --git a/StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/exit@2x.png b/StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/exit@2x.png new file mode 100644 index 0000000..c187614 Binary files /dev/null and b/StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/exit@2x.png differ diff --git a/StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/exit@3x.png b/StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/exit@3x.png new file mode 100644 index 0000000..1f98e89 Binary files /dev/null and b/StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/exit@3x.png differ