Skip to content

Commit f944863

Browse files
committed
feat #47: 그룹 API 연동
+ 그룹 탈퇴 추가, '인증 대기' -> '검사 대기' 문구 수정, UI 일부 개선
1 parent d3a7114 commit f944863

27 files changed

+425
-288
lines changed

dogether/Data/Model/RankingModel.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@ import Foundation
1010
struct RankingModel: Codable {
1111
let rank: Int
1212
let name: String
13-
let certificationRate: Int
14-
let approvalRate: Int
13+
let certificationRate: Double
1514
}

dogether/Data/Network/Request/CreateGroupRequest.swift

+10-10
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77

88
import Foundation
99

10-
struct CreateGroupRequest: GroupInfo, Encodable {
11-
let groupName: String
12-
let memberCount: Int
10+
struct CreateGroupRequest: Encodable {
11+
let name: String
12+
let maximumMemberCount: Int
1313
let startAt: String
14-
let challengeDuration: Int
15-
let dailyTodoLimit: Int
14+
let durationOption: Int
15+
let maximumTodoCount: Int
1616

17-
init(groupName: String, memberCount: Int, startAt: GroupStartAts, challengeDuration: GroupChallengeDurations, dailyTodoLimit: Int) {
18-
self.groupName = groupName
19-
self.memberCount = memberCount
17+
init(name: String, maximumMemberCount: Int, startAt: GroupStartAts, durationOption: GroupChallengeDurations, maximumTodoCount: Int) {
18+
self.name = name
19+
self.maximumMemberCount = maximumMemberCount
2020
self.startAt = startAt.rawValue
21-
self.challengeDuration = challengeDuration.rawValue
22-
self.dailyTodoLimit = dailyTodoLimit
21+
self.durationOption = durationOption.rawValue
22+
self.maximumTodoCount = maximumTodoCount
2323
}
2424
}

dogether/Data/Network/Response/GetGroupInfoResponse.swift

+6-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
import Foundation
99

10-
struct GetGroupInfoResponse: GroupInfo, Decodable {
11-
let groupName: String
12-
let memberCount: Int
13-
let dailyTodoLimit: Int
10+
struct GetGroupInfoResponse: Decodable {
11+
let name: String
12+
let duration: Int
13+
let joinCode: String
14+
let endAt: String
15+
let remainingDays: Int
1416
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//
2+
// GetGroupStatusResponse.swift
3+
// dogether
4+
//
5+
// Created by seungyooooong on 2/20/25.
6+
//
7+
8+
import Foundation
9+
10+
struct GetGroupStatusResponse: Decodable {
11+
let status : String
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//
2+
// GetIsJoiningResponse.swift
3+
// dogether
4+
//
5+
// Created by seungyooooong on 2/19/25.
6+
//
7+
8+
import Foundation
9+
10+
struct GetIsJoiningResponse: Decodable {
11+
let isJoining: Bool
12+
}

dogether/Data/Network/Response/GetMySummaryResponse.swift

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@
77

88
import Foundation
99

10-
/// 참여중인 그룹의 내 누적 활동 통계 조회
11-
struct GetMySummaryResponse: TotalCount, Decodable {
12-
/// 작성한 전체 투두 개수
10+
struct GetMySummaryResponse: Decodable {
1311
let totalTodoCount: Int
1412
/// 인증한 전체 투두 개수
1513
let totalCertificatedCount: Int
1614
/// 인정받은 투두 개수
1715
let totalApprovedCount: Int
18-
/// 노인정 투두 개수
1916
let totalRejectedCount: Int
2017
}

dogether/Data/Network/Response/GetTeamSummaryResponse.swift

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
import Foundation
99

10-
struct GetTeamSummaryResponse: TotalCount, Decodable {
11-
let totalTodoCount: Int
12-
let totalCertificatedCount: Int
13-
let totalApprovedCount: Int
10+
struct GetTeamSummaryResponse: Decodable {
1411
let ranking: [RankingModel]
1512
}

dogether/Data/Network/Router/GroupsRouter.swift

+12-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ enum GroupsRouter: NetworkEndpoint {
1313
case getGroupInfo
1414
case getMySummary
1515
case getTeamSummary
16+
case getIsJoining
17+
case leaveGroup
18+
case getGroupStatus
1619

1720
var path: String {
1821
switch self {
@@ -26,15 +29,23 @@ enum GroupsRouter: NetworkEndpoint {
2629
return Path.api + Path.groups + Path.summary + "/my"
2730
case .getTeamSummary:
2831
return Path.api + Path.groups + Path.summary + "/team"
32+
case .getIsJoining:
33+
return Path.api + Path.groups + "/isJoining"
34+
case .leaveGroup:
35+
return Path.api + Path.groups + "/leave"
36+
case .getGroupStatus:
37+
return Path.api + Path.groups + "/my" + "/status"
2938
}
3039
}
3140

3241
var method: NetworkMethod {
3342
switch self {
34-
case .getGroupInfo, .getMySummary, .getTeamSummary:
43+
case .getGroupInfo, .getMySummary, .getTeamSummary, .getIsJoining, .getGroupStatus:
3544
return .get
3645
case .createGroup, .joinGroup:
3746
return .post
47+
case .leaveGroup:
48+
return .delete
3849
}
3950
}
4051

dogether/Data/Protocol/GroupInfo.swift

-14
This file was deleted.

dogether/Data/Protocol/TotalCount.swift

-14
This file was deleted.

dogether/Domain/Entity/FilterTypes.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import UIKit
1010

1111
enum FilterTypes: String, CaseIterable {
1212
case all = "전체"
13-
case wait = "인증 대기"
13+
case wait = "검사 대기"
1414
case reject = "노인정"
1515
case approve = "인정"
1616

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//
2+
// GroupInfo.swift
3+
// dogether
4+
//
5+
// Created by seungyooooong on 2/19/25.
6+
//
7+
8+
import Foundation
9+
10+
struct GroupInfo {
11+
let name: String
12+
let duration: Int
13+
let joinCode: String
14+
let endAt: String
15+
let remainingDays: Int
16+
17+
init(name: String = "", duration: Int = 0, joinCode: String = "", endAt: String = "", remainingDays: Int = 0) {
18+
self.name = name
19+
self.duration = duration
20+
self.joinCode = joinCode
21+
self.endAt = endAt
22+
self.remainingDays = remainingDays
23+
}
24+
}

dogether/Domain/Entity/GroupTypes.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99
import UIKit
1010

11-
enum GroupTypes {
11+
enum GroupTypes: Int {
1212
case join
1313
case create
1414

dogether/Presentation/Common/DogetherHeader.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ final class DogetherHeader: UIView {
5050
}
5151

5252
@objc private func didTapMyPageButton() {
53-
// TODO: 추후 마이페이지로 이동하도록 구현
53+
NavigationManager.shared.pushViewController(MyPageViewController())
5454
}
5555
}

dogether/Presentation/View/CompleteViewController.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import SnapKit
1212
final class CompleteViewController: BaseViewController {
1313
private let groupType: GroupTypes
1414

15+
var viewModel = CompleteViewModel()
16+
1517
private let firecrackerImageView = {
1618
let imageView = UIImageView()
1719
imageView.image = .firecracker
@@ -83,7 +85,7 @@ final class CompleteViewController: BaseViewController {
8385
groupInfoView = DogetherGroupInfo(groupName: "groupName", memberCount: 0, duration: .threeDays, startAt: .today)
8486
case .create:
8587
noticeLabel.text = groupType.completeNoticeText
86-
joinCodeLabel.text = "123456"
88+
joinCodeLabel.text = viewModel.joinCode
8789
joinCodeShareButton.addTarget(self, action: #selector(didTapJoinCodeShareButton), for: .touchUpInside)
8890
}
8991
}

dogether/Presentation/View/GroupCreateViewController.swift

+29-7
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ final class GroupCreateViewController: BaseViewController {
7373
let view = UIView()
7474
view.backgroundColor = .grey800
7575
view.layer.cornerRadius = 12
76+
view.layer.borderWidth = 1
7677
return view
7778
}()
7879
private let groupNameTextField = {
@@ -89,13 +90,21 @@ final class GroupCreateViewController: BaseViewController {
8990
return textField
9091
}()
9192
private let groupNameCountLabel = {
93+
let label = UILabel()
94+
label.text = "0"
95+
label.font = Fonts.smallS
96+
return label
97+
}()
98+
private let groupNameMaxLengthLabel = {
9299
let label = UILabel()
93100
label.textColor = .grey300
94101
label.font = Fonts.smallS
95102
return label
96103
}()
97104
private var memberCountView = UIView()
98105
private var todoLimitView = UIView()
106+
107+
// TODO: 추후 durationStackView, startAtStackView 공용 컴포넌트로 빼기
99108
private func durationButton(duration: GroupChallengeDurations) -> UIButton {
100109
let button = UIButton()
101110
button.backgroundColor = .grey800
@@ -190,9 +199,11 @@ final class GroupCreateViewController: BaseViewController {
190199

191200
override func viewDidLoad() {
192201
super.viewDidLoad()
202+
groupNameTextField.becomeFirstResponder()
193203
setupKeyboardHandling()
194204
}
195205

206+
// TODO: 추후 확인 필요 (하도 헤메다가 추가한 부분이라.. 무슨 의미를 갖는지 모르겠네요)
196207
deinit {
197208
NotificationCenter.default.removeObserver(self)
198209
}
@@ -213,7 +224,9 @@ final class GroupCreateViewController: BaseViewController {
213224

214225
completeButton.action = { @MainActor in
215226
if self.viewModel.currentStep == .four {
216-
NavigationManager.shared.setNavigationController(CompleteViewController(type: .create))
227+
let completeViewController = CompleteViewController(type: .create)
228+
completeViewController.viewModel.joinCode = await self.viewModel.getJoinCode()
229+
NavigationManager.shared.setNavigationController(completeViewController)
217230
} else {
218231
await self.viewModel.completeAction()
219232
self.updateStep()
@@ -223,7 +236,7 @@ final class GroupCreateViewController: BaseViewController {
223236
groupName = componentTitleLabel(componentTitle: "그룹명")
224237
groupNameTextField.delegate = self
225238
groupNameTextField.addTarget(self, action: #selector(didChangeGroupName), for: .editingChanged)
226-
groupNameCountLabel.text = "0/\(viewModel.groupNameMaxLength)"
239+
groupNameMaxLengthLabel.text = "/\(viewModel.groupNameMaxLength)"
227240
memberCount = componentTitleLabel(componentTitle: "그룹 인원")
228241
memberCountView = DogetherCountView(changeCountAction: {
229242
self.viewModel.updateMemberCount(count: $0)
@@ -265,7 +278,7 @@ final class GroupCreateViewController: BaseViewController {
265278
].forEach { view.addSubview($0) }
266279

267280
[
268-
groupName, groupNameView, groupNameTextField, groupNameCountLabel,
281+
groupName, groupNameView, groupNameTextField, groupNameCountLabel, groupNameMaxLengthLabel,
269282
memberCount, memberCountView
270283
].forEach { stepOneView.addSubview($0) }
271284

@@ -325,6 +338,11 @@ final class GroupCreateViewController: BaseViewController {
325338
$0.height.equalTo(25)
326339
}
327340
groupNameCountLabel.snp.makeConstraints {
341+
$0.centerY.equalTo(groupNameView)
342+
$0.right.equalTo(groupNameMaxLengthLabel.snp.left)
343+
$0.height.equalTo(18)
344+
}
345+
groupNameMaxLengthLabel.snp.makeConstraints {
328346
$0.centerY.equalTo(groupNameView)
329347
$0.right.equalTo(groupNameView).inset(16)
330348
$0.height.equalTo(18)
@@ -466,9 +484,9 @@ final class GroupCreateViewController: BaseViewController {
466484
}
467485

468486
Task { @MainActor in
469-
let (groupName, countLabelText, buttonStatus) = await viewModel.updateGroupName(groupName: groupNameTextField.text)
487+
let (groupName, buttonStatus) = await viewModel.updateGroupName(groupName: groupNameTextField.text)
470488
groupNameTextField.text = groupName
471-
groupNameCountLabel.text = countLabelText
489+
groupNameCountLabel.text = String(groupName.count)
472490
completeButton.setButtonStatus(status: buttonStatus)
473491
}
474492
}
@@ -545,17 +563,21 @@ extension GroupCreateViewController: UITextFieldDelegate {
545563

546564
@objc private func keyboardWillShow(_ notification: NSNotification) {
547565
guard let keyboardFrame = notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue else { return }
566+
groupNameView.layer.borderColor = UIColor.blue300.cgColor
567+
groupNameCountLabel.textColor = .blue300
548568
completeButton.snp.updateConstraints {
549569
$0.bottom.equalToSuperview().inset(keyboardFrame.cgRectValue.height + 16)
550570
}
551-
UIView.animate(withDuration: 0.3) { self.view.layoutIfNeeded() }
571+
self.view.layoutIfNeeded()
552572
}
553573

554574
@objc private func keyboardWillHide(_ notification: NSNotification) {
575+
groupNameView.layer.borderColor = UIColor.grey800.cgColor
576+
groupNameCountLabel.textColor = .grey300
555577
completeButton.snp.updateConstraints {
556578
$0.bottom.equalToSuperview().inset(48)
557579
}
558-
UIView.animate(withDuration: 0.3) { self.view.layoutIfNeeded() }
580+
self.view.layoutIfNeeded()
559581
}
560582

561583
@objc private func dismissKeyboard() { view.endEditing(true) }

0 commit comments

Comments
 (0)