From a903076dcf9c7cf1fa861f3a6a50884070135d31 Mon Sep 17 00:00:00 2001 From: Joseph Cha Date: Fri, 16 Aug 2024 15:04:52 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8#297:=20Share=20Extension,=20=EC=9D=8C?= =?UTF-8?q?=EC=95=85=20=EC=9E=AC=EA=B2=80=EC=83=89=20UI=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReSearchingMusicForSharingView.swift | 173 ++++++++++++++++++ .../ReSearchingMusicTableViewCell.swift | 122 ++++++++++++ .../StreetDrop.xcodeproj/project.pbxproj | 16 ++ .../exit.imageset/Contents.json | 23 +++ .../Assets.xcassets/exit.imageset/exit.png | Bin 0 -> 238 bytes .../Assets.xcassets/exit.imageset/exit@2x.png | Bin 0 -> 407 bytes .../Assets.xcassets/exit.imageset/exit@3x.png | Bin 0 -> 579 bytes 7 files changed, 334 insertions(+) create mode 100644 StreetDrop/ShareExtension/View/ReSearchingMusic/ReSearchingMusicForSharingView.swift create mode 100644 StreetDrop/ShareExtension/View/ReSearchingMusic/ReSearchingMusicTableViewCell.swift create mode 100644 StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/Contents.json create mode 100644 StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/exit.png create mode 100644 StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/exit@2x.png create mode 100644 StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/exit@3x.png 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 0000000000000000000000000000000000000000..39facb15f3a0504de20bb2a8aa6a63d95e1f6432 GIT binary patch literal 238 zcmeAS@N?(olHy`uVBq!ia0vp^IzX(z!3HEV-DXt*Db50q$YKTtZeb8+WSBKa0w~B> z9OUlAui~bwMH#ftglU6%#zq-|o$*Xyr!=a0E4jQ+18!*kEe)acs gfsYO8JsW@cwe6Fu=adY!06K@k)78&qol`;+0H{V&=Kufz literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..c187614c0b7ced9611ed06152622e88064fc0d80 GIT binary patch literal 407 zcmeAS@N?(olHy`uVBq!ia0vp^5kTy~!3HGf32Zn7q&N#aB8wRq#8g3;(KATp15l8$ zILO_JVcj{Imp~3nx}&cn1H;CC?mvmFKsg;x7srqa#<#b4xta}l93F1yUT6NDLryU` zfMd4()@>6_-!mr~7<@6jVWrIk)D8p>&aZq`z3bRZsb|+8y?OcbtS6=t98nZxqbPf5M-+oXRP534PT zKeVQO{r=;)b6Skjbc>GJUmDewV=wmH-|3>aMBGf!WuFIkS%%BGCFa}qyVxxh{THq9 zsZXl#?B0%?t3BE8JfB2%?|61^qw@Bi?6f02Zv?NO=@PwZyl$qX`lf&L`17Q$pSjy5 w^QfjkNL_m3Zd-X9orRMvs;lfE{uVgTey@J*&8+LMAAkfrUHx3vIVCg!01#`c&;S4c literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..1f98e89afacc5cbcdc92405ddc390f12950c9e1d GIT binary patch literal 579 zcmeAS@N?(olHy`uVBq!ia0vp^EkK;W!3HGnOuS_bq&N#aB8wRq6fHoQ(RG?(0#J~# zILO_JVcj{Imp~3nx}&cn1H;CC?mvmFK)D;9E{-7;jBoG8W<53#X$Ulwp8qBxjs3A~ z8RsmiD6NcF7N73#J!Sb|dqV7)=?*zPUW`CPpdc=I?bq+WKYlCxqj@rAzWtP+OxNE3 zo2v3G^8J~5?Jqxngk9|k{3CGq&Dsm;iX9gMb&e=>=suf&eV0y*2!GOyzq((l_csJj z(+E3aAiC|eK&ynGm?f8Cj7pM7(vFBF8b<_NT7blvsev7eE3_90I2WY5DYmJc>u};Z zDI?h`G094a%TQ%|x=5155xKyQM1$x>0*4n=0f`6mI-Pj*lYB)&dDf@8iX>H-&JFZw zEwq(98X|H3l*Y12C)OVlD_wqmLTv4y{6$lrZFRJ=k!;p*y9Oe*D7CFrt8(t)eI;D3 z;A*(zR-tv2Nb@S`dA=P<2Bq!np^Jdl8Jav7a!so~c41Dih@`Bbb8%i^N>K{WS*b-Q z9`s1e+Ug>BbEct5c9+s3?WBxrVy-IT$1a>v=;Ba1a^Z|pm$qxy!kL~T;T;mr#bP0l+XkK Di2>lq literal 0 HcmV?d00001