Skip to content

Commit

Permalink
[feat] FeedDetailVC SaveView 추가 (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
BAEKYUJEONG committed Oct 30, 2024
1 parent 6537a7e commit 2391aa9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
20 changes: 18 additions & 2 deletions PLUV/Feed/FeedDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class FeedDetailViewController: UIViewController {
}
private var feedDetailTableViewHeightConstraint: NSLayoutConstraint!

private var saveView = MoveView(view: UIViewController())

private let disposeBag = DisposeBag()

init(viewModel: FeedViewModel) {
Expand All @@ -67,6 +69,12 @@ class FeedDetailViewController: UIViewController {
setFeedDetailMusicItemAPI()
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
/// 탭 바 숨기기
self.tabBarController?.tabBar.isHidden = true
}

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
setTableViewHeight() /// 레이아웃이 갱신될 때마다 테이블 뷰 높이 갱신
Expand Down Expand Up @@ -150,19 +158,27 @@ class FeedDetailViewController: UIViewController {

/// 테이블 뷰 높이 제약 추가
feedDetailTableViewHeightConstraint = feedDetailTableView.heightAnchor.constraint(equalToConstant: 0)
feedDetailTableViewHeightConstraint.isActive = true

/// ContentView의 마지막 요소와 ScrollView의 bottom을 맞추기 위한 제약 설정
feedDetailTableView.snp.makeConstraints { make in
make.bottom.equalTo(contentView.snp.bottom) /// 테이블 뷰의 아래쪽을 contentView의 아래쪽에 맞춤
}

feedDetailTableView.isScrollEnabled = false /// 테이블 뷰 스크롤 비활성화

saveView = MoveView(view: self)
self.view.addSubview(saveView)
saveView.snp.makeConstraints { make in
make.leading.trailing.bottom.equalToSuperview()
make.height.equalTo(101)
}

saveView.changeName(left: "저장", right: "플레이리스트 옮기기")
}

private func setTableViewHeight() {
feedDetailTableView.layoutIfNeeded() /// 테이블 뷰 레이아웃 갱신
let contentHeight = feedDetailTableView.contentSize.height + 30 /// 테이블 뷰 전체 셀 높이
let contentHeight = feedDetailTableView.contentSize.height + 101 /// 테이블 뷰 전체 셀 높이
feedDetailTableViewHeightConstraint.constant = contentHeight /// 높이 제약 업데이트

/// 이미지 높이 + 테이블 뷰 높이를 합산하여 스크롤뷰의 contentSize 설정
Expand Down
4 changes: 3 additions & 1 deletion PLUV/Feed/FeedViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ class FeedViewController: UIViewController {
setFeedAPI()
}


override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.setNavigationBarHidden(true, animated: false)

/// 탭 바 표시하기
self.tabBarController?.tabBar.isHidden = false
}

override func viewWillDisappear(_ animated: Bool) {
Expand Down

0 comments on commit 2391aa9

Please sign in to comment.