Skip to content

Commit

Permalink
Merge pull request #1201 from wakmusic/1199-ui-fix-fab-in-my-playlist…
Browse files Browse the repository at this point in the history
…-detail

🔀 :: (#1199) 보관함 > 내 플리 상세 진입 시 플로팅 버튼 위치 안맞는 UI 오류 수정
  • Loading branch information
KangTaeHoon authored Aug 20, 2024
2 parents ef0482b + c9471e5 commit 183dfc8
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ private extension MainContainerViewController {
view.addSubview(playlistFloatingActionButton)

let startPage: Int = PreferenceManager.startPage ?? 0
let bottomOffset: Int = startPage == 3 ? -80 : -20
let bottomOffset: CGFloat = startPage == 3 ?
PlaylistFloatingButtonPosition.top.bottomOffset :
PlaylistFloatingButtonPosition.default.bottomOffset
playlistFloatingActionButton.snp.makeConstraints {
$0.trailing.equalToSuperview().inset(20)
$0.bottom.equalTo(bottomContainerView.snp.top).offset(bottomOffset)
Expand Down Expand Up @@ -169,13 +171,21 @@ private extension MainContainerViewController {

Observable.combineLatest(
PreferenceManager.$startPage.map { $0 ?? 0 },
NotificationCenter.default.rx.notification(.didChangeTabInStorage).map { $0.object as? Int ?? 0 }
) { startPage, storagePage -> (Int, Int) in
return (startPage, storagePage)
NotificationCenter.default.rx
.notification(.shouldMovePlaylistFloatingButton)
.map { $0.object as? PlaylistFloatingButtonPosition ?? .default }
) { startPage, pos -> (Int, PlaylistFloatingButtonPosition) in
return (startPage, pos)
}
.bind(with: self, onNext: { owner, params in
let (startPage, storagePage) = params
let bottomOffset: Int = (startPage == 3) ? ((storagePage == 0) ? -80 : -20) : -20
let (startPage, pos) = params
var bottomOffset: CGFloat
switch startPage {
case 3:
bottomOffset = pos.bottomOffset
default:
bottomOffset = PlaylistFloatingButtonPosition.default.bottomOffset
}
owner.playlistFloatingActionButton.snp.updateConstraints {
$0.trailing.equalToSuperview().inset(20)
$0.bottom.equalTo(owner.bottomContainerView.snp.top).offset(bottomOffset)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ private extension MainTabBarViewController {
let viewController = playlistDetailFactory.makeView(key: key)
navigationController?.pushViewController(viewController, animated: true)

// 보관함에서 플리상세 접근 시 플로팅버튼 내림
if selectedIndex == 3 {
NotificationCenter.default.post(
name: .shouldMovePlaylistFloatingButton,
object: PlaylistFloatingButtonPosition.default
)
}

case "songDetail":
let id = params["id"] as? String ?? ""
songDetailPresenter.present(id: id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ final class ListStorageViewController: BaseReactorViewController<ListStorageReac
super.viewDidAppear(animated)
LogManager.analytics(CommonAnalyticsLog.viewPage(pageName: .storagePlaylist))
listStorageView.resetParticeAnimation()

// 플리 상세에서 내 리스트로 돌아오는 경우, 플로팅 버튼 올림
NotificationCenter.default.post(
name: .shouldMovePlaylistFloatingButton,
object: PlaylistFloatingButtonPosition.top
)
}

override func configureUI() {
Expand Down Expand Up @@ -91,6 +97,11 @@ final class ListStorageViewController: BaseReactorViewController<ListStorageReac
reactor.pulse(\.$showDetail)
.compactMap { $0 }
.bind(with: self, onNext: { owner, key in
// 플리 상세 진입 시, 플로팅 버튼 내림
NotificationCenter.default.post(
name: .shouldMovePlaylistFloatingButton,
object: PlaylistFloatingButtonPosition.default
)
owner.navigatePlaylistDetail(key: key)
})
.disposed(by: disposeBag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ final class StorageViewController: TabmanViewController, View {
animated: Bool
) {
self.reactor?.action.onNext(.switchTab(index))
NotificationCenter.default.post(name: .didChangeTabInStorage, object: index)
// 탭 이동 간 플로팅 버튼 위치 조정
NotificationCenter.default.post(
name: .shouldMovePlaylistFloatingButton,
object: index == 0 ?
PlaylistFloatingButtonPosition.top :
PlaylistFloatingButtonPosition.default
)
}

/// 탭맨 탭 터치 이벤트 감지 함수
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Foundation

public enum PlaylistFloatingButtonPosition {
case `default`
case top

public var bottomOffset: CGFloat {
switch self {
case .default:
return -20
case .top:
return -80
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ public extension Notification.Name {
static let willStatusBarEnterLightBackground = Notification.Name("willStatusBarEnterLightBackground")
static let shouldHidePlaylistFloatingButton = Notification.Name("shouldHidePlaylistFloatingButton")
static let shouldShowPlaylistFloatingButton = Notification.Name("shouldShowPlaylistFloatingButton")
static let didChangeTabInStorage = Notification.Name("didChangeTabInStorage")
static let shouldMovePlaylistFloatingButton = Notification.Name("shouldMovePlaylistFloatingButton")
}

0 comments on commit 183dfc8

Please sign in to comment.