-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHomePresentationModel.swift
More file actions
151 lines (136 loc) · 3.95 KB
/
Copy pathHomePresentationModel.swift
File metadata and controls
151 lines (136 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
//
// HomePresentationModel.swift
// HomeFeature
//
// Created by 최안용 on 2/4/26.
// Copyright © 2026 NDGL-iOS. All rights reserved.
//
import Foundation
import Domain
struct HomePresentationModel {
let banner: HomePresentationModel.Banner
let category: [HomePresentationModel.Category]
let popularTrip: [HomePresentationModel.PopularTrip]
let recommendedTrip: [HomePresentationModel.RecommendedTrip]
struct Banner: Hashable {
let id: Int
let title: String
let startDay: Date
let endDay: Date
let duration: String
let tripSchedule: Schedule
}
struct Schedule: Hashable {
let id: Int
let day: Int
let placeName: String
let thumbnailUrl: String
let transport: String
let estimatedDuration: Int
}
struct Category: Hashable {
let id: Int
let creator: String
let viedoType: VideoType
}
struct PopularTrip: Hashable {
let id: Int
let title: String
let thumbnailUrl: String
let creator: String
let schedule: String
let country: String
let city: String
}
struct RecommendedTrip: Hashable {
let id: Int
let title: String
let thumbnailUrl: String
let creator: String
let country: String
let schedule: String
let city: String
}
}
extension HomePresentationModel.Banner {
static var empty: Self {
return .init(
id: 0, // 0으로 설정하여 empty 배너임을 구분
title: "다가오는 여행이 없습니다.",
startDay: Date(),
endDay: Date(),
duration: "",
tripSchedule: .empty
)
}
}
extension HomePresentationModel.Schedule {
static var empty: Self {
return .init(
id: 0,
day: 0,
placeName: "",
thumbnailUrl: "",
transport: "",
estimatedDuration: 0
)
}
}
extension MyTripSummary {
func toPresention() -> HomePresentationModel.Banner {
let schedule: HomePresentationModel.Schedule
if let tripSchedule = self.tripSchedule {
schedule = .init(
id: tripSchedule.id,
day: tripSchedule.day,
placeName: tripSchedule.placeName,
thumbnailUrl: tripSchedule.thumbnailUrl,
transport: tripSchedule.transport,
estimatedDuration: tripSchedule.estimatedDuration
)
} else {
schedule = .empty
}
return HomePresentationModel.Banner(
id: self.id,
title: self.title,
startDay: self.startDay,
endDay: self.endDay,
duration: "\(self.startDay.toKoreanMMdd())~\(self.endDay.toKoreanMMdd())",
tripSchedule: schedule
)
}
}
extension TripCategory {
func toHomeModel() -> HomePresentationModel.Category {
return HomePresentationModel.Category(
id: self.id,
creator: self.creator,
viedoType: self.viedoType
)
}
}
extension TripInfo {
func toPopularHomeModel() -> HomePresentationModel.PopularTrip {
return HomePresentationModel.PopularTrip(
id: self.id,
title: self.title,
thumbnailUrl: self.thumbnailUrl,
creator: self.creator,
schedule: "\(self.nights)박 \(self.days)일",
country: self.country,
city: self.city
)
}
func toRecommendHomeModel() -> HomePresentationModel.RecommendedTrip {
return HomePresentationModel.RecommendedTrip(
id: self.id,
title: self.title,
thumbnailUrl: self.thumbnailUrl,
creator: self.creator,
country: self.country,
schedule: "\(self.nights)박 \(self.days)일",
city: self.city
)
}
}