Skip to content

Commit

Permalink
[Feat] 미션 결과확인하기 로직 구현 #76
Browse files Browse the repository at this point in the history
  • Loading branch information
HELLOHIDI committed Nov 1, 2024
1 parent 2c4fb19 commit e5ad5c9
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation

struct MemberResponse: Decodable {
let santa: UserResponse
let santa: SantaUserResponse
let manitto: UserResponse?
}

Expand Down
13 changes: 13 additions & 0 deletions SantaManito-iOS/SantaManito-iOS/Data/DTO/User/UserResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,21 @@ struct UserResponse: Decodable {
let username: String
}

struct SantaUserResponse: Decodable {
let id: String
let username: String
let missionId: String
}

extension UserResponse {
func toEntity() -> User {
.init(id: id, username: username)
}
}

extension SantaUserResponse {
func toEntity() -> SantaUser {
.init(id: id, username: username, missionId: missionId)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation

struct Member: Hashable {
var santa: User
var santa: SantaUser
var manitto: User?
}

Expand Down
23 changes: 20 additions & 3 deletions SantaManito-iOS/SantaManito-iOS/Data/Entity/Room/Mission.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,29 @@ import Foundation

public struct Mission: Identifiable, Hashable, Decodable {
var content: String
public var id = UUID() // TODO: 추후 서버로 부터 DTO어떻게 올지에 따라 달라짐
// public var id = UUID() // TODO: 추후 서버로 부터 DTO어떻게 올지에 따라 달라짐
public var id = String()
}

extension Mission {
static var stub: Mission {
.init(content: "손 잡기", id: UUID())
static var stub1: Mission {
// .init(content: "손 잡기", id: UUID())
.init(content: "손 잡기", id: "1")
}

static var stub2: Mission {
// .init(content: "손 잡기", id: UUID())
.init(content: "손 잡기", id: "2")
}

static var stub3: Mission {
// .init(content: "손 잡기", id: UUID())
.init(content: "손 잡기", id: "3")
}

static var stub4: Mission {
// .init(content: "손 잡기", id: UUID())
.init(content: "손 잡기", id: "4")
}

static func dummy() -> [Mission] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ extension RoomDetail {
creatorID: User.stub1.id,
creatorName: User.stub1.username,
members: .stub1,
mission: [],
mission: [
.stub1,
.stub2,
.stub3,
.stub4
],
createdAt: Date(),
expirationDate: Date()
)
Expand Down
25 changes: 25 additions & 0 deletions SantaManito-iOS/SantaManito-iOS/Data/Entity/User/User.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ struct User: Hashable {
let username: String
}

struct SantaUser: Hashable {
let id: String
let username: String
let missionId: String
}


extension User {
static var stub1: User {
Expand All @@ -30,3 +36,22 @@ extension User {
return .init(id: "userID4", username: "이한나")
}
}

extension SantaUser {
static var stub1: SantaUser {
return .init(id: "userID1", username: "류희재", missionId: "1")
}

static var stub2: SantaUser {
return .init(id: "userID2", username: "장석우" , missionId: "2")
}

static var stub3: SantaUser {
return .init(id: "userID3", username: "박상수", missionId: "3")
}

static var stub4: SantaUser {
return .init(id: "userID4", username: "이한나", missionId: "4")
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,6 @@ struct StubRoomService: RoomServiceType {
}

func getMyInfo(with roomID: String) -> AnyPublisher<(User, Mission), SMNetworkError> {
Just((.stub1, .stub)).setFailureType(to: SMNetworkError.self).eraseToAnyPublisher()
Just((.stub1, .stub1)).setFailureType(to: SMNetworkError.self).eraseToAnyPublisher()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ fileprivate struct ParticipateListView: View {
}

fileprivate struct ParticipateCellView: View {
var user: User
var user: SantaUser
var body: some View {
HStack {
Image(.graphicsRudolphCircle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ class FinishViewModel: ObservableObject {
}

var mission: String {
return "미션" // TODO: 미션 고르는 로직 구현해야함.
let missionId = member.santa.missionId
guard let mission = roomInfo.mission.first(where: {$0.id == missionId}) else {
return "미션이 없습니다."
}
return mission.content
}
}

Expand Down Expand Up @@ -91,7 +95,7 @@ class FinishViewModel: ObservableObject {
func send(action: Action) {
switch action {
case .onAppear:
return
return

case .toggleViewTypeButtonDidTap:
state.viewType = state.viewType == .me ? .all : .me
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ class MatchingResultViewModel: ObservableObject {
return roomInfo.members[내가마니또인멤버Index]
}

var me: User {
var me: SantaUser {
member.santa
}

var isAnimating: Bool = false

fileprivate var matchedInfo: (User, Mission) = (.stub1, .stub)
fileprivate var matchedInfo: (User, Mission) = (.stub1, .stub1)

var mannito: User { matchedInfo.0 }
var mission: String { matchedInfo.1.content }
Expand Down

0 comments on commit e5ad5c9

Please sign in to comment.