Skip to content

Commit

Permalink
Merge pull request #295 from OMZigak/refactor/#277-deduplication
Browse files Browse the repository at this point in the history
[refactor] 모임 생성, 약속 상세 전반적인 리팩토링
  • Loading branch information
youz2me authored Aug 16, 2024
2 parents 3382226 + 4aefeb9 commit 060a977
Show file tree
Hide file tree
Showing 39 changed files with 1,087 additions and 1,187 deletions.
93 changes: 41 additions & 52 deletions KkuMulKum.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions KkuMulKum/Network/Service/MeetingService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,29 @@ final class MeetingService {
}
}
}

extension MeetingService: CreateMeetingServiceProtocol {
func createMeeting(
request: MakeMeetingsRequestModel
) async throws -> ResponseBodyDTO<MakeMeetingsResponseModel>? {
return try await self.request(with: .createMeeting(request: request))
}
}

extension MeetingService: InviteCodeServiceProtocol {
func joinMeeting(
with request: RegisterMeetingsModel
) async throws -> ResponseBodyDTO<RegisterMeetingsResponseModel>? {
return try await self.request(with: .joinMeeting(request: request))
}
}

final class MockInviteCodeService: InviteCodeServiceProtocol {
func joinMeeting(with request: RegisterMeetingsModel) -> ResponseBodyDTO<RegisterMeetingsResponseModel>? {
let mockData = RegisterMeetingsResponseModel(
meetingID: 1
)

return ResponseBodyDTO<RegisterMeetingsResponseModel>.init(success: true, data: mockData, error: nil)
}
}
195 changes: 195 additions & 0 deletions KkuMulKum/Network/Service/PromiseService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,198 @@ final class PromiseService {
}
}
}

extension PromiseService: PromiseServiceProtocol {
func fetchTardyInfo(with promiseID: Int) async throws -> ResponseBodyDTO<TardyInfoModel>? {
return try await request(with: .fetchTardyInfo(promiseID: promiseID))
}

func updatePromiseCompletion(with promiseID: Int) async throws -> ResponseBodyDTO<EmptyModel>? {
return try await request(with: .updatePromiseCompletion(promiseID: promiseID))
}

func fetchPromiseInfo(with promiseID: Int) async throws -> ResponseBodyDTO<PromiseInfoModel>? {
return try await request(with: .fetchPromiseInfo(promiseID: promiseID))
}

func updatePreparationStatus(with promiseID: Int) async throws -> ResponseBodyDTO<EmptyModel>? {
return try await request(with: .updatePreparationStatus(promiseID: promiseID))
}

func updateDepartureStatus(with promiseID: Int) async throws -> ResponseBodyDTO<EmptyModel>? {
return try await request(with: .updateDepartureStatus(promiseID: promiseID))
}

func updateArrivalStatus(with promiseID: Int) async throws -> ResponseBodyDTO<EmptyModel>? {
return try await request(with: .updateArrivalStatus(promiseID: promiseID))
}

func fetchMyReadyStatus(with promiseID: Int) async throws -> ResponseBodyDTO<MyReadyStatusModel>? {
return try await request(with: .fetchMyReadyStatus(promiseID: promiseID))
}

func fetchPromiseParticipantList(with promiseID: Int) async throws -> ResponseBodyDTO<PromiseParticipantListModel>? {
return try await request(with: .fetchPromiseParticipantList(promiseID: promiseID))
}
}

final class MockPromiseService: PromiseServiceProtocol {
func fetchPromiseInfo(with promiseId: Int) async throws -> ResponseBodyDTO<PromiseInfoModel>? {
let mockData = PromiseInfoModel(
promiseID: 1,
promiseName: "냐미",
placeName: "우리집 앞",
address: "경기도 용인시 수지구 대지로 72",
roadAddress: "경기도 용인시 수지구 대지로 72",
time: "2024년 7월 24일 오후 10시 30분",
dressUpLevel: "LV 2. 냐미",
penalty: "냐미"
)

return ResponseBodyDTO<PromiseInfoModel>.init(
success: true,
data: mockData,
error: nil
)
}

func fetchTardyInfo(with promiseID: Int) -> ResponseBodyDTO<TardyInfoModel>? {
let mockData = TardyInfoModel(
penalty: "티라미수 케익 릴스",
isPastDue: true,
lateComers: [
Comer(participantId: 1, name: "유짐이", profileImageURL: ""),
Comer(participantId: 1, name: "유짐이", profileImageURL: ""),
Comer(participantId: 1, name: "유짐이", profileImageURL: ""),
Comer(participantId: 1, name: "유짐이", profileImageURL: ""),
Comer(participantId: 1, name: "유짐이",profileImageURL: "")
]
)

return ResponseBodyDTO<TardyInfoModel>.init(
success: true,
data: mockData,
error: nil
)
}

func updatePromiseCompletion(with promiseID: Int) -> ResponseBodyDTO<EmptyModel>? {
let mockData = EmptyModel()

return ResponseBodyDTO<EmptyModel>.init(
success: true,
data: mockData,
error: nil
)
}

func getPromiseTardyInfo(with promiseID: Int) -> ResponseBodyDTO<TardyInfoModel>? {
let mockData = TardyInfoModel(
penalty: "티라미수 케익 릴스",
isPastDue: true,
lateComers: [Comer(
participantId: 1,
name: "유짐이",
profileImageURL: ""
)]
)

return ResponseBodyDTO<TardyInfoModel>.init(
success: true,
data: mockData,
error: nil
)
}

func updatePromiseCompletion(with promiseID: Int) async throws -> ResponseBodyDTO<EmptyModel>? {
let mockData = EmptyModel()

return ResponseBodyDTO(
success: true,
data: mockData,
error: nil
)
}

func updatePreparationStatus(with promiseID: Int) async throws -> ResponseBodyDTO<EmptyModel>? {
let mockData = EmptyModel()

return ResponseBodyDTO(
success: true,
data: mockData,
error: nil
)
}

func updateDepartureStatus(with promiseID: Int) async throws -> ResponseBodyDTO<EmptyModel>? {
let mockData = EmptyModel()

return ResponseBodyDTO(
success: true,
data: mockData,
error: nil
)
}

func updateArrivalStatus(with promiseID: Int) async throws -> ResponseBodyDTO<EmptyModel>? {
let mockData = EmptyModel()

return ResponseBodyDTO(
success: true,
data: mockData,
error: nil
)
}

func fetchMyReadyStatus(with promiseID: Int) -> ResponseBodyDTO<MyReadyStatusModel>? {
let mockData = MyReadyStatusModel(
promiseTime: "",
preparationTime: 300,
travelTime: 230,
preparationStartAt: "AM 11:00",
departureAt: "PM 1:30",
arrivalAt: "PM 2:00"
)

return ResponseBodyDTO<MyReadyStatusModel>.init(
success: true,
data: mockData,
error: nil
)
}

func fetchPromiseParticipantList(with promiseID: Int) -> ResponseBodyDTO<PromiseParticipantListModel>? {
let mockData = PromiseParticipantListModel(
participantCount: 3,
participants: [
Participant(
participantId: 1,
memberId: 3,
name: "안꾸물이",
state: "도착",
profileImageURL: nil
),
Participant(
participantId: 2,
memberId: 4,
name: "꾸우우우웅물이",
state: "도착",
profileImageURL: nil
),
Participant(
participantId: 3,
memberId: 5,
name: "꾸물이",
state: "이동중",
profileImageURL: nil
)
]
)

return ResponseBodyDTO<PromiseParticipantListModel>.init(
success: true,
data: mockData,
error: nil
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ class CheckInviteCodeView: BaseView {


// MARK: Property

let enterInviteCodeView: JoinButtonView = JoinButtonView(
mainTitle: "초대 코드를 받았다면",
subTitle: "초대 코드가 없다면"
)

let createMeetingView: JoinButtonView = JoinButtonView(
mainTitle: "초대 코드 입력하기",
subTitle: "직접 모임 추가하기"
)

private let checkInviteLabel: UILabel = UILabel().then {
$0.setText("친구에게 받은\n모임 초대 코드가 있으신가요?", style: .head01, color: .gray8)
}

let enterInviteCodeView: JoinButtonView = JoinButtonView().then {
$0.setJoinButtonViewStatus(isReceived: true)
}

let createMeetingView: JoinButtonView = JoinButtonView().then {
$0.setJoinButtonViewStatus(isReceived: false)
}


// MARK: - Setup

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,18 @@ class JoinButtonView: BaseView {


// MARK: - Setup


init(mainTitle: String, subTitle: String) {
super.init(frame: .zero)

mainTitleLabel.setText(mainTitle, style: .body03, color: .gray8)
subTitleLabel.setText(subTitle, style: .caption02, color: .gray5)
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func setupView() {
self.backgroundColor = .green1

Expand Down Expand Up @@ -58,22 +69,3 @@ class JoinButtonView: BaseView {
}
}
}


// MARK: - Extension

extension JoinButtonView {
func setJoinButtonViewStatus(isReceived: Bool) {
subTitleLabel.setText(
isReceived ? "초대 코드를 받았다면" : "초대 코드가 없다면",
style: .caption02,
color: .gray5
)

mainTitleLabel.setText(
isReceived ? "초대 코드 입력하기" : "직접 모임 추가하기",
style: .body03,
color: .gray8
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ class CheckInviteCodeViewController: BaseViewController {

// MARK: Property

private let checkInviteCodeView: CheckInviteCodeView = CheckInviteCodeView()
private let rootView: CheckInviteCodeView = CheckInviteCodeView()


// MARK: LifeCycle

override func loadView() {
view = rootView
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)

Expand All @@ -28,10 +32,6 @@ class CheckInviteCodeViewController: BaseViewController {

navigationController?.isNavigationBarHidden = true
}

override func loadView() {
view = checkInviteCodeView
}


// MARK: Setup
Expand All @@ -44,11 +44,11 @@ class CheckInviteCodeViewController: BaseViewController {
}

override func setupAction() {
checkInviteCodeView.enterInviteCodeView.addGestureRecognizer(UITapGestureRecognizer(
rootView.enterInviteCodeView.addGestureRecognizer(UITapGestureRecognizer(
target: self,
action: #selector(inviteCodeViewDidTap)
))
checkInviteCodeView.createMeetingView.addGestureRecognizer(UITapGestureRecognizer(
rootView.createMeetingView.addGestureRecognizer(UITapGestureRecognizer(
target: self,
action: #selector(createMeetingViewDidTap)
))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// CreateMeetingServiceProtocol.swift
// KkuMulKum
//
// Created by YOUJIM on 7/13/24.
//

import Foundation

import Moya

protocol CreateMeetingServiceProtocol {
func createMeeting(
request: MakeMeetingsRequestModel
) async throws -> ResponseBodyDTO<MakeMeetingsResponseModel>?
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ class CreateMeetingView: BaseView {


// MARK: Property

private let mainTitleLabel: UILabel = UILabel().then {
$0.setText("모임 이름을\n입력해 주세요", style: .head01)
}

let nameTextField: CustomTextField = CustomTextField(
placeHolder: "모임 이름을 입력해 주세요"
Expand All @@ -29,6 +25,10 @@ class CreateMeetingView: BaseView {
isEnabled: false
)

private let mainTitleLabel: UILabel = UILabel().then {
$0.setText("모임 이름을\n입력해 주세요", style: .head01)
}


// MARK: - Setup

Expand Down
Loading

0 comments on commit 060a977

Please sign in to comment.