From 676545cdebcda144fec07fe9b007ebd72aab0b85 Mon Sep 17 00:00:00 2001 From: baegteun Date: Wed, 9 Oct 2024 20:43:08 +0900 Subject: [PATCH 1/4] =?UTF-8?q?:sparkles:=20::=20[#1306]=20=EB=B3=B4?= =?UTF-8?q?=EA=B4=80=ED=95=A8=20=ED=99=94=EB=A9=B4=20Long=20Press=20?= =?UTF-8?q?=ED=8E=B8=EC=A7=91=EB=AA=A8=EB=93=9C=20=EC=A7=84=EC=9E=85=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Sources/Reactors/LikeStorageReactor.swift | 11 +++++ .../Sources/Reactors/ListStorageReactor.swift | 29 +++++++++++--- .../LikeStorageViewController.swift | 40 ++++++++++++++----- .../ListStorageViewController.swift | 26 ++++++++---- .../Views/LikeStorageTableViewCell.swift | 17 -------- .../Sources/Views/LikeStorageView.swift | 1 + .../Views/ListStorageTableViewCell.swift | 33 +-------------- .../Sources/Views/ListStorageView.swift | 1 + 8 files changed, 86 insertions(+), 72 deletions(-) diff --git a/Projects/Features/StorageFeature/Sources/Reactors/LikeStorageReactor.swift b/Projects/Features/StorageFeature/Sources/Reactors/LikeStorageReactor.swift index 4dfabd9f7..aaa9133e0 100644 --- a/Projects/Features/StorageFeature/Sources/Reactors/LikeStorageReactor.swift +++ b/Projects/Features/StorageFeature/Sources/Reactors/LikeStorageReactor.swift @@ -19,6 +19,7 @@ final class LikeStorageReactor: Reactor { case itemMoved(ItemMovedEvent) case songDidTap(Int) case tapAll(isSelecting: Bool) + case didLongPressedPlaylist(IndexPath) case playDidTap(song: FavoriteSongEntity) case addToPlaylistButtonDidTap // 노래담기 case presentAddToPlaylistPopup @@ -104,6 +105,9 @@ final class LikeStorageReactor: Reactor { case let .songDidTap(index): return changeSelectingState(index) + case let .didLongPressedPlaylist(indexPath): + return didLongPressedPlaylist(indexPath: indexPath) + case let .playDidTap(song): return playWithAddToCurrentPlaylist(song: song) @@ -285,6 +289,13 @@ extension LikeStorageReactor { return .just(.showAddToPlaylistPopup(selectedItemIDs)) } + func didLongPressedPlaylist(indexPath: IndexPath) -> Observable { + guard !currentState.isEditing else { return .empty() } + storageCommonService.isEditingState.onNext(true) + changeSelectingState(indexPath.row) + return .just(.switchEditingState(true)) + } + func presentAddToPlaylistPopup() -> Observable { guard var tmp = currentState.dataSource.first?.items else { LogManager.printError("favorite datasource is empty") diff --git a/Projects/Features/StorageFeature/Sources/Reactors/ListStorageReactor.swift b/Projects/Features/StorageFeature/Sources/Reactors/ListStorageReactor.swift index 6c4564e88..29993659f 100644 --- a/Projects/Features/StorageFeature/Sources/Reactors/ListStorageReactor.swift +++ b/Projects/Features/StorageFeature/Sources/Reactors/ListStorageReactor.swift @@ -16,8 +16,8 @@ final class ListStorageReactor: Reactor { case viewDidLoad case refresh case itemMoved(ItemMovedEvent) - case cellDidTap(Int) - case listDidTap(IndexPath) + case didSelectPlaylist(IndexPath) + case didLongPressedPlaylist(IndexPath) case playDidTap(Int) case tapAll(isSelecting: Bool) case loginButtonDidTap @@ -117,11 +117,11 @@ final class ListStorageReactor: Reactor { case let .itemMoved((sourceIndex, destinationIndex)): return updateOrder(src: sourceIndex.row, dest: destinationIndex.row) - case let .cellDidTap(index): - return changeSelectingState(index) + case let .didSelectPlaylist(indexPath): + return didSelectPlaylistCell(indexPath: indexPath) - case let .listDidTap(indexPath): - return showDetail(indexPath) + case let .didLongPressedPlaylist(indexPath): + return didLongPressedPlaylist(indexPath: indexPath) case let .playDidTap(index): return playWithAddToCurrentPlaylist(index) @@ -333,6 +333,23 @@ extension ListStorageReactor { ) } + func didLongPressedPlaylist(indexPath: IndexPath) -> Observable { + guard !currentState.isEditing else { return .empty() } + storageCommonService.isEditingState.onNext(true) + return .concat( + changeSelectingState(indexPath.row), + .just(.switchEditingState(true)) + ) + } + + func didSelectPlaylistCell(indexPath: IndexPath) -> Observable { + if currentState.isEditing { + return changeSelectingState(indexPath.row) + } else { + return showDetail(indexPath) + } + } + func showDetail(_ indexPath: IndexPath) -> Observable { let selectedList = currentState.dataSource[indexPath.section].items[indexPath.row] let key = selectedList.key diff --git a/Projects/Features/StorageFeature/Sources/ViewControllers/LikeStorageViewController.swift b/Projects/Features/StorageFeature/Sources/ViewControllers/LikeStorageViewController.swift index a65b5b347..c167e0a97 100644 --- a/Projects/Features/StorageFeature/Sources/ViewControllers/LikeStorageViewController.swift +++ b/Projects/Features/StorageFeature/Sources/ViewControllers/LikeStorageViewController.swift @@ -211,14 +211,21 @@ final class LikeStorageViewController: BaseReactorViewController Bool { return false // 편집모드 시 셀의 들여쓰기를 없애려면 false를 리턴합니다. } + + func tableView( + _ tableView: UITableView, + contextMenuConfigurationForRowAt indexPath: IndexPath, + point: CGPoint + ) -> UIContextMenuConfiguration? { + if reactor?.currentState.isEditing == true { + return nil + } else { + return UIContextMenuConfiguration(identifier: nil, previewProvider: { [reactor] in + reactor?.action.onNext(.didLongPressedPlaylist(indexPath)) + return nil + }) + } + } } extension LikeStorageViewController { diff --git a/Projects/Features/StorageFeature/Sources/ViewControllers/ListStorageViewController.swift b/Projects/Features/StorageFeature/Sources/ViewControllers/ListStorageViewController.swift index dfaece595..b6dd71492 100644 --- a/Projects/Features/StorageFeature/Sources/ViewControllers/ListStorageViewController.swift +++ b/Projects/Features/StorageFeature/Sources/ViewControllers/ListStorageViewController.swift @@ -329,16 +329,9 @@ extension ListStorageViewController: SongCartViewDelegate { extension ListStorageViewController: ListStorageTableViewCellDelegate { public func buttonTapped(type: ListStorageTableViewCellDelegateConstant) { switch type { - case let .listTapped(passModel): - LogManager.analytics(CommonAnalyticsLog.clickPlaylistItem(location: .storage, key: passModel.key)) - self.reactor?.action.onNext(.listDidTap(passModel.indexPath)) - case let .playTapped(passModel): LogManager.analytics(CommonAnalyticsLog.clickPlayButton(location: .storagePlaylist, type: .playlist)) self.reactor?.action.onNext(.playDidTap(passModel.indexPath.row)) - - case let .cellTapped(passModel): - self.reactor?.action.onNext(.cellDidTap(passModel.indexPath.row)) } } } @@ -364,6 +357,25 @@ extension ListStorageViewController: UITableViewDelegate { public func tableView(_ tableView: UITableView, shouldIndentWhileEditingRowAt indexPath: IndexPath) -> Bool { return false // 편집모드 시 셀의 들여쓰기를 없애려면 false를 리턴합니다. } + + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + reactor?.action.onNext(.didSelectPlaylist(indexPath)) + } + + func tableView( + _ tableView: UITableView, + contextMenuConfigurationForRowAt indexPath: IndexPath, + point: CGPoint + ) -> UIContextMenuConfiguration? { + if reactor?.currentState.isEditing == true { + return nil + } else { + return UIContextMenuConfiguration(identifier: nil, previewProvider: { [reactor] in + reactor?.action.onNext(.didLongPressedPlaylist(indexPath)) + return nil + }) + } + } } extension ListStorageViewController { diff --git a/Projects/Features/StorageFeature/Sources/Views/LikeStorageTableViewCell.swift b/Projects/Features/StorageFeature/Sources/Views/LikeStorageTableViewCell.swift index 822f1a1ac..098a7a9a6 100644 --- a/Projects/Features/StorageFeature/Sources/Views/LikeStorageTableViewCell.swift +++ b/Projects/Features/StorageFeature/Sources/Views/LikeStorageTableViewCell.swift @@ -12,7 +12,6 @@ public protocol LikeStorageTableViewCellDelegate: AnyObject { } public enum LikeStorageTableViewCellDelegateConstant { - case cellTapped(indexPath: IndexPath) case playTapped(song: FavoriteSongEntity) } @@ -60,8 +59,6 @@ class LikeStorageTableViewCell: UITableViewCell { ) } - private let cellSelectButton = UIButton() - weak var delegate: LikeStorageTableViewCellDelegate? var indexPath: IndexPath? var model: FavoriteSongEntity? @@ -93,7 +90,6 @@ extension LikeStorageTableViewCell { self.artistLabel.text = model.artist self.backgroundColor = model.isSelected ? DesignSystemAsset.BlueGrayColor.blueGray200.color : UIColor.clear - self.cellSelectButton.isHidden = !isEditing self.playButton.isHidden = isEditing self.playButton.snp.updateConstraints { @@ -107,7 +103,6 @@ private extension LikeStorageTableViewCell { self.contentView.addSubviews( albumImageView, verticalStackView, - cellSelectButton, playButton ) verticalStackView.addArrangedSubviews(titleLabel, artistLabel) @@ -140,16 +135,9 @@ private extension LikeStorageTableViewCell { artistLabel.snp.makeConstraints { $0.height.equalTo(18) } - - cellSelectButton.snp.makeConstraints { - $0.verticalEdges.equalToSuperview() - $0.left.equalToSuperview() - $0.right.equalTo(verticalStackView.snp.right) - } } func setAction() { - self.cellSelectButton.addTarget(self, action: #selector(cellSelectButtonAction), for: .touchUpInside) self.playButton.addTarget(self, action: #selector(playButtonAction), for: .touchUpInside) } } @@ -159,9 +147,4 @@ private extension LikeStorageTableViewCell { guard let model else { return } delegate?.buttonTapped(type: .playTapped(song: model)) } - - @objc func cellSelectButtonAction() { - guard let indexPath else { return } - delegate?.buttonTapped(type: .cellTapped(indexPath: indexPath)) - } } diff --git a/Projects/Features/StorageFeature/Sources/Views/LikeStorageView.swift b/Projects/Features/StorageFeature/Sources/Views/LikeStorageView.swift index e8c10dfd5..05948a730 100644 --- a/Projects/Features/StorageFeature/Sources/Views/LikeStorageView.swift +++ b/Projects/Features/StorageFeature/Sources/Views/LikeStorageView.swift @@ -32,6 +32,7 @@ final class LikeStorageView: UIView { $0.backgroundColor = .clear $0.register(LikeStorageTableViewCell.self, forCellReuseIdentifier: LikeStorageTableViewCell.reuseIdentifer) $0.separatorStyle = .none + $0.allowsSelectionDuringEditing = true } fileprivate let loginWarningView = LoginWarningView(text: "로그인 하고\n좋아요를 확인해보세요.") { return } diff --git a/Projects/Features/StorageFeature/Sources/Views/ListStorageTableViewCell.swift b/Projects/Features/StorageFeature/Sources/Views/ListStorageTableViewCell.swift index b24e9adf8..64f2c330b 100644 --- a/Projects/Features/StorageFeature/Sources/Views/ListStorageTableViewCell.swift +++ b/Projects/Features/StorageFeature/Sources/Views/ListStorageTableViewCell.swift @@ -13,8 +13,6 @@ public protocol ListStorageTableViewCellDelegate: AnyObject { } public enum ListStorageTableViewCellDelegateConstant { - case cellTapped((indexPath: IndexPath, key: String)) - case listTapped((indexPath: IndexPath, key: String)) case playTapped((indexPath: IndexPath, key: String)) } @@ -65,9 +63,6 @@ class ListStorageTableViewCell: UITableViewCell { private let countContainerView: UIView = UIView() - private let cellSelectButton = UIButton() - private let listSelectButton = UIButton() - weak var delegate: ListStorageTableViewCellDelegate? var passToModel: (IndexPath, String) = (IndexPath(row: 0, section: 0), "") @@ -89,9 +84,7 @@ extension ListStorageTableViewCell { self.contentView.addSubviews( playlistImageView, verticalStackView, - playButton, - cellSelectButton, - listSelectButton + playButton ) verticalStackView.addArrangedSubviews(nameLabel, countContainerView) countContainerView.addSubviews(countLabel, lockImageView) @@ -116,18 +109,6 @@ extension ListStorageTableViewCell { $0.right.equalToSuperview().inset(20) } - cellSelectButton.snp.makeConstraints { - $0.verticalEdges.equalToSuperview() - $0.left.equalToSuperview() - $0.right.equalTo(verticalStackView.snp.right) - } - - listSelectButton.snp.makeConstraints { - $0.verticalEdges.equalToSuperview() - $0.left.equalToSuperview() - $0.right.equalTo(verticalStackView.snp.right) - } - nameLabel.snp.makeConstraints { $0.height.equalTo(22) } @@ -146,8 +127,6 @@ extension ListStorageTableViewCell { } func setAction() { - self.cellSelectButton.addTarget(self, action: #selector(cellSelectButtonAction), for: .touchUpInside) - self.listSelectButton.addTarget(self, action: #selector(listSelectButtonAction), for: .touchUpInside) self.playButton.addTarget(self, action: #selector(playButtonAction), for: .touchUpInside) } @@ -171,8 +150,6 @@ extension ListStorageTableViewCell { ) self.backgroundColor = model.isSelected ? DesignSystemAsset.BlueGrayColor.blueGray200.color : UIColor.clear - self.cellSelectButton.isHidden = !isEditing - self.listSelectButton.isHidden = isEditing self.playButton.isHidden = isEditing self.lockImageView.isHidden = !model.private @@ -198,14 +175,6 @@ extension ListStorageTableViewCell { } extension ListStorageTableViewCell { - @objc func cellSelectButtonAction() { - delegate?.buttonTapped(type: .cellTapped(passToModel)) - } - - @objc func listSelectButtonAction() { - delegate?.buttonTapped(type: .listTapped(passToModel)) - } - @objc func playButtonAction() { delegate?.buttonTapped(type: .playTapped(passToModel)) } diff --git a/Projects/Features/StorageFeature/Sources/Views/ListStorageView.swift b/Projects/Features/StorageFeature/Sources/Views/ListStorageView.swift index 5aae9c258..080cf64a2 100644 --- a/Projects/Features/StorageFeature/Sources/Views/ListStorageView.swift +++ b/Projects/Features/StorageFeature/Sources/Views/ListStorageView.swift @@ -35,6 +35,7 @@ final class ListStorageView: UIView { $0.backgroundColor = .clear $0.register(ListStorageTableViewCell.self, forCellReuseIdentifier: ListStorageTableViewCell.reuseIdentifer) $0.separatorStyle = .none + $0.allowsSelectionDuringEditing = true } fileprivate let drawFruitButton = UIButton().then { From 0b862d826fd50e676d8e2d5d97b2684f0f3d9b13 Mon Sep 17 00:00:00 2001 From: baegteun Date: Wed, 9 Oct 2024 20:43:56 +0900 Subject: [PATCH 2/4] =?UTF-8?q?:sparkles:=20::=20[#1306]=20=ED=94=8C?= =?UTF-8?q?=EB=A0=88=EC=9D=B4=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=ED=99=94?= =?UTF-8?q?=EB=A9=B4=20Long=20Press=20=ED=8E=B8=EC=A7=91=EB=AA=A8=EB=93=9C?= =?UTF-8?q?=20=EC=A7=84=EC=9E=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlaylistViewController+Delegate.swift | 19 +++++++--- .../PlaylistViewController.swift | 35 ++++++++++++------- .../ViewModels/PlaylistViewModel.swift | 18 ++++++++++ .../Sources/Views/PlayListView.swift | 1 + .../Sources/Views/PlaylistTableViewCell.swift | 15 -------- 5 files changed, 57 insertions(+), 31 deletions(-) diff --git a/Projects/Features/PlaylistFeature/Sources/ViewControllers/PlaylistViewController+Delegate.swift b/Projects/Features/PlaylistFeature/Sources/ViewControllers/PlaylistViewController+Delegate.swift index 87eea374e..6e8f3aeef 100644 --- a/Projects/Features/PlaylistFeature/Sources/ViewControllers/PlaylistViewController+Delegate.swift +++ b/Projects/Features/PlaylistFeature/Sources/ViewControllers/PlaylistViewController+Delegate.swift @@ -120,6 +120,21 @@ extension PlaylistViewController: UITableViewDelegate { } return proposedDestinationIndexPath } + + public func tableView( + _ tableView: UITableView, + contextMenuConfigurationForRowAt indexPath: IndexPath, + point: CGPoint + ) -> UIContextMenuConfiguration? { + if output.editState.value == true { + return nil + } else { + return UIContextMenuConfiguration(identifier: nil, previewProvider: { [didLongPressedSongSubject] in + didLongPressedSongSubject.onNext(indexPath.row) + return nil + }) + } + } } extension PlaylistViewController: PlaylistTableViewCellDelegate { @@ -132,8 +147,4 @@ extension PlaylistViewController: PlaylistTableViewCellDelegate { playPlatform: model.title.isContainShortsTagTitle ? .youtube : .automatic ).play() } - - func superButtonTapped(index: Int) { - tappedCellIndex.onNext(index) - } } diff --git a/Projects/Features/PlaylistFeature/Sources/ViewControllers/PlaylistViewController.swift b/Projects/Features/PlaylistFeature/Sources/ViewControllers/PlaylistViewController.swift index 2ac0bd8f7..e0f6159f1 100644 --- a/Projects/Features/PlaylistFeature/Sources/ViewControllers/PlaylistViewController.swift +++ b/Projects/Features/PlaylistFeature/Sources/ViewControllers/PlaylistViewController.swift @@ -24,6 +24,7 @@ public final class PlaylistViewController: UIViewController, SongCartViewType { var isSelectedAllSongs = PublishSubject() var tappedAddPlaylist = PublishSubject() var tappedRemoveSongs = PublishSubject() + var didLongPressedSongSubject = PublishSubject() private(set) var containSongsFactory: any ContainSongsFactory private(set) var songDetailPresenter: any SongDetailPresentable @@ -48,7 +49,8 @@ public final class PlaylistViewController: UIViewController, SongCartViewType { selectAllSongsButtonDidTapEvent: isSelectedAllSongs.asObservable(), addPlaylistButtonDidTapEvent: tappedAddPlaylist.asObservable(), removeSongsButtonDidTapEvent: tappedRemoveSongs.asObservable(), - itemMovedEvent: playlistView.playlistTableView.rx.itemMoved.asObservable() + itemMovedEvent: playlistView.playlistTableView.rx.itemMoved.asObservable(), + didLongPressedSongEvent: didLongPressedSongSubject ) lazy var output = self.viewModel.transform(from: input) @@ -220,18 +222,27 @@ private extension PlaylistViewController { playlistView.playlistTableView.rx.itemSelected .withLatestFrom(output.playlists) { ($0, $1) } - .map { $0.1[$0.0.row] } - .bind(with: self, onNext: { [songDetailPresenter] owner, item in - let currentSongs = output.playlists.value - .map(\.id) - - owner.dismiss(animated: true) { - songDetailPresenter.present( - ids: Array(currentSongs), - selectedID: item.id - ) + .bind(with: self) { [songDetailPresenter, isEditingSubject = output.editState, tappedCellIndex] owner, item in + + let isEditing = isEditingSubject.value + let (indexPath, playlists) = item + + if isEditing { + tappedCellIndex.onNext(indexPath.row) + } else { + guard let selectedSong = playlists[safe: indexPath.row] else { return } + + let currentSongs = playlists + .map(\.id) + + owner.dismiss(animated: true) { + songDetailPresenter.present( + ids: Array(currentSongs), + selectedID: selectedSong.id + ) + } } - }) + } .disposed(by: disposeBag) } diff --git a/Projects/Features/PlaylistFeature/Sources/ViewModels/PlaylistViewModel.swift b/Projects/Features/PlaylistFeature/Sources/ViewModels/PlaylistViewModel.swift index f51be9027..ad3d4f962 100644 --- a/Projects/Features/PlaylistFeature/Sources/ViewModels/PlaylistViewModel.swift +++ b/Projects/Features/PlaylistFeature/Sources/ViewModels/PlaylistViewModel.swift @@ -21,6 +21,7 @@ final class PlaylistViewModel: ViewModelType { let addPlaylistButtonDidTapEvent: Observable let removeSongsButtonDidTapEvent: Observable let itemMovedEvent: Observable<(sourceIndex: IndexPath, destinationIndex: IndexPath)> + let didLongPressedSongEvent: Observable } struct Output { @@ -152,6 +153,23 @@ final class PlaylistViewModel: ViewModelType { playlists.insert(movedData, at: destIndex) output.playlists.accept(playlists) }.disposed(by: disposeBag) + + input.didLongPressedSongEvent + .compactMap { output.playlists.value[safe: $0] } + .bind(with: self) { owner, item in + owner.isEditing.toggle() + + var mutableSelectedSongIds = output.selectedSongIds.value + if mutableSelectedSongIds.contains(item.id) { + mutableSelectedSongIds.remove(item.id) + } else { + mutableSelectedSongIds.insert(item.id) + } + + output.editState.send(owner.isEditing) + output.selectedSongIds.accept(mutableSelectedSongIds) + } + .disposed(by: disposeBag) } private func bindTableView(output: Output) { diff --git a/Projects/Features/PlaylistFeature/Sources/Views/PlayListView.swift b/Projects/Features/PlaylistFeature/Sources/Views/PlayListView.swift index b49ad6757..5cda95c8c 100644 --- a/Projects/Features/PlaylistFeature/Sources/Views/PlayListView.swift +++ b/Projects/Features/PlaylistFeature/Sources/Views/PlayListView.swift @@ -68,6 +68,7 @@ public final class PlaylistView: UIView { $0.sectionHeaderTopPadding = 0 $0.backgroundColor = DesignSystemAsset.BlueGrayColor.blueGray100.color $0.showsVerticalScrollIndicator = true + $0.allowsSelectionDuringEditing = true } override init(frame: CGRect) { diff --git a/Projects/Features/PlaylistFeature/Sources/Views/PlaylistTableViewCell.swift b/Projects/Features/PlaylistFeature/Sources/Views/PlaylistTableViewCell.swift index 58c4db485..c45f85336 100644 --- a/Projects/Features/PlaylistFeature/Sources/Views/PlaylistTableViewCell.swift +++ b/Projects/Features/PlaylistFeature/Sources/Views/PlaylistTableViewCell.swift @@ -10,7 +10,6 @@ import UIKit import Utility internal protocol PlaylistTableViewCellDelegate: AnyObject { - func superButtonTapped(index: Int) func playButtonDidTap(model: PlaylistItemModel) } @@ -78,10 +77,6 @@ internal class PlaylistTableViewCell: UITableViewCell { fatalError("") } - override func prepareForReuse() { - super.prepareForReuse() - } - private func configureContents() { self.backgroundColor = .clear self.contentView.addSubview(self.thumbnailImageView) @@ -110,11 +105,6 @@ internal class PlaylistTableViewCell: UITableViewCell { $0.centerY.equalTo(contentView.snp.centerY) $0.right.equalTo(contentView.snp.right).offset(-20) } - - superButton.snp.makeConstraints { - $0.left.top.bottom.equalToSuperview() - $0.right.equalToSuperview() - } } } @@ -151,10 +141,6 @@ extension PlaylistTableViewCell { owner.delegate?.playButtonDidTap(model: song) } .disposed(by: disposeBag) - - superButton.addAction { [weak self] in - self?.delegate?.superButtonTapped(index: self?.model.index ?? 0) - } } private func updateButtonHidden(isEditing: Bool) { @@ -163,7 +149,6 @@ extension PlaylistTableViewCell { } else { playImageView.isHidden = false } - superButton.isHidden = !isEditing } private func updateConstraintPlayImageView(isEditing: Bool) { From 3a991cb2dc2901f630dfdb8dd771f161421d727b Mon Sep 17 00:00:00 2001 From: baegteun Date: Wed, 9 Oct 2024 20:44:16 +0900 Subject: [PATCH 3/4] =?UTF-8?q?:sparkles:=20::=20[#1306]=20=EB=A7=88?= =?UTF-8?q?=EC=9D=B4=20=ED=94=8C=EB=A6=AC=20=ED=99=94=EB=A9=B4=20Long=20Pr?= =?UTF-8?q?ess=20=ED=8E=B8=EC=A7=91=EB=AA=A8=EB=93=9C=20=EC=A7=84=EC=9E=85?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reactors/MyPlaylistDetailReactor.swift | 12 ++++++ .../MyPlaylistDetailViewController.swift | 41 ++++++++++++------- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/Projects/Features/PlaylistFeature/Sources/Reactors/MyPlaylistDetailReactor.swift b/Projects/Features/PlaylistFeature/Sources/Reactors/MyPlaylistDetailReactor.swift index deb8b2603..3d6c95b0e 100644 --- a/Projects/Features/PlaylistFeature/Sources/Reactors/MyPlaylistDetailReactor.swift +++ b/Projects/Features/PlaylistFeature/Sources/Reactors/MyPlaylistDetailReactor.swift @@ -14,6 +14,7 @@ final class MyPlaylistDetailReactor: Reactor { case editButtonDidTap case privateButtonDidTap case completionButtonDidTap + case didLongPressedPlaylist(IndexPath) case restore case itemDidMoved(Int, Int) case forceSave @@ -120,6 +121,9 @@ final class MyPlaylistDetailReactor: Reactor { case .editButtonDidTap: return beginEditing() + case let .didLongPressedPlaylist(indexPath): + return didLongPressedPlaylist(indexPath: indexPath) + case .privateButtonDidTap: return updatePrivate() @@ -244,6 +248,14 @@ private extension MyPlaylistDetailReactor { ]) } + func didLongPressedPlaylist(indexPath: IndexPath) -> Observable { + guard !currentState.isEditing else { return .empty() } + return .concat( + beginEditing(), + updateItemSelected(indexPath.row) + ) + } + func endEditingWithSave() -> Observable { let state = currentState let currentPlaylists = state.playlistModels diff --git a/Projects/Features/PlaylistFeature/Sources/ViewControllers/MyPlaylistDetailViewController.swift b/Projects/Features/PlaylistFeature/Sources/ViewControllers/MyPlaylistDetailViewController.swift index 33049bb25..eb168891b 100644 --- a/Projects/Features/PlaylistFeature/Sources/ViewControllers/MyPlaylistDetailViewController.swift +++ b/Projects/Features/PlaylistFeature/Sources/ViewControllers/MyPlaylistDetailViewController.swift @@ -74,6 +74,7 @@ final class MyPlaylistDetailViewController: BaseReactorViewController Bool { return false // 편집모드 시 셀의 들여쓰기를 없애려면 false를 리턴합니다. } + + func tableView( + _ tableView: UITableView, + contextMenuConfigurationForRowAt indexPath: IndexPath, + point: CGPoint + ) -> UIContextMenuConfiguration? { + if reactor?.currentState.isEditing == true { + return nil + } else { + return UIContextMenuConfiguration(identifier: nil, previewProvider: { [reactor] in + reactor?.action.onNext(.didLongPressedPlaylist(indexPath)) + return nil + }) + } + } } /// 전체재생 , 랜덤 재생 델리게이트 @@ -585,11 +601,6 @@ extension MyPlaylistDetailViewController: PlaylistTableViewCellDelegate { playPlatform: model.title.isContainShortsTagTitle ? .youtube : .automatic ).play() } - - func superButtonTapped(index: Int) { - tableView.deselectRow(at: IndexPath(row: index, section: 0), animated: false) - reactor?.action.onNext(.itemDidTap(index)) - } } /// swipe pop 델리게이트 , 편집모드 시 막기 From 4a29ebb76cb15cac12b96b07e09b7a0e0ff11dff Mon Sep 17 00:00:00 2001 From: baegteun Date: Wed, 9 Oct 2024 20:44:22 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=8E=A8=20::=20=EC=BD=94=EB=93=9C=20Fo?= =?UTF-8?q?rmatting=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Projects/App/Support/Info.plist | 8 ++++---- .../Sources/ViewControllers/PlaylistViewController.swift | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Projects/App/Support/Info.plist b/Projects/App/Support/Info.plist index 118c93f85..be1febdff 100644 --- a/Projects/App/Support/Info.plist +++ b/Projects/App/Support/Info.plist @@ -55,8 +55,8 @@ LSApplicationQueriesSchemes - naversearchapp - naversearchthirdlogin + naversearchapp + naversearchthirdlogin youtube youtubemusic @@ -74,8 +74,8 @@ $(BASE_DEV_URL) BASE_PROD_URL $(BASE_PROD_URL) - CDN_DOMAIN_URL - $(CDN_DOMAIN_URL) + CDN_DOMAIN_URL + $(CDN_DOMAIN_URL) GOOGLE_CLIENT_ID $(GOOGLE_CLIENT_ID) GOOGLE_URL_SCHEME diff --git a/Projects/Features/PlaylistFeature/Sources/ViewControllers/PlaylistViewController.swift b/Projects/Features/PlaylistFeature/Sources/ViewControllers/PlaylistViewController.swift index e0f6159f1..c192d9e6b 100644 --- a/Projects/Features/PlaylistFeature/Sources/ViewControllers/PlaylistViewController.swift +++ b/Projects/Features/PlaylistFeature/Sources/ViewControllers/PlaylistViewController.swift @@ -222,7 +222,11 @@ private extension PlaylistViewController { playlistView.playlistTableView.rx.itemSelected .withLatestFrom(output.playlists) { ($0, $1) } - .bind(with: self) { [songDetailPresenter, isEditingSubject = output.editState, tappedCellIndex] owner, item in + .bind(with: self) { [ + songDetailPresenter, + isEditingSubject = output.editState, + tappedCellIndex + ] owner, item in let isEditing = isEditingSubject.value let (indexPath, playlists) = item