Skip to content

Commit

Permalink
#3 버튼 숨김 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
ezidayzi committed Mar 3, 2023
1 parent 63a6584 commit 515bdda
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
14 changes: 1 addition & 13 deletions dandi/dandi/Presentation/Home/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import RxSwift
import YDS

final class HomeViewController: BaseViewController {
private let notificationButton = YDSTopBarButton(image: YDSIcon.bellLine)
private let homeView: HomeView = .init()
private lazy var homeDataSource: HomeDataSource = .init(
collectionView: homeView.collectionView,
Expand All @@ -26,7 +25,6 @@ final class HomeViewController: BaseViewController {
override init() {
super.init()
bindTapAction()
setLayouts()
homeDataSource.update(
dayWeathers: [
DayWeatherInfo(
Expand Down Expand Up @@ -178,20 +176,10 @@ final class HomeViewController: BaseViewController {
})
.disposed(by: disposeBag)

notificationButton.rx.tap
homeView.notificationButton.rx.tap
.withUnretained(self)
.subscribe(onNext: { owner, _ in
owner.navigationController?.pushViewController(NotificationListViewController(), animated: true)
}).disposed(by: disposeBag)
}
}

extension HomeViewController {
private func setLayouts() {
view.addSubview(notificationButton)
notificationButton.snp.makeConstraints { make in
make.top.equalTo(view.safeAreaLayoutGuide)
make.trailing.equalToSuperview().inset(8)
}
}
}
15 changes: 11 additions & 4 deletions dandi/dandi/Presentation/Home/View/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Then
import YDS

final class HomeView: UIView {
private(set) lazy var notificationButton = YDSTopBarButton(image: YDSIcon.bellLine)
private(set) lazy var bannerView = WeatherBannerView()
private lazy var collectionViewLayout: UICollectionViewLayout = {
let layout = UICollectionViewCompositionalLayout { [weak self] index, _ in
Expand All @@ -32,7 +33,7 @@ final class HomeView: UIView {
let collectionView = UICollectionView(frame: self.bounds, collectionViewLayout: collectionViewLayout)
collectionView.backgroundColor = .clear
collectionView.showsVerticalScrollIndicator = false
collectionView.contentInset = .init(top: -20, left: .zero, bottom: 16, right: .zero)
collectionView.contentInset = .init(top: .zero, left: .zero, bottom: 16, right: .zero)
collectionView.delegate = self
return collectionView
}()
Expand Down Expand Up @@ -90,7 +91,7 @@ extension HomeView {
}

private func setLayouts() {
addSubviews(bannerView, collectionView, addButton, statusBarView)
addSubviews(bannerView, collectionView, addButton, statusBarView, notificationButton)
bannerView.snp.makeConstraints { make in
make.height.equalTo(350)
make.leading.top.trailing.equalToSuperview()
Expand All @@ -103,8 +104,13 @@ extension HomeView {
make.size.equalTo(60)
}
statusBarView.snp.makeConstraints { make in
make.leading.top.trailing.equalToSuperview()
make.height.equalTo(44)
make.leading.trailing.equalToSuperview()
make.height.equalTo(60)
make.bottom.equalTo(safeAreaLayoutGuide.snp.top)
}
notificationButton.snp.makeConstraints { make in
make.top.equalTo(safeAreaLayoutGuide)
make.trailing.equalToSuperview().inset(8)
}
}

Expand Down Expand Up @@ -176,6 +182,7 @@ extension HomeView: UICollectionViewDelegate {
UIView.animate(withDuration: 0.2) {
self.statusBarView.alpha = contentOffsetY < pointOfChange ? 0 : 1
self.bannerView.alpha = contentOffsetY < pointOfChange ? 1 : 0
self.notificationButton.alpha = contentOffsetY < pointOfChange ? 1 : 0
}
guard contentOffsetY < -39 else { return }
let scale = 1 + ((-contentOffsetY - 39) / bannerView.frame.height)
Expand Down

0 comments on commit 515bdda

Please sign in to comment.