-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨#297: Share Extension, 음악 재검색 UI 추가
- Loading branch information
Showing
7 changed files
with
334 additions
and
0 deletions.
There are no files selected for viewing
173 changes: 173 additions & 0 deletions
173
StreetDrop/ShareExtension/View/ReSearchingMusic/ReSearchingMusicForSharingView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> = .init() | ||
// View -> ViewController | ||
var reSearchingEvent: Observable<String> { | ||
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() | ||
} | ||
} | ||
} |
122 changes: 122 additions & 0 deletions
122
StreetDrop/ShareExtension/View/ReSearchingMusic/ReSearchingMusicTableViewCell.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "exit.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+238 Bytes
StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/exit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+407 Bytes
StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+579 Bytes
StreetDrop/StreetDrop/Resource/Assets.xcassets/exit.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.