-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEAT] #140 - 명함 그룹 뷰 서버연결 #188
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ef624aa
[FEAT] #140 - 그룹명 서버
dlwns33 7d19015
[FEAT] #140 - 서버통신 관련 주석 정리
dlwns33 9cbee26
[FEAT] #140 - 그룹 리스트 조회, 그룹 속 명함 조회 서버
dlwns33 0b5ed77
[FIX] #140 - Card 데이터 모델 수정
dlwns33 30694cf
[FIX] #140 - cardDetail 헤더 수정
dlwns33 b14fc50
[FEAT] #140 - 명함 상세 서버
dlwns33 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
import Photos | ||
import UIKit | ||
import Kingfisher | ||
|
||
class GroupViewController: UIViewController { | ||
|
||
|
@@ -59,24 +60,26 @@ class GroupViewController: UIViewController { | |
@IBOutlet weak var cardsCollectionView: UICollectionView! | ||
|
||
// 그룹 이름들을 담을 변수 생성 | ||
var groups = ["미분류", "SOPT", "그룹명엄청길어요이거", "인하대학교"] | ||
var serverGroups: Groups? | ||
var serverCards: CardsInGroupResponse? | ||
var serverCardsWithBack: Card? | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
registerCell() | ||
setUI() | ||
// 그룹 리스트 조회 서버 테스트 | ||
// groupListFetchWithAPI(userID: "nada") | ||
groupListFetchWithAPI(userID: "nada") | ||
// 그룹 삭제 서버 테스트 | ||
// groupDeleteWithAPI(groupID: 1) | ||
// 그룹 추가 서버 테스트 | ||
// groupAddWithAPI(groupRequest: GroupAddRequest(userId: "nada", groupName: "나다나다")) | ||
// groupAddWithAPI(groupRequest: GroupAddRequest(userId: "nada", groupName: "대학교")) | ||
// 그룹 수정 서버 테스트 | ||
// groupEditWithAPI(groupRequest: GroupEditRequest(groupId: 5, groupName: "수정나다")) | ||
// 그룹 속 명함 추가 테스트 | ||
// cardAddInGroupWithAPI(cardRequest: CardAddInGroupRequest(cardId: "cardA", userId: "nada", groupId: 1)) | ||
// cardAddInGroupWithAPI(cardRequest: CardAddInGroupRequest(cardId: "cardC", userId: "nada", groupId: 18)) | ||
// 그룹 속 명함 조회 테스트 | ||
// cardListInGroupWithAPI(cardListInGroupRequest: CardListInGroupRequest(userId: "nada2", groupId: 3, offset: 0)) | ||
// cardListInGroupWithAPI(cardListInGroupRequest: CardListInGroupRequest(userId: "nada", groupId: 5, offset: 0)) | ||
// 명함 검색 테스트 | ||
// cardDetailFetchWithAPI(cardID: "cardA") | ||
|
||
|
@@ -108,8 +111,9 @@ extension GroupViewController { | |
switch response { | ||
case .success(let data): | ||
if let group = data as? Groups { | ||
// print(group) | ||
// 그룹 리스트 조회 서버통신 성공했을때 | ||
self.serverGroups = group | ||
self.groupCollectionView.reloadData() | ||
self.cardListInGroupWithAPI(cardListInGroupRequest: CardListInGroupRequest(userId: "nada", groupId: group.groups[0].groupID, offset: 0)) | ||
} | ||
case .requestErr(let message): | ||
print("groupListFetchWithAPI - requestErr: \(message)") | ||
|
@@ -126,11 +130,8 @@ extension GroupViewController { | |
func groupDeleteWithAPI(groupID: Int) { | ||
GroupAPI.shared.groupDelete(groupID: groupID) { response in | ||
switch response { | ||
case .success(let data): | ||
if let group = data as? Groups { | ||
// print(group) | ||
// 그룹 삭제 서버 통신 성공했을 떄 | ||
} | ||
case .success: | ||
print("groupDeleteWithAPI - success") | ||
case .requestErr(let message): | ||
print("groupDeleteWithAPI - requestErr: \(message)") | ||
case .pathErr: | ||
|
@@ -146,11 +147,8 @@ extension GroupViewController { | |
func groupAddWithAPI(groupRequest: GroupAddRequest) { | ||
GroupAPI.shared.groupAdd(groupRequest: groupRequest) { response in | ||
switch response { | ||
case .success(let data): | ||
if let group = data as? Groups { | ||
// print(group) | ||
// 그룹 추가 서버 통신 성공했을 떄 | ||
} | ||
case .success: | ||
print("groupAddWithAPI - success") | ||
case .requestErr(let message): | ||
print("groupAddWithAPI - requestErr: \(message)") | ||
case .pathErr: | ||
|
@@ -166,11 +164,8 @@ extension GroupViewController { | |
func groupEditWithAPI(groupRequest: GroupEditRequest) { | ||
GroupAPI.shared.groupEdit(groupRequest: groupRequest) { response in | ||
switch response { | ||
case .success(let data): | ||
if let group = data as? Groups { | ||
// print(group) | ||
// 그룹 추가 서버 통신 성공했을 떄 | ||
} | ||
case .success: | ||
print("groupEditWithAPI - success") | ||
case .requestErr(let message): | ||
print("groupEditWithAPI - requestErr: \(message)") | ||
case .pathErr: | ||
|
@@ -188,9 +183,8 @@ extension GroupViewController { | |
switch response { | ||
case .success(let data): | ||
if let cards = data as? CardsInGroupResponse { | ||
// print(group) | ||
// 그룹 추가 서버 통신 성공했을 떄 | ||
print(cards) | ||
self.serverCards = cards | ||
self.cardsCollectionView.reloadData() | ||
} | ||
case .requestErr(let message): | ||
print("cardListInGroupWithAPI - requestErr: \(message)") | ||
|
@@ -208,9 +202,26 @@ extension GroupViewController { | |
CardAPI.shared.cardDetailFetch(cardID: cardID) { response in | ||
switch response { | ||
case .success(let data): | ||
if let card = data as? Card { | ||
// print(card) | ||
// 통신 성공 | ||
if let card = data as? CardClass { | ||
guard let nextVC = UIStoryboard.init(name: Const.Storyboard.Name.cardDetail, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Identifier.cardDetailViewController) as? CardDetailViewController else { return } | ||
|
||
nextVC.cardDataModel = Card(cardID: card.card.cardID, | ||
background: card.card.background, | ||
title: card.card.title, | ||
name: card.card.name, | ||
birthDate: card.card.birthDate, | ||
mbti: card.card.mbti, | ||
instagram: card.card.instagram, | ||
link: card.card.link, | ||
cardDescription: card.card.cardDescription, | ||
isMincho: card.card.isMincho, | ||
isSoju: card.card.isSoju, | ||
isBoomuk: card.card.isBoomuk, | ||
isSauced: card.card.isSauced, | ||
oneTmi: card.card.oneTmi, | ||
twoTmi: card.card.twoTmi, | ||
threeTmi: card.card.threeTmi) | ||
Comment on lines
+208
to
+223
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
self.navigationController?.pushViewController(nextVC, animated: true) | ||
} | ||
case .requestErr(let message): | ||
print("cardDetailFetchWithAPI - requestErr: \(message)") | ||
|
@@ -223,6 +234,23 @@ extension GroupViewController { | |
} | ||
} | ||
} | ||
|
||
func cardAddInGroupWithAPI(cardRequest: CardAddInGroupRequest) { | ||
GroupAPI.shared.cardAddInGroup(cardRequest: cardRequest) { response in | ||
switch response { | ||
case .success: | ||
print("postCardAddInGroupWithAPI - success") | ||
case .requestErr(let message): | ||
print("postCardAddInGroupWithAPI - requestErr", message) | ||
case .pathErr: | ||
print("postCardAddInGroupWithAPI - pathErr") | ||
case .serverErr: | ||
print("postCardAddInGroupWithAPI - serverErr") | ||
case .networkFail: | ||
print("postCardAddInGroupWithAPI - networkFail") | ||
} | ||
} | ||
} | ||
} | ||
|
||
// MARK: - UICollectionViewDelegate | ||
|
@@ -235,9 +263,9 @@ extension GroupViewController: UICollectionViewDataSource { | |
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { | ||
switch collectionView { | ||
case groupCollectionView: | ||
return groups.count | ||
return serverGroups?.groups.count ?? 0 | ||
case cardsCollectionView: | ||
return 5 | ||
return serverCards?.cards.count ?? 0 | ||
default: | ||
return 0 | ||
} | ||
|
@@ -250,7 +278,8 @@ extension GroupViewController: UICollectionViewDataSource { | |
return UICollectionViewCell() | ||
} | ||
|
||
groupCell.groupName.text = groups[indexPath.row] | ||
groupCell.groupName.text = serverGroups?.groups[indexPath.row].groupName | ||
|
||
if indexPath.row == 0 { | ||
collectionView.selectItem(at: indexPath, animated: true, scrollPosition: .init()) | ||
} | ||
|
@@ -260,6 +289,16 @@ extension GroupViewController: UICollectionViewDataSource { | |
return UICollectionViewCell() | ||
} | ||
|
||
cardCell.backgroundImageView.updateServerImage(serverCards?.cards[indexPath.row].background ?? "") | ||
cardCell.cardId = serverCards?.cards[indexPath.row].cardID | ||
cardCell.titleLabel.text = serverCards?.cards[indexPath.row].title | ||
cardCell.descriptionLabel.text = serverCards?.cards[indexPath.row].cardDescription | ||
cardCell.userNameLabel.text = serverCards?.cards[indexPath.row].name | ||
cardCell.birthLabel.text = serverCards?.cards[indexPath.row].birthDate | ||
cardCell.mbtiLabel.text = serverCards?.cards[indexPath.row].mbti | ||
cardCell.instagramIDLabel.text = serverCards?.cards[indexPath.row].instagram | ||
cardCell.lineURLLabel.text = serverCards?.cards[indexPath.row].link | ||
|
||
return cardCell | ||
default: | ||
return UICollectionViewCell() | ||
|
@@ -269,11 +308,9 @@ extension GroupViewController: UICollectionViewDataSource { | |
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { | ||
switch collectionView { | ||
case groupCollectionView: | ||
print(indexPath.row) | ||
cardListInGroupWithAPI(cardListInGroupRequest: CardListInGroupRequest(userId: "nada", groupId: serverGroups?.groups[indexPath.row].groupID ?? 0, offset: 0)) | ||
case cardsCollectionView: | ||
guard let nextVC = UIStoryboard.init(name: Const.Storyboard.Name.cardDetail, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Identifier.cardDetailViewController) as? CardDetailViewController else { return } | ||
|
||
navigationController?.pushViewController(nextVC, animated: true) | ||
cardDetailFetchWithAPI(cardID: serverCards?.cards[indexPath.row].cardID ?? "") | ||
default: | ||
print(indexPath.row) | ||
} | ||
|
@@ -289,8 +326,8 @@ extension GroupViewController: UICollectionViewDelegateFlowLayout { | |
|
||
switch collectionView { | ||
case groupCollectionView: | ||
if groups[indexPath.row].count > 4 { | ||
width = CGFloat(groups[indexPath.row].count) * 16 | ||
if serverGroups?.groups[indexPath.row].groupName.count ?? 0 > 4 { | ||
width = CGFloat(serverGroups?.groups[indexPath.row].groupName.count ?? 0) * 16 | ||
} else { | ||
width = 62 | ||
} | ||
|
@@ -316,8 +353,6 @@ extension GroupViewController: UICollectionViewDelegateFlowLayout { | |
} | ||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { | ||
switch collectionView { | ||
case groupCollectionView: | ||
return 5 | ||
case cardsCollectionView: | ||
return collectionView.frame.size.width * 15/327 | ||
default: | ||
|
@@ -326,6 +361,8 @@ extension GroupViewController: UICollectionViewDelegateFlowLayout { | |
} | ||
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { | ||
switch collectionView { | ||
case groupCollectionView: | ||
return 5 | ||
case cardsCollectionView: | ||
return collectionView.frame.size.width * 15/327 | ||
default: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
화긴했습니다 감사합니다!