Skip to content

Commit

Permalink
Merge pull request #289 from boostcampwm-2021/issue/#271
Browse files Browse the repository at this point in the history
[정거장 정보] 마지막 셀의 알람 버튼을 누를 수 없다
  • Loading branch information
minsangKang authored Nov 25, 2021
2 parents 45e5821 + f17ce06 commit affefa0
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 5 deletions.
4 changes: 4 additions & 0 deletions BBus/BBus.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
4AA294B3273C111C008E5497 /* GetFavoriteItemListFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AA294B2273C111C008E5497 /* GetFavoriteItemListFetcher.swift */; };
4AA294B5273C11DE008E5497 /* CreateFavoriteItemFetcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AA294B4273C11DE008E5497 /* CreateFavoriteItemFetcher.swift */; };
4AA294B7273C1275008E5497 /* DeleteFavoriteItemFetchable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AA294B6273C1275008E5497 /* DeleteFavoriteItemFetchable.swift */; };
4AC79161274F6FDB00019827 /* SourceFooterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4AC79160274F6FDB00019827 /* SourceFooterView.swift */; };
4ACA51E3272FCD9600EC0531 /* HomeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ACA51E2272FCD9600EC0531 /* HomeModel.swift */; };
4ACA51E5272FCD9C00EC0531 /* HomeUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ACA51E4272FCD9C00EC0531 /* HomeUseCase.swift */; };
4ACA51E7272FCDA600EC0531 /* HomeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4ACA51E6272FCDA600EC0531 /* HomeViewModel.swift */; };
Expand Down Expand Up @@ -194,6 +195,7 @@
4AA294B2273C111C008E5497 /* GetFavoriteItemListFetcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetFavoriteItemListFetcher.swift; sourceTree = "<group>"; };
4AA294B4273C11DE008E5497 /* CreateFavoriteItemFetcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateFavoriteItemFetcher.swift; sourceTree = "<group>"; };
4AA294B6273C1275008E5497 /* DeleteFavoriteItemFetchable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeleteFavoriteItemFetchable.swift; sourceTree = "<group>"; };
4AC79160274F6FDB00019827 /* SourceFooterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceFooterView.swift; sourceTree = "<group>"; };
4ACA51E2272FCD9600EC0531 /* HomeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeModel.swift; sourceTree = "<group>"; };
4ACA51E4272FCD9C00EC0531 /* HomeUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeUseCase.swift; sourceTree = "<group>"; };
4ACA51E6272FCDA600EC0531 /* HomeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -437,6 +439,7 @@
4A1A22DA27326FD100476861 /* HomeNavigationView.swift */,
4A7BBFF02737D6C20029915F /* RemainCongestionBadgeLabel.swift */,
4A917DF127462E36002489FE /* EmptyFavoriteNoticeView.swift */,
4AC79160274F6FDB00019827 /* SourceFooterView.swift */,
);
path = View;
sourceTree = "<group>";
Expand Down Expand Up @@ -959,6 +962,7 @@
4A06AEC8274159D10027222D /* FavoriteItemDTO.swift in Sources */,
4ACA521F272FCEAA00EC0531 /* AlarmSettingBusArriveInfo.swift in Sources */,
4A1A22DB27326FD100476861 /* HomeNavigationView.swift in Sources */,
4AC79161274F6FDB00019827 /* SourceFooterView.swift in Sources */,
0484107627464D49006F8636 /* AlarmSettingBusArriveInfos.swift in Sources */,
4ACA5225272FCEBF00EC0531 /* AlarmSettingView.swift in Sources */,
87038A92273C12320078EAE3 /* GetBusPosByRtidFetcher.swift in Sources */,
Expand Down
40 changes: 38 additions & 2 deletions BBus/BBus/Foreground/Home/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ final class HomeViewController: UIViewController {

NSLayoutConstraint.activate([
self.homeView.topAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.topAnchor),
self.homeView.bottomAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.bottomAnchor),
self.homeView.bottomAnchor.constraint(equalTo: self.view.bottomAnchor),
self.homeView.leadingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.leadingAnchor),
self.homeView.trailingAnchor.constraint(equalTo: self.view.safeAreaLayoutGuide.trailingAnchor)
])
Expand Down Expand Up @@ -222,7 +222,38 @@ extension HomeViewController: UICollectionViewDataSource {
}

func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: FavoriteCollectionHeaderView.identifier, for: indexPath) as? FavoriteCollectionHeaderView else { return UICollectionReusableView() }
switch kind {
case UICollectionView.elementKindSectionFooter :
if let footer = footer(with: collectionView, indexPath: indexPath) {
return footer
}
case UICollectionView.elementKindSectionHeader :
if let header = header(with: collectionView, indexPath: indexPath) {
return header
}
default :
return UICollectionReusableView()
}
return UICollectionReusableView()
}

private func footer(with collectionView: UICollectionView, indexPath: IndexPath) -> SourceFooterView? {
guard let footer = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: SourceFooterView.identifier, for: indexPath) as? SourceFooterView else { return nil }
if let maxSize = self.footerSize(with: collectionView) {
footer.frame.size = maxSize
}
return footer
}

private func footerSize(with collectionView: UICollectionView) -> CGSize? {
guard collectionView.contentSize.height < collectionView.frame.height else { return nil }
let gap = collectionView.frame.height - collectionView.contentSize.height
return CGSize(width: self.view.frame.width, height: SourceFooterView.height + gap)
}

private func header(with collectionView: UICollectionView, indexPath: IndexPath) -> FavoriteCollectionHeaderView? {
guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: FavoriteCollectionHeaderView.identifier, for: indexPath) as? FavoriteCollectionHeaderView else { return nil }

guard let stationId = self.viewModel?.homeFavoriteList?[indexPath.section]?.stationId,
let stationName = self.viewModel?.stationName(by: stationId),
let arsId = self.viewModel?.homeFavoriteList?[indexPath.section]?.arsId else { return header }
Expand All @@ -248,6 +279,11 @@ extension HomeViewController: UICollectionViewDelegateFlowLayout {
return CGSize(width: self.view.frame.width, height: FavoriteCollectionHeaderView.height)
}
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
guard section == (self.viewModel?.homeFavoriteList?.count() ?? 1) - 1 else { return CGSize.zero }
return CGSize(width: self.view.frame.width, height: SourceFooterView.height)
}
}

// MARK: - HomeSearchButtonDelegate : UICollectionView
Expand Down
15 changes: 14 additions & 1 deletion BBus/BBus/Foreground/Home/View/EmptyFavoriteNoticeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ final class EmptyFavoriteNoticeView: UIView {
label.font = UIFont.systemFont(ofSize: 15)
return label
}()
private lazy var sourceLabel: UILabel = {
let label = UILabel()
label.text = "출처 : 서울특별시"
label.font = UIFont.systemFont(ofSize: 15)
label.textColor = BBusColor.bbusGray
return label
}()

convenience init() {
self.init(frame: CGRect())
Expand All @@ -43,7 +50,7 @@ final class EmptyFavoriteNoticeView: UIView {
let half: CGFloat = 0.5
let centerYInterval: CGFloat = -30

self.addSubviews(self.noticeImage, self.noticeLabel)
self.addSubviews(self.noticeImage, self.noticeLabel, self.sourceLabel)

NSLayoutConstraint.activate([
self.noticeImage.centerXAnchor.constraint(equalTo: self.centerXAnchor),
Expand All @@ -57,5 +64,11 @@ final class EmptyFavoriteNoticeView: UIView {
self.noticeLabel.centerXAnchor.constraint(equalTo: self.centerXAnchor),
self.noticeLabel.widthAnchor.constraint(equalTo: self.noticeImage.widthAnchor, multiplier: 1.2)
])

let sourceLabelBottominterval: CGFloat = -30
NSLayoutConstraint.activate([
self.sourceLabel.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: sourceLabelBottominterval),
self.sourceLabel.centerXAnchor.constraint(equalTo: self.centerXAnchor)
])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class FavoriteCollectionViewCell: UICollectionViewCell {

private lazy var busNumberLabel: UILabel = {
let label = UILabel()
label.text = "272"
label.font = UIFont.boldSystemFont(ofSize: self.busNumberFontSize)
label.textColor = BBusColor.bbusTypeBlue
return label
Expand Down
7 changes: 6 additions & 1 deletion BBus/BBus/Foreground/Home/View/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ final class HomeView: UIView {

private lazy var favoriteCollectionView: UICollectionView = {
let collectionView = UICollectionView(frame: CGRect(), collectionViewLayout: self.collectionViewLayout())
collectionView.register(FavoriteCollectionHeaderView.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: FavoriteCollectionHeaderView.identifier)
collectionView.register(FavoriteCollectionHeaderView.self,
forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader,
withReuseIdentifier: FavoriteCollectionHeaderView.identifier)
collectionView.register(SourceFooterView.self,
forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter,
withReuseIdentifier: SourceFooterView.identifier)
collectionView.register(FavoriteCollectionViewCell.self, forCellWithReuseIdentifier: FavoriteCollectionViewCell.identifier)
let backgroundView = UIView()
backgroundView.backgroundColor = BBusColor.bbusBackground
Expand Down
42 changes: 42 additions & 0 deletions BBus/BBus/Foreground/Home/View/SourceFooterView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//
// CollectionReusableView.swift
// BBus
//
// Created by 이지수 on 2021/11/25.
//

import UIKit

final class SourceFooterView: UICollectionReusableView {

static let identifier = "SourceFooterView"
static let height: CGFloat = 100

private lazy var sourceLabel: UILabel = {
let label = UILabel()
label.text = "출처 : 서울특별시"
label.font = UIFont.systemFont(ofSize: 15)
label.textColor = BBusColor.bbusGray
return label
}()

required override init(frame: CGRect) {
super.init(frame: frame)
self.configureLayout()
}

required init?(coder: NSCoder) {
super.init(coder: coder)
self.configureLayout()
}

private func configureLayout() {
self.addSubviews(self.sourceLabel)

let half: CGFloat = 0.5
NSLayoutConstraint.activate([
self.sourceLabel.bottomAnchor.constraint(equalTo: self.bottomAnchor, constant: -Self.height * half),
self.sourceLabel.centerXAnchor.constraint(equalTo: self.centerXAnchor)
])
}
}
5 changes: 5 additions & 0 deletions BBus/BBus/Foreground/Station/View/StationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ final class StationView: UIView {
collectionView.register(SimpleCollectionHeaderView.self,
forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader,
withReuseIdentifier: SimpleCollectionHeaderView.identifier)
collectionView.register(SourceFooterView.self,
forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter,
withReuseIdentifier: SourceFooterView.identifier)
collectionView.backgroundColor = BBusColor.bbusLightGray
return collectionView
}()
Expand Down Expand Up @@ -71,7 +74,9 @@ final class StationView: UIView {
self.stationBodyCollectionView.trailingAnchor.constraint(equalTo: self.stationScrollContentsView.trailingAnchor),
self.stationBodyCollectionView.topAnchor.constraint(equalTo: self.stationHeaderView.bottomAnchor)
])

self.stationScrollView.addSubviews(self.stationScrollContentsView)

NSLayoutConstraint.activate([
self.stationScrollContentsView.topAnchor.constraint(equalTo: self.stationScrollView.contentLayoutGuide.topAnchor),
self.stationScrollContentsView.leadingAnchor.constraint(equalTo: self.stationScrollView.contentLayoutGuide.leadingAnchor),
Expand Down

0 comments on commit affefa0

Please sign in to comment.