Skip to content

Commit

Permalink
[Del] Keyneez#46 - 코드 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
kpk0616 committed Jan 13, 2023
1 parent 5b61fb6 commit d84c035
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Keyneez/Keyneez/Global/Auth/UserSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ final class UserSession {
private init() { }

var profile: Profile?
var accessToken: String? = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2tleSI6MzEyLCJpYXQiOjE2NzM2NDExOTUsImV4cCI6MTY3MzY0ODM5NX0.thu5Mu3sVDYgC_lnKDbXthIo0z4ubl-Col67OTm4Eh8"
var accessToken: String? = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2tleSI6MzE1LCJpYXQiOjE2NzM2NDE0MjksImV4cCI6MTY3MzY0ODYyOX0.ChHzYfCvhd2idnpnBC2SBXllt3335YcCXiSbCYId2h0"

}
Original file line number Diff line number Diff line change
Expand Up @@ -95,38 +95,17 @@ extension HomeContentViewController: UICollectionViewDelegateFlowLayout {

extension HomeContentViewController: UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
// switch(segmentedNumber) {
// case 0:
// return h.count
// case 1:
// return popularContentList.count
// case 2:
// return newestContentList.count
// default:
// return recommendContentList.count
// }
return contentList.count
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let model: [HomeContentModel]
// switch(segmentedNumber) {
// case 0:
// model = recommendContentList
// case 1:
// model = popularContentList
// case 2:
// model = newestContentList
// default:
// model = recommendContentList
// }
guard let homeContentCell = collectionView.dequeueReusableCell(
withReuseIdentifier: HomeContentCollectionViewCell.identifier, for: indexPath)
as? HomeContentCollectionViewCell else { return UICollectionViewCell() }

homeContentCell.bindHomeData(model: contentList[indexPath.item])
// 여기서 setCategory
homeContentCell.setHomeCategoryCard(category: contentList[indexPath.item].category[0])
homeContentCell.setHomeCategoryView(category: contentList[indexPath.item].category[0])
return homeContentCell
}
}
14 changes: 13 additions & 1 deletion Keyneez/Keyneez/Tab/Home/Controllers/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,23 @@ final class HomeViewController: NiblessViewController, NavigationBarProtocol {
setLayout()
addContentViews(asChildViewController: HomeContentViewController())
addNavigationViewToSubview()
guard let token = UserSession.shared.accessToken else { return }
repository.getAllContents(token: token) {
[weak self] arr in
guard let self else {return}
self.datasources.append(arr)
DispatchQueue.main.async {
self.VCs.forEach {
$0.contentList = self.datasources[0]
$0.recommendContentCollectionView.reloadData()
}
}
}
}
private var repository: ContentRepository = KeyneezContentRepository()

var datasources: [[HomeContentResponseDto]] = []
let VCs: [HomeContentViewController] = [HomeContentViewController(), HomeContentViewController(), HomeContentViewController()]
var VCs: [HomeContentViewController] = [HomeContentViewController(), HomeContentViewController(), HomeContentViewController()]

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
Expand Down
42 changes: 33 additions & 9 deletions Keyneez/Keyneez/Tab/Home/Views/HomeContentCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ final class HomeContentCollectionViewCell: UICollectionViewCell {
static let identifier = "HomeContentCollectionViewCell"
var homeContentID = -1
var homeContentImageURL: String = ""
private var homeContentCategory = ""

let repository: ContentRepository = KeyneezContentRepository()
// MARK: - UI Components
Expand Down Expand Up @@ -47,7 +48,7 @@ final class HomeContentCollectionViewCell: UICollectionViewCell {
$0.font = UIFont.font(.pretendardSemiBold, ofSize: 12)
$0.textColor = UIColor.gray900
}
private var homeContentCategoryView = CategoryView()
lazy var homeContentCategoryView = CategoryView()
private lazy var likeButton = UIButton().then {
$0.setImage(UIImage(named: "ic_favorite_home_line"), for: .normal)
$0.setImage(UIImage(named: "ic_favorite_home_filled"), for: .selected)
Expand All @@ -64,6 +65,8 @@ final class HomeContentCollectionViewCell: UICollectionViewCell {
$0.font = UIFont.font(.pretendardMedium, ofSize: 14)
$0.textColor = UIColor.gray600
}

var categoryInfo: String = ""
// MARK: - Life Cycle

override init(frame: CGRect) {
Expand All @@ -76,6 +79,33 @@ final class HomeContentCollectionViewCell: UICollectionViewCell {
}

extension HomeContentCollectionViewCell {

// override func prepareForReuse() {
// super.prepareForReuse()
// self.homeContentCategoryView = setHomeCategoryView(category: categoryInfo)
// }

private func setHomeCategoryView(category: String) -> CategoryView {
let categoryview = CategoryView()
homeContentCategoryView.setCategory(with: category)
switch(category) {
case "진로" :
categoryview.setCategory(with: "진로")
case "봉사":
categoryview.setCategory(with: "봉사")
case "여행":
categoryview.setCategory(with: "여행")
case "문화":
categoryview.setCategory(with: "문화")
case "경제":
categoryview.setCategory(with: "경제")
default:
break
}
return categoryview
}


private func setLayout() {
contentView.addSubviews(shadowView, containerView)
containerView.addSubviews(
Expand Down Expand Up @@ -139,13 +169,10 @@ extension HomeContentCollectionViewCell {
func bindHomeData(model: HomeContentResponseDto) {
homeContentID = model.contentKey
dateLabel.text = setDateLabel(model: model)
// category.text = model.categoty[0] // 카테고리 여러 개 받기
contentTitle.text = setTitle(fullTitle: model.contentTitle)
contentIntroduction.text = model.introduction
likeButton.isSelected = model.liked
contentImageView.setImage(url: model.contentImg)
// setCategoryCard(category: model.category[0]) // 여기야
// homeContentCategoryView.setCategory(with: model.category[0])
}
private func setTitle(fullTitle: String) -> String {
guard let title = fullTitle as? String else {return ""}
Expand All @@ -163,7 +190,8 @@ extension HomeContentCollectionViewCell {
if model.startAt!.isEmpty || model.endAt!.isEmpty { dateView.isHidden = true; return "" }
return getDate(fullDate: model.startAt!) + " ~ " + getDate(fullDate: model.endAt!)
}
func setHomeCategoryCard(category: String) {
func setHomeCategoryCard(category: String) { // 카드 색 변경
homeContentCategoryView.setCategory(with: category)
switch(category) {
case "진로" :
cardImageView.image = UIImage(named: "card_green_home")
Expand All @@ -180,10 +208,6 @@ extension HomeContentCollectionViewCell {
}
}

func setHomeCategoryView(category: String) {
homeContentCategoryView.setCategory(with: category)
}

@objc
private func touchUpLikeButton() {
likeButton.isSelected = !likeButton.isSelected
Expand Down
23 changes: 13 additions & 10 deletions Keyneez/Keyneez/Tab/KeyneezTabbarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ final class KeyneezTabbarController: UITabBarController {
extension KeyneezTabbarController {
fileprivate func createTabbarItems() {

// let homeViewController = HomeViewController()
// let homeViewNavigationController = makeHomeNaviController(homeViewController: homeViewController)
let homeViewController = HomeViewController()
homeViewController.viewWillAppear(true)
let homeViewNavigationController = makeHomeNaviController(homeViewController: homeViewController)
//
// guard let token = UserSession.shared.accessToken else { return }
// repository.getAllContents(token: token) {
Expand All @@ -55,7 +56,7 @@ extension KeyneezTabbarController {
// }

let tabInfos: [TabInfo] = [
TabInfo(viewController: HomeViewController.self, title: "", imageName: "ic_home_tabbar"),
// TabInfo(viewController: HomeViewController.self, title: "홈", imageName: "ic_home_tabbar"),
TabInfo(viewController: LikeViewController.self, title: "좋아요", imageName: "ic_like_tabbar"),
TabInfo(viewController: IDViewController.self, imageName: "id_card_tabbar"),
TabInfo(viewController: MyPageViewController.self, title: "캐릭터",
Expand All @@ -66,9 +67,10 @@ extension KeyneezTabbarController {
var navigations = tabInfos.map {
makeViewController(viewController: $0.viewController!, title: $0.title, imageName: $0.imageName)
}
navigations.insert(homeViewNavigationController, at: 0)
navigations[3].tabBarItem.isEnabled = false
navigations[4].tabBarItem.isEnabled = false
// navigations.insert(homeViewNavigationController, at: 0)
// homeViewNavigationController.viewDidLoad()
self.viewControllers = navigations
}

Expand All @@ -85,10 +87,11 @@ extension KeyneezTabbarController {
return nav
}

// private func makeHomeNaviController(homeViewController: HomeViewController) -> UINavigationController {
// let nav = UINavigationController(rootViewController: homeViewController)
// nav.isNavigationBarHidden = true
// nav.tabBarItem = UITabBarItem(title: "홈", image: UIImage(named: "ic_home_tabbar"), selectedImage: nil)
// return nav
// }
private func makeHomeNaviController(homeViewController: HomeViewController) -> UINavigationController {
let nav = UINavigationController(rootViewController: homeViewController)
homeViewController.viewWillAppear(true)
nav.isNavigationBarHidden = true
nav.tabBarItem = UITabBarItem(title: "", image: UIImage(named: "ic_home_tabbar"), selectedImage: nil)
return nav
}
}

0 comments on commit d84c035

Please sign in to comment.