Skip to content

Commit

Permalink
๐Ÿ”จ[FIX] #285 - ๊ฒ€์ƒ‰์— ์‚ฌ์šฉ๋œ tag๋ทฐ ์ƒ๋‹จ์— ๊ณ ์ •๋˜๋„๋ก ์ˆ˜์ •
Browse files Browse the repository at this point in the history
  • Loading branch information
hryeong66 committed Jul 25, 2022
1 parent a81742e commit 92808fa
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ extension PostDetailVC: UITableViewDataSource {
userName: postData.author,
date: "\(additionalData.year)๋…„ \(additionalData.month)์›” \(additionalData.day)์ผ",
imageName: postData.profileImage)
//TODO: - user ์ด๋ฏธ์ง€ + ํ…์ŠคํŠธ ๋ˆŒ๋ €์„ ๋•Œ ํ•ด๋‹น ์œ ์ € ๋งˆ์ดํŽ˜์ด์ง€๋กœ ์ด๋™
// let otherVC = OtherMyPageVC()
// otherVC.setOtherUserID(userID: follow.userEmail)
// otherVC.modalPresentationStyle = .overFullScreen
// self?.present(otherVC, animated: true)
return cell

case 1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
//

import UIKit

import SnapKit
import Then

class SearchResultVC: UIViewController {
final class SearchResultVC: UIViewController {

//MARK: Result Data
public var lastPostId: Int = 0
Expand All @@ -31,10 +32,10 @@ class SearchResultVC: UIViewController {
private let separateLineView = UIView().then {
$0.backgroundColor = .gray20
}
private var collectionView: UICollectionView = {

private lazy var collectionView: UICollectionView = {
let collectionView = UICollectionView(frame: .zero,
collectionViewLayout: UICollectionViewFlowLayout())

collectionView.isPagingEnabled = true
collectionView.backgroundColor = .clear
collectionView.showsHorizontalScrollIndicator = false
Expand All @@ -45,14 +46,15 @@ class SearchResultVC: UIViewController {
layout.minimumInteritemSpacing = 0
layout.scrollDirection = .vertical
collectionView.setCollectionViewLayout(layout, animated: true)

collectionView.registerCustomXib(xibName: PostResultHeaderCVC.identifier)
collectionView.delegate = self
collectionView.dataSource = self
collectionView.registerCustomXib(xibName: CommonCVC.identifier)

collectionView.registerCustomXib(xibName: HomePostDetailCVC.identifier)
return collectionView
}()

private let closeButton = UIButton().then {

private lazy var closeButton = UIButton().then {
$0.setTitle("๋‹ซ๊ธฐ", for: .normal)
$0.titleLabel?.font = .notoSansMediumFont(ofSize: 17)
$0.setTitleColor(.mainBlue, for: .normal)
Expand All @@ -70,7 +72,7 @@ class SearchResultVC: UIViewController {
$0.textColor = .gray50
}

private let searchButton = UIButton().then {
private lazy var searchButton = UIButton().then {
$0.setTitle("๋“œ๋ผ์ด๋ธŒ ์ฝ”์Šค ์ž‘์„ฑํ•˜๊ธฐ", for: .normal)
$0.setTitleColor(.white, for: .normal)
$0.titleLabel?.font = .notoSansBoldFont(ofSize: 16)
Expand All @@ -83,8 +85,12 @@ class SearchResultVC: UIViewController {
super.viewDidLoad()
postSearchPost(type: "like")
setupConstraint()
configureUI()
setFilterViewCompletion()
configureCollectionView()
}

private func configureUI() {
view.backgroundColor = .white
}

public func setFilterTagList(list: [String]) {
Expand All @@ -106,20 +112,7 @@ class SearchResultVC: UIViewController {
}
}

func configureCollectionView() {
collectionView.register(UINib(nibName: PostResultHeaderCVC.identifier, bundle: nil),
forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader,
withReuseIdentifier: PostResultHeaderCVC.identifier)

collectionView.registerCustomXib(xibName: CommonCVC.identifier)
collectionView.registerCustomXib(xibName: HomePostDetailCVC.identifier)

collectionView.delegate = self
collectionView.dataSource = self
collectionView.isPagingEnabled = false
}

func setFilterViewLayout() {
private func setFilterViewLayout() {
self.view.addSubview(filterView)
filterView.isHidden = true
filterView.snp.makeConstraints{
Expand All @@ -130,9 +123,9 @@ class SearchResultVC: UIViewController {
}
}

func setFilterViewCompletion(){
private func setFilterViewCompletion() {
filterView.touchCellCompletion = { index in
switch index{
switch index {
case 0:
self.currentState = "์ธ๊ธฐ์ˆœ"
self.postSearchPost(type: "new")
Expand Down Expand Up @@ -171,7 +164,7 @@ extension SearchResultVC: UICollectionViewDataSource {
nextVC.setPostId(id: postid)
self.navigationController?.pushViewController(nextVC, animated: true)
}
if indexPath.row == 0{
if indexPath.row == 0 {
if myCellIsFirstLoaded {
myCellIsFirstLoaded = false
topCVCCell = dropDownCell
Expand All @@ -189,38 +182,14 @@ extension SearchResultVC: UICollectionViewDataSource {
postID: post.postID)
return cell!
}


func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {

guard let header = collectionView.dequeueReusableSupplementaryView(ofKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: PostResultHeaderCVC.identifier, for: indexPath) as? PostResultHeaderCVC else {
return UICollectionReusableView()
}
header.setStackViewData(list: filterResultList)
header.addSubview(separateLineView)
separateLineView.snp.makeConstraints{
$0.leading.trailing.equalTo(view.safeAreaLayoutGuide)
$0.bottom.equalToSuperview()
$0.height.equalTo(1)
}
return header
}

}

extension SearchResultVC: UICollectionViewDelegateFlowLayout {

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
return CGSize(width: UIScreen.getDeviceWidth(), height: 40)
}
extension SearchResultVC: UICollectionViewDelegateFlowLayout {

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {

if indexPath.row == 0 {
return CGSize(width: collectionView.frame.size.width-40, height: 57)
}

return CGSize(width: collectionView.frame.size.width-40, height: 260)
let height = indexPath.row == 0 ? 57 : 260
return CGSize(width: UIScreen.getDeviceWidth() - 40, height: height)
}

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
Expand All @@ -246,18 +215,18 @@ extension SearchResultVC {
}

navigationView.addSubviews([backButton,navigationTitleLabel,closeButton])
backButton.snp.makeConstraints{
backButton.snp.makeConstraints {
$0.top.equalToSuperview().offset(1)
$0.leading.equalToSuperview()
$0.bottom.equalToSuperview().offset(-9)
}

navigationTitleLabel.snp.makeConstraints{
navigationTitleLabel.snp.makeConstraints {
$0.centerX.equalToSuperview()
$0.centerY.equalTo(backButton.snp.centerY)
}

closeButton.snp.makeConstraints{
closeButton.snp.makeConstraints {
$0.trailing.equalToSuperview().offset(-20)
$0.centerY.equalTo(backButton.snp.centerY)
}
Expand Down Expand Up @@ -294,18 +263,73 @@ extension SearchResultVC {
$0.leading.trailing.bottom.equalTo(view.safeAreaLayoutGuide).inset(20)
$0.height.equalTo(48)
}

}

private func setResultViewConstraint() {
view.addSubview(collectionView)
let tagHeaderView = initTagHearderView()
view.addSubviews([collectionView, separateLineView, tagHeaderView])
tagHeaderView.snp.makeConstraints {
$0.top.equalTo(navigationView.snp.bottom)
$0.leading.trailing.equalToSuperview()
$0.height.equalTo(65)
}

separateLineView.snp.makeConstraints {
$0.top.equalTo(tagHeaderView.snp.bottom)
$0.leading.trailing.equalToSuperview()
$0.height.equalTo(1)
}

collectionView.snp.makeConstraints{
$0.top.equalTo(self.navigationView.snp.bottom).offset(15)
$0.top.equalTo(separateLineView.snp.bottom)
$0.leading.trailing.bottom.equalToSuperview()
}
}
}

// MARK: - ์ƒ๋‹จ tag header view
extension SearchResultVC {
private func initTagHearderView() -> UIView {
let view = UIView(frame: CGRect(x: 0, y: 0,
width: UIScreen.getDeviceWidth(),
height: 65))
view.backgroundColor = .white

let stackView = UIStackView(arrangedSubviews: makeTagLabelList())
stackView.axis = .horizontal
stackView.alignment = .leading
stackView.distribution = .fill
stackView.spacing = 4

view.addSubview(stackView)
stackView.snp.makeConstraints{
$0.leading.equalTo(view.snp.leading).offset(20)
$0.centerY.equalToSuperview()
$0.height.equalTo(34)
}
return view
}

private func makeTagLabelList() -> [UIButton] {
var list: [UIButton] = []
for index in 0..<filterResultList.count {
if filterResultList[index] == "" || filterResultList[index] == "์„ ํƒ์•ˆํ•จ" { continue }
let isWarningIndex = index == 3
let buttonTitle = isWarningIndex ? "โ€#\(filterResultList[index])Xโ€" : "โ€#\(filterResultList[index])โ€"
let button = UIButton().then {
$0.titleLabel?.font = .notoSansRegularFont(ofSize: 12)
$0.layer.cornerRadius = 15
$0.layer.borderWidth = 1
$0.setTitle(buttonTitle, for: .normal)
$0.setTitleColor(isWarningIndex ? .gray30 : .mainBlue, for: .normal)
$0.layer.borderColor = isWarningIndex ? UIColor.gray30.cgColor : UIColor.mainLightBlue.cgColor
}
list.append(button)
}
return list
}
}


//MARK: Network
extension SearchResultVC{
Expand All @@ -319,12 +343,10 @@ extension SearchResultVC{
func postSearchPost(type: String) {
let themeEng = CommonData.themeDict[filterResultList[2]] ?? ""
let warningEng = CommonData.warningDataDict[filterResultList[3]] ?? ""
print("themeEng =\(themeEng), warningEng = \(warningEng)")
PostResultService.shared.postSearchKeywords(region: filterResultList[1],
theme: themeEng,
warning: warningEng,
type: type) { response in

switch(response) {
case .success(let resultData):
if let data = resultData as? Drive {
Expand Down
7 changes: 2 additions & 5 deletions ChaRo-iOS/ChaRo-iOS/Source/Views/VCs/SignScene/LoginVC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,8 @@ class LoginVC: UIViewController {
self.makeAlert(title: "๋กœ๊ทธ์ธ ์‹คํŒจ", message: "๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.")
return
}
LoginService.shared.login(id: userEmail, password: userPassword) {
result in

switch result
{
LoginService.shared.login(id: userEmail, password: userPassword) { result in
switch result {
case .success(let data):
print("์ผ๋ฐ˜ ๋กœ๊ทธ์ธ ์„ฑ๊ณต \(data)")
let loginData = data as? LoginDataModel
Expand Down

0 comments on commit 92808fa

Please sign in to comment.